コード例 #1
0
 /**
  * @covers \PhpCqrs\Domain\Serializer\Serializer::serialize
  */
 public function testCanSerializeObject()
 {
     $serializer = new Serializer();
     $payload = new BookRegistered('1234', 'Title!');
     $object = $serializer->serialize($payload);
     $this->assertInstanceOf(SerializedObject::class, $object);
     $this->assertSame('PhpCqrs\\Helpers\\Domain\\Event\\BookRegistered', $object->name());
     $this->assertSame(['id' => '1234', 'title' => 'Title!'], $object->payload());
 }
コード例 #2
0
 /**
  * @param DomainEventMessage $message
  * @return SerializedMessageObject
  */
 public function serialize(DomainEventMessage $message)
 {
     $object = $this->serializer->serialize($message->payload());
     return new SerializedMessageObject($message->aggregateId(), $message->sequence(), $object->name(), $object->payload(), $message->metaData()->serialize(), $message->occurredOn()->format(DATE_ISO8601));
 }