Phalcon\Test\Unit\Mvc\ViewTest::testRenderingWithPartials PHP Method

testRenderingWithPartials() public method

Tests rendering with partials
Since: 2012-05-28
Author: Andres Gutierrez ([email protected])
    public function testRenderingWithPartials()
    {
        $this->specify('The rendering with partials does not work as expected', function () {
            $view = new View();
            $view->setViewsDir(PATH_DATA . 'views' . DIRECTORY_SEPARATOR);
            $view->setParamToView('cool_var', 'le-this');
            $view->start();
            $view->render('test5', 'index');
            $view->finish();
            expect($view->getContent())->equals("<html>Hey, this is a partial, also le-this</html>\n");
            $view->start();
            $view->render('test9', 'index');
            $view->finish();
            expect($view->getContent())->equals("<html>Hey, this is a partial, also le-this<br />Hey, this is a second partial, also le-this</html>\n");
            $view->start();
            $view->render('test5', 'subpartial');
            $view->finish();
            expect($view->getContent())->equals("<html>Including Hey, this is a partial, also le-this</html>\n");
            $view->setMainView('html5');
            $view->start();
            $view->render('test5', 'index');
            $view->finish();
            expect($view->getContent())->equals("<!DOCTYPE html><html>Hey, this is a partial, also le-this</html>\n");
            expect($view->getPartial('partials/_partial1', ['cool_var' => 'le-this']))->equals('Hey, this is a partial, also le-this');
        });
    }