Files
compras/tests/Support/ImportQaIdentity.php
T
nala e709d900d1
tests / ci (push) Waiting to run
commit compras 2711
2026-11-27 13:49:31 +02:00

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.');
}
}