public function testGenerate()
 {
     $utilities = $this->getMockBuilder('Faker\\Components\\Engine\\Common\\Utilities')->disableOriginalConstructor()->getMock();
     $locale = $this->getMock('\\Faker\\Locale\\LocaleInterface');
     $generatorA = $this->getMock('PHPStats\\Generator\\GeneratorInterface');
     $generatorA->expects($this->at(0))->method('generate')->with($this->equalTo(1), $this->equalTo(1))->will($this->returnValue(1));
     $generatorA->expects($this->at(1))->method('generate')->with($this->equalTo(1), $this->equalTo(1))->will($this->returnValue(1.8));
     $generatorA->expects($this->at(2))->method('generate')->with($this->equalTo(1), $this->equalTo(1))->will($this->returnValue(1.3));
     $type = new RandomSelector();
     $type->setGenerator($generatorA);
     $type->setLocale($locale);
     $type->setUtilities($utilities);
     $type->setOption('set', 1);
     $type->validate();
     $values = array();
     $this->assertEquals(1, $type->generate(1, $values));
     $this->assertEquals(2, $type->generate(1, $values));
     # rounds up
     $this->assertEquals(1, $type->generate(1, $values));
     # rounds down
 }
 /**
  *  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 RandomSelector();
     $type->setGenerator($this->generator);
     $type->setUtilities($this->utilities);
     $type->setLocale($this->locale);
     $type->setOption('set', count($this->children()));
     foreach ($this->attributes as $attribute => $value) {
         $type->setOption($attribute, $value);
     }
     # return the composite generator selectorNode
     return new SelectorNode('selectorNode', $this->eventDispatcher, $type);
 }