/**
  * @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);
 }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
 /**
  * @test
  * @group library
  */
 public function getByIdShouldReturnExpectedTemplate()
 {
     $websiteId = 'SITE-30490289-dddb-4501-879f-9c6c7965f871-SITE';
     $create = array('name' => uniqid(__METHOD__, true), 'content' => array(array('id' => 'TEST_CONTENT_GET_BY_ID')), 'pageType' => 'TEST_PAGETYPE_GET_BY_ID');
     $this->service->create($websiteId, $create);
     $templates = $this->service->getAll($websiteId);
     foreach ($templates as $template) {
         if ($template->getName() === $create['name']) {
             $createdTemplate = $template;
             break;
         }
     }
     $idOfCreatedTemplated = $createdTemplate->getId();
     $getByIdTemplate = $this->service->getById($idOfCreatedTemplated, $websiteId);
     $this->assertInstanceOf('Cms\\Data\\Template', $getByIdTemplate);
     $this->assertSame($create['name'], $getByIdTemplate->getName());
     $this->assertSame(\Zend_Json::encode($create['content']), $getByIdTemplate->getContent());
     $this->assertSame($create['pageType'], $getByIdTemplate->getPageType());
     $uuidValidator = new UniqueIdValidator(\Orm\Data\Template::ID_PREFIX, \Orm\Data\Template::ID_SUFFIX);
     $this->assertTrue($uuidValidator->isValid($getByIdTemplate->getId()));
 }
 /**
  * @test
  * @group small
  * @group dev
  * @group library
  */
 public function test_updateDefaultFormValuesOfTemplate_success()
 {
     // ARRANGE
     $websiteId = 'SITE-update00-defa-ult0-form-values000001-SITE';
     $templateId = 'TPL-update00-defa-ult0-form-values000001-TPL';
     $orgTemplateContentChecksum = 'theoriginaltemplatechecksum';
     $contentUpdaterService = new ContentUpdaterService('ContentUpdater');
     $templateService = new TemplateService('Template');
     $expectedContentJson = FS::readContentFromFile(FS::joinPath($this->jsonFilesDirectory, 'expected_template_content.json'));
     $expectedContent = json_decode($expectedContentJson);
     // ACT
     $contentUpdaterService->updateDefaultFormValuesOfTemplate($websiteId, $templateId);
     // ASSERT
     $template = $templateService->getById($templateId, $websiteId);
     $this->assertNotSame($orgTemplateContentChecksum, $template->getContentchecksum());
     $templateContent = json_decode($template->getContent());
     $this->assertEquals($expectedContent, $templateContent);
 }
Exemplo n.º 5
0
 /**
  * @test
  * @group library
  *
  * @dataProvider provider_test_updateOrCreateTemplateFromTemplateJson_success
  */
 public function test_updateOrCreateTemplateFromTemplateJson_success($websiteId, $templateId, $expectedTemplate)
 {
     // ARRANGE
     $templateJsonFile = FS::joinPath($this->testFilesDirectory, 'import', 'import_test_002', 'templates', $templateId, 'template.json');
     $templateService = new TemplateService('Template');
     $importServiceMock = $this->getMockBuilder('\\Cms\\Service\\Import')->setConstructorArgs(array('Import'))->setMethods(array('cleaningColorIds'))->getMock();
     // ACT
     $actualImportedData = $this->callMethod($importServiceMock, 'updateOrCreateTemplateFromTemplateJson', array($templateId, $websiteId, $templateJsonFile));
     // ASSERT
     $this->assertEquals($templateId, $actualImportedData['id']);
     $actualTemplate = $templateService->getById($templateId, $websiteId);
     $this->assertInstanceOf('\\Cms\\Data\\Template', $actualTemplate);
     $actualTemplateAsArray = $actualTemplate->toArray();
     foreach ($expectedTemplate as $attributeName => $expectedValue) {
         $this->assertArrayHasKey($attributeName, $actualTemplateAsArray);
         $this->assertEquals($expectedValue, $actualTemplateAsArray[$attributeName]);
     }
 }