/** * @test */ public function it_combines_properties_from_all_injected_property_factories() { $domainMessage = new DomainMessage('7a8ccbc5-d802-46c8-b9ec-7a286bc7653b', 0, new Metadata(), new \stdClass(), DateTime::now()); $this->mockFactory1->expects($this->once())->method('createProperties')->with($domainMessage)->willReturn(['correlation_id' => '123456', 'content_type' => 'text/plain']); $this->mockFactory2->expects($this->once())->method('createProperties')->with($domainMessage)->willReturn(['content_type' => 'application/json+ld', 'delivery_mode' => 2]); $expectedProperties = ['correlation_id' => '123456', 'content_type' => 'application/json+ld', 'delivery_mode' => 2]; $actualProperties = $this->compositeFactory->createProperties($domainMessage); $this->assertEquals($expectedProperties, $actualProperties); }
/** * @test */ public function it_delegates_body_and_properties_creation_to_the_respective_injected_factories() { $domainMessage = new DomainMessage('06d0906d-e235-40d2-b9f3-1fa6aebc9e00', 1, new Metadata(), new DummyEvent('06d0906d-e235-40d2-b9f3-1fa6aebc9e00', 'foo'), DateTime::now()); $body = '{"foo":"bar"}'; $properties = ['deliver_mode' => 2]; $expectedAMQPMessage = new AMQPMessage($body, $properties); $this->bodyFactory->expects($this->once())->method('createBody')->with($domainMessage)->willReturn($body); $this->propertiesFactory->expects($this->once())->method('createProperties')->with($domainMessage)->willReturn($properties); $actualAMQPMessage = $this->messageFactory->createAMQPMessage($domainMessage); $this->assertEquals($expectedAMQPMessage, $actualAMQPMessage); }