/** * @covers \eZ\Publish\Core\MVC\Legacy\Templating\Twig\Environment::loadTemplate * @covers \eZ\Publish\Core\MVC\Legacy\Templating\Twig\Template::getTemplateName * * @expectedException \Twig_Error_Loader */ public function testLoadNonExistingTemplateLegacy() { $legacyEngine = $this->getMockBuilder('eZ\\Publish\\Core\\MVC\\Legacy\\Templating\\LegacyEngine')->disableOriginalConstructor()->getMock(); $templateName = 'design:test/helloworld.tpl'; $legacyEngine->expects($this->any())->method('supports')->with($templateName)->will($this->returnValue(true)); $legacyEngine->expects($this->any())->method('exists')->with($templateName)->will($this->returnValue(false)); $twigEnv = new Environment($this->getMock('Twig_LoaderInterface')); $twigEnv->setEzLegacyEngine($legacyEngine); $template = $twigEnv->loadTemplate($templateName); }
/** * @covers \eZ\Publish\Core\MVC\Legacy\Templating\Twig\Environment::loadTemplate * @covers \eZ\Publish\Core\MVC\Legacy\Templating\Twig\Template::getTemplateName */ public function testLoadTemplateLegacy() { $legacyEngine = $this->getMockBuilder('eZ\\Publish\\Core\\MVC\\Legacy\\Templating\\LegacyEngine')->disableOriginalConstructor()->getMock(); $templateName = 'design:test/helloworld.tpl'; $legacyEngine->expects($this->any())->method('supports')->with($templateName)->will($this->returnValue(true)); $twigEnv = new Environment($this->getMock('Twig_LoaderInterface')); $twigEnv->setEzLegacyEngine($legacyEngine); $template = $twigEnv->loadTemplate($templateName); $this->assertInstanceOf('eZ\\Publish\\Core\\MVC\\Legacy\\Templating\\Twig\\Template', $template); $this->assertSame($templateName, $template->getTemplateName()); // Calling loadTemplate a 2nd time with the same template name should return the very same Template object. $this->assertSame($template, $twigEnv->loadTemplate($templateName)); }