CheckDbConnectionTest.php 929 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace Tests\Feature\Console;
  3. use App\User;
  4. use Tests\FeatureTestCase;
  5. use Illuminate\Support\Facades\Config;
  6. use Illuminate\Support\Facades\DB;
  7. /**
  8. * @covers \App\Console\Commands\CheckDbConnection
  9. */
  10. class CheckDbConnectionTest extends FeatureTestCase
  11. {
  12. /**
  13. * @test
  14. */
  15. public function test_CheckDbConnection_ends_successfully()
  16. {
  17. $this->artisan('2fauth:check-db-connection')
  18. ->expectsOutput('This will return the name of the connected database, otherwise false')
  19. ->expectsOutput(DB::connection()->getDatabaseName())
  20. ->assertExitCode(1);
  21. }
  22. /**
  23. * @test
  24. */
  25. public function test_CheckDbConnection_without_db_returns_false()
  26. {
  27. DB::shouldReceive('connection', 'getPDO')
  28. ->andThrow(new \Exception());
  29. $this->artisan('2fauth:check-db-connection')
  30. ->assertExitCode(0);
  31. }
  32. }