Files
2026-11-02 08:06:45 +02:00

30 lines
1.2 KiB
PHP

<?php
namespace Tests;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
protected function setUp(): void
{
if (in_array(\Illuminate\Foundation\Testing\RefreshDatabase::class, class_uses_recursive(static::class), true)
&& !preg_match('/^[a-f0-9]{12}$/D', (string)getenv('SGF_ISOLATED_REGRESSION_RUN'))) {
throw new \RuntimeException('SGF_DESTRUCTIVE_SUITE_REFUSED: use scripts/modular-regression-run.mjs; preserve the persistent demonstration.');
}
parent::setUp();
\App\Shared\Testing\TestingDatabaseGuard::assertSafe();
}
protected function setUpTraits()
{
// Called after application boot, before RefreshDatabase can issue DDL.
if ($run=getenv('SGF_ISOLATED_REGRESSION_RUN')) {
\App\Shared\Testing\TestingDatabaseGuard::assertSafe();
$cluster=\Illuminate\Support\Facades\DB::selectOne("SELECT current_setting('cluster_name') AS name")->name;
if ($cluster!=='sgf_modular_regression_'.$run) throw new \RuntimeException('SGF_DESTRUCTIVE_SUITE_REFUSED: unexpected cluster identity.');
}
return parent::setUpTraits();
}
}