/** * @test */ public function it_deserialize_the_message_before_emitting() { $stream = new DomainEventStream([new DomainMessage('a', 0, new Metadata(), [], DateTime::now())]); $consumer = new EventBusConsumer($this->serializer, $this->eventBus); $this->serializer->shouldReceive('deserialize')->with("[]")->andReturn($stream); $this->eventBus->shouldReceive('publish')->with($stream)->once(); $consumer->consume("[]"); }
/** * @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); }