public function testGuessAttributeParametersCollectionAssociation() { $propertyPath = 'entity.association'; $rootClass = 'RootClass'; $metadata = $this->getMock('Doctrine\\Common\\Persistence\\Mapping\\ClassMetadata'); $metadata->expects($this->any())->method('getName')->will($this->returnValue($rootClass)); $metadata->expects($this->any())->method('hasAssociation')->with('association')->will($this->returnValue(true)); $metadata->expects($this->any())->method('hasField')->with('association')->will($this->returnValue(false)); $metadata->expects($this->any())->method('isCollectionValuedAssociation')->with('association')->will($this->returnValue(true)); $this->setEntityMetadata(array($rootClass => $metadata)); $this->setEntityConfigProvider($rootClass, 'association', true, false); $this->assertAttributeOptions($this->guesser->guessAttributeParameters($rootClass, $propertyPath), null, 'object', array('class' => 'Doctrine\\Common\\Collections\\ArrayCollection')); }
/** * @param array $options * @param string $rootClass * @param string $propertyPath * @return array */ protected function guessOptions(array $options, $rootClass, $propertyPath) { $guessedOptions = array('label', 'type', 'options'); $needGuess = false; foreach ($guessedOptions as $option) { if (empty($options[$option])) { $needGuess = true; break; } } if (!$needGuess) { return $options; } $attributeParameters = $this->attributeGuesser->guessAttributeParameters($rootClass, $propertyPath); if ($attributeParameters) { foreach ($guessedOptions as $option) { if (empty($options[$option]) && !empty($attributeParameters[$option])) { $options[$option] = $attributeParameters[$option]; } } } return $options; }