예제 #1
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);
 }
 /**
  * It should return any localizations if neither parent nor children.
  */
 public function testWebspaceAnyLocalization()
 {
     $this->inspector->getWebspace($this->document->reveal())->willReturn(self::FIX_WEBSPACE);
     $this->inspector->getLocales($this->document->reveal())->willReturn(['de']);
     $this->webspace->getLocalization(self::FIX_LOCALE)->willReturn($this->localization1->reveal());
     $this->localization1->getLocalization()->willReturn('en');
     $this->localization2->getLocalization()->willReturn('de');
     $this->hydrateEvent->getOption('load_ghost_content', true)->willReturn(true);
     $this->localization1->getParent()->willReturn(null);
     $this->localization1->getChildren()->willReturn([]);
     $this->webspace->getLocalizations()->willReturn([$this->localization2->reveal()]);
     $this->registry->updateLocale($this->document->reveal(), 'de', 'en')->shouldBeCalled();
     $this->hydrateEvent->setLocale('de')->shouldBeCalled();
     $this->subscriber->handleHydrate($this->hydrateEvent->reveal());
 }