/**
  * Instantiate and configure the node according to this definition
  *
  * @return Faker\Components\Engine\Common\Composite\TypeNode The node instance
  *
  * @throws InvalidDefinitionException When the definition is invalid
  */
 public function getNode()
 {
     $type = new Numeric();
     $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('Numeric', $this->eventDispatcher, $type);
 }
示例#2
0
 public function testGenerateWithDecimal()
 {
     $utilities = $this->getMockBuilder('Faker\\Components\\Engine\\Common\\Utilities')->disableOriginalConstructor()->getMock();
     $generator = $this->getMock('\\PHPStats\\Generator\\GeneratorInterface');
     $locale = $this->getMock('\\Faker\\Locale\\LocaleInterface');
     $utilities->expects($this->once())->method('generateRandomNum')->with($this->equalTo('xxxx.xx'))->will($this->returnValue(1234.22));
     $type = new Numeric();
     $type->setGenerator($generator);
     $type->setLocale($locale);
     $type->setUtilities($utilities);
     $type->setOption('format', 'xxxx.xx');
     $type->validate();
     $values = array();
     $this->assertEquals(1234.22, $type->generate(1, $values));
 }