/** * @dataProvider configurationDataProvider * @param array $configuration * @param Attribute $expectedAttribute */ public function testAssemble($configuration, $expectedAttribute) { $assembler = new AttributeAssembler(); $attributes = $assembler->assemble($configuration); $this->assertInstanceOf('Doctrine\\Common\\Collections\\ArrayCollection', $attributes); $this->assertCount(1, $attributes); $this->assertTrue($attributes->containsKey($expectedAttribute->getName())); $this->assertEquals($expectedAttribute, $attributes->get($expectedAttribute->getName())); }
/** * @dataProvider configurationDataProvider * @param array $configuration * @param Attribute $expectedAttribute * @param array $guessedParameters */ public function testAssemble($configuration, $expectedAttribute, array $guessedParameters = array()) { $relatedEntity = '\\stdClass'; $attributeGuesser = $this->getAttributeGuesser(); $attributeGuesser->expects($this->any())->method('fixPropertyPath')->will($this->returnArgument(0)); $attributeConfiguration = current($configuration); if ($guessedParameters && array_key_exists('property_path', $attributeConfiguration)) { $attributeGuesser->expects($this->any())->method('guessAttributeParameters')->with($relatedEntity, $attributeConfiguration['property_path'])->will($this->returnValue($guessedParameters)); } $assembler = new AttributeAssembler($attributeGuesser); $definition = $this->getWorkflowDefinition(); $definition->expects($this->once())->method('getEntityAttributeName')->will($this->returnValue('entity_attribute')); $definition->expects($this->any())->method('getRelatedEntity')->will($this->returnValue($relatedEntity)); $expectedAttributesCount = 1; if (!array_key_exists('entity_attribute', $configuration)) { $expectedAttributesCount++; } $attributes = $assembler->assemble($definition, $configuration); $this->assertInstanceOf('Doctrine\\Common\\Collections\\ArrayCollection', $attributes); $this->assertCount($expectedAttributesCount, $attributes); $this->assertTrue($attributes->containsKey($expectedAttribute->getName())); $this->assertEquals($expectedAttribute, $attributes->get($expectedAttribute->getName())); }
/** * @param WorkflowDefinition $definition * @param array $configuration * @return Attribute[]|Collection */ protected function assembleAttributes(WorkflowDefinition $definition, array $configuration) { $attributesConfiguration = $this->getOption($configuration, WorkflowConfiguration::NODE_ATTRIBUTES, array()); return $this->attributeAssembler->assemble($definition, $attributesConfiguration); }