/** * Instantiate and configure the node according to this definition * * @return Faker\Components\Engine\Common\Composite\CompositeInterface The node instance * * @throws InvalidDefinitionException When the definition is invalid */ public function getNode() { $type = new Cities($this->database); $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('Cities', $this->eventDispatcher, $type); }
/** * @expectedException \Faker\Components\Engine\EngineException * @expectedExceptionMessage Cities::no cities found for countries ASASAASAAU */ public function testExceptionBadCityCode() { $utilities = $this->getMockBuilder('Faker\\Components\\Engine\\Common\\Utilities')->disableOriginalConstructor()->getMock(); $generator = $this->getMock('\\PHPStats\\Generator\\GeneratorInterface'); $locale = $this->getMock('\\Faker\\Locale\\LocaleInterface'); $database = $this->getProject()->getGeneratorDatabase(); $generator->expects($this->exactly(0))->method('generate'); $type = new Cities($database); $type->setGenerator($generator); $type->setLocale($locale); $type->setUtilities($utilities); $type->setOption('countries', 'ASASAASAAU'); $type->validate(); $values = array(); $type->generate(1, $values); }