예제 #1
0
 /**
  * Website loeschen
  *
  * Der Test holt sich erst alle vorhanden Websites, der erste Eintrag
  * wird genutzt um die Pruefung von delete durchzufuehren
  *
  * @test
  * @group integration
  */
 public function success()
 {
     // ARRANGE
     $websiteId = 'SITE-1964e89c-22af-46cd-a651-fc42dc78fe50-SITE';
     $runId = 'CMSRUNID-00000000-0000-0000-0000-000000000001-CMSRUNID';
     $websiteService = new \Cms\Service\Website('Website');
     $templateService = new \Cms\Service\Template('Template');
     $snippetService = new \Cms\Service\TemplateSnippet('TemplateSnippet');
     $pageService = new \Cms\Service\Page('Page');
     $packageService = new \Cms\Service\Package('Package');
     $moduleService = new \Cms\Service\Modul('Modul');
     // check if items exists
     $this->assertTrue($websiteService->existsWebsiteAlready($websiteId));
     $this->assertNotEmpty($templateService->getAll($websiteId));
     $this->assertNotEmpty($snippetService->getAll($websiteId));
     $this->assertNotEmpty($pageService->getIdsByWebsiteId($websiteId));
     $this->assertNotEmpty($packageService->getAll($websiteId));
     $this->assertNotEmpty($moduleService->getAll($websiteId));
     $params = array('id' => $websiteId, 'runId' => $runId);
     $paramsAsJson = json_encode($params);
     // ACT
     $this->dispatch('website/delete/params/' . $paramsAsJson);
     // ASSERT
     $this->getValidatedSuccessResponse();
     // check if website is deleted
     $websiteExists = $websiteService->existsWebsiteAlready($websiteId);
     $this->assertFalse($websiteExists);
     // verify that all templates of the website has been deleted
     $templates = $templateService->getAll($websiteId);
     $this->assertInternalType('array', $templates);
     $this->assertCount(0, $templates);
     // verify that all templates snippets of the website has been deleted
     $snippets = $snippetService->getAll($websiteId);
     $this->assertInternalType('array', $snippets);
     $this->assertCount(0, $snippets);
     // verify that all pages of the website has been deleted
     $pageIds = $pageService->getIdsByWebsiteId($websiteId);
     $this->assertInternalType('array', $pageIds);
     $this->assertCount(0, $pageIds);
     // verify that all packages of the website has been deleted
     $allPackagesAfterDeleteWebsite = $packageService->getAll($websiteId);
     $this->assertCount(0, $allPackagesAfterDeleteWebsite, 'Failed asserting that deleted website has no packages');
     // verify that all modules of the website has been deleted
     $allModulesAfterDeleteWebsite = $moduleService->getAll($websiteId);
     $this->assertCount(0, $allModulesAfterDeleteWebsite, 'Failed asserting that deleted website has no modules');
 }
예제 #2
0
파일: CopyTest.php 프로젝트: rukzuk/rukzuk
 /**
  * Website kopieren
  *
  * Der Test holt sich erst alle vorhanden Websites, der erste Eintrag
  * wird genutzt um die Pruefung von update durchzufuehren
  *
  * @test
  * @group integration
  */
 public function success()
 {
     // ARRANGE
     $expectedLocalPackageIds = array('rz_local_test_1', 'rz_local_test_2');
     $copyWebsite = $this->getOneWebsite();
     // website kopieren
     $params = array('id' => $copyWebsite->id, 'name' => md5(time()));
     $paramsAsJson = json_encode($params);
     $this->dispatch('website/copy/params/' . $paramsAsJson);
     // Response holen
     $response = $this->getResponseBody();
     $this->assertInternalType('string', $response);
     $this->assertNotNull($response);
     $responseObject = json_decode($response);
     // Response allgemein pruefen
     $this->assertResponseBodySuccess($responseObject);
     // neue Website-ID muss zurueckgegeben werden
     $this->assertNotNull($responseObject->data);
     $this->assertNotNull($responseObject->data->id);
     $this->assertNotSame($params['id'], $responseObject->data->id);
     $newWebsiteId = $responseObject->data->id;
     // Pruefung, ob Description und Navigation kopiert wurden
     $this->dispatch('/website/getAll');
     $response = $this->getResponseBody();
     $responseObject = json_decode($response);
     $websites = $responseObject->data->websites;
     foreach ($websites as $website) {
         if ($website->name == $params['name']) {
             // Website gefunden -> Website Daten holen
             $params = array('id' => $website->id);
             $paramsAsJson = json_encode($params);
             $this->dispatch('website/getbyid/params/' . $paramsAsJson);
             $response = $this->getResponseBody();
             $responseObject = json_decode($response);
             $this->assertResponseBodySuccess($responseObject);
             $newWebsite = $responseObject->data;
             // Daten pruefen
             $this->assertSame($copyWebsite->description, $newWebsite->description);
             // Navigation (Pages) pruefen
             $this->assertSame(\Zend_Json::encode($copyWebsite->navigation), \Zend_Json::encode($newWebsite->navigation));
             break;
         }
     }
     // Pruefung, ob TemplateSnippets kopiert wurden
     $this->dispatch('templatesnippet/getall/params/{"websiteid":"' . $newWebsiteId . '"}');
     $response = $this->getResponseBody();
     $responseObject = json_decode($response);
     $this->assertResponseBodySuccess($responseObject);
     $this->assertInternalType('array', $responseObject->data->templatesnippets);
     $this->assertSame(1, count($responseObject->data->templatesnippets));
     // check local packages
     $actualLocalPackageIds = array();
     $packageService = new \Cms\Service\Package('Package');
     $actualPackages = $packageService->getAll($newWebsiteId);
     foreach ($actualPackages as $package) {
         if ($package->getSourceType() == AbstractSourceItem::SOURCE_LOCAL) {
             $actualLocalPackageIds[] = $package->getId();
         }
     }
     sort($actualLocalPackageIds);
     $this->assertEquals($expectedLocalPackageIds, $actualLocalPackageIds);
 }