コード例 #1
0
ファイル: DeleteTest.php プロジェクト: rukzuk/rukzuk
 /**
  * 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
ファイル: CreateTest.php プロジェクト: rukzuk/rukzuk
 /**
  * @test
  * @group library
  */
 public function success()
 {
     $attributes = array('email' => '*****@*****.**', 'lastname' => 'create test', 'firstname' => 'service user', 'gender' => 'm', 'isSuperuser' => false, 'isDeletable' => true);
     $newUser = $this->service->create($attributes);
     $this->assertInstanceOf('Cms\\Data\\User', $newUser);
     $this->assertSame($attributes['email'], $newUser->getEmail());
     $this->assertSame($attributes['lastname'], $newUser->getLastname());
     $this->assertSame($attributes['firstname'], $newUser->getFirstname());
     $this->assertSame($attributes['gender'], $newUser->getGender());
     $this->assertSame($attributes['isSuperuser'], $newUser->isSuperuser());
     $this->assertSame($attributes['isDeletable'], $newUser->isDeletable());
     $uuidValidator = new UniqueIdValidator(\Orm\Data\User::ID_PREFIX, \Orm\Data\User::ID_SUFFIX);
     $this->assertTrue($uuidValidator->isValid($newUser->getId()));
     // Timestamp der letzten Aenderung darf nicht aelter sein als ein paar Sekunden
     $this->assertNotNull($newUser->getLastupdate());
     $currentTime = time();
     $this->assertLessThanOrEqual($currentTime, $newUser->getLastupdate());
     $this->assertGreaterThan($currentTime - 2, $newUser->getLastupdate());
 }