コード例 #1
0
ファイル: ImportPagesTest.php プロジェクト: rukzuk/rukzuk
 /**
  * @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));
 }
コード例 #2
0
ファイル: ImportWebsiteTest.php プロジェクト: rukzuk/rukzuk
 /**
  * @test
  * @group library
  */
 public function test_importWebsiteShouldCreateNewWebsiteId()
 {
     // ARRANGE
     $websiteId = 'SITE-import00-test-use0-id00-000000000002-SITE';
     $allowedImportMode = 'WEBSITE';
     $importFilePath = $this->createImportFile('test_service_import_website_take_given_websiteid.zip');
     $importService = new ImportService();
     // ACT
     $importData = $importService->import($websiteId, $importFilePath, $allowedImportMode);
     // ASSERT
     $this->assertNotEquals($websiteId, $importData['websiteId']);
     $this->assertCount(1, $importData['website']);
     $this->assertInternalType('array', $importData['website'][0]);
     $this->assertArrayHasKey('id', $importData['website'][0]);
     $this->assertNotEquals($websiteId, $importData['website'][0]['id']);
     $this->assertCount(0, $importData['modules']);
     $this->assertCount(0, $importData['templatesnippets']);
     $this->assertCount(0, $importData['templates']);
     $this->assertCount(0, $importData['pages']);
     $this->assertCount(0, $importData['media']);
     $this->assertCount(0, $importData['albums']);
     $this->assertCount(0, $importData['usergroups']);
     $actualWebsite = $this->getWebsiteService()->getById($importData['websiteId']);
     $this->assertEmpty($actualWebsite->getUsedSetId());
 }
コード例 #3
0
 public function getWebsiteService()
 {
     if (!is_null($this->phpunitWebsiteService)) {
         return $this->phpunitWebsiteService;
     }
     return parent::getWebsiteService();
 }