Carew\Tests\Event\Listener\Decorator\TwigTest::testPostRenderWithLayout PHP Method

testPostRenderWithLayout() public method

public testPostRenderWithLayout ( $layout )
    public function testPostRenderWithLayout($layout)
    {
        $document = new Document();
        $document->setBody('Hello {{ name }}');
        $document->setLayout($layout);
        $document->setVars(array('key' => 'value', 'currentPath' => 'should not appear'));
        $template = <<<EOL
"{{ carew.document.body }}"
"{{ carew.relativeRoot }}"
"{{ carew.currentPath }}"
"{{ carew.extra.foo }}"
"{{ carew.extra.key }}"
EOL;
        $this->twigLoader->setTemplate('default.html.twig', $template);
        $event = new CarewEvent(array($document));
        $this->getTwigGlobals()->fromArray(array('foo' => 'bar', 'relativeRoot' => 'should not appear'));
        $this->twigListenner->postRender($event);
        $expected = <<<EOL
"Hello {{ name }}"
"."
""
"bar"
"value"
EOL;
        $this->assertSame($expected, $document->getBodyDecorated());
    }