Exemplo n.º 1
0
 /**
  * @return array
  */
 public function test_configLoadReturnAllMergedConfigAsExpectedProvider()
 {
     $testConfigPath = Registry::getConfig()->test->configs->storage->directory;
     $configPath_allConfigs = FS::joinPath($testConfigPath, 'all_configs');
     $configPath_withLocalConfig = FS::joinPath($testConfigPath, 'with_local-application-ini');
     return array(array('not_exists_env', $configPath_allConfigs, null, null, array('configLoaded' => array('app_php' => true), 'valueFrom' => 'app_php', 'overwritten' => array('from' => 'app_php'))), array('production', $configPath_allConfigs, null, null, array('configLoaded' => array('app_php' => true, 'app_production_php' => true), 'valueFrom' => 'app_production_php', 'overwritten' => array('from' => 'app_production_php'))), array('production', $configPath_allConfigs, FS::joinPath($configPath_allConfigs, 'config.php'), null, array('configLoaded' => array('app_php' => true, 'app_production_php' => true, 'config_php' => true), 'valueFrom' => 'config_php', 'overwritten' => array('from' => 'config_php'))), array('production', $configPath_allConfigs, FS::joinPath($configPath_allConfigs, 'config.php'), FS::joinPath($configPath_allConfigs, 'meta.json'), array('configLoaded' => array('app_php' => true, 'app_production_php' => true, 'config_php' => true), 'valueFrom' => 'config_php', 'overwritten' => array('from' => 'config_php'), 'quota' => 'quota from meta.json', 'owner' => 'owner from meta.json', 'services' => array('someConfig' => 'services.someConfig from meta.json'), 'publisher' => array('externalrukzukservice' => array('tokens' => 'publisher.tokens from meta.json', 'liveHostingDomain' => 'publisher.liveHostingDomain from meta.json')))), array('staging', $configPath_allConfigs, null, null, array('configLoaded' => array('app_php' => true, 'app_staging_php' => true), 'valueFrom' => 'app_staging_php', 'overwritten' => array('from' => 'app_staging_php'))), array('development', $configPath_allConfigs, null, null, array('configLoaded' => array('app_php' => true, 'app_staging_php' => true, 'app_development_php' => true), 'valueFrom' => 'app_development_php', 'overwritten' => array('from' => 'app_development_php'))), array('development', $configPath_allConfigs, FS::joinPath($configPath_allConfigs, 'config.php'), null, array('configLoaded' => array('app_php' => true, 'app_staging_php' => true, 'app_development_php' => true, 'config_php' => true), 'valueFrom' => 'config_php', 'overwritten' => array('from' => 'config_php'))), array('development', $configPath_withLocalConfig, null, null, array('configLoaded' => array('app_php' => true, 'app_staging_php' => true, 'app_development_php' => true, 'local-application_ini-production' => 1, 'local-application_ini-staging' => 2, 'local-application_ini-development' => 3), 'valueFrom' => 'local-application_ini:development', 'overwritten' => array('from' => 'local-application_ini:development'))));
 }
Exemplo n.º 2
0
 /**
  * @test
  * @group small
  * @group dev
  * @group library
  */
 public function getAllShouldRetrieveExpectedWebsiteSettings()
 {
     // ARRANGE
     $websiteId = 'SITE-website0-sett-ings-test-000000000001-SITE';
     $globalSetDirectory = $this->getGlobalSetDirectory('rukzuk_test');
     $pathToPackage1WebsiteSettingsDir = FS::joinPath($globalSetDirectory, 'rz_package_1', 'websiteSettings');
     $pathToPackage2WebsiteSettingsDir = FS::joinPath($globalSetDirectory, 'rz_package_2', 'websiteSettings');
     $websiteSettingsSource = $this->getWebsiteSettingsSource($websiteId);
     $service = $this->getWebsiteSettingsService($websiteSettingsSource);
     $form = array((object) array('foo' => 'bar', 'emtpyStdClass' => new \stdClass(), 'emptyArray' => array()));
     $expectedWebsiteSettings = array('rz_shop' => array('websiteId' => $websiteId, 'id' => 'rz_shop', 'name' => (object) array('de' => 'Shop Konfiguration', 'en' => 'Shop configuration'), 'description' => null, 'version' => 'rz_shop.version', 'form' => $form, 'formValues' => (object) array('foo' => 'bar'), 'readonly' => true, 'sourceType' => SourceItem::SOURCE_REPOSITORY, 'source' => new SourceItem('rz_shop', FS::joinPath($pathToPackage1WebsiteSettingsDir, 'rz_shop'), '/url/to/rz_shop', SourceItem::SOURCE_REPOSITORY, true, false)), 'rz_shop_pro' => array('websiteId' => $websiteId, 'id' => 'rz_shop_pro', 'name' => (object) array('de' => 'Pro-Shop Konfiguration', 'en' => 'Pro shop configuration'), 'description' => null, 'version' => 'rz_shop_pro.version', 'form' => $form, 'formValues' => (object) array('bar' => 'foo'), 'readonly' => true, 'sourceType' => SourceItem::SOURCE_REPOSITORY, 'source' => new SourceItem('rz_shop_pro', FS::joinPath($pathToPackage1WebsiteSettingsDir, 'rz_shop_pro'), '/url/to/rz_shop_pro', SourceItem::SOURCE_REPOSITORY, true, false)), 'rz_website_settings_test' => array('websiteId' => $websiteId, 'id' => 'rz_website_settings_test', 'name' => (object) array('de' => 'Website Konfiguration', 'en' => 'Website configuration'), 'description' => null, 'version' => null, 'form' => $form, 'formValues' => null, 'readonly' => true, 'sourceType' => SourceItem::SOURCE_REPOSITORY, 'source' => new SourceItem('rz_website_settings_test', FS::joinPath($pathToPackage2WebsiteSettingsDir, 'rz_website_settings_test'), '/url/to/rz_website_settings_test', SourceItem::SOURCE_REPOSITORY, true, false)));
     // ACT
     $allWebsiteSettings = $service->getAll($websiteId);
     // ASSERT
     $this->assertInternalType('array', $allWebsiteSettings);
     $this->assertCount(3, $allWebsiteSettings);
     foreach ($allWebsiteSettings as $actualWebsiteSettings) {
         $this->assertInstanceOf('\\Cms\\Data\\WebsiteSettings', $actualWebsiteSettings);
         $this->assertArrayHasKey($actualWebsiteSettings->getId(), $expectedWebsiteSettings);
         $expectedSettings = $expectedWebsiteSettings[$actualWebsiteSettings->getId()];
         $actualWebsiteSettingsAsArray = $actualWebsiteSettings->toArray();
         foreach ($expectedSettings as $attributeName => $expectedValue) {
             if ($attributeName == 'source') {
                 $this->assertEquals($expectedValue->toArray(), $actualWebsiteSettingsAsArray[$attributeName]->toArray(), 'Failed asserting that website setting source are equal.');
             } else {
                 $this->assertEquals($expectedValue, $actualWebsiteSettingsAsArray[$attributeName], sprintf("Failed asserting that website setting property '%s' are equal.", $attributeName));
             }
         }
     }
 }
 /**
  * @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.º 4
0
 /**
  * @test
  * @group small
  * @group dev
  * @group library
  */
 public function test_getAllReturnsDataAsExpected()
 {
     // ARRANGE
     $dao = $this->getFilesystemDao();
     $baseDirectory = $this->getBaseDirectory();
     $source = $this->getWebsiteSettingsSource('WEBSITE-ID', array(array($baseDirectory, 'rz_shop', SourceItem::SOURCE_REPOSITORY), array($baseDirectory, 'rz_shop_pro', SourceItem::SOURCE_REPOSITORY)));
     $form = array((object) array('foo' => 'bar', 'emtpyStdClass' => new \stdClass(), 'emptyArray' => array()));
     $expectedWebsiteSettings = array('rz_shop' => array('name' => (object) array('de' => 'Shop Konfiguration', 'en' => 'Shop configuration'), 'description' => null, 'version' => 'rz_shop.version', 'form' => $form, 'formValues' => null, 'readonly' => true, 'sourceType' => 'repo', 'source' => new SourceItem('rz_shop', FS::joinPath($baseDirectory, 'rz_shop'), '/url/to/websiteSettings/rz_shop', SourceItem::SOURCE_REPOSITORY, true, false)), 'rz_shop_pro' => array('name' => (object) array('de' => 'Pro-Shop Konfiguration', 'en' => 'Pro shop configuration'), 'description' => null, 'version' => 'rz_shop_pro.version', 'form' => $form, 'formValues' => null, 'readonly' => true, 'sourceType' => 'repo', 'source' => new SourceItem('rz_shop_pro', FS::joinPath($baseDirectory, 'rz_shop_pro'), '/url/to/websiteSettings/rz_shop_pro', SourceItem::SOURCE_REPOSITORY, true, false)));
     // ACT
     $allWebsiteSettings = $dao->getAll($source);
     // ASSERT
     $this->assertInternalType('array', $allWebsiteSettings);
     $this->assertCount(count($expectedWebsiteSettings), $allWebsiteSettings);
     foreach ($allWebsiteSettings as $actualWebsiteSettings) {
         $this->assertInstanceOf('\\Cms\\Data\\WebsiteSettings', $actualWebsiteSettings);
         $this->assertArrayHasKey($actualWebsiteSettings->getId(), $expectedWebsiteSettings);
         $expectedSettings = $expectedWebsiteSettings[$actualWebsiteSettings->getId()];
         $actualWebsiteSettingsAsArray = $actualWebsiteSettings->toArray();
         foreach ($expectedSettings as $attributeName => $expectedValue) {
             if ($attributeName == 'source') {
                 $this->assertEquals($expectedValue->toArray(), $actualWebsiteSettingsAsArray[$attributeName]->toArray(), 'Failed asserting that website-settings source  is equal.');
             } else {
                 $this->assertEquals($expectedValue, $actualWebsiteSettingsAsArray[$attributeName], sprintf("Failed asserting that website-settings property '%s' is equal.", $attributeName));
             }
         }
     }
 }
Exemplo n.º 5
0
 /**
  * @test
  * @group small
  * @group dev
  * @group library
  */
 public function test_getAll_returnsDataAsExpected()
 {
     // ARRANGE
     $dao = $this->getFilesystemDao();
     $baseDirectory = $this->getBaseDirectory();
     $source = $this->getPageTypeSource('WEBSITE-ID', array(array($baseDirectory, 'rz_shop_product', SourceItem::SOURCE_REPOSITORY), array($baseDirectory, 'rz_shop_product_pro', SourceItem::SOURCE_REPOSITORY)));
     $form = array((object) array('foo' => 'bar', 'emtpyStdClass' => new \stdClass(), 'emptyArray' => array()));
     $expectedPageTypes = array('rz_shop_product' => array('name' => (object) array('de' => 'Shop Produkt', 'en' => 'Shop product'), 'description' => (object) array('de' => 'rz_shop_product.description.de', 'en' => 'rz_shop_product.description.en'), 'version' => 'rz_shop_product.version', 'form' => $form, 'formValues' => (object) array('price' => 9999), 'previewImageUrl' => '/url/to/pageType/rz_shop_product/assets/pageType.svg', 'readonly' => true, 'sourceType' => SourceItem::SOURCE_REPOSITORY, 'source' => new SourceItem('rz_shop_product', FS::joinPath($baseDirectory, 'rz_shop_product'), '/url/to/pageType/rz_shop_product', SourceItem::SOURCE_REPOSITORY, true, false)), 'rz_shop_product_pro' => array('name' => (object) array('de' => 'Shop Pro-Produkt', 'en' => 'Shop pro product'), 'description' => null, 'version' => null, 'form' => $form, 'formValues' => null, 'previewImageUrl' => null, 'readonly' => true, 'sourceType' => SourceItem::SOURCE_REPOSITORY, 'source' => new SourceItem('rz_shop_product_pro', FS::joinPath($baseDirectory, 'rz_shop_product_pro'), '/url/to/pageType/rz_shop_product_pro', SourceItem::SOURCE_REPOSITORY, true, false)));
     // ACT
     $allPageTypes = $dao->getAll($source);
     // ASSERT
     $this->assertInternalType('array', $allPageTypes);
     $this->assertCount(count($expectedPageTypes), $allPageTypes);
     foreach ($allPageTypes as $actualPageType) {
         $this->assertInstanceOf('\\Cms\\Data\\PageType', $actualPageType);
         $this->assertArrayHasKey($actualPageType->getId(), $expectedPageTypes);
         $expectedPageType = $expectedPageTypes[$actualPageType->getId()];
         $actualPageTypeAsArray = $actualPageType->toArray();
         foreach ($expectedPageType as $attributeName => $expectedValue) {
             if ($attributeName == 'source') {
                 $this->assertEquals($expectedValue->toArray(), $actualPageTypeAsArray[$attributeName]->toArray(), 'Failed asserting that page type source is equal.');
             } else {
                 $this->assertEquals($expectedValue, $actualPageTypeAsArray[$attributeName], sprintf("Failed asserting that page type property '%s' is equal.", $attributeName));
             }
         }
     }
 }
Exemplo n.º 6
0
 /**
  * @test
  * @group library
  * @ticket SBCMS-891
  * @ticket SBCMS-2393
  */
 public function test_import_importingPagesShouldThrowExceptionAndRemoveImportFiles()
 {
     // ARRANGE
     $importService = new ImportService('Import');
     $websiteId = 'SITE-rs13up2c-exm0-4ea8-a477-4ee79e8e62pa-SITE';
     $config = Registry::getConfig();
     $testImportDirectory = $config->import->directory;
     $testFilesDirectory = $config->test->files->directory;
     $testImportFilename = 'test_pages_export_non_existing_pages_templates_and_modules.zip';
     $testImportFile = FS::joinPath($testFilesDirectory, 'test_exports', $testImportFilename);
     $this->fakedImportFileToDelete = FS::joinPath($testImportDirectory, $testImportFilename);
     $this->importUnzipDirectoryToDelete = str_replace('.zip', '', $this->fakedImportFileToDelete);
     $this->assertFileExists($testImportFile, sprintf("Failed asserting import file '%s' exists", $testImportFile));
     copy($testImportFile, $this->fakedImportFileToDelete);
     mkdir($this->importUnzipDirectoryToDelete);
     // ACT
     try {
         $importService->import($websiteId, $this->fakedImportFileToDelete, null);
         $occurredException = null;
     } catch (\Exception $e) {
         $occurredException = $e;
     }
     // ASSERT
     $this->assertInstanceOf('\\Cms\\Exception', $occurredException);
     $this->assertEquals(25, $occurredException->getCode());
     $this->assertFileNotExists($this->fakedImportFileToDelete, sprintf("Faked import file '%s' wasn't deleted", $this->fakedImportFileToDelete));
     $this->assertFileNotExists($this->importUnzipDirectoryToDelete, sprintf("Import unzip directory '%s' wasn't deleted", $this->importUnzipDirectoryToDelete));
 }
Exemplo n.º 7
0
 /**
  * @test
  * @group small
  * @group dev
  * @group library
  */
 public function test_getAllReturnsPackagesAsExpected()
 {
     // ARRANGE
     $dao = $this->getFilesystemDao();
     $globalSetDir = $this->getGlobalSetDirectory('rukzuk_test');
     $source = $this->getPackageSource('WEBSITE-ID', $globalSetDir);
     $expectedPackages = array('rz_package_1' => array('name' => (object) array('en' => 'rz_package_1.name'), 'description' => (object) array('en' => 'rz_package_1.description'), 'version' => 'rz_package_1.version', 'websiteSettings' => array('rz_shop', 'rz_shop_pro'), 'pageTypes' => array('rz_shop_product', 'rz_shop_product_pro'), 'readonly' => true, 'sourceType' => 'repo', 'source' => new SourceItem('rz_package_1', FS::joinPath($globalSetDir, 'rz_package_1'), '/url/to/package/rz_package_1', SourceItem::SOURCE_REPOSITORY, true, false)), 'rz_package_2' => array('name' => (object) array('en' => 'rz_package_2.name'), 'description' => null, 'version' => null, 'websiteSettings' => array('rz_website_settings_test'), 'pageTypes' => array(), 'readonly' => true, 'sourceType' => 'repo', 'source' => new SourceItem('rz_package_2', FS::joinPath($globalSetDir, 'rz_package_2'), '/url/to/package/rz_package_2', SourceItem::SOURCE_REPOSITORY, true, false)), 'rz_package_3' => array('name' => (object) array('en' => 'rz_package_3.name'), 'description' => null, 'version' => null, 'websiteSettings' => array(), 'pageTypes' => array('rz_blog_post', 'rz_no_existing_page_type'), 'readonly' => true, 'sourceType' => 'repo', 'source' => new SourceItem('rz_package_3', FS::joinPath($globalSetDir, 'rz_package_3'), '/url/to/package/rz_package_3', SourceItem::SOURCE_REPOSITORY, true, false)));
     // ACT
     $allPackages = $dao->getAll($source);
     // ASSERT
     $this->assertInternalType('array', $allPackages);
     $this->assertCount(3, $allPackages);
     foreach ($allPackages as $actualPackage) {
         $this->assertInstanceOf('\\Cms\\Data\\Package', $actualPackage);
         $expectedPackage = $expectedPackages[$actualPackage->getId()];
         $actualPackageData = $actualPackage->toArray();
         foreach ($expectedPackage as $attributeName => $expectedValue) {
             if ($attributeName == 'source') {
                 $this->assertEquals($expectedValue->toArray(), $actualPackageData[$attributeName]->toArray(), 'Failed asserting that package source is equal.');
             } else {
                 $this->assertEquals($expectedValue, $actualPackageData[$attributeName], sprintf("Failed asserting that package property '%s' is equal.", $attributeName));
             }
         }
     }
 }
Exemplo n.º 8
0
 /**
  * @test
  * @group small
  * @group dev
  * @group library
  */
 public function test_getAll_retrieveExpectedPageTypes()
 {
     // ARRANGE
     $websiteId = 'WEBSITE-ID';
     $globalSetDirectory = $this->getGlobalSetDirectory('rukzuk_test');
     $pathToPackage1PageTypeDir = FS::joinPath($globalSetDirectory, 'rz_package_1', 'pageTypes');
     $pathToPackage3PageTypeDir = FS::joinPath($globalSetDirectory, 'rz_package_3', 'pageTypes');
     $pageTypeSource = $this->getPageTypeSource($websiteId);
     $service = $this->getPageTypeService($pageTypeSource);
     $form = array((object) array('foo' => 'bar', 'emtpyStdClass' => new \stdClass(), 'emptyArray' => array()));
     $expectedPageTypes = array('rz_shop_product' => array('websiteId' => $websiteId, 'id' => 'rz_shop_product', 'name' => (object) array('de' => 'Shop Produkt', 'en' => 'Shop product'), 'description' => (object) array('de' => 'rz_shop_product.description.de', 'en' => 'rz_shop_product.description.en'), 'version' => 'rz_shop_product.version', 'form' => $form, 'formValues' => (object) array('price' => 9999), 'previewImageUrl' => '/url/to/rz_shop_product/assets/pageType.svg', 'readonly' => true, 'sourceType' => SourceItem::SOURCE_REPOSITORY, 'source' => new SourceItem('rz_shop_product', FS::joinPath($pathToPackage1PageTypeDir, 'rz_shop_product'), '/url/to/rz_shop_product', SourceItem::SOURCE_REPOSITORY, true, false)), 'rz_shop_product_pro' => array('websiteId' => $websiteId, 'id' => 'rz_shop_product_pro', 'name' => (object) array('de' => 'Shop Pro-Produkt', 'en' => 'Shop pro product'), 'description' => null, 'version' => null, 'form' => $form, 'formValues' => null, 'previewImageUrl' => null, 'readonly' => true, 'sourceType' => SourceItem::SOURCE_REPOSITORY, 'source' => new SourceItem('rz_shop_product_pro', FS::joinPath($pathToPackage1PageTypeDir, 'rz_shop_product_pro'), '/url/to/rz_shop_product_pro', SourceItem::SOURCE_REPOSITORY, true, false)), 'rz_blog_post' => array('websiteId' => $websiteId, 'id' => 'rz_blog_post', 'name' => (object) array('de' => 'Blog Artikel', 'en' => 'Blog post'), 'description' => (object) array('de' => 'rz_blog_post.description'), 'version' => null, 'form' => $form, 'formValues' => null, 'previewImageUrl' => null, 'readonly' => true, 'sourceType' => SourceItem::SOURCE_REPOSITORY, 'source' => new SourceItem('rz_blog_post', FS::joinPath($pathToPackage3PageTypeDir, 'rz_blog_post'), '/url/to/rz_blog_post', SourceItem::SOURCE_REPOSITORY, true, false)));
     // ACT
     $allPageTypes = $service->getAll($websiteId);
     // ASSERT
     $this->assertInternalType('array', $allPageTypes);
     $this->assertCount(count($expectedPageTypes), $allPageTypes);
     foreach ($allPageTypes as $actualPageType) {
         $this->assertInstanceOf('\\Cms\\Data\\PageType', $actualPageType);
         $this->assertArrayHasKey($actualPageType->getId(), $expectedPageTypes);
         $expectedPageType = $expectedPageTypes[$actualPageType->getId()];
         $actualPageTypeAsArray = $actualPageType->toArray();
         foreach ($expectedPageType as $attributeName => $expectedValue) {
             if ($attributeName == 'source') {
                 $this->assertEquals($expectedValue->toArray(), $actualPageTypeAsArray[$attributeName]->toArray(), "Failed asserting that page type source is equal.");
             } else {
                 $this->assertEquals($expectedValue, $actualPageTypeAsArray[$attributeName], sprintf("Failed asserting that page type property '%s' is equal.", $attributeName));
             }
         }
     }
 }
 /**
  * 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);
 }
Exemplo n.º 10
0
 /**
  * @param string $websiteId
  *
  * @return PageTypeSource
  */
 protected function getPageTypeSource($websiteId)
 {
     $globalSetDirectory = $this->getGlobalSetDirectory('rukzuk_test');
     $pathToPackage1PageTypeDir = FS::joinPath($globalSetDirectory, 'rz_package_1', 'pageTypes');
     $pathToPackage3PageTypeDir = FS::joinPath($globalSetDirectory, 'rz_package_3', 'pageTypes');
     $sources = array(new SourceItem('rz_shop_product', FS::joinPath($pathToPackage1PageTypeDir, 'rz_shop_product'), '/url/to/rz_shop_product', SourceItem::SOURCE_REPOSITORY, true, false), new SourceItem('rz_shop_product_pro', FS::joinPath($pathToPackage1PageTypeDir, 'rz_shop_product_pro'), '/url/to/rz_shop_product_pro', SourceItem::SOURCE_REPOSITORY, true, false), new SourceItem('rz_blog_post', FS::joinPath($pathToPackage3PageTypeDir, 'rz_blog_post'), '/url/to/rz_blog_post', SourceItem::SOURCE_REPOSITORY, true, false));
     return new PageTypeSource($websiteId, $sources);
 }
Exemplo n.º 11
0
 /**
  * @param string $websiteId
  *
  * @return WebsiteSettingsSource
  */
 protected function getWebsiteSettingsSource($websiteId)
 {
     $globalSetDirectory = $this->getGlobalSetDirectory('rukzuk_test');
     $pathToPackage1WebsiteSettingsDir = FS::joinPath($globalSetDirectory, 'rz_package_1', 'websiteSettings');
     $pathToPackage2WebsiteSettingsDir = FS::joinPath($globalSetDirectory, 'rz_package_2', 'websiteSettings');
     $sources = array(new SourceItem('rz_shop', FS::joinPath($pathToPackage1WebsiteSettingsDir, 'rz_shop'), '/url/to/rz_shop', SourceItem::SOURCE_REPOSITORY, true, false), new SourceItem('rz_shop_pro', FS::joinPath($pathToPackage1WebsiteSettingsDir, 'rz_shop_pro'), '/url/to/rz_shop_pro', SourceItem::SOURCE_REPOSITORY, true, false), new SourceItem('rz_website_settings_test', FS::joinPath($pathToPackage2WebsiteSettingsDir, 'rz_website_settings_test'), '/url/to/rz_website_settings_test', SourceItem::SOURCE_REPOSITORY, true, false));
     return new WebsiteSettingsSource($websiteId, $sources);
 }
Exemplo n.º 12
0
 /**
  * @param $moduleDataPath
  *
  * @return string
  */
 public function getModuleMainClassFilePath($moduleId)
 {
     if (!isset($this->cache['mainClassFilePath'][$moduleId])) {
         $moduleDataPath = $this->getModuleDataPath($moduleId);
         $moduleClassFileName = $this->getModuleMainClassFileName($moduleId);
         $this->cache['mainClassFilePath'][$moduleId] = SBFS::joinPath($moduleDataPath, $moduleClassFileName);
     }
     return $this->cache['mainClassFilePath'][$moduleId];
 }
Exemplo n.º 13
0
 protected function setUp()
 {
     parent::setUp();
     $weburl = parse_url(Registry::getBaseUrl());
     $this->spaceHost = preg_replace('/\\.$/', '', $weburl['host']);
     $this->cfg_segmentio = Registry::getConfig()->stats->segmentio->toArray();
     $this->analyticsLogFile = $this->cfg_segmentio['api_options']['filename'];
     FS::rmFile($this->analyticsLogFile);
 }
Exemplo n.º 14
0
 /**
  * @param string|null $baseUri
  */
 public function __construct($baseUri = null)
 {
     $davConfig = Registry::getConfig()->dav;
     $this->baseUri = $baseUri;
     $this->rootDirectory = $davConfig->directory;
     $tmpDirectory = $davConfig->temp_dir;
     FS::createDirIfNotExists($tmpDirectory);
     $this->lockFilePath = FS::joinPath($tmpDirectory, 'davlocks');
     $this->initServer();
 }
 /**
  * @return array
  */
 protected function createTestDataForMediaItemFileNotExists()
 {
     $websiteId = $this->websiteId;
     $mediaId = 'MEDIA-00000000-0000-0000-0000-00not0exists-MEDIA';
     $mediaItem = $this->createMediaItem($websiteId, $mediaId, 'filenotexists.jpg', time(), 10, time(), FS::joinPath($this->getMediaFileDirectory($websiteId), 'filenotexists.jpg'), FS::joinPath($this->getMediaFileDirectory($this->websiteId), 'iconnotexists.jpg'));
     $infoStorageMock = $this->createMediaItemInfoStorageMock(array($mediaItem->getId() => $mediaItem));
     $mediaContext = $this->createMediaContext($infoStorageMock);
     $httpRequestMock = $this->createHttpRequestMock();
     $mediaRequest = new MediaRequest($mediaId, MediaRequest::TYPE_STREAM);
     return array($mediaContext, $httpRequestMock, $mediaRequest, '\\Render\\MediaCDNHelper\\MediaResponse\\NotFoundResponse');
 }
Exemplo n.º 16
0
 /**
  * @test
  * @group library
  */
 public function importWebsiteSettingsFromJsonFileSuccess()
 {
     // ARRANGE
     $importService = new ImportService();
     $unzipDirectory = FS::joinPath($this->testFilesDirectory, 'import', 'import_test_001');
     $expectedImportData = array('rz_shop' => array('id' => 'rz_shop', 'name' => (object) array('de' => 'Shop Konfiguration', 'en' => 'Shop configuration')), 'rz_shop_pro' => array('id' => 'rz_shop_pro', 'name' => (object) array('de' => 'Pro-Shop Konfiguration', 'en' => 'Pro shop configuration')));
     // ACT
     $actualImportedData = $this->callMethod($importService, 'importWebsiteSettingsFromJsonFile', array($this->websiteId, $unzipDirectory));
     // ASSERT
     $this->assertEquals($expectedImportData, $actualImportedData);
 }
Exemplo n.º 17
0
 /**
  * @param  string       $templateName
  * @param  SbLocale     $locale
  * @return string
  */
 private function getTemplateFilenameForLocal($templateName, SbLocale $locale)
 {
     $templateFile = FS::joinPath($locale->getLanguageCode(), $templateName);
     if (is_readable(FS::joinPath($this->templateDirectory, $templateFile))) {
         return $templateFile;
     }
     $templateFile = FS::joinPath($locale->getLanguage(), $templateName);
     if (is_readable(FS::joinPath($this->templateDirectory, $templateFile))) {
         return $templateFile;
     }
     return null;
 }
 /**
  * @return array
  */
 protected function createTestDataForMovedResponse()
 {
     $websiteId = $this->websiteId;
     $mediaId = 'MEDIA-00000000-0000-0000-0000-000000000001-MEDIA';
     $uploadData = time() - 3600;
     $mediaItem = new MediaInfoStorageItem($mediaId, FS::joinPath($this->getMediaFileDirectory($websiteId), 'logo.jpg'), 'logo.jpg', time(), 10, time(), FS::joinPath($this->getMediaFileDirectory($websiteId), '/icon_jpg.png'), $websiteId);
     $infoStorageMock = $this->createMediaItemInfoStorageMock(array($mediaItem->getId() => $mediaItem));
     $mediaContext = $this->createMediaContext($infoStorageMock);
     $httpRequestMock = $this->createHttpRequestMock();
     $mediaRequest = new MediaRequest($mediaId, MediaRequest::TYPE_STREAM, $uploadData - 1);
     return array($mediaContext, $httpRequestMock, $mediaRequest, '\\Render\\MediaCDNHelper\\MediaResponse\\MovedResponse');
 }
 /**
  * @return array
  */
 protected function createTestData2ForIconResponse()
 {
     $websiteId = $this->websiteId;
     $mediaId = 'MEDIA-00000000-0000-0000-0000-000000000003-MEDIA';
     $uploadData = time();
     $mediaItem = $this->createMediaItem($websiteId, $mediaId, 'logo.pdf', $uploadData, 10, $uploadData, FS::joinPath($this->getMediaFileDirectory($websiteId), 'logo.pdf'), FS::joinPath($this->getMediaFileDirectory($websiteId), '/icon_pdf.png'));
     $infoStorageMock = $this->createMediaItemInfoStorageMock(array($mediaItem->getId() => $mediaItem));
     $imageToolMock = $this->createImageToolMock(false);
     $mediaContext = $this->createMediaContext($infoStorageMock, $imageToolMock);
     $httpRequestMock = $this->createHttpRequestMock();
     $mediaRequest = new MediaRequest($mediaId, MediaRequest::TYPE_ICON, $uploadData, $this->websiteId, array(), true);
     return array($mediaContext, $httpRequestMock, $mediaRequest, '\\Render\\MediaCDNHelper\\MediaResponse\\IconResponse');
 }
Exemplo n.º 20
0
 /**
  * @test
  * @group library
  */
 public function test_createStorageForWebsite_success()
 {
     // ARRANGE
     $dao = $this->createModuleDao(true);
     $websiteId = $this->newWebsiteId;
     $expectedModuleDataDirectory = FS::joinPath(Registry::getConfig()->item->data->directory, $websiteId, $dao::SUBDIR_MODULES);
     FS::rmdir($expectedModuleDataDirectory);
     $this->assertFileNotExists($expectedModuleDataDirectory);
     // ACT
     $dao->createStorageForWebsite($this->newWebsiteId);
     // ASSERT
     $this->assertFileExists($expectedModuleDataDirectory);
 }
Exemplo n.º 21
0
 /**
  * @param string $websiteId
  * @param array  $baseInfo
  *
  * @return PageTypeSource
  */
 protected function getPageTypeSource($websiteId = '', array $baseInfo = null)
 {
     $sources = array();
     if (is_array($baseInfo)) {
         foreach ($baseInfo as $data) {
             $baseDirectory = $data[0];
             $subDirectory = $data[1];
             $sourceType = isset($data[2]) ? $data[2] : SourceItem::SOURCE_UNKNOWN;
             $sources[] = new SourceItem($subDirectory, FS::joinPath($baseDirectory, $subDirectory), '/url/to/pageType/' . $subDirectory, $sourceType, true, false);
         }
     }
     return new PageTypeSource($websiteId, $sources);
 }
 /**
  * @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);
 }
Exemplo n.º 23
0
 /**
  * @test
  * @group library
  * @group small
  * @group dev
  */
 public function test_getUsedSetSource_success()
 {
     // ARRANGE
     $this->enableGlobalSets();
     $service = new WebsiteService('Website');
     $expectedSourceItem = new SourceItem('rukzuk_test', FS::joinPath(Registry::getConfig()->test->directory, '_sets', 'rukzuk_test'), '/URL/TO/SETS/rukzuk_test', SourceItem::SOURCE_REPOSITORY, true, false);
     // ACT
     $usedSetSource = $service->getUsedSetSource($this->websiteId);
     $actualSourceItems = $usedSetSource->getSources();
     // ASSERT
     $this->assertInstanceOf('\\Cms\\Dao\\Website\\GlobalSetSource', $usedSetSource);
     $this->assertInternalType('array', $actualSourceItems);
     $this->assertCount(1, $actualSourceItems);
     $this->assertEquals($expectedSourceItem, $actualSourceItems[0]);
 }
Exemplo n.º 24
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))));
     }
 }
Exemplo n.º 25
0
 /**
  * @param string $websiteId
  * @param array  $baseInfo
  *
  * @return TemplateSnippetSource
  */
 protected function getTemplateSnippetSource($websiteId = '', array $baseInfo = null)
 {
     $sources = array();
     if (is_array($baseInfo)) {
         foreach ($baseInfo as $data) {
             if ($data instanceof SourceItem) {
                 $sources[] = $data;
             } else {
                 $baseDirectory = $data[0];
                 $subDirectory = $data[1];
                 $sourceType = isset($data[2]) ? $data[2] : SourceItem::SOURCE_UNKNOWN;
                 $sources[] = new SourceItem($subDirectory, FS::joinPath($baseDirectory, $subDirectory), '/url/to/templateSnippet/' . $subDirectory, $sourceType, true);
             }
         }
     }
     return new TemplateSnippetSource($websiteId, $sources);
 }
 /**
  * @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;
     }
 }
Exemplo n.º 28
0
 /**
  * @param   string $websiteId
  * @param   string $id
  * @param   string $type
  * @param   string $originFile
  * @param   string $relativeDir
  * @param   array  $option
  * @return  string
  */
 protected function modifyScreenhot($websiteId, $id, $type, $originFile, $relativeDir, $options)
 {
     $width = (int) $options['width'];
     $height = (int) $options['height'];
     $cacheFilePath = FS::joinPath(Registry::getConfig()->screens->cache->directory, $relativeDir, $id);
     $cacheFile = FS::joinPath($cacheFilePath, sprintf("%dx%d.%s", $width, $height, Registry::getConfig()->screens->filetype));
     if (file_exists($cacheFile) && $this->isScreenshotFileValid($cacheFile, $type, $id, $websiteId)) {
         return $cacheFile;
     }
     FS::createDirIfNotExists($cacheFilePath, true);
     // Breite und Hoehe fuer crop berechnen
     list($originWidth, $originHeight) = getimagesize($originFile);
     $widthFaktor = $originWidth / $width;
     $heightFaktor = $originHeight / $height;
     if ($widthFaktor < $heightFaktor) {
         $cropWidth = (int) $originWidth;
         $cropHeight = (int) ($widthFaktor * $height);
     } else {
         $cropWidth = (int) ($heightFaktor * $width);
         $cropHeight = (int) $originHeight;
     }
     $bildBearbeitung = $this->getImageAdapter();
     $bildBearbeitung->setFile($originFile);
     $bildBearbeitung->crop(array('width' => $cropWidth, 'height' => $cropHeight, 'x' => 0, 'y' => 0));
     $bildBearbeitung->resize(array('width' => $width, 'height' => $height));
     $bildBearbeitung->quality(array('quality' => 100));
     if (!$bildBearbeitung->save($cacheFile)) {
         return;
     }
     return $cacheFile;
 }
Exemplo n.º 29
0
 /**
  * @param SourceItem $sourceItem
  *
  * @return null|string
  */
 protected function getPreviewImageUrl(SourceItem $sourceItem)
 {
     $imageFileName = 'pageType.' . self::PREVIEW_IMAGE_EXTENSION;
     $imageFilePath = FS::joinPath($sourceItem->getDirectory(), self::PREVIEW_IMAGE_SUBDIRECTORY, $imageFileName);
     if (!file_exists($imageFilePath)) {
         return null;
     }
     return $sourceItem->getUrl() . '/' . self::PREVIEW_IMAGE_SUBDIRECTORY . '/' . $imageFileName;
 }
Exemplo n.º 30
0
 /**
  * @param string $shortId
  *
  * @return string
  */
 protected function getOutputDirectoryForShortId($shortId)
 {
     return FS::joinPath($this->getOutputDirectory(), $shortId);
 }