public function addTable($name, array $options = array()) { # check if schema exist if (!$this->head instanceof SchemaNode) { throw new EngineException('Must add a scheam first before adding a table'); } if (isset($options['name']) === false) { $options['name'] = $name; } # merge options with default $options = array_merge(array('locale' => $this->head->getOption('locale')), $options); # create the new table $id = $name; $table = new TableNode($id, $this->eventDispatcher); # set the options foreach ($options as $optionKey => $optionValue) { $table->setOption($optionKey, $optionValue); } # add table to schema $this->head->addChild($table); # assign table as head $this->head = $table; return $this; }
/** * @expectedException \Faker\Components\Engine\Common\Composite\CompositeException * @expectedExceptionMessage generatorSeed must be an integer */ public function testEmptyStringNotAcceptedGeneratorSeed() { $id = 'schema_1'; $event = $this->getMockBuilder('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface')->getMock(); $table = new TableNode($id, $event); $table->setOption('name', 'tableNode'); $table->setOption('generatorSeed', ''); $table->setOption('generate', 100); $table->validate(); }