Fix compressed draft saves provenance and Beira documentary continuity
tests / ci (push) Canceled after 0s
tests / ci (push) Canceled after 0s
This commit is contained in:
@@ -17,6 +17,41 @@ use Tests\TestCase;
|
||||
final class InvestmentPortfolioContinuityTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
public function test_draft_version_guard_still_rejects_a_real_stale_version(): void
|
||||
{
|
||||
$draft = new \App\Models\SimulationFormDraft;
|
||||
$draft->forceFill(['id'=>(string)Str::uuid(),'version_no'=>2]);
|
||||
$service=app(\App\Services\SimulationFormDrafts::class);
|
||||
$guard=new \ReflectionMethod($service,'requireMatch');
|
||||
$tag=$service->etag($draft);
|
||||
foreach (['W/'.$tag, str_replace('-v2','-v1',$tag)] as $invalid) {
|
||||
$request=\Illuminate\Http\Request::create('/','PUT'); $request->headers->set('If-Match',$invalid);
|
||||
try { $guard->invoke($service,$request,$draft); $this->fail('A mismatching version must be rejected'); }
|
||||
catch (\Symfony\Component\HttpKernel\Exception\HttpException $error) { $this->assertSame(412,$error->getStatusCode()); }
|
||||
}
|
||||
$request=\Illuminate\Http\Request::create('/','PUT'); $request->headers->set('If-Match',$tag);
|
||||
$this->assertNull($guard->invoke($service,$request,$draft));
|
||||
}
|
||||
|
||||
public function test_beira_documentary_membership_opens_the_same_published_opportunities_without_inferring_by_province(): void
|
||||
{
|
||||
$portfolio = InvestmentPortfolioController::visible()->where('content->code', 'COR-02')->firstOrFail();
|
||||
$service = app(CorridorAgribusinessOpportunities::class);
|
||||
$ids = $service->portfolioOpportunityIds($portfolio);
|
||||
$this->assertCount(7, $ids);
|
||||
$this->get('/carteira/'.$portfolio->id)->assertOk()->assertInertia(fn(Assert $page) => $page->has('opportunities', 7));
|
||||
$catalogueIds=app(\App\Services\InvestmentCatalogue::class)->query(['corridor_id'=>$portfolio->corridor_id])->pluck('opportunities.id')->all();
|
||||
$this->assertSame([], array_values(array_diff($ids,$catalogueIds)));
|
||||
$opportunity=Opportunity::findOrFail($ids[0]);
|
||||
$this->get('/oportunidades/'.$opportunity->slug.'?from_dossier='.$portfolio->id)->assertOk();
|
||||
$origins=app(InvestmentOpportunityChoices::class)->portfolioOrigins([$portfolio->id],$opportunity->id);
|
||||
$this->assertSame($portfolio->id,$origins[0]['id']);
|
||||
$this->assertSame('corridor',$origins[0]['kind']);
|
||||
$other=Opportunity::published()->whereNotIn('id',$ids)->firstOrFail();
|
||||
$this->get('/oportunidades/'.$other->slug.'?from_dossier='.$portfolio->id)->assertNotFound();
|
||||
$this->assertSame([], $service->portfolioOpportunityIds(InvestmentPortfolioController::visible()->whereNotNull('project_id')->firstOrFail()));
|
||||
}
|
||||
private User $actor;
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user