Exemplo n.º 1
0
 /**
  * @return integer
  */
 protected function getLatchDateAndTime()
 {
     if (isset(self::$testLatchDateAndTime)) {
         return self::$testLatchDateAndTime;
     }
     return parent::getLatchDateAndTime();
 }
Exemplo n.º 2
0
 /**
  * @test
  * @group library
  */
 public function test_latchImportFile_zipDirectoryIfZipFileNotGiven()
 {
     // ARRANGE
     $config = Registry::getConfig();
     $importLatchDirectory = $config->import->latch->directory;
     $this->assertFileNotExists($importLatchDirectory);
     $storageFile = FS::joinPath($importLatchDirectory, LatchBusiness::IMPORT_LATCH_STORAGE_FILE);
     $testImportTime = 1325379661;
     // 01.01.2012 01:01:01
     LatchBusiness::setTestLatchDateAndTime($testImportTime);
     $websiteId = 'SITE-latch000-test-0000-0000-business0003-SITE';
     $localId = 'local_test_import_001';
     $importDirectory = FS::joinPath($config->test->files->directory, 'test_imports', $localId);
     // ACT
     $latchImportId = $this->business->latchImportFile($websiteId, $importDirectory);
     // ASSERT
     $this->assertFileExists($importLatchDirectory);
     $expectedImportLatchFile = FS::joinPath($importLatchDirectory, $latchImportId . '.zip');
     $this->assertFileExists($expectedImportLatchFile);
     $expectedStorage = array($latchImportId => array('websiteId' => $websiteId, 'file' => $expectedImportLatchFile, 'date' => $testImportTime, 'name' => $localId));
     $actualStorage = \json_decode(file_get_contents($storageFile), true);
     $this->assertSame($expectedStorage, $actualStorage);
 }
Exemplo n.º 3
0
 /**
  * @test
  * @group integration
  */
 public function overwriteShouldOverwriteStatedModules()
 {
     $config = Registry::getConfig();
     DirectoryHelper::clearLatchDirectory();
     $websiteId = 'SITE-im12maec-ovwr-4ea8-a477-t4e79e8e62m3-SITE';
     $this->dispatch(sprintf('/modul/getAll/params/{"websiteid":"%s"}', $websiteId));
     $response = new Response($this->getResponseBody());
     $responseData = $response->getData();
     $this->assertTrue(count($responseData->modules) === 4);
     $modules = array('MODUL-0rap5eb8-0df3-47e9-exti-71ae9d96d3m0-MODUL', 'MODUL-0rap5eb8-0df3-47e9-exti-71ae9d96d3m1-MODUL');
     $templates = $media = array();
     $importLatchFilesDirectory = $config->import->latch->files->directory;
     $importFileToLatch = $importLatchFilesDirectory . DIRECTORY_SEPARATOR . 'import_modules_conflict_modules.zip';
     $this->assertFileExists($importFileToLatch);
     $latchBusiness = new LatchBusiness('Latch');
     $importId = $latchBusiness->latchImportFile($websiteId, $importFileToLatch);
     $data = array('templates' => $templates, 'modules' => $modules, 'media' => $media, 'importId' => $importId);
     $request = sprintf('/import/overwrite/params/%s', json_encode($data));
     $this->dispatch($request);
     $response = $this->getValidatedSuccessResponse();
     $responseData = $response->getData();
     $this->assertObjectHasAttribute('modules', $responseData);
     $this->assertObjectHasAttribute('templates', $responseData);
     $this->assertObjectHasAttribute('media', $responseData);
     $this->assertObjectHasAttribute('pages', $responseData);
     $this->assertObjectHasAttribute('website', $responseData);
     $this->assertEmpty($responseData->website);
     $this->assertEmpty($responseData->pages);
     $this->assertEmpty($responseData->templates);
     $this->assertEmpty($responseData->media);
     $this->assertNotEmpty($responseData->modules);
     $importedModules = $responseData->modules;
     $this->assertTrue(count($importedModules) === 3);
     $this->dispatch(sprintf('/modul/getAll/params/{"websiteid":"%s"}', $websiteId));
     $response = new Response($this->getResponseBody());
     $responseData = $response->getData();
     $this->assertTrue(count($responseData->modules) === 5);
     $this->removeImportMediaDirectoryAndFiles($websiteId);
 }
Exemplo n.º 4
0
 /**
  * @test
  * @group integration
  */
 public function importAgainstNonExistingAlbumsCreatesThemImportsIntoThem()
 {
     DirectoryHelper::clearLatchDirectory();
     $websiteId = 'SITE-im12maec-imal-4ea8-a477-t4e79e8e62m1-SITE';
     $this->dispatch(sprintf('/album/getall/params/{"websiteid":"%s"}', $websiteId));
     $response = new Response($this->getResponseBody());
     $responseData = $response->getData();
     $this->assertTrue(count($responseData->albums) === 0);
     $media = array('MDB-exp0d0ec-cb0f-4961-imal-765d4aa581n0-MDB', 'MDB-exp0d0ec-cb0f-4961-imal-765d4aa581n1-MDB', 'MDB-exp0d0ec-cb0f-4961-imal-765d4aa581n2-MDB');
     $templates = $templateSnippet = $modules = array();
     $config = Registry::getConfig();
     $importLatchFilesDirectory = $config->import->latch->files->directory;
     $importFileToLatch = $importLatchFilesDirectory . DIRECTORY_SEPARATOR . 'import_templatesnippet_conflict_media_non_existing_album.zip';
     $this->assertFileExists($importFileToLatch);
     $latchBusiness = new LatchBusiness('Latch');
     $importId = $latchBusiness->latchImportFile($websiteId, $importFileToLatch);
     $data = array('templates' => $templates, 'templatesnippets' => $templateSnippet, 'modules' => $modules, 'media' => $media, 'importId' => $importId);
     $request = sprintf('/import/overwrite/params/%s', json_encode($data));
     $this->dispatch($request);
     $response = $this->getValidatedSuccessResponse();
     $expectedAlbumIdsAndMediaCount = array('ALBUM-ex0wcf0d-acc4-4fdb-imal-72ebb08780ne-ALBUM' => 2, 'ALBUM-ex0wcf0d-acc4-4fdb-imal-72ebb08781ne-ALBUM' => 1);
     $expectedAlbumIds = array_keys($expectedAlbumIdsAndMediaCount);
     $this->dispatch(sprintf('/album/getall/params/{"websiteid":"%s"}', $websiteId));
     $response = new Response($this->getResponseBody());
     $responseData = $response->getData();
     $this->assertTrue(count($responseData->albums) === count($expectedAlbumIds));
     $createdAlbumIds = array();
     array_filter($responseData->albums, function ($album) use(&$createdAlbumIds) {
         return $createdAlbumIds[] = $album->id;
     });
     sort($expectedAlbumIds);
     sort($createdAlbumIds);
     $this->assertEquals($expectedAlbumIds, $createdAlbumIds);
     $this->dispatch(sprintf('/media/getall/params/{"websiteid":"%s","albumid":"%s"}', $websiteId, $createdAlbumIds[0]));
     $response = new Response($this->getResponseBody());
     $responseData = $response->getData();
     $this->assertNotEmpty($responseData->media);
     $this->assertEquals($expectedAlbumIdsAndMediaCount[$createdAlbumIds[0]], $responseData->total);
     $this->dispatch(sprintf('/media/getall/params/{"websiteid":"%s","albumid":"%s"}', $websiteId, $createdAlbumIds[1]));
     $response = new Response($this->getResponseBody());
     $responseData = $response->getData();
     $this->assertNotEmpty($responseData->media);
     $this->assertEquals($expectedAlbumIdsAndMediaCount[$createdAlbumIds[1]], $responseData->total);
     $this->removeImportMediaDirectoryAndFiles($websiteId);
 }