/** * populate all the properties for the object described by the given fixture * * @param Fixture $fixture */ public function populate(Fixture $fixture) { $class = $fixture->getClass(); $name = $fixture->getName(); $object = $this->objects->get($name); foreach ($fixture->getProperties() as $property) { $key = $property->getName(); $val = $property->getValue(); if (is_array($val) && '{' === key($val)) { throw new \RuntimeException('Misformatted string in object ' . $name . ', ' . $key . '\'s value should be quoted if you used yaml'); } $value = $property->requiresUnique() ? $this->generateUnique($fixture, $property) : $this->processor->process($property, $fixture->getSetProperties(), $fixture->getValueForCurrent()); foreach ($this->setters as $setter) { if ($setter->canSet($fixture, $object, $key, $value)) { $setter->set($fixture, $object, $key, $value); $fixture->setPropertyValue($key, $value); break; } } if (!array_key_exists($key, $fixture->getSetProperties())) { throw new \UnexpectedValueException('Could not determine how to assign ' . $key . ' to a ' . $class . ' object'); } } }
public function testGetPropertiesWillReturnOnlyBasicValueProperties() { $fixture = new Fixture(self::USER, 'user', array('name' => 'John Doe', 'email' => '*****@*****.**', '__construct' => array('1', '2'), '__set' => 'setterFunc'), null); $properties = $fixture->getProperties(); $this->assertEquals(array('name' => $properties['name'], 'email' => $properties['email']), $fixture->getProperties()); }