public function handle(AsyncDomainEvent $event) { if (!isset($event->values()['userId'])) { throw new AsyncDomainEventValueDoesNotExistException('userId'); } $this->commandBus->handle(new AddUserCommand($event->values()['userId'])); }
function it_cannot_be_handle_when_values_does_not_contain_user_id(AsyncDomainEvent $event) { $event->values()->shouldBeCalled()->willReturn([]); $this->shouldThrow(AsyncDomainEventValueDoesNotExistException::class)->duringHandle($event); }