/** * @group SwitchFactory * @covers FOF30\Factory\SwitchFactory::model * @dataProvider SwitchFactoryDataprovider::getTestModel */ public function testModel($test, $check) { $msg = 'SwitchFactory::model %s - Case: ' . $check['case']; $platform = static::$container->platform; $platform::$isAdmin = $test['backend']; $factory = new SwitchFactory(static::$container); $result = $factory->model($test['view']); $this->assertEquals($check['result'], get_class($result), sprintf($msg, 'Returned the wrong result')); }
/** * Create a new Model object * * @param string $viewName The name of the view we're getting a Model for. * @param array $config Optional MVC configuration values for the Model object. * * @return Model */ public function model($viewName, array $config = array()) { try { return parent::model($viewName, $config); } catch (ModelNotFound $e) { $magic = new Magic\ModelFactory($this->container); return $magic->make($viewName, $config); } }
/** * Create a new Model object * * @param string $viewName The name of the view we're getting a Model for. * @param array $config Optional MVC configuration values for the Model object. * * @return Model */ public function model($viewName, array $config = array()) { try { return parent::model($viewName, $config); } catch (ModelNotFound $e) { $magic = new Magic\ModelFactory($this->container); // Let's pass the section override (if any) $magic->setSection($this->getSection()); return $magic->make($viewName, $config); } }