コード例 #1
0
 /**
  * @dataProvider getUuidAttributeFixture
  */
 public function testCreateValue($uuid)
 {
     $uuid_attribute = new UuidAttribute(self::ATTR_NAME, $this->getTypeMock());
     $value = $uuid_attribute->createValueHolder();
     $this->assertInstanceOf(UuidValueHolder::CLASS, $value);
     $value->setValue($uuid);
     $this->assertEquals($uuid, $value->getValue());
 }
コード例 #2
0
ファイル: AggregateRoot.php プロジェクト: honeybee/honeybee
 /**
  * Process the given aggregate-command, hence build the corresponding aggregate-event.
  *
  * @param CommandInterface $command
  * @param array $custom_event_state
  *
  * @return EmbeddedEntityEventInterface
  */
 protected function processEmbeddedEntityCommand(CommandInterface $command, array $custom_event_state = [])
 {
     $event_class = $command->getEventClass();
     $attribute_name = $command->getParentAttributeName();
     $event_state = ['parent_attribute_name' => $attribute_name, 'embedded_entity_type' => $command->getEmbeddedEntityType()];
     if ($command instanceof RemoveEmbeddedEntityCommand) {
         $event_state['embedded_entity_identifier'] = $command->getEmbeddedEntityIdentifier();
     } elseif ($command instanceof AddEmbeddedEntityCommand) {
         $create_data = $command->getValues();
         if (!isset($create_data['identifier'])) {
             $create_data['identifier'] = UuidAttribute::generateVersion4();
         }
         $event_state = array_merge($event_state, ['data' => $create_data, 'position' => $command->getPosition(), 'embedded_entity_identifier' => $create_data['identifier']]);
     } elseif ($command instanceof ModifyEmbeddedEntityCommand) {
         $event_state = array_merge($event_state, ['data' => $command->getValues(), 'position' => $command->getPosition(), 'embedded_entity_identifier' => $command->getEmbeddedEntityIdentifier()]);
     }
     $embedded_entity_events = new EmbeddedEntityEventList();
     foreach ($command->getEmbeddedEntityCommands() as $embedded_command) {
         $embedded_entity_events->push($this->processEmbeddedEntityCommand($embedded_command));
     }
     $event_state['embedded_entity_events'] = $embedded_entity_events;
     return new $event_class($event_state);
 }