static function build($alias, $attributes = array()) { $_this = self::getInstance(); if (!empty($_this->models[$alias])) { $extends = array(); if (!empty($_this->models[$alias]['extends'])) { $extends = FFactory::build($_this->models[$alias]['extends']); } $data = array_merge($extends, $_this->models[$alias]['attributes'], $attributes); foreach ($data as &$value) { if (is_array($value)) { switch ($value[0]) { case 'sequence': $value = $_this->next($value[1]); break; case 'assoc': if (empty($value[2])) { $value[2] = 'id'; } $value = $_this->assoc($value[1], $value[2]); break; default: $value = null; } } } return $data; } else { throw new FactoryNotDefinedException("Factory [{$alias}] is not defined."); } return null; }
function testBuildThrowsExceptionIfFactoryIsNotDefined() { $this->expectException('FactoryNotDefinedException'); FFactory::build('Undefined'); }