testUserCommand.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace Tests\Unit;
  3. use App\Classes\Pterodactyl;
  4. use Illuminate\Foundation\Auth\User;
  5. use Illuminate\Foundation\Testing\DatabaseTransactions;
  6. use Illuminate\Support\Facades\DB;
  7. use Tests\TestCase;
  8. class testUserCommand extends TestCase
  9. {
  10. use DatabaseTransactions;
  11. /**
  12. * A basic feature test example.
  13. * @dataProvider invalidPteroIdDataProvider
  14. * @param array $apiResponse
  15. * @param int $expectedExitCode
  16. * @return void
  17. */
  18. public function testMakeUserCommand(array $apiResponse, int $expectedExitCode): void
  19. {
  20. $pterodactyl = $this->getMockBuilder(Pterodactyl::class)->getMock();
  21. $pterodactyl->expects(self::once())->method('getUser')->willReturn($apiResponse);
  22. $this->app->instance(Pterodactyl::class, $pterodactyl);
  23. $this->artisan('make:user')
  24. ->expectsQuestion('Please specify your Pterodactyl ID.', 0)
  25. ->expectsQuestion('Please specify your password.', 'password')
  26. ->assertExitCode($expectedExitCode);
  27. }
  28. public function invalidPteroIdDataProvider(): array
  29. {
  30. return [
  31. 'Good Response' => [
  32. 'apiResponse' => [
  33. 'id' => 12345,
  34. 'first_name' => 'Test',
  35. 'email' => 'test@test.test'
  36. ],
  37. 'expectedExitCode' => 1
  38. ],
  39. 'Bad Response' => [
  40. 'apiResponse' => [],
  41. 'expectedExitCode' => 0
  42. ]
  43. ];
  44. }
  45. }