Ejemplo n.º 1
0
 /**
  *  Fetch the node managed by this definition
  *
  *  @access public
  *  @return Faker\Components\Engine\Common\Composite\CompositeInterface the new node
  */
 public function getNode()
 {
     # construct the selector type
     $type = new SwapSelector();
     $type->setGenerator($this->generator);
     $type->setUtilities($this->utilities);
     $type->setLocale($this->locale);
     foreach ($this->attributes as $attribute => $value) {
         $type->setOption($attribute, $value);
     }
     $node = new SelectorNode('selectorNode', $this->eventDispatcher, $type);
     # return the composite generator selectorNode
     return $node;
 }
Ejemplo 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 SwapSelector();
     $type->setGenerator($generator);
     $type->setLocale($locale);
     $type->setUtilities($utilities);
     $type->registerSwap(new PositionManager(3));
     $type->registerSwap(new PositionManager(3));
     $type->validate();
     $values = array();
     $this->assertEquals(1, $type->generate(0, $values));
     $this->assertEquals(1, $type->generate(0, $values));
     $this->assertEquals(1, $type->generate(0, $values));
     $this->assertEquals(2, $type->generate(0, $values));
     $this->assertEquals(2, $type->generate(0, $values));
     $this->assertEquals(2, $type->generate(0, $values));
     # loops?
     $this->assertEquals(1, $type->generate(0, $values));
     $this->assertEquals(1, $type->generate(0, $values));
     $this->assertEquals(1, $type->generate(0, $values));
     $this->assertEquals(2, $type->generate(0, $values));
     $this->assertEquals(2, $type->generate(0, $values));
     $this->assertEquals(2, $type->generate(0, $values));
 }
Ejemplo n.º 3
0
 /**
  *  Fetch the node managed by this definition
  *
  *  @access public
  *  @return Faker\Components\Engine\Common\Composite\CompositeInterface the new node
  */
 public function getNode()
 {
     # construct the selector type
     $type = new SwapSelector();
     $type->setGenerator($this->generator);
     $type->setUtilities($this->utilities);
     $type->setLocale($this->locale);
     foreach ($this->attributes as $attribute => $value) {
         $type->setOption($attribute, $value);
     }
     # register position managers
     foreach ($this->positionManagers as $mgr) {
         $type->registerSwap($mgr);
     }
     $node = new SelectorNode('selectorNode', $this->eventDispatcher, $type);
     # register children
     foreach ($this->children as $aNode) {
         $node->addChild($aNode);
     }
     # return the composite generator selectorNode
     return $node;
 }