shouldReceive('findByIncoId')->with($incoId)->andReturn($composition); $usecase = new FindIncoComposition($directory); $input = new Input($incoId); // WHEN $output = $usecase->execute($input); // THEN expect($output)->toBeInstanceOf(Output::class) ->and($output->id)->toBe($compoId) ->and($output->idInco)->toBe($incoId); }); it('throws NotFoundException when composition does not exist', function (): void { // GIVEN $incoId = new IncoId('99999'); $directory = Mockery::mock(IncoCompositionDirectory::class); $directory->shouldReceive('findByIncoId')->with($incoId)->andReturn(null); $usecase = new FindIncoComposition($directory); $input = new Input($incoId); // WHEN & THEN expect(fn () => $usecase->execute($input))->toThrow(NotFoundException::class); }); });