public function testReferencesOne() { $closure = DefaultGenerator::referencesOne($this->factory, 'test', array('class' => 'Model\\Author', 'value' => null)); $this->assertInstanceOf('Model\\Author', $closure()); $closure = DefaultGenerator::referencesOne($this->factory, 'test', array('class' => 'Model\\Author', 'value' => '49a7011a05c677b9a916612a')); $this->assertEquals('49a7011a05c677b9a916612a', (string) $closure()->getId()); $closure = DefaultGenerator::referencesOne($this->factory, 'test', array('class' => 'Model\\Author', 'value' => new \MongoId('49a7011a05c677b9a916612a'))); $this->assertEquals('49a7011a05c677b9a916612a', (string) $closure()->getId()); $closure = DefaultGenerator::referencesOne($this->factory, 'test', array('class' => 'Model\\Category', 'value' => array('name' => 'my special test name'))); $repository = $this->factory->getMongator()->getRepository('Model\\Category'); $category = $repository->findOneById($closure()->getId()); $this->assertEquals('my special test name', $category->getName()); }