@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\PurchasingRole;
|
||||
use App\Models\User;
|
||||
use App\Services\CommonBudget;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Tempo\Finance\Budget\BudgetControl;
|
||||
|
||||
require_once __DIR__.'/../Support/ReceiptFixture.php';
|
||||
require_once __DIR__.'/../Support/BudgetDistributionSchema.php';
|
||||
|
||||
test('old pinned runtime refuses partial optional schema even when its source table is absent', function () {
|
||||
if (method_exists(BudgetControl::class, 'recordDistribution')) {
|
||||
$this->markTestSkipped('Recovery boundary requires the unchanged installed artifact.');
|
||||
}
|
||||
$f = receiptFixture();
|
||||
budgetDistributionFixtureSchema();
|
||||
DB::connection()->getSchemaBuilder()->drop('budget_distributions');
|
||||
$actor = User::factory()->create(['tenant_id' => $f['tenant']->id, 'purchasing_role' => PurchasingRole::Finance]);
|
||||
$this->actingAs($actor);
|
||||
try {
|
||||
app(CommonBudget::class)->for($actor);
|
||||
$this->fail('Partial optional schema cannot silently become a legacy balance.');
|
||||
} catch (HttpException $error) {
|
||||
expect($error->getStatusCode())->toBe(503);
|
||||
}
|
||||
expect(DB::table('budget_entries')->count())->toBe(0);
|
||||
});
|
||||
|
||||
test('old pinned runtime refuses to ignore a distributed origin instead of presenting a false available balance', function () {
|
||||
if (method_exists(BudgetControl::class, 'recordDistribution')) {
|
||||
$this->markTestSkipped('This recovery boundary exercises the unchanged installed artifact.');
|
||||
}
|
||||
$f = receiptFixture();
|
||||
budgetDistributionFixtureSchema();
|
||||
$actor = User::factory()->create(['tenant_id' => $f['tenant']->id, 'purchasing_role' => PurchasingRole::Finance]);
|
||||
$this->actingAs($actor);
|
||||
DB::table('budget_distributions')->insert(['tenant_id' => $actor->tenant_id, 'requisition_id' => $f['r']->id,
|
||||
'phase' => 'reserve', 'snapshot' => '{}', 'created_by' => $actor->id, 'created_at' => now(), 'updated_at' => now()]);
|
||||
try {
|
||||
app(CommonBudget::class)->for($actor);
|
||||
$this->fail('An incompatible runtime must fail closed.');
|
||||
} catch (HttpException $error) {
|
||||
expect($error->getStatusCode())->toBe(503);
|
||||
}
|
||||
expect(DB::table('budget_entries')->count())->toBe(0)->and(DB::table('budget_consumptions')->count())->toBe(0);
|
||||
});
|
||||
Reference in New Issue
Block a user