getDriverName() === 'sqlite' && $connection->getDatabaseName() === ':memory:') || ($connection->getDriverName() === 'pgsql' && preg_match('/^compras_receipts_test_[a-f0-9]{12}$/', $connection->getDatabaseName())); if (! app()->environment('testing') || ! $isolated) { throw new LogicException('Regras fictícias proibidas na base de negócio.'); } $admins = []; for ($index = 0; $index < 3; $index++) { $admins[] = User::factory()->create(['tenant_id' => $tenantId, 'purchasing_role' => PurchasingRole::Admin]); } auth()->guard()->setUser($admins[0]); $previous = InvestmentPolicy::query()->latest('revision')->first(); $policy = app(InvestmentWorkflow::class)->propose($admins[0], ['previous_id' => $previous->id ?? 0, 'mode' => 'ceiling', 'scope' => 'process_total', 'currency' => 'MZN', 'ceiling' => $ceiling, 'includes_tax' => $includesTax, 'valid_from' => today()->format('Y-m-d'), 'valid_until' => today()->addMonth()->format('Y-m-d'), 'reason' => 'Política fictícia para teste isolado']); foreach ([$admins[1], $admins[2]] as $admin) { auth()->guard()->setUser($admin); app(InvestmentWorkflow::class)->review($admin, $policy, 'approved', 'Decisão independente de teste'); } return $policy->refresh(); }