/**
  * 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 Text();
     $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('Text', $this->eventDispatcher, $type);
 }
示例#2
0
 public function testGenerate2()
 {
     $generator_valuemap = array(array(5, 30, 5), array(0, 182, 0));
     $utilities = $this->getMockBuilder('Faker\\Components\\Engine\\Common\\Utilities')->disableOriginalConstructor()->getMock();
     $generator = $this->getMock('\\PHPStats\\Generator\\GeneratorInterface');
     $locale = $this->getMock('\\Faker\\Locale\\LocaleInterface');
     $generator->expects($this->any())->method('generate')->will($this->returnValueMap($generator_valuemap));
     $locale->expects($this->exactly(5))->method('getFillerText')->will($this->returnValue(self::$words));
     $type = new Text();
     $type->setGenerator($generator);
     $type->setLocale($locale);
     $type->setUtilities($utilities);
     $type->setOption('paragraphs', 5);
     $type->setOption('maxlines', 30);
     $type->setOption('minlines', 5);
     $this->assertTrue($type->validate());
     $values = array();
     $this->assertContains('Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Lorem ipsum dolor sit amet', $type->generate(1, $values));
 }