/**
  * Instantiate and configure the node according to this definition
  *
  * @return Faker\Components\Engine\Common\Composite\CompositeInterface The node instance
  *
  * @throws InvalidDefinitionException When the definition is invalid
  */
 public function getNode()
 {
     $type = new Country($this->database);
     $type->setGenerator($this->generator);
     $type->setUtilities($this->utilities);
     $type->setLocale($this->locale);
     foreach ($this->attributes as $attribute => $value) {
         $type->setOption($attribute, $value);
     }
     return new TypeNode('Country', $this->eventDispatcher, $type);
 }
Пример #2
0
 public function testGenerateMultipleCodes()
 {
     $utilities = $this->getMockBuilder('Faker\\Components\\Engine\\Common\\Utilities')->disableOriginalConstructor()->getMock();
     $generator = $this->getMock('\\PHPStats\\Generator\\GeneratorInterface');
     $locale = $this->getMock('\\Faker\\Locale\\LocaleInterface');
     $database = $this->getProject()->getGeneratorDatabase();
     $generator->expects($this->exactly(3))->method('generate')->with($this->equalTo(0), $this->equalTo(2))->will($this->returnValue(2));
     $type = new Country($database);
     $type->setGenerator($generator);
     $type->setLocale($locale);
     $type->setUtilities($utilities);
     $type->setOption('countries', 'AU,GB,US');
     $type->validate();
     $values = array();
     $this->assertEquals('United States', $type->generate(1, $values));
     $this->assertEquals('United States', $type->generate(1, $values));
     $this->assertEquals('United States', $type->generate(1, $values));
 }