Ejemplo n.º 1
0
 private function getWebspace()
 {
     $webspace = new Webspace();
     $webspace->setName('test');
     $theme = new Theme();
     $theme->setKey('default');
     $webspace->setTheme($theme);
     return $webspace;
 }
Ejemplo n.º 2
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());
 }
Ejemplo n.º 3
0
 public function testToArray()
 {
     $expected = ['key' => 'foo', 'name' => 'portal_key', 'localizations' => [['fr']], 'security' => ['system' => 'sec_sys'], 'segments' => [['asd']], 'portals' => [['one']], 'theme' => ['dsa'], 'navigation' => ['contexts' => []]];
     $this->security->getSystem()->willReturn($expected['security']['system']);
     $this->localization->toArray()->willReturn($expected['localizations'][0]);
     $this->segment->toArray()->willReturn($expected['segments'][0]);
     $this->theme->toArray()->willReturn($expected['theme']);
     $this->portal->toArray()->willReturn($expected['portals'][0]);
     $this->webspace->setKey($expected['key']);
     $this->webspace->setName($expected['name']);
     $this->webspace->setLocalizations([$this->localization->reveal()]);
     $this->webspace->setSecurity($this->security->reveal());
     $this->webspace->setSegments([$this->segment->reveal()]);
     $this->webspace->setPortals([$this->portal->reveal()]);
     $this->webspace->setTheme($this->theme->reveal());
     $res = $this->webspace->toArray();
     $this->assertEquals($expected, $res);
 }
Ejemplo n.º 4
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));
 }
Ejemplo n.º 5
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;
 }
Ejemplo n.º 6
0
 public function testGetCollectionMovedResourceLocator()
 {
     // Set up test
     $path = '/qwertz/';
     $prefix = '/de';
     $uuid = 1;
     $portal = new Portal();
     $portal->setKey('portal');
     $theme = new Theme();
     $theme->setKey('theme');
     $webspace = new Webspace();
     $webspace->setTheme($theme);
     $portal->setWebspace($webspace);
     $localization = new Localization();
     $localization->setLanguage('de');
     $structure = $this->getStructureMock($uuid);
     $requestAnalyzer = $this->getRequestAnalyzerMock($portal, $path, $prefix, $localization, RequestAnalyzerInterface::MATCH_TYPE_FULL, 'sulu.lo', 'sulu.lo/en-us');
     $activeTheme = $this->getActiveThemeMock();
     $contentMapper = $this->getContentMapperMock();
     $contentMapper->expects($this->any())->method('loadByResourceLocator')->will($this->throwException(new ResourceLocatorMovedException('/new-test', '123-123-123')));
     $portalRouteProvider = new ContentRouteProvider($contentMapper, $requestAnalyzer, $activeTheme);
     $request = $this->getRequestMock($path);
     // Test the route provider
     $routes = $portalRouteProvider->getRouteCollectionForRequest($request);
     $this->assertCount(1, $routes);
     $route = $routes->getIterator()->current();
     $this->assertEquals('SuluWebsiteBundle:Default:redirect', $route->getDefaults()['_controller']);
     $this->assertEquals('/de/new-test', $route->getDefaults()['url']);
 }
Ejemplo n.º 7
0
 public function setUp()
 {
     $webspaces = [];
     $portals = [];
     $portalInformations = ['prod' => [], 'dev' => []];
     $this->webspaceCollection = new WebspaceCollection();
     // first portal
     $portal = new Portal();
     $portal->setName('Portal1');
     $portal->setKey('portal1');
     $theme = new Theme();
     $theme->setKey('portal1theme');
     $environment = new Environment();
     $url = new Url();
     $url->setUrl('www.portal1.com');
     $url->setLanguage('en');
     $url->setCountry('us');
     $environment->addUrl($url);
     $environment->setType('prod');
     $url = new Url();
     $url->setUrl('portal1.com');
     $url->setRedirect('www.portal1.com');
     $environment->addUrl($url);
     $portal->addEnvironment($environment);
     $localizationEnUs = new Localization();
     $localizationEnUs->setCountry('us');
     $localizationEnUs->setLanguage('en');
     $localizationEnUs->setShadow('auto');
     $localizationEnUs->setDefault(true);
     $localizationEnCa = new Localization();
     $localizationEnCa->setCountry('ca');
     $localizationEnCa->setLanguage('en');
     $localizationEnCa->setDefault(false);
     $localizationEnUs->addChild($localizationEnCa);
     $localizationFrCa = new Localization();
     $localizationFrCa->setCountry('ca');
     $localizationFrCa->setLanguage('fr');
     $localizationFrCa->setDefault(false);
     $portal->addLocalization($localizationEnUs);
     $portal->addLocalization($localizationEnCa);
     $portal->addLocalization($localizationFrCa);
     $portal->setDefaultLocalization($localizationEnUs);
     $portal->setResourceLocatorStrategy('tree');
     $webspace = new Webspace();
     $webspace->addLocalization($localizationEnUs);
     $webspace->addLocalization($localizationFrCa);
     $segmentSummer = new Segment();
     $segmentSummer->setName('Summer');
     $segmentSummer->setKey('s');
     $segmentSummer->setDefault(true);
     $segmentWinter = new Segment();
     $segmentWinter->setName('Winter');
     $segmentWinter->setKey('w');
     $segmentWinter->setDefault(false);
     $webspace->addSegment($segmentSummer);
     $webspace->addSegment($segmentWinter);
     $webspace->setTheme($theme);
     $webspace->addPortal($portal);
     $webspace->setKey('default');
     $webspace->setName('Default');
     $webspace->addPortal($portal);
     $webspace->setNavigation(new Navigation([new NavigationContext('main', [])]));
     $portals[] = $portal;
     $webspaces[] = $webspace;
     $portalInformations['prod']['www.portal1.com'] = new PortalInformation(RequestAnalyzerInterface::MATCH_TYPE_FULL, $webspace, $portal, $localizationEnUs, 'www.portal1.com', $segmentSummer);
     $portalInformations['dev']['portal1.lo'] = new PortalInformation(RequestAnalyzerInterface::MATCH_TYPE_FULL, $webspace, $portal, $localizationEnUs, 'portal1.lo', $segmentSummer);
     $this->webspaceCollection->setWebspaces($webspaces);
     $this->webspaceCollection->setPortals($portals);
     $this->webspaceCollection->setPortalInformations($portalInformations);
 }