Пример #1
0
 protected function importFixture($type_name, array $fixture)
 {
     $aggregate_root_type = $this->aggregate_root_type_map->getItem($type_name);
     $type_class_name = get_class($aggregate_root_type);
     $command_namespace = array_slice(explode('\\', $type_class_name), 0, -2);
     $command_class = isset($fixture['@command']) ? $fixture['@command'] : sprintf('%1$s\\Task\\Create%2$s\\Create%2$sCommand', implode('\\', $command_namespace), $aggregate_root_type->getName());
     $builder = new AggregateRootCommandBuilder($aggregate_root_type, $command_class);
     if (isset($fixture['@command'])) {
         unset($fixture['@command']);
         foreach ($fixture as $command_property => $command_data) {
             $builder->{'with' . StringToolkit::asCamelCase($command_property)}($command_data);
         }
     } else {
         $builder->withValues($fixture);
     }
     $result = $builder->build();
     if (!$result instanceof Success) {
         $this->logger->error('Error importing fixtures:' . print_r($result->get(), true));
         throw new RuntimeError(sprintf('Error importing fixtures. Incidents have been logged.'));
     }
     $this->command_bus->post($result->get());
 }
 /**
  * @expectedException Assert\InvalidArgumentException
  */
 public function testModifyCommandWithMissingIdentifier()
 {
     $author_type = new AuthorType();
     $builder = new AggregateRootCommandBuilder($author_type, ModifyAuthorCommand::CLASS);
     $build_result = $builder->withKnownRevision(1)->withValues(['firstname' => 'Amitav', 'lastname' => 'Gosh', 'email' => '*****@*****.**'])->build();
 }