/**
  * @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);
 }
 /**
  * Loads the SQL fixtures from the given json file
  *
  * @param $fixtureFilePath -- the path of the fixtures file
  */
 protected function loadSqlFixtureFromJsonFile($fixtureFilePath)
 {
     $dataSetsAsArray = json_decode(FS::readContentFromFile($fixtureFilePath), true);
     if (json_last_error() !== JSON_ERROR_NONE) {
         throw new \RuntimeException($fixtureFilePath . '::' . json_last_error_msg());
     }
     $this->loadSqlFixtureFromArray($dataSetsAsArray);
 }
 /**
  * @test
  * @group small
  * @group dev
  * @group library
  */
 public function test_updateDefaultFormValuesOfTemplate_success()
 {
     // ARRANGE
     $websiteId = 'SITE-update00-defa-ult0-form-values000001-SITE';
     $templateSnippetId = 'TPLS-update00-defa-ult0-form-values000001-TPLS';
     $contentUpdaterService = new ContentUpdaterService('ContentUpdater');
     $templateSnippetService = new TemplateSnippetService('TemplateSnippet');
     $expectedContent = json_decode(FS::readContentFromFile(FS::joinPath($this->jsonFilesDirectory, 'expected_templatesnippet_content.json')));
     // ACT
     $contentUpdaterService->updateDefaultFormValuesOfTemplateSnippet($websiteId, $templateSnippetId);
     // ASSERT
     $templateSnippet = $templateSnippetService->getById($websiteId, $templateSnippetId);
     $actualContent = json_decode($templateSnippet->getContent());
     $this->assertEquals($expectedContent, $actualContent);
 }
예제 #4
0
 /**
  * @param array $expectedValuesInThemeFiles
  *
  * @throws FS\FileSystemException
  */
 protected function assertValuesExistsInFiles(array $expectedValuesInThemeFiles)
 {
     foreach (new \DirectoryIterator($this->getTestTargetPath()) as $fileInfo) {
         if ($fileInfo->isDot() || !$fileInfo->isFile()) {
             continue;
         }
         $content = FS::readContentFromFile($fileInfo->getPathname());
         foreach ($expectedValuesInThemeFiles as $key => $searchValue) {
             if (strstr($content, $searchValue) !== false) {
                 unset($expectedValuesInThemeFiles[$key]);
             }
         }
     }
     if (count($expectedValuesInThemeFiles) > 0) {
         $this->fail(sprintf("The values of the keys '%s' didn't exists in theme files", implode(', ', array_keys($expectedValuesInThemeFiles))));
     }
 }
 /**
  * @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);
 }
 /**
  * loads the legacy data
  */
 protected function initLegacyDefaultFormValues()
 {
     try {
         $legacyDataFile = FS::joinPath(__DIR__, 'legacyDefaultFormValues.json');
         if (!file_exists($legacyDataFile)) {
             $this->legacyDefaultFormValues = array();
             return;
         }
         $this->legacyDefaultFormValues = json_decode(FS::readContentFromFile($legacyDataFile));
         if (is_object($this->legacyDefaultFormValues)) {
             $this->legacyDefaultFormValues = (array) $this->legacyDefaultFormValues;
         }
         if (!is_array($this->legacyDefaultFormValues)) {
             $this->legacyDefaultFormValues = array();
             return;
         }
     } catch (\Exception $doNothing) {
         $this->legacyDefaultFormValues = array();
         return;
     }
 }
예제 #7
0
 /**
  * @test
  * @group small
  * @group library
  */
 public function test_publish_shouldPublishAsExpected()
 {
     // ARRANGE
     ConfigHelper::mergeIntoConfig(array('publisher' => array('type' => 'standalone')));
     $websiteId = 'INTERNAL_THIS_IS_THE_WEBSITE_ID';
     $shortId = 'THIS_IS_THE_SHORT_ID';
     $publishingId = 'INTERNAL_THIS_IS_THE_PUBLISHING_ID';
     $cname = 'internal.my.live.domain.intern';
     $publishingFilePath = FS::joinPath($this->getTestFileDirectory(), 'publishing_file.zip');
     $publishConfig = array('type' => 'internal', 'cname' => $cname, 'shortId' => $shortId);
     $serviceUrls = array('download' => '/INTERNAL/service/endpoint/for/download/website/zip', 'status' => '/INTERNAL/service/endpoint/for/status/request');
     $expectedFilePathname = FS::joinPath($this->getTestFileDirectory(), 'expected_live_tree.json');
     $expectedFileTree = json_decode(FS::readContentFromFile($expectedFilePathname), true);
     $outputLiveDirectory = $this->getOutputDirectoryForShortId($shortId);
     // ACT
     $actualPublishedStatus = $this->getPublisher()->publish($websiteId, $publishingId, $publishingFilePath, $publishConfig, $serviceUrls);
     // ASSERT
     $this->assertInstanceOf('\\Cms\\Data\\PublisherStatus', $actualPublishedStatus);
     $this->assertSame($actualPublishedStatus::STATUS_FINISHED, $actualPublishedStatus->getStatus());
     $actualFileTreeAsJson = DirectoryHelper::getRecursive($outputLiveDirectory);
     $this->assertEquals($expectedFileTree, $actualFileTreeAsJson);
     $this->assertCnameLinksExists($this->getOutputDirectory(), $cname, $outputLiveDirectory);
     $this->assertDirectoryIsEmpty($this->getTempDirectory());
 }
예제 #8
0
 /**
  * @param string $moduleDataPath
  * @return array
  */
 protected function getModuleLegacyCode($moduleDataPath)
 {
     $codeArray = array();
     $rendererFile = FS::joinPath($moduleDataPath, ImportService::MODULE_LEGACY_FILE_RENDERER);
     if (file_exists($rendererFile)) {
         $codeArray['renderer'] = FS::readContentFromFile($rendererFile);
     } else {
         $codeArray['renderer'] = null;
     }
     $cssFile = FS::joinPath($moduleDataPath, ImportService::MODULE_LEGACY_FILE_CSS);
     if (file_exists($cssFile)) {
         $codeArray['css'] = FS::readContentFromFile($cssFile);
     } else {
         $codeArray['css'] = null;
     }
     $headerFile = FS::joinPath($moduleDataPath, ImportService::MODULE_LEGACY_FILE_HEADER);
     if (file_exists($headerFile)) {
         $codeArray['header'] = FS::readContentFromFile($headerFile);
     } else {
         $codeArray['header'] = null;
     }
     return $codeArray;
 }
예제 #9
0
파일: Import.php 프로젝트: rukzuk/rukzuk
 /**
  * collect the package info inside the unzipped import
  */
 protected function collectPackageInfo()
 {
     $this->currentImportPackageInfo = array();
     $packagesUnzipDirectory = FS::joinPath($this->currentImportUnzipDirectory, 'packages');
     if (!is_dir($packagesUnzipDirectory)) {
         return;
     }
     $iterator = new \DirectoryIterator($packagesUnzipDirectory);
     while ($iterator->valid()) {
         if (!$iterator->isDot() && $this->isCurrentIteratorAPackageDirectory($iterator)) {
             $packageId = $iterator->getFilename();
             $packageDirectory = $iterator->getPathname();
             $importPackageManifestFile = FS::joinPath($packageDirectory, 'pkg.json');
             if (!file_exists($importPackageManifestFile)) {
                 continue;
             }
             $packageInfo = json_decode(FS::readContentFromFile($importPackageManifestFile), true);
             if (!is_array($packageInfo)) {
                 continue;
             }
             $this->currentImportPackageInfo[$packageId] = array('id' => $packageId, 'name' => isset($packageInfo['name']) ? $packageInfo['name'] : 'unknown', 'directory' => $packageDirectory);
         }
         $iterator->next();
     }
 }
예제 #10
0
 /**
  * @test
  * @group integration
  */
 public function exportWebsiteShouldCreateExpectedFiles()
 {
     // ARRANGE
     $websiteId = 'SITE-controll-er0e-xpor-t0we-bsite0000001-SITE';
     $config = Registry::getConfig();
     $expectedJsonFilesDirectory = $config->test->json->storage->directory;
     $testFilesDirectory = $config->test->files->directory;
     $expectedExportedPackagesTree = FS::readContentFromFile(FS::joinPath($testFilesDirectory, 'trees', 'export', $websiteId, 'packages.tree'));
     $exportDirectoryName = 'test_export_0_website_with_album';
     $exportBaseDirectory = $config->export->directory;
     $exportDirectory = FS::joinPath($exportBaseDirectory, md5($exportDirectoryName));
     $exportZipFileName = md5($exportDirectoryName) . '.' . self::EXPORT_FILE_EXTENSION;
     $exportZipFile = FS::joinPath($exportDirectory, $exportZipFileName);
     $expectedTemplates = array('TPL-controll-er0e-xpor-t0we-bsite0000001-TPL' => (object) array('id' => 'TPL-controll-er0e-xpor-t0we-bsite0000001-TPL', 'name' => 'template export 1', 'content' => json_encode(array((object) array('abc' => 'def'))), 'pageType' => 'the_page_type_id'), 'TPL-controll-er0e-xpor-t0we-bsite0000002-TPL' => (object) array('id' => 'TPL-controll-er0e-xpor-t0we-bsite0000002-TPL', 'name' => 'template export 2', 'content' => json_encode(array()), 'pageType' => null));
     // ACT
     $this->dispatchWithParams('export/website', array('websiteid' => $websiteId, 'name' => $exportDirectoryName));
     // ASSERT
     $this->getValidatedSuccessResponse();
     $this->assertTrue(is_dir($exportDirectory));
     $this->assertFileExists($exportZipFile);
     $unzipCommand = sprintf("unzip %s -d %s", $exportZipFile, $exportDirectory);
     if (strstr($unzipCommand, $exportBaseDirectory)) {
         SystemHelper::user_proc_exec($unzipCommand);
         DirectoryHelper::removeRecursiv($exportZipFile, $exportBaseDirectory);
     }
     $expectedWebsiteJsonFile = FS::joinPath($expectedJsonFilesDirectory, 'expected_website.json');
     $this->assertFileExists($expectedWebsiteJsonFile);
     $this->assertWebsiteJsonCreatedAsExpected($exportDirectory, $expectedWebsiteJsonFile);
     $expectedWebsiteSettingsJsonFile = FS::joinPath($expectedJsonFilesDirectory, 'expected_export_websitesettings.json');
     $this->assertFileExists($expectedWebsiteSettingsJsonFile);
     $this->assertWebsiteSettingsJsonCreatedAsExpected($exportDirectory, $expectedWebsiteSettingsJsonFile);
     $this->assertTemplateJsonCreatedAsExpected($exportDirectory, $expectedTemplates);
     $exportedPackagesDirectory = FS::joinPath($exportDirectory, 'packages');
     $actualExportedPackagesTree = DirectoryHelper::getRecursiveAsJson($exportedPackagesDirectory, true);
     $this->assertSame($actualExportedPackagesTree, $expectedExportedPackagesTree, "Tree mismatch between export package directory tree and expected package directory tree");
     DirectoryHelper::removeRecursiv($exportDirectory, $exportBaseDirectory);
 }
예제 #11
0
 /**
  * @param string $directory
  * @param string $filename
  *
  * @return null|string
  * @throws \Exception
  */
 protected function getFileContent($directory, $filename)
 {
     $filePath = FS::joinPath($directory, $filename);
     if (!file_exists($filePath)) {
         return null;
     }
     return FS::readContentFromFile($filePath);
 }
예제 #12
0
 /**
  * @param string $directory
  *
  * @return array
  */
 protected function getCacheDirectories($directory)
 {
     $content = FS::readContentFromFile(FS::joinPath($directory, 'cache.txt'));
     return explode("\n", $content);
 }
예제 #13
0
파일: Publisher.php 프로젝트: rukzuk/rukzuk
 private function readPublisherStatusFromCache($websiteId, $buildId)
 {
     $publishedStatus = new PublisherStatusData();
     $publishedStatus->setStatus(PublisherStatusData::STATUS_UNKNOWN);
     $publishedInfoFilePath = $this->getPublisherStatusCacheFilePath($websiteId, $buildId);
     if (file_exists($publishedInfoFilePath)) {
         $publishedStatus->setFromArray(SbJson::decode(FS::readContentFromFile($publishedInfoFilePath), SbJson::TYPE_ARRAY));
     }
     return $publishedStatus;
 }