| @@ 12-35 (lines=24) @@ | ||
| 9 | use PhpSpec\ObjectBehavior; |
|
| 10 | use Prophecy\Argument; |
|
| 11 | ||
| 12 | class UseCaseSpec extends ObjectBehavior |
|
| 13 | { |
|
| 14 | function let(DomainRepositoryInterface $domainRepository) |
|
| 15 | { |
|
| 16 | $this->beConstructedWith($domainRepository); |
|
| 17 | } |
|
| 18 | ||
| 19 | function it_is_initializable() |
|
| 20 | { |
|
| 21 | $this->shouldHaveType(UseCase::class); |
|
| 22 | } |
|
| 23 | ||
| 24 | function it_should_handle_command(DomainRepositoryInterface $domainRepository, Command $command) |
|
| 25 | { |
|
| 26 | /** @var DomainId $domainId */ |
|
| 27 | $domainId = Argument::type(DomainId::class); |
|
| 28 | $domainRepository->getById($domainId)->shouldBeCalled(); |
|
| 29 | $this->beConstructedWith($domainRepository); |
|
| 30 | ||
| 31 | $command->getDomainId()->shouldBeCalled(); |
|
| 32 | $command->getModelId()->shouldBeCalled(); |
|
| 33 | $this->handle($command)->shouldReturn(null); |
|
| 34 | } |
|
| 35 | } |
|
| 36 | ||
| @@ 12-36 (lines=25) @@ | ||
| 9 | use PhpSpec\ObjectBehavior; |
|
| 10 | use Prophecy\Argument; |
|
| 11 | ||
| 12 | class UseCaseSpec extends ObjectBehavior |
|
| 13 | { |
|
| 14 | function let(DomainRepositoryInterface $domainRepository) |
|
| 15 | { |
|
| 16 | $this->beConstructedWith($domainRepository); |
|
| 17 | } |
|
| 18 | ||
| 19 | function it_is_initializable() |
|
| 20 | { |
|
| 21 | $this->shouldHaveType(UseCase::class); |
|
| 22 | } |
|
| 23 | ||
| 24 | function it_should_have_handle_method_for_command(DomainRepositoryInterface $domainRepository, Command $command) |
|
| 25 | { |
|
| 26 | /** @var DomainId $domainId */ |
|
| 27 | $domainId = Argument::type(DomainId::class); |
|
| 28 | $domainRepository->getById($domainId)->shouldBeCalled(); |
|
| 29 | ||
| 30 | $command->getDomainId()->shouldBeCalled(); |
|
| 31 | $command->getUseCaseId()->shouldBeCalled(); |
|
| 32 | $command->getUseCaseType()->willReturn('command'); |
|
| 33 | ||
| 34 | $this->handle($command)->shouldReturn(null); |
|
| 35 | } |
|
| 36 | } |
|
| 37 | ||