/**
  * 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 BooleanType();
     $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('Boolean', $this->eventDispatcher, $type);
 }
Esempio n. 2
0
 public function testGenerate()
 {
     $utilities = $this->getMockBuilder('Faker\\Components\\Engine\\Common\\Utilities')->disableOriginalConstructor()->getMock();
     $generator = $this->getMock('\\PHPStats\\Generator\\GeneratorInterface');
     $locale = $this->getMock('\\Faker\\Locale\\LocaleInterface');
     $type = new BooleanType();
     $type->setGenerator($generator);
     $type->setLocale($locale);
     $type->setUtilities($utilities);
     $type->setOption('value', true);
     $type->validate();
     $values = array();
     $this->assertEquals(true, $type->generate(1, $values));
     $type = new BooleanType();
     $type->setGenerator($generator);
     $type->setLocale($locale);
     $type->setUtilities($utilities);
     $type->setOption('value', false);
     $type->validate();
     $this->assertEquals(false, $type->generate(1, $values));
 }