FOF30\Factory\MagicSwitchFactory::view PHP Méthode

view() public méthode

Create a new View object
public view ( string $viewName, string $viewType = 'html', array $config = [] ) : View
$viewName string The name of the view we're getting a View object for.
$viewType string The type of the View object. By default it's "html".
$config array Optional MVC configuration values for the View object.
Résultat FOF30\View\View
    public function view($viewName, $viewType = 'html', array $config = array())
    {
        try {
            return parent::view($viewName, $viewType, $config);
        } catch (ViewNotFound $e) {
            $magic = new Magic\ViewFactory($this->container);
            // Let's pass the section override (if any)
            $magic->setSection($this->getSection());
            return $magic->make($viewName, $viewType, $config);
        }
    }

Usage Example

 /**
  * @group           MagicSwitchFactory
  * @covers          FOF30\Factory\MagicSwitchFactory::view
  * @dataProvider    MagicSwitchFactoryDataprovider::getTestView
  */
 public function testView($test, $check)
 {
     $msg = 'MagicSwitchFactory::view %s - Case: ' . $check['case'];
     $platform = static::$container->platform;
     $platform::$template = 'fake_test_template';
     $platform::$uriBase = 'www.example.com';
     $factory = new MagicSwitchFactory(static::$container);
     $result = $factory->view($test['view']);
     $this->assertEquals($check['result'], get_class($result), sprintf($msg, 'Returned the wrong result'));
 }