mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-11-26 10:15:40 +01:00
Use db lazy refresh in tests & Fix some tests
This commit is contained in:
parent
1119a0fb07
commit
9cda570b13
@ -2,7 +2,6 @@
|
||||
|
||||
namespace Tests\Feature\Console;
|
||||
|
||||
use App\Models\User;
|
||||
use Tests\FeatureTestCase;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
@ -16,7 +15,7 @@ public function test_reset_demo_without_demo_mode_succeeded()
|
||||
{
|
||||
$this->artisan('2fauth:reset-demo')
|
||||
->expectsOutput('2fauth:reset-demo can only run when isDemoApp option is On')
|
||||
->assertExitCode(0);
|
||||
->assertSuccessful();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -29,8 +28,7 @@ public function test_reset_demo_succeeded()
|
||||
$this->artisan('2fauth:reset-demo')
|
||||
->expectsOutput('This will reset the app in order to run a clean and fresh demo.')
|
||||
->expectsQuestion('To prevent any mistake please type the word "demo" to go on', 'demo')
|
||||
->expectsOutput('Demo app refreshed')
|
||||
->assertExitCode(0);
|
||||
->assertSuccessful();
|
||||
|
||||
$this->assertDatabaseCount('twofaccounts', 9);
|
||||
|
||||
@ -147,7 +145,7 @@ public function test_reset_demo_with_invalid_confirmation_succeeded()
|
||||
$this->artisan('2fauth:reset-demo')
|
||||
->expectsQuestion('To prevent any mistake please type the word "demo" to go on', 'null')
|
||||
->expectsOutput('Bad confirmation word, nothing appened')
|
||||
->assertExitCode(0);
|
||||
->assertSuccessful();
|
||||
}
|
||||
|
||||
|
||||
@ -158,9 +156,10 @@ public function test_reset_demo_with_no_confirm_option_succeeded()
|
||||
{
|
||||
Config::set('2fauth.config.isDemoApp', true);
|
||||
|
||||
$this->artisan('2fauth:reset-demo --no-confirm')
|
||||
->expectsOutput('Demo app refreshed')
|
||||
->assertExitCode(0);
|
||||
$this->artisan('2fauth:reset-demo', [
|
||||
'--no-confirm' => true
|
||||
])
|
||||
->assertSuccessful();
|
||||
}
|
||||
|
||||
}
|
@ -2,7 +2,6 @@
|
||||
|
||||
namespace Tests\Feature\Console;
|
||||
|
||||
use App\Models\User;
|
||||
use Tests\FeatureTestCase;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
@ -16,7 +15,7 @@ public function test_reset_testing_without_testing_mode_succeeded()
|
||||
{
|
||||
$this->artisan('2fauth:reset-testing')
|
||||
->expectsOutput('2fauth:reset-testing can only run when isTestingApp option is On')
|
||||
->assertExitCode(0);
|
||||
->assertSuccessful();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -29,8 +28,7 @@ public function test_reset_testing_succeeded()
|
||||
$this->artisan('2fauth:reset-testing')
|
||||
->expectsOutput('This will reset the app in order to run a clean and fresh testing app.')
|
||||
->expectsQuestion('To prevent any mistake please type the word "testing" to go on', 'testing')
|
||||
->expectsOutput('Testing app refreshed')
|
||||
->assertExitCode(0);
|
||||
->assertSuccessful();
|
||||
|
||||
$this->assertDatabaseCount('twofaccounts', 9);
|
||||
|
||||
@ -147,7 +145,7 @@ public function test_reset_testing_with_invalid_confirmation_succeeded()
|
||||
$this->artisan('2fauth:reset-testing')
|
||||
->expectsQuestion('To prevent any mistake please type the word "testing" to go on', 'null')
|
||||
->expectsOutput('Bad confirmation word, nothing appened')
|
||||
->assertExitCode(0);
|
||||
->assertSuccessful();
|
||||
}
|
||||
|
||||
|
||||
@ -159,8 +157,7 @@ public function test_reset_testing_with_no_confirm_option_succeeded()
|
||||
Config::set('2fauth.config.isTestingApp', true);
|
||||
|
||||
$this->artisan('2fauth:reset-testing --no-confirm')
|
||||
->expectsOutput('Testing app refreshed')
|
||||
->assertExitCode(0);
|
||||
->assertSuccessful();
|
||||
}
|
||||
|
||||
}
|
@ -3,22 +3,26 @@
|
||||
namespace Tests;
|
||||
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
||||
|
||||
abstract class FeatureTestCase extends BaseTestCase
|
||||
{
|
||||
use CreatesApplication;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Rollback and execute migrations for each test.
|
||||
*/
|
||||
use DatabaseTransactions;
|
||||
use LazilyRefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
|
||||
/**
|
||||
* Perform any work that should take place once the database has finished refreshing.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function afterRefreshingDatabase()
|
||||
{
|
||||
parent::setUp();
|
||||
Artisan::call('migrate');
|
||||
Artisan::call('passport:install',['--verbose' => 2]);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user