/**
  * Set the value for the given property.
  *
  * @param object $object
  * @param string $property
  * @param mixed  $value
  */
 protected function setPropertyValue($object, $property, $value)
 {
     if ($this->entityManager->isSingleAssociation(get_class($object), $property)) {
         $relatedObject = $this->entityManager->merge($this->fixtures->getReference(trim($value)));
         $method = $this->getPropertyMethod($property, $object);
         $object->{$method}($relatedObject);
     } elseif ($this->entityManager->isCollectionAssociation(get_class($object), $property)) {
         if (is_string($value)) {
             $value = explode($this->collectionDelimiter, $value);
         }
         $method = $this->getPropertyMethod($property, $object, false);
         foreach ($value as $elmt) {
             $relatedObject = $this->entityManager->merge($this->fixtures->getReference(trim($elmt)));
             $object->{$method}($relatedObject);
         }
     } else {
         $method = $this->getPropertyMethod($property, $object);
         $object->{$method}($value);
     }
 }
示例#2
0
 public function addReference($name, $object)
 {
     parent::addReference($name, $object);
     self::$tests[$name] = $object;
 }