2021-11-30 17:39:33 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Feature\Console;
|
|
|
|
|
2021-12-02 13:15:53 +01:00
|
|
|
use App\Models\User;
|
2021-11-30 17:39:33 +01:00
|
|
|
use Tests\FeatureTestCase;
|
|
|
|
use Illuminate\Support\Facades\Config;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers \App\Console\Commands\CheckDbConnection
|
|
|
|
*/
|
|
|
|
class CheckDbConnectionTest extends FeatureTestCase
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function test_CheckDbConnection_ends_successfully()
|
|
|
|
{
|
|
|
|
$this->artisan('2fauth:check-db-connection')
|
|
|
|
->expectsOutput('This will return the name of the connected database, otherwise false')
|
|
|
|
->expectsOutput(DB::connection()->getDatabaseName())
|
|
|
|
->assertExitCode(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function test_CheckDbConnection_without_db_returns_false()
|
|
|
|
{
|
|
|
|
DB::shouldReceive('connection', 'getPDO')
|
|
|
|
->andThrow(new \Exception());
|
|
|
|
|
|
|
|
$this->artisan('2fauth:check-db-connection')
|
|
|
|
->assertExitCode(0);
|
|
|
|
}
|
|
|
|
}
|