public function testMetatags() { $urlManager = $this->getMock('RedKiteLabs\\RedKiteCms\\RedKiteCmsBundle\\Core\\UrlManager\\UrlManagerInterface'); $theme = $this->getMockBuilder('RedKiteLabs\\ThemeEngineBundle\\Core\\Theme\\Theme')->disableOriginalConstructor()->getMock(); $themeSlots = $this->getMock('RedKiteLabs\\ThemeEngineBundle\\Core\\ThemeSlots\\ThemeSlotsInterface'); $theme->expects($this->once())->method('getThemeSlots')->will($this->returnValue($themeSlots)); $pageTree = $this->getMockBuilder('RedKiteLabs\\RedKiteCms\\RedKiteCmsBundle\\Core\\PageTree\\PageTree')->disableOriginalConstructor()->setMethods(array('getMetaTitle', 'getMetaDescription', 'getMetaKeywords'))->getMock(); $pageTree->expects($this->once())->method('getMetaTitle')->will($this->returnValue('Website title')); $pageTree->expects($this->once())->method('getMetaDescription')->will($this->returnValue('Website description')); $pageTree->expects($this->once())->method('getMetaKeywords')->will($this->returnValue('website,keywords')); $metatagsSection = new MetatagSection($urlManager); $options = array("uploadAssetsFullPath" => "", "uploadAssetsAbsolutePath" => "", "deployBundleAssetsPath" => ""); $expectedResult = PHP_EOL . "{#-------------- METATAGS SECTION --------------#}" . PHP_EOL; $expectedResult .= "{% block title %} Website title {% endblock %}" . PHP_EOL; $expectedResult .= "{% block description %} Website description {% endblock %}" . PHP_EOL; $expectedResult .= "{% block keywords %} website,keywords {% endblock %}" . PHP_EOL; $this->assertEquals($expectedResult, $metatagsSection->generateSection($pageTree, $theme, $options)); }
/** * Generates the template's subsections and the full template itself */ protected function generatePageTemplate(PageTree $pageTree, ThemeInterface $theme, array $options) { if (!$this->page->getIsPublished()) { $this->twigTemplate = "{% extends 'RedKiteLabsThemeEngineBundle:Frontend:unpublished.html.twig' %}"; return $this; } $options["filter"] = array('page'); $this->twigTemplate = sprintf("{%% extends '%s:%s:%s/base/%s.html.twig' %%}" . PHP_EOL, $options["deployBundle"], $options["templatesDir"], $this->language->getLanguageName(), $this->page->getTemplateName()); $this->twigTemplate .= $this->metatagsSection->generateSection($pageTree, $theme, $options); $this->twigTemplate .= $this->assetsSection->generateSection($pageTree, $theme, $options); $this->twigTemplate .= $this->contentSection->generateSection($pageTree, $theme, $options); return $this; }