/** * @param string $websiteId * @param string $expectedId * @param string $expectedUserlogin * @param string $expectedAction * @param array $expectedAdditionalinfo */ protected function assertActionLogEntry($websiteId, $expectedId, $expectedUserlogin, $expectedAction, $expectedAdditionalinfo = array()) { $getLogRequest = sprintf('log/get/params/{"websiteId":"%s","format":"json"}', $websiteId); $this->dispatch($getLogRequest); $response = $this->getResponseBody(); $response = new Response($response); $this->assertTrue($response->getSuccess()); $responseData = $response->getData(); $this->assertInternalType('array', $responseData); $expectedLogEntriesCount = 1; $this->assertSame($expectedLogEntriesCount, count($responseData)); $expectedLogKeys = array('id', 'name', 'dateTime', 'userlogin', 'action', 'additionalinfo'); $this->assertInstanceOf('stdClass', $responseData[0]); $actualLogKeys = array_keys(get_object_vars($responseData[0])); sort($actualLogKeys); sort($expectedLogKeys); $this->assertSame($expectedLogKeys, $actualLogKeys); $this->assertSame($expectedId, $responseData[0]->id); $this->assertSame($expectedUserlogin, $responseData[0]->userlogin); $this->assertSame($expectedAction, $responseData[0]->action); if (count($expectedAdditionalinfo) > 0) { $this->assertObjectHasAttribute('additionalinfo', $responseData[0]); $actualAdditionalInfo = json_decode($responseData[0]->additionalinfo, false); foreach ($expectedAdditionalinfo as $key => $expectedValue) { $this->assertObjectHasAttribute($key, $actualAdditionalInfo); $this->assertSame($expectedValue, $actualAdditionalInfo->{$key}); } } return $responseData[0]; }
/** * @test * @group integration */ public function getByIdShouldReturnExpectedTemplateSnippet() { $existingId = 'TPLS-template-snip-pet0-test-000000000001-TPLS'; $websiteId = 'SITE-template-snip-pet0-test-000000000001-SITE'; $request = sprintf('/templatesnippet/getbyid/params/{"id":"%s","websiteid":"%s"}', $existingId, $websiteId); $this->dispatch($request); $response = $this->getResponseBody(); $this->assertNotNull($response); $this->assertInternalType('string', $response); $response = new Response($response); $this->assertTrue($response->getSuccess()); $actualTemplateSnippet = $response->getData(); $this->assertInstanceOf('stdClass', $actualTemplateSnippet); $this->assertObjectHasAttribute('id', $actualTemplateSnippet); $this->assertSame($existingId, $actualTemplateSnippet->id); $this->assertObjectHasAttribute('websiteId', $actualTemplateSnippet); $this->assertSame($websiteId, $actualTemplateSnippet->websiteId); $this->assertObjectHasAttribute('name', $actualTemplateSnippet); $this->assertSame('TEMPLATE_SNIPPET_NAME_1', $actualTemplateSnippet->name); $this->assertObjectHasAttribute('description', $actualTemplateSnippet); $this->assertSame('TEMPLATE_SNIPPET_DESCRIPTION_1', $actualTemplateSnippet->description); $this->assertObjectHasAttribute('category', $actualTemplateSnippet); $this->assertSame('TEMPLATE_SNIPPET_CATEGORY_1', $actualTemplateSnippet->category); $this->assertObjectHasAttribute('baseLayout', $actualTemplateSnippet); $this->assertFalse($actualTemplateSnippet->baseLayout); $this->assertObjectHasAttribute('pageTypes', $actualTemplateSnippet); $this->assertInternalType('array', $actualTemplateSnippet->pageTypes); $this->assertCount(0, $actualTemplateSnippet->pageTypes); $this->assertObjectHasAttribute('content', $actualTemplateSnippet); $this->assertSame('[]', \Zend_Json::encode($actualTemplateSnippet->content)); $this->assertEquals('local', $actualTemplateSnippet->sourceType); $this->assertFalse($actualTemplateSnippet->readonly); }
/** * @test * @group integration */ public function getAllOnUserWithWebsiteIdShouldReturnExpectedUsers() { $websiteId = 'SITE-0r7g62te-0t4c-42c7-8628-f2cb4236e5gw-SITE'; $getAllRequest = sprintf('/user/getall/params/{"websiteId":"%s"}', $websiteId); $this->dispatch($getAllRequest); $response = $this->getResponseBody(); $this->assertNotNull($response); $this->assertInternalType('string', $response); $response = new Response($response); $this->assertTrue($response->getSuccess()); $expectedUsersOfWebsiteCount = 5; $expectedUsersIdsOfWebsite = array('USER-re02eaa7-7fc5-464a-bd47-16b3b8af360p-USER', 'USER-re02eaa7-7fc5-464a-bd47-16b3b8af361p-USER', 'USER-re02eaa7-7fc5-464a-bd47-16b3b8af362p-USER', 'USER-re02eaa7-7fc5-464a-bd47-16b3b8af363p-USER', 'USER-re02eaa7-7fc5-464a-bd47-16b3b8af364p-USER'); $responseData = $response->getData(); $this->assertObjectHasAttribute('users', $responseData); $actualUsersOfWebsite = $responseData->users; $this->assertInternalType('array', $actualUsersOfWebsite); $actualUsersOfWebsiteCount = count($actualUsersOfWebsite); $this->assertSame($expectedUsersOfWebsiteCount, $actualUsersOfWebsiteCount); $actualUsersIdsOfWebsite = array_map(function ($user) { return $user->id; }, $actualUsersOfWebsite); sort($expectedUsersIdsOfWebsite); sort($actualUsersIdsOfWebsite); $this->assertSame($expectedUsersIdsOfWebsite, $actualUsersIdsOfWebsite); }
/** * @test * @group integration */ public function getAllAlbumsShouldReturnExpectedAlbumsSortedByName() { $websiteId = 'SITE-ce6e702f-10ac-4e1e-951f-307e4b8760as-SITE'; $request = sprintf('/album/getall/params/{"websiteId":"%s"}', $websiteId); $this->dispatch($request); $response = $this->getResponseBody(); $this->assertNotNull($response); $this->assertInternalType('string', $response); $response = new Response($response); $this->assertTrue($response->getSuccess()); $responseData = $response->getData(); $this->assertObjectHasAttribute('albums', $responseData); $allAlbumsForWebsiteId = $responseData->albums; $this->assertInternalType('array', $allAlbumsForWebsiteId); $expectedAlbumNameOrder = array('a_controller_test_album', 'b_controller_test_album', 'z_controller_test_album'); $this->assertSame(3, count($allAlbumsForWebsiteId)); $actualAlbumNameOrder = array(); foreach ($allAlbumsForWebsiteId as $albumsOfWebsiteId) { $this->assertInstanceOf('stdClass', $albumsOfWebsiteId); $this->objectHasAttribute('websiteId', $albumsOfWebsiteId); $this->assertSame($websiteId, $albumsOfWebsiteId->websiteId); $this->objectHasAttribute('id', $albumsOfWebsiteId); $this->assertTrue($this->validateUniqueId(new DataAlbum(), $albumsOfWebsiteId->id)); $this->objectHasAttribute('name', $albumsOfWebsiteId); $this->assertNotEmpty($albumsOfWebsiteId->name); $actualAlbumNameOrder[] = $albumsOfWebsiteId->name; } $assertionMessage = sprintf("Actual album name order [%s] doesn't match expected album name order [%s]", implode(",", $actualAlbumNameOrder), implode(",", $expectedAlbumNameOrder)); $this->assertSame($expectedAlbumNameOrder, $actualAlbumNameOrder, $assertionMessage); }
/** * @test * @group integration */ public function getByIdShouldReturnExpectedMedia() { $websiteId = 'SITE-me10e89c-r2af-46cd-a651-fc42dc78fe5l-SITE'; $mediaId = 'MDB-1frc4a9f-6793-471e-96bf-ge9039a0d703-MDB'; $expectedAlbumId = 'ALBUM-ce1e6f03-gbc4-4fdb-add4-72ebb0878006-ALBUM'; $requestUri = sprintf('/media/getbyid/params/{"websiteid":"%s","id":"%s"}', $websiteId, $mediaId); $this->dispatch($requestUri); $response = $this->getResponseBody(); $this->assertNotNull($response); $this->assertInternalType('string', $response); $response = new Response($response); $responseData = $response->getData(); $this->assertTrue($response->getSuccess()); $this->assertNotEmpty($responseData); // Response Felder pruefen $expectedResponseProperties = array('id', 'websiteId', 'name', 'url', 'icon', 'type', 'extension', 'filesize', 'dateUploaded', 'albumId'); $actualResponseProperties = array_keys(get_object_vars($responseData)); foreach ($expectedResponseProperties as $expectedResponseProperty) { $this->assertContains($expectedResponseProperty, $actualResponseProperties); } // Response Inhalte pruefen $this->assertObjectHasAttribute('id', $responseData); $this->assertSame($mediaId, $responseData->id); $this->assertObjectHasAttribute('websiteId', $responseData); $this->assertSame($websiteId, $responseData->websiteId); $this->assertObjectHasAttribute('albumId', $responseData); $this->assertSame($expectedAlbumId, $responseData->albumId); $this->assertObjectHasAttribute('url', $responseData); $this->assertNotEmpty($responseData->url); $this->assertObjectHasAttribute('icon', $responseData); $this->assertNotEmpty($responseData->icon); }
/** * @test * @group integration * @dataProvider createTicketIdProvider */ public function successCreateRenderTicket($params) { $this->assertSuccessfulLogin('*****@*****.**', 'seitenbau'); $request = $this->createRequestUrl('Shortener', 'createRenderTicket', $params); $this->dispatch($request); $response = $this->getResponseBody(); $response = new Response($response); $this->assertTrue($response->getSuccess()); }
/** * @test * @group integration */ public function loginShouldLoginGivenUser() { $username = '******'; $password = '******'; $loginRequest = sprintf('/user/login/params/{"username":"******","password":"******"}', $username, $password); $this->dispatch($loginRequest); $response = new Response($this->getResponseBody()); $this->assertTrue($response->getSuccess()); }
/** * @test * @group integration * @dataProvider invalidIdsProvider * @param mixed $websiteId * @param mixed $moduleIds */ public function exportModulesShouldReturnValidationErrorForInvalidWebsiteIdAndModulIds($websiteId, $moduleIds) { $requestUri = sprintf('export/modules/params/{"websiteid":"%s","ids":%s}', $websiteId, $moduleIds); $this->dispatch($requestUri); $response = $this->getResponseBody(); $this->assertInternalType('string', $response); $this->assertNotNull($response); $response = new Response($response); $this->assertFalse($response->getSuccess()); }
/** * @test * @integration */ public function templateSnippetImportShouldRespondWithConflictingTemplateSnippet() { $websiteId = 'SITE-ae6e702f-10ac-4e1e-exmo-307e4b8765db-SITE'; $config = Registry::getConfig(); $testImportDirectory = $config->import->directory; $testFilesDirectory = $config->test->files->directory; $testImportFilename = 'test_export_0_templatesnippets_conflict_only_templatesnippet.zip'; $testImportFile = $testFilesDirectory . DIRECTORY_SEPARATOR . 'test_exports' . DIRECTORY_SEPARATOR . $testImportFilename; $expectedImportFile = $testImportDirectory . DIRECTORY_SEPARATOR . $testImportFilename; $importUnzipDirectory = str_replace('.zip', '', $expectedImportFile); $assertionMessage = sprintf("Import file '%s' existiert nicht", $testImportFile); $this->assertFileExists($testImportFile, $assertionMessage); $testImportTmpFile = DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . 'phpe7f3im'; $fileInputname = 'import'; $requestUri = sprintf('/import/file/params/{"websiteid":"%s","fileinputname":"%s"}', $websiteId, $fileInputname); $this->assertFakeUpload($fileInputname, $testImportFile, $testImportTmpFile); $this->dispatch($requestUri); $this->assertHeaderContains('Content-Type', 'text/plain'); $response = new Response($this->getResponseBody()); $this->assertFalse($response->getSuccess()); $reponseError = $response->getError(); $this->assertEquals(11, $reponseError[0]->code); $responseData = $response->getData(); $this->assertObjectHasAttribute('importId', $responseData); $this->assertObjectHasAttribute('conflict', $responseData); $conflictData = $responseData->conflict; $this->assertObjectHasAttribute('templatesnippets', $conflictData); $this->assertObjectHasAttribute('templates', $conflictData); $this->assertObjectHasAttribute('modules', $conflictData); $this->assertObjectHasAttribute('media', $conflictData); $expectedConflictingTemplateSnippets = array(); $conflictingTemplateSnippet = new \StdClass(); $conflictingTemplateSnippet->id = 'TPLS-template-snip-pet0-test-000000000023-TPLS'; $conflictingTemplateSnippet->oldName = 'TEMPLATE_SNIPPET_NAME_23'; $conflictingTemplateSnippet->newName = 'Export_Test_TemplateSnippet_0'; $expectedConflictingTemplateSnippets[] = $conflictingTemplateSnippet; $this->assertTrue(count($conflictData->templatesnippets) === count($expectedConflictingTemplateSnippets)); $this->assertEquals($expectedConflictingTemplateSnippets, $conflictData->templatesnippets); $errorData = $response->getError(); $this->assertEquals(11, $errorData[0]->code); $errorMessage = \Cms\Error::getMessageByCode(11); $this->assertEquals($errorMessage, $errorData[0]->text); if (file_exists($testImportTmpFile)) { unlink($testImportTmpFile); } if (strstr($importUnzipDirectory, $testImportDirectory)) { DirectoryHelper::removeRecursiv($importUnzipDirectory, $testImportDirectory); if (is_dir($importUnzipDirectory)) { rmdir($importUnzipDirectory); } if (file_exists($expectedImportFile)) { unlink($expectedImportFile); } } }
/** * @test * @group integration */ public function getAllOnGroupWithUnassociatedWebsiteIdShouldReturnError() { $websiteId = 'SITE-no37e89c-r2no-18cf-a6n9-ff45ds98f6no-SITE'; $getAllRequest = sprintf('/group/getall/params/{"websiteId":"%s"}', $websiteId); $this->dispatch($getAllRequest); $response = $this->getResponseBody(); $this->assertNotNull($response); $this->assertInternalType('string', $response); $response = new Response($response); $this->assertFalse($response->getSuccess()); }
/** * @test * @group integration */ public function getByIdOnNonExistingUserShouldReturnError() { $userId = 'USER-gbi7e2no-11r5-45e9-bc6d-a25cee8a74c1-USER'; $getByIdRequest = sprintf('/user/getbyid/params/{"id":"%s"}', $userId); $this->dispatch($getByIdRequest); $response = $this->getResponseBody(); $this->assertNotNull($response); $this->assertInternalType('string', $response); $response = new Response($response); $this->assertFalse($response->getSuccess()); }
/** * @test * @group integration */ public function getAllShouldReturnAtLeastOneTemplate() { $websiteId = 'SITE-30490289-dddb-4501-879f-9c6c7965f871-SITE'; $this->dispatch(sprintf('/template/getAll/params/{"websiteid":"%s"}', $websiteId)); $response = $this->getResponseBody(); $this->assertNotNull($response); $this->assertInternalType('string', $response); $response = new Response($response); $this->assertTrue($response->getSuccess()); $responseData = $response->getData(); $this->assertObjectHasAttribute('templates', $responseData); $this->assertInternalType('array', $responseData->templates); $this->assertGreaterThan(0, count($responseData->templates)); }
/** * @test * @group integration * @dataProvider invalidCompleteValueProvider */ public function exportWebsiteShouldReturnValidationErrorForNonBooleanCompleteValue($completeValue) { $exportDirectoryName = 'test_export_0_website_complete'; $websiteId = 'SITE-ae6e702f-10ac-4e1e-exwc-307e4b8765db-SITE'; $requestUri = sprintf('export/website/params/{"websiteid":"%s","name":"%s","complete":"%s"}', $websiteId, $exportDirectoryName, $completeValue); $this->dispatch($requestUri); $response = $this->getResponseBody(); $this->assertInternalType('string', $response); $this->assertNotNull($response); $response = new Response($response); $this->assertFalse($response->getSuccess()); $responseError = $response->getError(); $this->assertSame('complete', $responseError[0]->param->field); }
/** * @test * @group integration */ public function getAllShouldReturnAtLeastOneSnippet() { $websiteId = 'SITE-template-snip-pet0-test-000000000002-SITE'; $this->dispatch(sprintf('/templatesnippet/getAll/params/{"websiteid":"%s"}', $websiteId)); $response = $this->getResponseBody(); $this->assertNotNull($response); $this->assertInternalType('string', $response); $response = new Response($response); $this->assertTrue($response->getSuccess()); $responseData = $response->getData(); $this->assertObjectHasAttribute('templatesnippets', $responseData); $this->assertInternalType('array', $responseData->templatesnippets); $this->assertGreaterThan(0, count($responseData->templatesnippets)); }
/** * @test * @group integration */ public function movePageShouldBeRejectedWhenAuthenticatedUserHasNoPagesPrivileges() { $params = array('id' => 'PAGE-m01rsfb8-0363-47e9-0sup-90ae9d96d3c2-PAGE', 'parentId' => 'PAGE-m00rsfb8-0363-47e9-0sup-90ae9d96d3c2-PAGE', 'websiteId' => 'SITE-mo64e89c-00su-46cd-a651-fc42dc78fe50-SITE'); $paramsAsJson = json_encode($params); $userName = '******'; $userPassword = '******'; $this->assertSuccessfulLogin($userName, $userPassword); $this->activateGroupCheck(); $this->dispatch('page/move/params/' . $paramsAsJson); $this->deactivateGroupCheck(); $response = $this->getResponseBody(); $response = new Response($response); $this->assertFalse($response->getSuccess()); $responseError = $response->getError(); $this->assertSame(7, $responseError[0]->code); $this->assertNull($response->getData()); }
/** * @test * @group integration */ public function createAlbumShouldCreateAlbumAsExpected() { $websiteId = 'SITE-ce6e702f-10ac-4e1e-951f-307e4b8765al-SITE'; $albumName = 'controller_test_album_1'; $request = sprintf('/album/create/params/{"websiteId":"%s","name":"%s"}', $websiteId, $albumName); $this->dispatch($request); $response = $this->getResponseBody(); $this->assertNotNull($response); $this->assertInternalType('string', $response); $response = new Response($response); $this->assertTrue($response->getSuccess()); $responseData = $response->getData(); $this->assertObjectHasAttribute('id', $responseData); $albumId = $responseData->id; $this->assertNotNull($albumId, 'Album ID muss im Response geliefert werden'); $this->assertTrue($this->validateUniqueId(new DataAlbum(), $albumId)); }
/** * @test * @group integration */ public function buildWebsiteShouldBeRejectedWhenUserHasNoPublishRights() { $userlogin = '******'; $password = '******'; $this->assertSuccessfulLogin($userlogin, $password); $websiteId = 'SITE-bw11fg14-3bbe-4301-ae51-f58464f1708e-SITE'; $comment = 'sometext'; $request = sprintf('/builder/buildwebsite/params/{"websiteId":"%s","comment":"%s"}', $websiteId, $comment); $this->activateGroupCheck(); $this->dispatch($request); $this->deactivateGroupCheck(); $response = $this->getResponseBody(); $response = new Response($response); $this->assertFalse($response->getSuccess()); $responseError = $response->getError(); $this->assertSame(7, $responseError[0]->code); }
/** * @test * @group integration */ public function buildWebsiteShouldBeLogged() { $websiteId = 'SITE-bw00fg14-3bbe-4301-ae51-f58464f1708e-SITE'; $params = array('websiteId' => $websiteId, 'comment' => 'test_website_build_1'); $paramsAsJson = json_encode($params); $userlogin = '******'; $userPassword = '******'; $this->assertSuccessfulLogin($userlogin, $userPassword); $this->activateGroupCheck(); $this->dispatch('builder/buildwebsite/params/' . $paramsAsJson); $this->deactivateGroupCheck(); $response = $this->getResponseBody(); $response = new Response($response); $this->assertTrue($response->getSuccess()); $responseData = $response->getData(); $this->assertActionLogEntry($params['websiteId'], $responseData->id, $userlogin, BuilderBusiness::BUILDER_BUILD_ACTION); $this->removeCreatedWebsite($websiteId); }
/** * @test * @group integration */ public function infoShouldRespondWithExpectedUserJsonWithoutGroupAssociation() { $userName = '******'; $userPassword = '******'; $this->assertSuccessfulLogin($userName, $userPassword); $this->activateGroupCheck(); $infoRequest = '/user/info'; $this->dispatch($infoRequest); $this->deactivateGroupCheck(); $response = $this->getResponseBody(); $response = new Response($response); $this->assertTrue($response->getSuccess()); $responseData = $response->getData(); $this->assertObjectHasAttribute('userInfo', $responseData); $expectedUserInfo = array('id' => 'USER-lo01eaa7-7fc5-464a-bd47-16b3b8af36c0-USER', 'lastname' => 'login_lastname_0', 'firstname' => 'login_firstname_0', 'gender' => 'm', 'email' => '*****@*****.**', 'language' => null, 'superuser' => true, 'owner' => false, 'readonly' => false, 'dashboardUrl' => null, 'upgradeUrl' => null, 'groups' => array(), 'privilege' => array()); $actualUserInfo = get_object_vars($responseData->userInfo); $this->assertSame($expectedUserInfo, $actualUserInfo); }
/** * @test * @group integration */ public function deleteShouldDeleteExpectedTemplateSnippet() { $runId = 'CMSRUNID-00000000-0000-0000-0000-000000000001-CMSRUNID'; $websiteId = 'SITE-template-snip-pet0-test-000000000002-SITE'; $request = sprintf('/templatesnippet/getall/params/{"websiteid":"%s"}', $websiteId); $this->dispatch($request); $response = $this->getResponseBody(); $this->assertNotNull($response); $this->assertInternalType('string', $response); $response = new Response($response); $this->assertTrue($response->getSuccess()); $responseData = $response->getData(); $this->assertObjectHasAttribute('templatesnippets', $responseData); $this->assertInternalType('array', $responseData->templatesnippets); $this->assertGreaterThan(0, count($responseData->templatesnippets)); $templateSnippetCountBeforeDelete = count($responseData->templatesnippets); $templateSnippetIdForDelete = 'TPLS-template-snip-pet0-test-deleteaction-TPLS'; $request = sprintf('/templatesnippet/delete/params/%s', \Zend_Json::encode(array('runid' => $runId, 'ids' => array($templateSnippetIdForDelete), 'websiteid' => $websiteId))); $this->dispatch($request); $response = $this->getResponseBody(); $this->assertNotNull($response); $this->assertInternalType('string', $response); $response = new Response($response); $this->assertTrue($response->getSuccess()); $request = sprintf('/templatesnippet/getall/params/{"websiteid":"%s"}', $websiteId); $this->dispatch($request); $response = $this->getResponseBody(); $this->assertNotNull($response); $this->assertInternalType('string', $response); $response = new Response($response); $this->assertTrue($response->getSuccess()); $responseData = $response->getData(); $this->assertObjectHasAttribute('templatesnippets', $responseData); $this->assertInternalType('array', $responseData->templatesnippets); $this->assertGreaterThan(0, count($responseData->templatesnippets)); $this->assertLessThan($templateSnippetCountBeforeDelete, count($responseData->templatesnippets)); foreach ($responseData->templatesnippets as $templateSnippet) { $this->assertInstanceOf('stdClass', $templateSnippet); $this->assertObjectHasAttribute('id', $templateSnippet); $this->assertNotSame($templateSnippetIdForDelete, $templateSnippet->id); } }
/** * @test * @group integration * @dataProvider invalidSearchFilterProvider */ public function getWithSearchFilterShouldOnlyReturnMatchingMediasAndExpectedTotal() { $websiteId = 'SITE-ra10e89c-22af-46sf-a651-fc42dc78fe50-SITE'; $searchFilter = 'Test_Data_Search_Filter'; $requestUri = sprintf('/media/get/params/{"websiteid":"%s","search":"%s"}', $websiteId, $searchFilter); $this->dispatch($requestUri); $response = $this->getResponseBody(); $this->assertNotNull($response); $this->assertInternalType('string', $response); $response = new Response($response); $this->assertTrue($response->getSuccess()); $this->assertNotEmpty($response->getData()); $responseData = $response->getData(); $this->assertObjectHasAttribute('media', $responseData); $this->assertObjectHasAttribute('total', $responseData); $mediaItems = $responseData->media; $this->assertInternalType('array', $mediaItems); $this->assertTrue(count($mediaItems) == 2); $this->assertTrue($responseData->total == 2); }
/** * @test * @group integration */ public function editTemplateShouldBeLogged() { $runId = 'CMSRUNID-00000000-0000-0000-0000-000000000001-CMSRUNID'; $websiteId = 'SITE-30490289-dddb-4501-879f-9c6c7965f871-SITE'; $idOfTemplateToUpdate = 'TPL-4mrap53m-2al2-4g1f-a49b-4a93in3f70pd-TPL'; $nameBeforeUpdate = 'Integration_Edit_Template_Original'; $request = sprintf('/template/edit/params/{"runid":"%s","id":"%s","name":"%s_Edit","websiteid":"%s","content":[]}', $runId, $idOfTemplateToUpdate, $nameBeforeUpdate, $websiteId); $userlogin = '******'; $userPassword = '******'; $this->assertSuccessfulLogin($userlogin, $userPassword); $this->activateGroupCheck(); $this->assertSuccessfulLock($runId, $idOfTemplateToUpdate, $websiteId, 'template'); $deactivated = false; $this->dispatch($request); $this->deactivateGroupCheck(); $response = $this->getResponseBody(); $response = new Response($response); $this->assertTrue($response->getSuccess()); $this->assertActionLogEntry($websiteId, $idOfTemplateToUpdate, $userlogin, TemplateBusiness::TEMPLATE_EDIT_ACTION); $this->assertSuccessfulUnlock($runId, $idOfTemplateToUpdate, $websiteId, 'template'); }
/** * Existiert ein bestimmter Lock */ protected function lockExists($runId, $userId, $websiteId, $id, $type, $returnLock = false) { $params = array('runid' => $runId, 'websiteid' => $websiteId); $request = '/lock/getAll/params/' . json_encode($params); $this->dispatch($request); $response = $this->getResponseBody(); $responseJsonObj = json_decode($response); $this->assertResponseBodySuccess($responseJsonObj); $response = new Response($response); $responseData = $response->getData(); $this->assertObjectHasAttribute('locks', $responseData); $this->assertInternalType('array', $responseData->locks); foreach ($responseData->locks as $nextLock) { if ($websiteId == $nextLock->websiteid && $id == $nextLock->id && $type == $nextLock->type && $userId == $nextLock->userid && $runId == $nextLock->runid) { // Lock existiert return $returnLock === true ? $nextLock : true; } } // Lock existiert nicht return false; }
/** * @test * @group integration */ public function getByIdShouldReturnExpectedTemplate() { $existingId = 'TPL-in6c753f-2rap-474f-a4et-4a97223fbdea-TPL'; $websiteId = 'SITE-30490289-dddb-4501-879f-9c6c7965f871-SITE'; $request = sprintf('/template/getbyid/params/{"id":"%s","websiteid":"%s"}', $existingId, $websiteId); $this->dispatch($request); $response = $this->getResponseBody(); $this->assertNotNull($response); $this->assertInternalType('string', $response); $response = new Response($response); $this->assertTrue($response->getSuccess()); $actualTemplate = $response->getData(); $this->assertInstanceOf('stdClass', $actualTemplate); $this->assertObjectHasAttribute('id', $actualTemplate); $this->assertSame($existingId, $actualTemplate->id); $this->assertObjectHasAttribute('websiteId', $actualTemplate); $this->assertSame($websiteId, $actualTemplate->websiteId); $this->assertObjectHasAttribute('name', $actualTemplate); $this->assertSame('Template_Name_Int_GetById', $actualTemplate->name); $this->assertObjectHasAttribute('content', $actualTemplate); $this->assertSame('[{"some":"value"}]', \Zend_Json::encode($actualTemplate->content)); }
/** * @test * @group integration */ public function createShouldCreateExpectedTemplateSnippet() { $websiteId = 'SITE-template-snip-pet0-test-000000000001-SITE'; $this->dispatch(sprintf('/templatesnippet/getall/params/{"websiteid":"%s"}', $websiteId)); $response = $this->getResponseBody(); $this->assertNotNull($response); $this->assertInternalType('string', $response); $response = new Response($response); $this->assertTrue($response->getSuccess()); $responseData = $response->getData(); $this->assertObjectHasAttribute('templatesnippets', $responseData); $this->assertInternalType('array', $responseData->templatesnippets); $this->assertGreaterThan(0, count($responseData->templatesnippets)); $templateSnippetCountBeforeCreate = count($responseData->templatesnippets); $name = 'TemplateSnippet_Create_Via_Integration_Test'; $request = sprintf('/templatesnippet/create/params/{"name":"%s","websiteid":"%s", "content":[]}', $name, $websiteId); $this->dispatch($request); $response = $this->getResponseBody(); $this->assertNotNull($response); $this->assertInternalType('string', $response); $response = new Response($response); $this->assertTrue($response->getSuccess()); $newTemplateSnippet = $response->getData(); $this->assertNotNull($newTemplateSnippet); $this->assertObjectHasAttribute('id', $newTemplateSnippet); $this->assertNotNull($newTemplateSnippet->id); $this->dispatch(sprintf('/templatesnippet/getall/params/{"websiteid":"%s"}', $websiteId)); $response = $this->getResponseBody(); $this->assertNotNull($response); $this->assertInternalType('string', $response); $response = new Response($response); $this->assertTrue($response->getSuccess()); $responseData = $response->getData(); $this->assertObjectHasAttribute('templatesnippets', $responseData); $this->assertInternalType('array', $responseData->templatesnippets); $this->assertGreaterThan(0, count($responseData->templatesnippets)); $this->assertGreaterThan($templateSnippetCountBeforeCreate, count($responseData->templatesnippets)); $newTemplateSnippetData = null; foreach ($responseData->templatesnippets as $templateSnippet) { $this->assertInstanceOf('stdClass', $templateSnippet); $this->assertObjectHasAttribute('id', $templateSnippet); $this->assertObjectHasAttribute('name', $templateSnippet); $this->assertObjectHasAttribute('content', $templateSnippet); if ($templateSnippet->id == $newTemplateSnippet->id) { $newTemplateSnippetData = $templateSnippet; } } $this->assertNotNull($newTemplateSnippetData); $this->assertSame($name, $newTemplateSnippetData->name); $this->assertSame(array(), $newTemplateSnippetData->content); $this->assertEquals('local', $newTemplateSnippetData->sourceType); $this->assertFalse($newTemplateSnippetData->readonly); }
/** * @test * @group integration */ public function addUsersOnGroupShouldAddUsersAsExpectedOnExistingUsers() { $groupId = 'GROUP-au00e5a7-7fc5-464a-bd47-16b3b8af00de-GROUP'; $websiteId = 'SITE-au00eaa7-7fc5-464a-bd47-16b3b8af00fr-SITE'; $userIdsToAdd = array('"USER-au00ega7-7fc5-464a-bd47-16b3b8af00kl-USER"', '"USER-au01eaa7-7fc5-464a-bd47-16b3b8af01zk-USER"', '"USER-au02eaa7-7fc5-464a-bd47-16b3b8af01zk-USER"'); $alreadyExistingGroupUserIds = array('USER-au00ega0-7fc5-464a-bd47-16b3b8af00kl-USER', 'USER-au00ega1-7fc5-464a-bd47-16b3b8af00kl-USER'); $expectedUserCount = count($userIdsToAdd) + count($alreadyExistingGroupUserIds); $addUsersRequest = sprintf('/group/addusers/params/{"id":"%s","websiteid":"%s","userIds":[%s]}', $groupId, $websiteId, implode(',', $userIdsToAdd)); $this->dispatch($addUsersRequest); $response = $this->getResponseBody(); $this->assertNotNull($response); $this->assertInternalType('string', $response); $response = new Response($response); $this->assertTrue($response->getSuccess()); $getByIdRequest = sprintf('/group/getbyid/params/{"id":"%s","websiteId":"%s"}', $groupId, $websiteId); $this->dispatch($getByIdRequest); $response = $this->getResponseBody(); $this->assertNotNull($response); $this->assertInternalType('string', $response); $response = new Response($response); $this->assertTrue($response->getSuccess()); $actualGroup = $response->getData(); $actualGroupUsers = $actualGroup->users; $this->assertSame($expectedUserCount, count($actualGroupUsers)); $expectedGroupUsersIds = array_merge($userIdsToAdd, $alreadyExistingGroupUserIds); $expectedGroupUsersIds = array_map(function ($id) { return str_replace('"', '', $id); }, $expectedGroupUsersIds); $actualGroupUsersIds = array_map(function ($user) { return $user->id; }, $actualGroupUsers); sort($actualGroupUsersIds); sort($expectedGroupUsersIds); $this->assertSame($expectedGroupUsersIds, $actualGroupUsersIds); }
/** * @param string $websiteId * @param string $assertionMessage */ protected function assertHasNoTemplates($websiteId, $assertionMessage = null) { $mediaRequestUri = sprintf('/template/getAll/params/{"websiteid":"%s"}', $websiteId); $this->dispatch($mediaRequestUri); $response = $this->getResponseBody(); $this->assertInternalType('string', $response); $this->assertNotNull($response); $response = new Response($response); $this->assertTrue($response->getSuccess()); $responseData = $response->getData(); $this->assertObjectHasAttribute('templates', $responseData); $responseMedias = $responseData->templates; if ($assertionMessage === null) { $assertionMessage = 'There are already templates attached to this website'; } $this->assertTrue(empty($responseMedias), $assertionMessage); }
/** * @test * @group integration */ public function editMediaShouldAlterAlbumIdAsExpected() { $mediaId = 'MDB-co91d0ec-cb0f-4961-92bd-765d4aa581a4-MDB'; $websiteId = 'SITE-ra10e89c-22ed-46cd-a651-fc42dc78fe51-SITE'; $alteredAlbumId = 'ALBUM-ce1ecf03-acc4-4adb-ed34-72ebb0878alt-ALBUM'; $requestUri = sprintf('/media/edit/params/{"websiteId":"%s","id":"%s","albumId":"%s"}', $websiteId, $mediaId, $alteredAlbumId); $this->dispatch($requestUri); $response = $this->getResponseBody(); $this->assertNotNull($response); $this->assertInternalType('string', $response); $response = new Response($response); $this->assertEmpty($response->getError()); $this->assertTrue($response->getSuccess()); $getAllRequestUri = sprintf('/media/get/params/{"websiteId":"%s"}', $websiteId); $this->dispatch($getAllRequestUri); $response = $this->getResponseBody(); $this->assertNotNull($response); $this->assertInternalType('string', $response); $response = new Response($this->getResponseBody()); $this->dispatch($getAllRequestUri); $response = $this->getResponseBody(); $this->assertNotNull($response); $this->assertInternalType('string', $response); $response = new Response($this->getResponseBody()); $this->assertTrue($response->getSuccess()); $responseData = $response->getData(); $this->assertObjectHasAttribute('media', $responseData); $this->assertInternalType('array', $responseData->media); $this->assertTrue(count($responseData->media) === 1); $allMediaForWebsiteAndAlbumId = $responseData->media; foreach ($allMediaForWebsiteAndAlbumId as $media) { $this->assertInstanceOf('stdClass', $media); $this->assertObjectHasAttribute('websiteId', $media); $this->assertSame($websiteId, $media->websiteId); $this->assertObjectHasAttribute('id', $media); $this->assertSame($mediaId, $media->id); $this->assertObjectHasAttribute('albumId', $media); $this->assertSame($alteredAlbumId, $media->albumId); } }
/** * @test * @group integration */ public function getUnitIdsShouldReturnNonSuccessfulCmsResponseForCountValueGreaterThanConfiguredLimit() { $config = Registry::getConfig(); $configuredUuidLimit = intval($config->uuid->limit); $exceedingUuidLimit = $configuredUuidLimit + 1; $dispatchUri = sprintf('/uuid/getunitids/params/{"count":%d}', $exceedingUuidLimit); $this->dispatch($dispatchUri); $cmsResponse = new CmsResponse($this->getResponseBody()); $this->assertFalse($cmsResponse->getSuccess()); }
/** * @test * @group integration */ public function uploadShouldStoreFileAsExpectedAndHaveTextPlainContentType() { $expectedUploadCount = 1; $expectedUploadExtension = 'js'; $config = Registry::getConfig(); $testMediaFilesDirectory = $config->media->files->directory; $testFilesDirectory = $config->test->files->directory; $testUploadFile = $testFilesDirectory . DIRECTORY_SEPARATOR . 'backbone.js'; $testTmpFile = DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . 'phpIsd9te'; $websiteId = 'SITE-ra10e8ul-11af-46cd-a651-fc42dc78fe50-SITE'; $mediaName = 'integration_test_upload'; $albumId = 'ALBUM-ce2ecf03-acc4-4adb-ed34-72ebb08780up-ALBUM'; $fileInputname = 'upload'; $requestUri = sprintf('/media/upload/params/{"websiteid":"%s","albumid":"%s","name":"%s","fileinputname":"%s"}', $websiteId, $albumId, $mediaName, $fileInputname); $this->assertFakeUpload($fileInputname, $testUploadFile, $testTmpFile); $this->dispatch($requestUri); $response = $this->getResponseBody(); $this->assertHeaderContains('Content-Type', 'text/plain'); $this->assertNotNull($response); $this->assertInternalType('string', $response); $response = new Response($response); $this->assertTrue($response->getSuccess()); $uniqueidValidator = new UniqueIdValidator(DataMedia::ID_PREFIX, DataMedia::ID_SUFFIX); $responseData = $response->getData(); $this->assertObjectHasAttribute('id', $responseData); $mediaId = $responseData->id; $this->assertTrue($uniqueidValidator->isValid($mediaId)); $expectedMediaWebsiteDirectory = $testMediaFilesDirectory . DIRECTORY_SEPARATOR . $websiteId; $this->assertTrue(is_dir($expectedMediaWebsiteDirectory)); $directory = new \DirectoryIterator($expectedMediaWebsiteDirectory); $uploadedFiles = array(); foreach ($directory as $fileinfo) { if (!$fileinfo->isDot()) { $splitFileName = explode(".", $fileinfo->getFilename()); $this->assertSame($expectedUploadExtension, end($splitFileName)); $uploadedFiles[] = $fileinfo->getFilename(); } } $this->assertSame($expectedUploadCount, count($uploadedFiles)); $testMediaWebsiteUploadDirectory = $testMediaFilesDirectory . DIRECTORY_SEPARATOR . $websiteId; $this->dispatch('/media/getbyid/params/{"websiteid":"' . $websiteId . '","id":"' . $mediaId . '"}'); $response = $this->getResponseBody(); $response = new Response($response); $this->assertTrue($response->getSuccess()); $responseData = $response->getData(); $this->assertObjectHasAttribute('dateUploaded', $responseData); $this->assertNotNull($responseData->dateUploaded, 'Upload-Datum muss automatisch gesetzt werden'); $this->assertInternalType('int', $responseData->dateUploaded, 'Upload-Datum muss Timestamp sein'); DirectoryHelper::removeRecursiv($testMediaWebsiteUploadDirectory, $testMediaFilesDirectory); }