FactoryGirl\Provider\Doctrine\FieldDef::reference PHP Метод

reference() публичный статический Метод

The normal semantics of get() apply. Normally this means that the field gets a fresh instance of the named entity. If a singleton has been defined, get() will return that.
public static reference ( string $name ) : callable
$name string The name of the entity to get.
Результат callable
    public static function reference($name)
    {
        return function (FixtureFactory $factory) use($name) {
            return $factory->get($name);
        };
    }

Usage Example

 /**
  * @test
  */
 public function whenTheOneSideIsASingletonItMayGetSeveralChildObjects()
 {
     $this->factory->defineEntity('SpaceShip');
     $this->factory->defineEntity('Person', array('spaceShip' => FieldDef::reference('SpaceShip')));
     $ship = $this->factory->getAsSingleton('SpaceShip');
     $p1 = $this->factory->get('Person');
     $p2 = $this->factory->get('Person');
     $this->assertTrue($ship->getCrew()->contains($p1));
     $this->assertTrue($ship->getCrew()->contains($p2));
 }
All Usage Examples Of FactoryGirl\Provider\Doctrine\FieldDef::reference