Пример #1
0
 public function testAddDefaultTemplate()
 {
     $expected = ['key' => 'foo', 'errorTemplates' => [], 'defaultTemplates' => ['page' => 'default', 'homepage' => 'overview']];
     $theme = new Theme();
     $theme->setKey($expected['key']);
     $theme->addDefaultTemplate('page', 'default');
     $theme->addDefaultTemplate('homepage', 'overview');
     $this->assertEquals($expected['defaultTemplates'], $theme->getDefaultTemplates());
     $this->assertEquals($expected['defaultTemplates']['page'], $theme->getDefaultTemplate('page'));
     $this->assertEquals($expected['defaultTemplates']['homepage'], $theme->getDefaultTemplate('homepage'));
     $this->assertNull($theme->getDefaultTemplate('other-type'));
     $this->assertEquals($expected, $theme->toArray());
 }
Пример #2
0
 protected function prepareWebspaceManager()
 {
     if ($this->webspaceManager !== null) {
         return;
     }
     $this->webspace = new Webspace();
     $this->webspace->setKey('sulu_io');
     $local1 = new Localization();
     $local1->setLanguage('en');
     $local2 = new Localization();
     $local2->setLanguage('en');
     $local2->setCountry('us');
     $this->webspace->setLocalizations([$local1, $local2]);
     $this->webspace->setName('Default');
     $theme = new Theme();
     $theme->setKey('test');
     $theme->addDefaultTemplate('page', 'default');
     $this->webspace->setTheme($theme);
     $this->webspace->setNavigation(new Navigation([new NavigationContext('main', []), new NavigationContext('footer', [])]));
     $this->webspaceManager = $this->getMock('Sulu\\Component\\Webspace\\Manager\\WebspaceManagerInterface');
     $this->webspaceManager->expects($this->any())->method('findWebspaceByKey')->will($this->returnValue($this->webspace));
 }
Пример #3
0
 private function generateDefaultTemplates(Theme $theme)
 {
     $expected = ['page', 'homepage'];
     $found = [];
     $nodes = $this->xpath->query('/x:webspace/x:theme/x:default-templates/x:default-template');
     foreach ($nodes as $node) {
         /* @var \DOMNode $node */
         $template = $node->nodeValue;
         $type = $node->attributes->getNamedItem('type')->nodeValue;
         $theme->addDefaultTemplate($type, $template);
         $found[] = $type;
     }
     foreach ($expected as $item) {
         if (!in_array($item, $found)) {
             throw new ExpectedDefaultTemplatesNotFound($this->webspace->getKey(), $expected, $found);
         }
     }
     return $theme;
 }