protected function setUp() { $this->role = new RoleDescription(new RoleName('Testrole')); $this->actionDescription = ActionDescription::asQuery(new Name('testaction')); $this->processStepCollection = array(ProcessStep::fromRoleAndActionDescription($this->role, $this->actionDescription)); }
/** * @test */ public function is_query_factory_method_creating_valid_actionDescription_with_structure_from_strong_types() { $query = ActionDescription::asQuery(new Name('Testquery'), new Arguments(array('arg1' => 'some value')), StructureDefinition::fromPathValueTypeList(array('prop1' => 'string'))); $this->assertInstanceOf('GingerCore\\Model\\JsonWDL\\Action\\ActionDescription', $query); $this->assertEquals('Testquery', $query->name()->toString()); $this->assertEquals('some value', $query->arguments()->argument('arg1')); $this->assertEquals('prop1', $query->structureDefinition()->structureItems()[0]->pathWithKey()); }
/** * @param array $anActionDescriptionDefinition * @return ActionDescription */ public static function actionDescriptionFromDefinition(array $anActionDescriptionDefinition) { Assertion::keyExists($anActionDescriptionDefinition, 'name', sprintf("Missing name property in ActionDescriptionDefinition: %s", json_encode($anActionDescriptionDefinition))); Assertion::keyExists($anActionDescriptionDefinition, 'type', sprintf("Missing type property in ActionDescriptionDefinition: %s", json_encode($anActionDescriptionDefinition))); if ($anActionDescriptionDefinition['type'] === Type::COMMAND) { Assertion::keyExists($anActionDescriptionDefinition, 'events', sprintf("Missing events property in ActionDescriptionDefinition: %s", json_encode($anActionDescriptionDefinition))); $eventsDefinition = EventsDefinition::fromEventDescriptionDefinitions($anActionDescriptionDefinition['events']); } else { $eventsDefinition = null; } if (isset($anActionDescriptionDefinition['arguments'])) { Assertion::isArray($anActionDescriptionDefinition['arguments'], sprintf("The arguments property of ActionDescriptionDefinition must be an array: %s given in %s", Util::getType($anActionDescriptionDefinition['arguments']), json_encode($anActionDescriptionDefinition))); $arguments = new Arguments($anActionDescriptionDefinition['arguments']); } else { $arguments = new Arguments(array()); } if (isset($anActionDescriptionDefinition['structure'])) { Assertion::isArray($anActionDescriptionDefinition['structure'], sprintf("The structure property of ActionDescriptionDefinition must be an array: %s given in %s", Util::getType($anActionDescriptionDefinition['structure']), json_encode($anActionDescriptionDefinition))); $structureDefinition = StructureDefinition::fromPathValueTypeList($anActionDescriptionDefinition['structure']); } else { $structureDefinition = null; } if ($anActionDescriptionDefinition['type'] === Type::COMMAND) { return ActionDescription::asCommand(new Name($anActionDescriptionDefinition['name']), $eventsDefinition, $arguments, $structureDefinition); } else { return ActionDescription::asQuery(new Name($anActionDescriptionDefinition['name']), $arguments, $structureDefinition); } }