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); }
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)); }