['project_title' => 'Synthetic QA dossier'], 'selection' => [], 'opportunity_choices' => []]; try { app(InvestmentConsumerScope::class)->context($context, 'opportunity:99999999'); $this->fail('An explicit opportunity outside the dossier must be rejected instead of becoming general context.'); } catch (HttpException $error) { $this->assertSame(422, $error->getStatusCode()); $this->assertSame([], $context['opportunity_choices']); $this->assertSame('Synthetic QA dossier', $context['fields']['project_title']); } } public function test_general_context_without_an_opportunity_preserves_an_empty_dossier(): void { $context = ['fields' => ['project_title' => 'Synthetic QA dossier'], 'selection' => []]; $this->assertSame($context, app(InvestmentConsumerScope::class)->context($context, null)); } public function test_an_explicit_opportunity_outside_existing_choices_is_rejected(): void { $context = ['fields' => [], 'selection' => [], 'opportunity_choices' => [['opportunity' => ['key' => 'opportunity:1']]]]; $this->expectException(HttpException::class); app(InvestmentConsumerScope::class)->context($context, 'opportunity:2'); } }