19 lines
817 B
PHP
19 lines
817 B
PHP
<?php
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
/** Clear a manually assigned CLI fixture actor without rotating a user's remember token. */
|
|
function clearImportQaIdentity(): void
|
|
{
|
|
$db = DB::connection();
|
|
$isolated = ($db->getDriverName() === 'sqlite' && $db->getDatabaseName() === ':memory:')
|
|
|| ($db->getDriverName() === 'pgsql' && preg_match('/^compras_receipts_test_[a-f0-9]{12}$/D', $db->getDatabaseName()));
|
|
if (! app()->environment('testing') || ! app()->runningInConsole() || ! $isolated || request()->hasSession()) {
|
|
throw new LogicException('Only a sessionless disposable CLI fixture actor may be cleared this way.');
|
|
}
|
|
auth()->forgetGuards();
|
|
if (auth()->check()) {
|
|
throw new LogicException('The synthetic inspection still has an authenticated actor.');
|
|
}
|
|
}
|