/**
  * 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 UniqueString();
     $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('UniqueString', $this->eventDispatcher, $type);
 }
Exemple #2
0
 public function testUniqueStringGenerate()
 {
     $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('generateRandomAlphanumeric')->with($this->equalTo('ccCC'), $this->isInstanceOf($generator), $this->isInstanceOf($locale))->will($this->returnValue('dgHJ'));
     $type = new UniqueString();
     $type->setGenerator($generator);
     $type->setLocale($locale);
     $type->setUtilities($utilities);
     $type->setOption('format', 'ccCC');
     $type->validate();
     $values = array();
     $this->assertEquals('dgHJ', $type->generate(1, $values));
 }