/** * Page reparsen und updaten * * @param Cms\Data\Page $page * @param Cms\Data\Template $template * @param string $reparseType */ public static function reparseAndUpdatePage(Page &$page, Template $template, $reparseType = self::TYPE_REPARSE) { // Content reparsen $newPageContent = array(); $newPageContent = self::reparseContent($page->getWebsiteid(), $page->getContent(), $page->getTemplatecontent(), $template->getContent(), $reparseType); // Page mit den neuen Werten updaten $page->setContent(\Zend_Json::encode($newPageContent)); $page->setTemplatecontent($template->getContent()); $page->setTemplatecontentchecksum($template->getContentchecksum()); // Page speichern $pageBusiness = new \Cms\Business\Page('Page'); $pageBusiness->update($page->getId(), $page->getWebsiteId(), array('content' => \Zend_Json::encode($newPageContent), 'templatecontent' => $template->getContent(), 'templatecontentchecksum' => $template->getContentchecksum())); return true; }
/** * @test * @group integration */ public function copySuccess() { // ARRANGE $pageBusiness = new \Cms\Business\Page('Page'); $websiteId = 'SITE-1964e89c-22af-46cd-a651-fc42dc78fe50-SITE'; $paramsForCopy = array('id' => 'PAGE-03565eb8-0363-47e9-afac-90ae9d96d3c2-PAGE', 'websiteId' => $websiteId, 'name' => 'copy page test'); // ACT $this->dispatch('page/copy/params/' . urlencode(json_encode($paramsForCopy))); $response = $this->getValidatedSuccessResponse(); // ASSERT $responseData = $response->getData(); $this->assertInternalType('object', $responseData); $this->assertNotNull($responseData->id); $this->assertNotSame($paramsForCopy['id'], $responseData->id); // check if page was copied $pageIdsAfterCopy = $pageBusiness->getIdsByWebsiteId($websiteId); $pageFound = false; foreach ($pageIdsAfterCopy as $pageId) { $page = $pageBusiness->getById($pageId, $websiteId); if ($page->getName() == $paramsForCopy['name']) { $pageFound = true; break; } } $this->assertTrue($pageFound); }