/** * Runs a command on the {@link MockDataBuilder} object using options * defined in the request. * * @param string The command to run * @param string The class to create or update */ protected function runBuilderCommand($cmd, $className) { $count = $this->request->getVar('count') ?: 10; $parent = $this->request->getVar('parent'); $parentField = $this->request->getVar('parentField') ?: "ParentID"; try { $builder = MockDataBuilder::create($className); } catch (Exception $e) { echo $e->getMessage(); die; } $builder->setOnlyEmpty($this->request->getVar('onlyEmpty') === "false" ? false : true)->setDownloadImages($this->request->getVar('downloadImages') === "false" ? false : true)->setCount($count)->setParentIdentifier($parent ?: null)->setParentField($parentField); try { $builder->{$cmd}(); } catch (Exception $e) { echo $e->getMessage() . "\n\n"; die; } }
public function testGeneratorCreatesRecords() { MockDataBuilder::create("MockDataObjectTest_Person")->setCount(10)->setIncludeRelations(false)->generate(); $this->assertEquals(11, $this->getList()->count()); }