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;
|
namespace Tests\Feature\Console;
|
||||||
|
|
||||||
use App\Models\User;
|
|
||||||
use Tests\FeatureTestCase;
|
use Tests\FeatureTestCase;
|
||||||
use Illuminate\Support\Facades\Config;
|
use Illuminate\Support\Facades\Config;
|
||||||
|
|
||||||
@ -16,7 +15,7 @@ public function test_reset_demo_without_demo_mode_succeeded()
|
|||||||
{
|
{
|
||||||
$this->artisan('2fauth:reset-demo')
|
$this->artisan('2fauth:reset-demo')
|
||||||
->expectsOutput('2fauth:reset-demo can only run when isDemoApp option is On')
|
->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')
|
$this->artisan('2fauth:reset-demo')
|
||||||
->expectsOutput('This will reset the app in order to run a clean and fresh 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')
|
->expectsQuestion('To prevent any mistake please type the word "demo" to go on', 'demo')
|
||||||
->expectsOutput('Demo app refreshed')
|
->assertSuccessful();
|
||||||
->assertExitCode(0);
|
|
||||||
|
|
||||||
$this->assertDatabaseCount('twofaccounts', 9);
|
$this->assertDatabaseCount('twofaccounts', 9);
|
||||||
|
|
||||||
@ -147,7 +145,7 @@ public function test_reset_demo_with_invalid_confirmation_succeeded()
|
|||||||
$this->artisan('2fauth:reset-demo')
|
$this->artisan('2fauth:reset-demo')
|
||||||
->expectsQuestion('To prevent any mistake please type the word "demo" to go on', 'null')
|
->expectsQuestion('To prevent any mistake please type the word "demo" to go on', 'null')
|
||||||
->expectsOutput('Bad confirmation word, nothing appened')
|
->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);
|
Config::set('2fauth.config.isDemoApp', true);
|
||||||
|
|
||||||
$this->artisan('2fauth:reset-demo --no-confirm')
|
$this->artisan('2fauth:reset-demo', [
|
||||||
->expectsOutput('Demo app refreshed')
|
'--no-confirm' => true
|
||||||
->assertExitCode(0);
|
])
|
||||||
|
->assertSuccessful();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace Tests\Feature\Console;
|
namespace Tests\Feature\Console;
|
||||||
|
|
||||||
use App\Models\User;
|
|
||||||
use Tests\FeatureTestCase;
|
use Tests\FeatureTestCase;
|
||||||
use Illuminate\Support\Facades\Config;
|
use Illuminate\Support\Facades\Config;
|
||||||
|
|
||||||
@ -16,7 +15,7 @@ public function test_reset_testing_without_testing_mode_succeeded()
|
|||||||
{
|
{
|
||||||
$this->artisan('2fauth:reset-testing')
|
$this->artisan('2fauth:reset-testing')
|
||||||
->expectsOutput('2fauth:reset-testing can only run when isTestingApp option is On')
|
->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')
|
$this->artisan('2fauth:reset-testing')
|
||||||
->expectsOutput('This will reset the app in order to run a clean and fresh testing app.')
|
->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')
|
->expectsQuestion('To prevent any mistake please type the word "testing" to go on', 'testing')
|
||||||
->expectsOutput('Testing app refreshed')
|
->assertSuccessful();
|
||||||
->assertExitCode(0);
|
|
||||||
|
|
||||||
$this->assertDatabaseCount('twofaccounts', 9);
|
$this->assertDatabaseCount('twofaccounts', 9);
|
||||||
|
|
||||||
@ -147,7 +145,7 @@ public function test_reset_testing_with_invalid_confirmation_succeeded()
|
|||||||
$this->artisan('2fauth:reset-testing')
|
$this->artisan('2fauth:reset-testing')
|
||||||
->expectsQuestion('To prevent any mistake please type the word "testing" to go on', 'null')
|
->expectsQuestion('To prevent any mistake please type the word "testing" to go on', 'null')
|
||||||
->expectsOutput('Bad confirmation word, nothing appened')
|
->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);
|
Config::set('2fauth.config.isTestingApp', true);
|
||||||
|
|
||||||
$this->artisan('2fauth:reset-testing --no-confirm')
|
$this->artisan('2fauth:reset-testing --no-confirm')
|
||||||
->expectsOutput('Testing app refreshed')
|
->assertSuccessful();
|
||||||
->assertExitCode(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -3,22 +3,26 @@
|
|||||||
namespace Tests;
|
namespace Tests;
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Artisan;
|
use Illuminate\Support\Facades\Artisan;
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;
|
||||||
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
||||||
|
|
||||||
abstract class FeatureTestCase extends BaseTestCase
|
abstract class FeatureTestCase extends BaseTestCase
|
||||||
{
|
{
|
||||||
use CreatesApplication;
|
use CreatesApplication;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rollback and execute migrations for each test.
|
* 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]);
|
Artisan::call('passport:install',['--verbose' => 2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user