2FAuth/tests/Feature/Console/CheckDbConnectionTest.php

36 lines
865 B
PHP
Raw Normal View History

2021-11-30 17:39:33 +01:00
<?php
namespace Tests\Feature\Console;
use Illuminate\Support\Facades\DB;
2022-11-22 15:15:52 +01:00
use Tests\FeatureTestCase;
2021-11-30 17:39:33 +01:00
/**
* @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());
2022-11-22 15:15:52 +01:00
$this->artisan('2fauth:check-db-connection')
2021-11-30 17:39:33 +01:00
->assertExitCode(0);
}
2022-11-22 15:15:52 +01:00
}