Ejemplo n.º 1
0
 public function testAddPopulator()
 {
     $class = self::CONTACT;
     $fixture = new Fixture($class, 'test', array('magicProp' => 'magicValue'), null);
     $object = new $class(new \Nelmio\Alice\support\models\User());
     $this->createPopulator(array('objects' => new Collection(array('test' => $object))));
     $this->populator->addPopulator(new CustomPopulator());
     $this->populator->populate($fixture);
     $this->assertEquals('magicValue set by magic setter', $object->magicProp);
 }
Ejemplo n.º 2
0
 public function testSettingPrivatePropertiesDirectly()
 {
     $class = self::PLURAL;
     $fixture = new Fixture($class, 'test', ['fields' => 'a', 'properties' => 'b'], null);
     $object = new $class();
     $this->createPopulator(['objects' => new Collection(['test' => $object])]);
     $this->populator->addPopulator(new Property());
     $this->populator->populate($fixture);
     $this->assertEquals('a', $object->getFields());
     $this->assertEquals('b', $object->getProperties());
 }
Ejemplo n.º 3
0
 /**
  * @TODO https://github.com/nelmio/alice/pull/220#issuecomment-113524513
  */
 public function testArrayAdd()
 {
     $class = self::PLURAL;
     $fixture = new Fixture($class, 'test', ['fields' => ['a', 'b', 'c'], 'properties' => ['q', 'w', 'e']], null);
     $object = new $class();
     $this->createPopulator(['objects' => new Collection(['test' => $object])]);
     $this->populator->addPopulator(new ArrayAdd(new TypeHintChecker()));
     $this->populator->populate($fixture);
     $this->assertEquals(['a', 'b', 'c'], $object->getFields());
     $this->assertEquals(['q', 'w', 'e'], $object->getProperties());
 }