public function testAddingFieldsFromMultipleInstancesOfTheSameModelWithCustomNamesWorks() { require_once __DIR__ . '/Db/table/DewdropTestFruits.php'; $one = new \DewdropTest\DewdropTestFruits(); $two = new \DewdropTest\DewdropTestFruits(); $this->fields->add($one->field('name'), 'one')->add($two->field('name'), 'two'); $modelNames = array_keys($this->fields->getModelsByName()); $this->assertContains('one', $modelNames); $this->assertContains('two', $modelNames); }
/** * Get a model from the fields object by its model name. * * @throws Exception * @param string $modelName * @return \Dewdrop\Db\Table */ public function getModel($modelName) { $models = $this->fields->getModelsByName(); if (!isset($models[$modelName])) { throw new Exception("Could not find model with name '{$modelName}'"); } return $models[$modelName]; }