Ejemplo n.º 1
0
 /**
  * @test
  * @group integration
  */
 public function renewPasswordShouldReturnErrorForUnknownEmail()
 {
     $nonExistingEmail = '*****@*****.**';
     $renewRequest = sprintf('/user/renewpassword/params/{"email":"%s"}', $nonExistingEmail);
     $this->dispatch($renewRequest);
     $response = new Response($this->getResponseBody());
     $this->assertFalse($response->getSuccess());
     $responseError = $response->getError();
     $this->assertEquals(1040, $responseError[0]->code);
 }
Ejemplo n.º 2
0
 /**
  * @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);
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * @test
  * @group integration
  */
 public function loginShouldReturnErrorForNonExistingUser()
 {
     $username = '******';
     $password = '******';
     $loginRequest = sprintf('/user/login/params/{"username":"******","password":"******"}', $username, $password);
     $this->dispatch($loginRequest);
     $response = new Response($this->getResponseBody());
     $this->assertFalse($response->getSuccess());
     $responseError = $response->getError();
     $this->assertSame(6, $responseError[0]->code);
 }
Ejemplo n.º 4
0
 /**
  * @test
  * @group integration
  * @dataProvider invalidWebsiteIdsProvider
  */
 public function editAlbumShouldReturnValidationErrorForInvalidWebsiteIds($websiteId)
 {
     $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->assertFalse($response->getSuccess());
     $errorData = $response->getError();
     $this->assertSame('websiteid', $errorData[0]->param->field);
 }
Ejemplo n.º 5
0
 /**
  * @test
  * @group integration
  * @dataProvider invalidUserIdsProvider
  */
 public function getByIdOnUserShouldReturnValidationErrorForInvalidUserIds($userId)
 {
     $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());
     $responseError = $response->getError();
     $this->assertSame('id', $responseError[0]->param->field);
 }
Ejemplo n.º 6
0
 /**
  * @test
  * @group integration
  */
 public function registerUserShouldBeRejectedWhenUserNotLoggedIn()
 {
     $this->activateGroupCheck();
     $userIds = array('"USER-reg00gc0-b7a3-4599-b396-94c8bb6c10d9-USER"');
     $registerRequest = sprintf('/user/register/params/{"ids":[%s]}', implode(',', $userIds));
     $this->dispatch($registerRequest);
     $this->deactivateGroupCheck();
     $response = new Response($this->getResponseBody());
     $this->assertFalse($response->getSuccess());
     $responseError = $response->getError();
     $this->assertEquals(5, $responseError[0]->code);
 }
Ejemplo n.º 7
0
 /**
  * @test
  * @group integration
  * @dataProvider invalidWebsiteIdsProvider
  */
 public function getAllOnUserWithInvalidWebsiteIdShouldReturnError($websiteId)
 {
     $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->assertFalse($response->getSuccess());
     $errorData = $response->getError();
     $this->assertSame('websiteid', $errorData[0]->param->field);
 }
Ejemplo n.º 8
0
 /**
  * @test
  * @group integration
  * @dataProvider invalidAlbumIdsProvider
  */
 public function deleteAlbumShouldReturnValidationErrorForInvalidAlbumIds($albumId)
 {
     $websiteId = 'SITE-ce6e702d-10ac-4e1e-951f-307e4b8765al-SITE';
     $request = sprintf('/album/delete/params/{"websiteId":"%s","id":"%s"}', $websiteId, $albumId);
     $this->dispatch($request);
     $response = $this->getResponseBody();
     $this->assertNotNull($response);
     $this->assertInternalType('string', $response);
     $response = new Response($response);
     $this->assertFalse($response->getSuccess());
     $errorData = $response->getError();
     $this->assertSame('id', $errorData[0]->param->field);
 }
Ejemplo n.º 9
0
 /**
  * @test
  * @group integration
  * @dataProvider invalidNamesProvider
  */
 public function createAlbumShouldReturnValidationErrorForInvalidNames($name)
 {
     $websiteId = 'SITE-ce6e702f-10ac-4e1e-951f-307e4b8765al-SITE';
     $request = sprintf('/album/create/params/{"websiteId":"%s","name":"%s"}', $websiteId, $name);
     $this->dispatch($request);
     $response = $this->getResponseBody();
     $this->assertNotNull($response);
     $this->assertInternalType('string', $response);
     $response = new Response($response);
     $this->assertFalse($response->getSuccess());
     $responseError = $response->getError();
     $this->assertSame('name', $responseError[0]->param->field);
 }
Ejemplo n.º 10
0
 /**
  * @test
  * @group integration
  */
 public function getByIdShouldFailOnMissingMediaId()
 {
     $websiteId = 'SITE-me10e89c-r2af-46cd-a651-fc42dc78fe5l-SITE';
     $requestUri = sprintf('/media/getbyid/params/{"websiteid":"%s"}', $websiteId);
     $this->dispatch($requestUri);
     $response = $this->getResponseBody();
     $this->assertNotNull($response);
     $this->assertInternalType('string', $response);
     $response = new Response($response);
     $this->assertFalse($response->getSuccess());
     $responseError = $response->getError();
     $this->assertNotEmpty($responseError[0]->param);
     $this->assertSame('id', $responseError[0]->param->field);
 }
Ejemplo n.º 11
0
 /**
  * @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);
 }
Ejemplo n.º 12
0
 /**
  * @test
  * @group integration
  * @dataProvider invalidNamesProvider
  */
 public function editAlbumShouldReturnValidationErrorForInvalidNames($albumName)
 {
     $websiteId = 'SITE-ce6e702f-10ac-4e1e-951f-307e4b8765al-SITE';
     $albumId = 'ALBUM-ca3ecf03-acc4-4fdb-add4-72ebb08780al-ALBUM';
     $request = sprintf('/album/edit/params/{"websiteId":"%s","id":"%s","name":"%s"}', $websiteId, $albumId, $albumName);
     $this->dispatch($request);
     $response = $this->getResponseBody();
     $this->assertNotNull($response);
     $this->assertInternalType('string', $response);
     $response = new Response($response);
     $this->assertFalse($response->getSuccess());
     $errorData = $response->getError();
     $this->assertSame('name', $errorData[0]->param->field);
 }
Ejemplo n.º 13
0
 /**
  * @test
  * @group integration
  */
 public function infoShouldRespondWithErrorWhenUserIsNotAuthenticated()
 {
     $this->activateGroupCheck();
     $infoRequest = '/user/info';
     $this->dispatch($infoRequest);
     $response = $this->getResponseBody();
     $this->deactivateGroupCheck();
     $response = new Response($response);
     $this->assertFalse($response->getSuccess());
     $responseError = $response->getError();
     $expectedErrorCode = 5;
     $actualErrorCode = $responseError[0]->code;
     $assertionMessage = sprintf("Actual error code '%s' doesn't match expected error code '%s'", $actualErrorCode, $expectedErrorCode);
     $this->assertSame($expectedErrorCode, $actualErrorCode);
 }
Ejemplo n.º 14
0
 /**
  * @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);
 }
Ejemplo n.º 15
0
 /**
  * @test
  * @group integration
  * @dataProvider invalidIdsProvider
  */
 public function deleteShouldReturnValidationErrorForInvalidIds($id)
 {
     $runId = 'CMSRUNID-00000000-0000-0000-0000-000000000001-CMSRUNID';
     $websiteId = 'SITE-template-snip-pet0-test-000000000002-SITE';
     $request = sprintf('/templatesnippet/delete/params/%s', \Zend_Json::encode(array('runid' => $runId, 'ids' => array($id), 'websiteid' => $websiteId)));
     $this->dispatch($request);
     $response = $this->getResponseBody();
     $this->assertNotNull($response);
     $this->assertInternalType('string', $response);
     $response = new Response($response);
     $this->assertFalse($response->getSuccess());
     $error = $response->getError();
     $expectedErrorCode = 3;
     $actualErrorCode = $error[0]->code;
     $assertionMessage = sprintf("Expected error code '%d' doesn't match actual code '%d'", $expectedErrorCode, $actualErrorCode);
     $this->assertSame($expectedErrorCode, $actualErrorCode, $assertionMessage);
 }
Ejemplo n.º 16
0
 /**
  * @test
  * @group integration
  */
 public function getByIdShouldReturnErrorForNonExistingId()
 {
     $nonExistingId = 'TPLS-template-snip-pet0-not0-existing0001-TPLS';
     $websiteId = 'SITE-30490289-dddb-4501-879f-9c6c7965f871-SITE';
     $request = sprintf('/templatesnippet/getbyid/params/{"id":"%s","websiteid":"%s"}', $nonExistingId, $websiteId);
     $this->dispatch($request);
     $response = $this->getResponseBody();
     $this->assertNotNull($response);
     $this->assertInternalType('string', $response);
     $response = new Response($response);
     $this->assertFalse($response->getSuccess());
     $error = $response->getError();
     $expectedErrorCode = 1602;
     $actualErrorCode = $error[0]->code;
     $assertionMessage = sprintf("Expected error code '%d' doesn't match actual code '%d'", $expectedErrorCode, $actualErrorCode);
     $this->assertSame($expectedErrorCode, $actualErrorCode, $assertionMessage);
 }
Ejemplo n.º 17
0
 /**
  * @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());
 }
Ejemplo n.º 18
0
 /**
  * @test
  * @group integration
  */
 public function deleteShouldReturnErrorWhenTemplateIsReferencedByPage()
 {
     $runId = 'CMSRUNID-00000000-0000-0000-0000-000000000001-CMSRUNID';
     $websiteId = 'SITE-30490289-dddb-4501-879f-9c6c7965f871-SITE';
     $byPageReferencedTemplateId = 'TPL-ejrap53m-2bf8-2g4h-a47b-4a97in3fbdel-TPL';
     $request = sprintf('/template/delete/params/{"runId":"%s","id":"%s","websiteid":"%s"}', $runId, $byPageReferencedTemplateId, $websiteId);
     $this->dispatch($request);
     $response = $this->getResponseBody();
     $this->assertNotNull($response);
     $this->assertInternalType('string', $response);
     $response = new Response($response);
     $this->assertFalse($response->getSuccess());
     $error = $response->getError();
     $expectedErrorCode = 308;
     $actualErrorCode = $error[0]->code;
     $assertionMessage = sprintf("Expected error code '%d' doesn't match actual code '%d'", $expectedErrorCode, $actualErrorCode);
     $this->assertSame($expectedErrorCode, $actualErrorCode, $assertionMessage);
 }
Ejemplo n.º 19
0
 /**
  * @test
  * @group integration
  */
 public function checkRequiredParams()
 {
     $this->dispatch('/templatesnippet/create/');
     $response = $this->getResponseBody();
     $this->assertNotNull($response);
     $this->assertInternalType('string', $response);
     $response = new Response($response);
     $this->assertFalse($response->getSuccess());
     $errors = $response->getError();
     $invalidParams = array();
     foreach ($errors as $error) {
         $this->assertSame(3, $error->code);
         $this->assertObjectHasAttribute('field', $error->param);
         $invalidParams[] = $error->param->field;
     }
     $this->assertContains('websiteid', $invalidParams);
     $this->assertContains('name', $invalidParams);
     $this->assertSame(2, count($invalidParams));
 }
 /**
  * @test
  * @group integration
  * @dataProvider requiredParamsProvider
  */
 public function checkRequiredParams($requiredParams)
 {
     $userName = '******';
     $userPassword = '******';
     $this->assertSuccessfulLogin($userName, $userPassword);
     $request = sprintf($this->serviceUrl, '');
     $this->dispatch($request);
     $response = $this->getResponseBody();
     $this->assertNotNull($response);
     $this->assertInternalType('string', $response);
     $response = new Response($response);
     $this->assertFalse($response->getSuccess());
     $errors = $response->getError();
     foreach ($errors as $error) {
         $this->assertSame(3, $error->code);
         $this->assertObjectHasAttribute('field', $error->param);
         $this->assertContains($error->param->field, $requiredParams, 'Parameter "' . $error->param->field . '" wird invalid zurueckgegeben, obwohl er korrekt ist');
         $key = array_search($error->param->field, $requiredParams);
         unset($requiredParams[$key]);
     }
     $this->assertSame(0, count($requiredParams), 'Parameter "' . implode(', ', $requiredParams) . '" wurde nicht als Fehler zurueckgegeben');
 }
Ejemplo n.º 21
0
 /**
  * @test
  * @group integration
  */
 public function cancelShouldReturnErrorForNonExistingImportId()
 {
     DirectoryHelper::clearLatchDirectory();
     $fakeImportId = str_repeat('a', LatchBusiness::LATCH_IMPORT_ID_LENGTH);
     $fakeImportId1 = str_repeat('b', LatchBusiness::LATCH_IMPORT_ID_LENGTH);
     $fakeImportId2 = str_repeat('c', LatchBusiness::LATCH_IMPORT_ID_LENGTH);
     $fakeLatches[$fakeImportId] = 'fake_import_1.zip';
     $fakeLatches[$fakeImportId1] = 'fake_import_2.zip';
     $fakeLatches[$fakeImportId2] = 'fake_import_3.zip';
     $this->buildFakeLatchStorage($fakeLatches);
     $nonExistingImportId = str_repeat('d', LatchBusiness::LATCH_IMPORT_ID_LENGTH);
     $request = sprintf('/import/cancel/params/{"importid":"%s"}', $nonExistingImportId);
     $this->dispatch($request);
     $response = new Response($this->getResponseBody());
     $this->assertInternalType('string', $this->getResponseBody());
     $this->assertNotNull($this->getResponseBody());
     $this->assertFalse($response->getSuccess());
     $errorData = $response->getError();
     $expectedErrorText = sprintf('Import Id %s existiert nicht', $nonExistingImportId);
     $expectedErrorText = \Cms\Error::getMessageByCode(15, array('value' => $nonExistingImportId));
     $this->assertEquals($expectedErrorText, $errorData[0]->text);
 }
Ejemplo n.º 22
0
 /**
  * @test
  * @group integration
  * @dataProvider invalidRightsProvider
  */
 public function setPageRightsShouldReturnValidationErrorForInvalidRights($right)
 {
     $websiteId = 'SITE-edl54f03-nac4-4fdb-af34-72ebr0878rg7-SITE';
     $groupId = 'GROUP-edl54f03-nac4-4fdb-af34-72ebr0878rg7-GROUP';
     $request = sprintf('/group/setpagerights/params/{"id":"%s","websiteId":"%s","allRights":false,"rights":%s}', $groupId, $websiteId, json_encode($right));
     $this->dispatch($request);
     $response = $this->getResponseBody();
     $this->assertNotNull($response);
     $this->assertInternalType('string', $response);
     $response = new Response($response);
     $this->assertFalse($response->getSuccess());
     $responseError = $response->getError();
     $this->assertSame('rights', $responseError[0]->param->field);
 }
Ejemplo n.º 23
0
 /**
  * @test
  * @group integration
  * @dataProvider invalidUserIdsProvider
  */
 public function addUsersOnGroupShouldReturnValidationErrorForInvalidUserIds($userIds)
 {
     $websiteId = 'SITE-0db7eaa7-7fc5-464a-bd47-16b3b8af00rg-SITE';
     $groupId = 'GROUP-0db7eaa7-7fc5-464a-bd47-16b3j8af03rg-GROUP';
     $addUsersRequest = sprintf('/group/addusers/params/{"id":"%s","websiteid":"%s","userIds":[%s]}', $groupId, $websiteId, implode(',', $userIds));
     $this->dispatch($addUsersRequest);
     $response = $this->getResponseBody();
     $this->assertNotNull($response);
     $this->assertInternalType('string', $response);
     $response = new Response($response);
     $this->assertFalse($response->getSuccess());
     $errorData = $response->getError();
     $this->assertSame('userid', $errorData[0]->param->field);
 }
Ejemplo n.º 24
0
 /**
  * @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);
     }
 }
Ejemplo n.º 25
0
 /**
  * @test
  * @integration
  */
 public function moduleImportShouldRespondWithConflictingModules()
 {
     $websiteId = 'SITE-im12maec-20dr-4ea8-a477-m4e79e8e62c0-SITE';
     $config = Registry::getConfig();
     $testImportDirectory = $config->import->directory;
     $testFilesDirectory = $config->test->files->directory;
     $testImportFilename = 'test_export_0_modules_conflict.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');
     $responseBody = $this->getResponseBody();
     $response = new Response($responseBody);
     $this->assertFalse($response->getSuccess(), $responseBody);
     $error = $response->getError();
     $this->assertEquals(11, $error[0]->code);
     $responseData = $response->getData();
     $this->assertObjectHasAttribute('importId', $responseData);
     $this->assertObjectHasAttribute('conflict', $responseData);
     $conflictData = $responseData->conflict;
     $this->assertObjectHasAttribute('templates', $conflictData);
     $this->assertObjectHasAttribute('modules', $conflictData);
     $this->assertObjectHasAttribute('media', $conflictData);
     $expectedConflictingModules = array();
     for ($i = 0; $i < 3; ++$i) {
         $conflictingModule = new \StdClass();
         $conflictingModule->id = 'MODUL-0rap5eb8-0df3-47e9-conf-90ae9d96d3c' . $i . '-MODUL';
         $conflictingModule->oldName = 'module ' . $i;
         $conflictingModule->newName = 'Page_Export_' . $i;
         $expectedConflictingModules[] = $conflictingModule;
     }
     $actualConflictingModules = $conflictData->modules;
     usort($actualConflictingModules, function ($a, $b) {
         return strcmp($a->id, $b->id);
     });
     $this->assertTrue(count($actualConflictingModules) === count($expectedConflictingModules));
     $this->assertEquals($expectedConflictingModules, $actualConflictingModules);
     $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);
         }
     }
     DirectoryHelper::clearLatchDirectory();
 }
Ejemplo n.º 26
0
 /**
  * @test
  * @group integration
  */
 public function uploadShouldFailOnInvalidAlbumId()
 {
     $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 . 'phpIsd9t2';
     $websiteId = 'SITE-ra10e8ul-11af-46cd-a651-fc42dc78fe50-SITE';
     $name = 'integration_test_upload';
     $fileInputname = 'upload';
     $invalidAlbumId = 'SITE-ce6e702f-10ac-4e1e-951f-307e4b8765al-SITE';
     $requestUri = sprintf('/media/upload/params/{"websiteid":"%s","albumId":"%s","name":"%s", "fileinputname":"%s"}', $websiteId, $invalidAlbumId, $name, $fileInputname);
     $this->assertFakeUpload($fileInputname, $testUploadFile, $testTmpFile);
     $this->dispatch($requestUri);
     $response = $this->getResponseBody();
     $this->assertNotNull($response);
     $this->assertInternalType('string', $response);
     $response = new Response($response);
     $errorData = $response->getError();
     $errorFields = array();
     foreach ($errorData as $error) {
         $errorFields[] = $error->param->field;
     }
     $this->assertNotEmpty($errorData);
     $this->assertFalse($response->getSuccess());
     $this->assertContains('albumid', $errorFields);
 }
Ejemplo n.º 27
0
 /**
  * @test
  * @group integration
  */
 public function getAllShouldReturnResponseErrorOnInvalidTypeValue()
 {
     $websiteId = 'SITE-ge10e89c-r2af-46cd-a651-fc42dc78fe5l-SITE';
     $albumId = 'ALBUM-g02ecf03-moe9-4adb-ed3f-72ebb0878008-ALBUM';
     $invalidType = 'INVALID_MEDIA_TYPE';
     $requestUri = sprintf('/media/getall/params/{"websiteid":"%s","albumId":"%s","type":"%s"}', $websiteId, $albumId, $invalidType);
     $this->dispatch($requestUri);
     $response = $this->getResponseBody();
     $this->assertNotNull($response);
     $this->assertInternalType('string', $response);
     $response = new Response($response);
     $this->assertFalse($response->getSuccess());
     $responseError = $response->getError();
     $this->assertNotEmpty($responseError[0]->param);
     $this->assertSame('type', $responseError[0]->param->field);
 }
Ejemplo n.º 28
0
 /**
  * @test
  * @group integration
  * @dataProvider invalidGroupIdsProvider
  */
 public function removeGroupsOnUserShouldReturnValidationErrorForInvalidGroupIds($groupIds)
 {
     $websiteId = 'SITE-0db7eaa7-7fc5-464a-bd47-16b3b8af00rg-SITE';
     $userId = 'USER-0db7eaa7-7fc5-464a-bd47-16b3b8af03rg-USER';
     $removeGroupsRequest = sprintf('/user/removegroups/params/{"id":"%s","websiteid":"%s","groupIds":[%s]}', $userId, $websiteId, implode(',', $groupIds));
     $this->dispatch($removeGroupsRequest);
     $response = $this->getResponseBody();
     $this->assertNotNull($response);
     $this->assertInternalType('string', $response);
     $response = new Response($response);
     $this->assertFalse($response->getSuccess());
     $errorData = $response->getError();
     $this->assertSame('groupid', $errorData[0]->param->field);
 }
Ejemplo n.º 29
0
 /**
  * @test
  * @group  integration
  * @group  bugs
  * @ticket SBCMS-458
  *
  */
 public function createUserShouldReturnErrorForAlreadyTakenEmail()
 {
     $lastname = 'create_test_lastname';
     $firstname = 'create_test_firstname';
     $gender = 'f';
     $superuser = '******';
     $email = '*****@*****.**';
     $requestEndpoint = '/user/create/params/{"email":"%s","lastname":"%s",' . '"firstname":"%s","gender":"%s","superuser":"******"}';
     $createRequest = sprintf($requestEndpoint, $email, $lastname, $firstname, $gender, $superuser);
     $this->dispatch($createRequest);
     $response = $this->getResponseBody();
     $this->assertNotNull($response);
     $this->assertInternalType('string', $response);
     $response = new Response($response);
     $this->assertFalse($response->getSuccess());
     $responseError = $response->getError();
     $assertionMessage = 'Error code liegt nicht zwischen 1000 <> 1100';
     $this->assertGreaterThanOrEqual(1000, $responseError[0]->code, $assertionMessage);
     $this->assertLessThan(1100, $responseError[0]->code, $assertionMessage);
 }
Ejemplo n.º 30
0
 /**
  * @test
  * @group integration
  * @dataProvider invalidImportIdsProvider
  * @param string $importId
  */
 public function overwriteShouldReturnValidationErrorForInvalidImportIds($importId)
 {
     //$websiteId = 'SITE-02a7358d-ovwr-4b9a-b3c8-75c8ec37d324-SITE';
     $templates = array('TPL-3b249276-ovwr-4b56-b52c-aeaa49e541c9-TPL');
     $modules = array('MODUL-5rap62rs-ovwr-aa01-8de8-f2cb4236eb45-MODUL', 'MODUL-5rap62rs-ovwr-aa02-8de8-f2cb4236eb45-MODUL');
     $media = array('MDB-me4mo49e-ovwr-b9fh-92bd-af5d4c4df4a6-MDB');
     $data = array('templates' => $templates, 'modules' => $modules, 'media' => $media, 'importId' => $importId);
     $request = sprintf('/import/overwrite/params/%s', json_encode($data));
     $this->dispatch($request);
     $response = new Response($this->getResponseBody());
     $this->assertInternalType('string', $this->getResponseBody());
     $this->assertNotNull($this->getResponseBody());
     $this->assertFalse($response->getSuccess());
     $errorData = $response->getError();
     $this->assertEquals('importid', $errorData[0]->param->field);
 }