/** * @test */ public function it_publishes_the_event_in_the_QueuePublisher() { $event = new Event('SomethingHappened'); $this->serializer->shouldReceive('serialize')->with($event)->andReturn('serialized'); $this->queuePublisher->shouldReceive('publish')->with('serialized', 'SomethingHappened')->once(); $this->listener->handle($event); }
/** * @test */ public function it_should_throw_the_exception_if_it_catches_one() { $stream = new DomainEventStream([new DomainMessage('a', 0, new Metadata(), [], DateTime::now())]); $this->serializer->shouldReceive('serialize')->with($stream)->andReturn('serialized'); $this->queuePublisher->shouldReceive('publish')->andThrow(\Exception::class); $this->setExpectedException(\Exception::class); $eventBus = new QueuePublishingEventBus($this->serializer, $this->queuePublisher); $eventBus->publish($stream); }