/** * @test * @group small * @group library */ public function test_copy_success() { // ARRANGE $fromWebsiteId = 'old-website-id'; $newName = 'new website name'; $toWebsiteId = 'new-website-id'; $expectedWebsite = new DataWebsite(); $expectedWebsite->setId($toWebsiteId); $expectedWebsite->setName($newName); $websiteServiceMock = $this->getMockBuilder('\\Cms\\Service\\Website')->disableOriginalConstructor()->getMock(); $websiteServiceMock->expects($this->once())->method('copy')->with($this->equalTo($fromWebsiteId), $this->equalTo($newName))->will($this->returnValue($expectedWebsite)); $pageServiceMock = $this->getMockBuilder('\\Cms\\Service\\Page')->disableOriginalConstructor()->getMock(); $pageServiceMock->expects($this->once())->method('copyPagesToNewWebsite')->with($this->equalTo($fromWebsiteId), $this->equalTo($toWebsiteId)); $templateServiceMock = $this->getMockBuilder('\\Cms\\Service\\Template')->disableOriginalConstructor()->getMock(); $templateServiceMock->expects($this->once())->method('copyToNewWebsite')->with($this->equalTo($fromWebsiteId), $this->equalTo($toWebsiteId)); $snippetServiceMock = $this->getMockBuilder('\\Cms\\Service\\TemplateSnippet')->disableOriginalConstructor()->getMock(); $snippetServiceMock->expects($this->once())->method('copyToNewWebsite')->with($this->equalTo($fromWebsiteId), $this->equalTo($toWebsiteId)); $moduleServiceMock = $this->getMockBuilder('\\Cms\\Service\\Modul')->disableOriginalConstructor()->getMock(); $moduleServiceMock->expects($this->once())->method('copyToNewWebsite')->with($this->equalTo($fromWebsiteId), $this->equalTo($toWebsiteId)); $albumServiceMock = $this->getMockBuilder('\\Cms\\Service\\Album')->disableOriginalConstructor()->getMock(); $albumServiceMock->expects($this->once())->method('copyAlbumsToNewWebsiteId')->with($this->equalTo($fromWebsiteId), $this->equalTo($toWebsiteId)); $mediaServiceMock = $this->getMockBuilder('\\Cms\\Service\\Media')->disableOriginalConstructor()->getMock(); $mediaServiceMock->expects($this->once())->method('copyMediaToNewWebsite')->with($this->equalTo($fromWebsiteId), $this->equalTo($toWebsiteId)); $websiteSettingsMock = $this->getMockBuilder('\\Cms\\Service\\WebsiteSettings')->disableOriginalConstructor()->getMock(); $websiteSettingsMock->expects($this->once())->method('copyToNewWebsite')->with($this->equalTo($fromWebsiteId), $this->equalTo($toWebsiteId)); $packageMock = $this->getMockBuilder('\\Cms\\Service\\Package')->disableOriginalConstructor()->getMock(); $packageMock->expects($this->once())->method('copyToNewWebsite')->with($this->equalTo($fromWebsiteId), $this->equalTo($toWebsiteId)); $websiteBusinessMock = $this->getMockBuilder('\\Cms\\Business\\Website')->disableOriginalConstructor()->setMethods(array('getService'))->getMock(); $websiteBusinessMock->expects($this->any())->method('getService')->will($this->returnValueMap(array(array('', $websiteServiceMock), array('Page', $pageServiceMock), array('Template', $templateServiceMock), array('TemplateSnippet', $snippetServiceMock), array('Modul', $moduleServiceMock), array('Album', $albumServiceMock), array('Media', $mediaServiceMock), array('WebsiteSettings', $websiteSettingsMock), array('Package', $packageMock)))); // ACT $actualWebsite = $websiteBusinessMock->copy($fromWebsiteId, $newName); // ASSERT $this->assertInstanceOf('\\Cms\\Data\\Website', $actualWebsite); $this->assertEquals($expectedWebsite->getId(), $actualWebsite->getId()); $this->assertEquals($expectedWebsite->getName(), $actualWebsite->getName()); }
/** * Get full publish configuration * @param \Cms\Data\Website $website * @return array */ public function getPublishData($website) { $publishData = json_decode($website->getPublish(), true); // use default publish data if (!is_array($publishData) || count($publishData) <= 0) { $publishData = $this->getDefaultPublishData(); } // add the website domain for live hosting (this should not be overwritten by user input) if ($publishData['type'] === 'internal') { $publishData['domain'] = $this->getInternalLiveDomainName($website); } else { // add default ports for ftp/sftp if (isset($publishData['protocol']) && (!isset($publishData['port']) || !$publishData['port'])) { if ($publishData['protocol'] === 'ftp') { $publishData['port'] = 21; } elseif ($publishData['protocol'] === 'sftp') { $publishData['port'] = 22; } } } // default config from configuration files $publishDefaultData = $this->getDefaultPublishData($publishData['type']); return array_replace_recursive($publishDefaultData, $publishData); }
protected function setValuesFromData(WebsiteData $data) { $this->setId($data->getId()); $this->setResolutions(\Zend_Json::decode($data->getResolutions(), \Zend_Json::TYPE_OBJECT)); }
/** * Gibt das Password aus dem Daten Objekt zurueck * * @param \Cms\Data\Website $website * @return string */ protected function getPasswordFromOrm(\Cms\Data\Website $website) { $publishData = $website->getPublish(); $publishArr = \Zend_Json::decode($publishData); if (isset($publishArr['password'])) { return $publishArr['password']; } else { return ''; } }
protected function setValuesFromData(WebsiteData $data) { $this->setId($data->getId()); $this->setName($data->getName()); $this->setDescription($data->getDescription()); $this->setNavigation($data->getNavigation()); $this->setPublishingEnabled($data->getPublishingEnabled()); $this->setPublish(\Zend_Json::decode($data->getPublish())); $this->setColorscheme(\Zend_Json::decode($data->getColorscheme())); $this->setResolutions(\Zend_Json::decode($data->getResolutions(), \Zend_Json::TYPE_OBJECT)); $this->setVersion($data->getVersion()); $this->setScreenshot(); $this->setHome($data->getHome()); }
/** * @param Data\Website $website * @return string */ private function getWebsiteJson(Data\Website $website) { $websiteColumnsAndValues = $website->getExportColumnsAndValues(); return json_encode($websiteColumnsAndValues); }
/** * Get full publish configuration * * @param \Cms\Data\Website $website * * @return array */ public function getPublishData($website) { $publishData = json_decode($website->getPublish(), true); // use default publish data if (!is_array($publishData) || count($publishData) <= 0) { $publishData = $this->getDefaultPublishData(); } // this should not be overwritten by user input $publishData['shortId'] = $website->getShortId(); // default config from configuration files $publishDefaultData = $this->getDefaultPublishData($publishData['type']); return array_replace_recursive($publishDefaultData, $publishData); }
protected function setValuesFromData(WebsiteData $data) { $this->setId($data->getId()); $this->setColorscheme(\Zend_Json::decode($data->getColorscheme())); }
/** * Internal Live Domain (e.g. ef3sbae.zuk.io) * * @param \Cms\Data\Website $website * * @return string */ public function getInternalLiveUrl($website) { $shortId = $website->getShortId(); return Registry::getBaseUrl() . $this->liveHostingWebPath . '/' . $shortId; }
/** * * @param Cms\Data\Website $website * @return array */ protected function getWebsitePrivileges($website) { $websiteId = $website->getId(); $accessManager = AccessManager::singleton(); $allWebsitePrivileges = $accessManager->getWebsitePrivileges(); if (is_null($websiteId) || !isset($allWebsitePrivileges[$websiteId])) { return $this->getBusiness('Group')->getDefaultNegativeWebsitePrivileges(); } return $allWebsitePrivileges[$websiteId]; }