/** * @test * @group small * @group dev * @group library */ public function test_updateAllContentsOfWebsite_success() { // ARRANGE $websiteId = 'SITE-update00-defa-ult0-form-values000001-SITE'; $templateSnippetId = 'TPLS-update00-defa-ult0-form-values000001-TPLS'; $templateId = 'TPL-update00-defa-ult0-form-values000001-TPL'; $pageId = 'PAGE-update00-defa-ult0-form-values000001-PAGE'; $orgTemplateContentChecksum = 'theoriginaltemplatechecksum'; $contentUpdaterBusiness = new ContentUpdaterBusiness('ContentUpdater'); $templateSnippetService = new TemplateSnippetService('TemplateSnippet'); $templateService = new TemplateService('Template'); $pageService = new PageService('Page'); $expectedSnippetContent = json_decode(FS::readContentFromFile(FS::joinPath($this->jsonFilesDirectory, 'expected_templatesnippet_content.json'))); $expectedTemplateContent = json_decode(FS::readContentFromFile(FS::joinPath($this->jsonFilesDirectory, 'expected_template_content.json'))); $expectedPageContent = json_decode(FS::readContentFromFile(FS::joinPath($this->jsonFilesDirectory, 'expected_page_1_content.json'))); // ACT $contentUpdaterBusiness->updateAllContentsOfWebsite($websiteId); // ASSERT $snippet = $templateSnippetService->getById($websiteId, $templateSnippetId); $actualSnippetContent = json_decode($snippet->getContent()); $this->assertEquals($expectedSnippetContent, $actualSnippetContent); $template = $templateService->getById($templateId, $websiteId); $this->assertNotSame($orgTemplateContentChecksum, $template->getContentchecksum()); $actualTemplateContent = json_decode($template->getContent()); $this->assertEquals($expectedTemplateContent, $actualTemplateContent); $page = $pageService->getById($pageId, $websiteId); $this->assertNotSame($orgTemplateContentChecksum, $page->getTemplatecontentchecksum()); $actualPageContent = json_decode($page->getContent()); $this->assertFormValuesOfPageContent($expectedPageContent, $actualPageContent); }
public function setUp() { parent::setUp(); $pageService = new PageService('Page'); $this->page = $pageService->getById('PAGE-033d84e8-cc3e-4a1f-a408-b8fa374af75f-PAGE', $this->websiteId); $templateService = new TemplateService('Template'); $this->template = $templateService->getById('TPL-0db7eaa7-7fc5-464a-bd47-16b3b8af67eb-TPL', $this->websiteId); }
/** * @param string $websiteId * * @return \Cms\Data\Page[] */ private function getAllPages($websiteId) { $allPages = array(); $allIds = $this->service->getIdsByWebsiteId($websiteId); foreach ($allIds as $pageId) { $allPages[$pageId] = $this->service->getById($pageId, $websiteId); } return $allPages; }
/** * @param string $websiteId * @return string */ public function indexWebsite($websiteId) { $websiteService = new Website('Website'); if (!$websiteService->existsWebsiteAlready($websiteId)) { throw new CmsException('602', __METHOD__, __LINE__); } // Zum Rendern muss die Business-Schicht verwendet werden $renderBusiness = new BusinessRender('Render'); $modulService = new Modul('Modul'); $pageService = new Page('Page'); $allPageIds = $pageService->getIdsByWebsiteId($websiteId); $indexFileOfWebsite = $this->getIndexFileForWebsite($websiteId); if (is_array($allPageIds) && count($allPageIds) > 0) { if (file_exists($indexFileOfWebsite)) { $index = \Zend_Search_Lucene::open($indexFileOfWebsite); $numberOfIndexedDocuments = $index->numDocs(); for ($id = 0; $id < $numberOfIndexedDocuments; ++$id) { if (!$index->isDeleted($id)) { $document = $index->delete($id); } } } else { $index = \Zend_Search_Lucene::create($indexFileOfWebsite); } foreach ($allPageIds as $pageId) { $pageContent = $this->getPageContent($websiteId, $pageId); if ($this->isStoreContentEnabled()) { $document = \Zend_Search_Lucene_Document_Html::loadHTML($pageContent, true, 'UTF-8'); } else { $document = \Zend_Search_Lucene_Document_Html::loadHTML($pageContent, false, 'UTF-8'); } $document->addField(\Zend_Search_Lucene_Field::unIndexed('md5', md5($pageContent))); $document->addField(\Zend_Search_Lucene_Field::unIndexed('pageId', $pageId)); $index->addDocument($document); } $index->commit(); $index->optimize(); unset($index); } return $indexFileOfWebsite; }