コード例 #1
0
 /**
  * Instantiate and configure the node according to this definition
  *
  * @return Faker\Components\Engine\Common\Composite\TypeNode instance
  *
  * @throws InvalidDefinitionException When the definition is invalid
  */
 public function getNode()
 {
     $type = new Regex();
     $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('Regex', $this->eventDispatcher, $type);
 }
コード例 #2
0
ファイル: RegexTest.php プロジェクト: icomefromthenet/faker
 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 Regex();
     $type->setGenerator($generator);
     $type->setLocale($locale);
     $type->setUtilities($utilities);
     $type->setOption('format', 'aaaa[0-9]{4}');
     $type->validate();
     $values = array();
     $this->assertRegExp('/a{4}[0-9]{4}/', $type->generate(1, $values));
     $this->assertRegExp('/a{4}[0-9]{4}/', $type->generate(1, $values));
     $this->assertRegExp('/a{4}[0-9]{4}/', $type->generate(1, $values));
     $this->assertRegExp('/a{4}[0-9]{4}/', $type->generate(1, $values));
     $this->assertRegExp('/a{4}[0-9]{4}/', $type->generate(1, $values));
 }