auth tests
This commit is contained in:
@@ -3,8 +3,30 @@
|
||||
namespace Tests;
|
||||
|
||||
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Tests\Concerns\CreatesUsers;
|
||||
use Tests\Support\UnsafeTestDatabaseException;
|
||||
|
||||
abstract class TestCase extends BaseTestCase
|
||||
{
|
||||
//
|
||||
use CreatesUsers;
|
||||
|
||||
/**
|
||||
* Cintura di sicurezza. refreshApplication() gira PRIMA di setUpTraits()
|
||||
* (quindi prima dell'eventuale migrate:fresh di RefreshDatabase): se la
|
||||
* connessione non punta al DB di test dedicato, abortiamo invece di azzerare
|
||||
* il database di sviluppo `dyncoll`. (Non si può usare beforeRefreshingDatabase:
|
||||
* nelle classi che usano il trait RefreshDatabase la sua versione vuota
|
||||
* soppianta quella ereditata dal parent.) Esegui sempre con `make test`.
|
||||
*/
|
||||
protected function refreshApplication(): void
|
||||
{
|
||||
parent::refreshApplication();
|
||||
|
||||
$database = DB::connection()->getDatabaseName();
|
||||
|
||||
if ($database !== 'dyncoll_test') {
|
||||
throw UnsafeTestDatabaseException::for($database);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user