34 lines
2.0 KiB
PHP
34 lines
2.0 KiB
PHP
<?php
|
|
|
|
use App\Services\StandaloneArtifact;
|
|
use App\Services\StandaloneRuntime;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
/** Own PostgreSQL QA database only; no active installation or business fixture. */
|
|
function prepareSyntheticStandaloneRuntime(): void
|
|
{
|
|
if (getenv('COMPRAS_STANDALONE_BUSINESS_QA') !== '1' || ! app()->environment('testing') || DB::getDriverName() !== 'pgsql'
|
|
|| DB::connection()->getConfig('host') !== '127.0.0.1'
|
|
|| ! preg_match('/^compras_receipts_test_[a-f0-9]{12}$/D', DB::connection()->getDatabaseName())) {
|
|
throw new LogicException('Synthetic standalone business database required.');
|
|
}
|
|
$settings = config('standalone-runtime');
|
|
$settings['enabled'] = true;
|
|
$settings['prepare_only'] = false;
|
|
$settings['features'] = array_fill_keys(StandaloneRuntime::FEATURES, true);
|
|
config(['standalone-runtime' => [...$settings, 'enabled' => false], 'common-payables.source_instance' => 'standalone-business-synthetic']);
|
|
$runtime = new StandaloneRuntime($settings, new StandaloneArtifact);
|
|
$runtime->artifact();
|
|
(require base_path('database/standalone-migrations/2026_11_29_000001_create_runtime_installations.php'))->up();
|
|
DB::table('compras_runtime_installations')->insert(['id' => $settings['installation_id'], 'product' => 'compras',
|
|
'contract' => StandaloneArtifact::CONTRACT, 'manifest_sha256' => $settings['manifest_sha256'],
|
|
'database_binding_sha256' => StandaloneRuntime::databaseBinding(DB::connection()),
|
|
'recorded_by' => 'Synthetic standalone business regression', 'reason' => 'Authorised isolated candidate verification', 'installed_at' => now()]);
|
|
(require base_path('database/standalone-migrations/2026_11_29_000002_install_standalone_extensions.php'))->up();
|
|
config(['standalone-runtime' => $settings]);
|
|
app()->instance(StandaloneRuntime::class, $runtime);
|
|
$paths = $runtime->configure(DB::connection());
|
|
config(['general-ledger.path' => $paths['general-ledger']]);
|
|
$runtime->assertLoadedPackages();
|
|
}
|