| @@ 53-61 (lines=9) @@ | ||
| 50 | * @depends testCreateLocation |
|
| 51 | * Covers GET /content/locations?remoteId=<locationRemoteId> |
|
| 52 | */ |
|
| 53 | public function testRedirectLocationByRemoteId($locationHref) |
|
| 54 | { |
|
| 55 | $response = $this->sendHttpRequest( |
|
| 56 | $this->createHttpRequest('GET', '/api/ezp/v2/content/locations?remoteId=' . $this->addTestSuffix('testCreateLocation')) |
|
| 57 | ); |
|
| 58 | ||
| 59 | self::assertHttpResponseCodeEquals($response, 307); |
|
| 60 | self::assertHttpResponseHasHeader($response, 'Location', $locationHref); |
|
| 61 | } |
|
| 62 | ||
| 63 | /** |
|
| 64 | * @depends testCreateLocation |
|
| @@ 229-237 (lines=9) @@ | ||
| 226 | * @depends testCreateUser |
|
| 227 | * Covers GET /user/users?remoteId={userRemoteId} |
|
| 228 | */ |
|
| 229 | public function testLoadUserByRemoteId() |
|
| 230 | { |
|
| 231 | $remoteId = $this->addTestSuffix('testCreateUser'); |
|
| 232 | $response = $this->sendHttpRequest( |
|
| 233 | $this->createHttpRequest('GET', "/api/ezp/v2/user/users?remoteId=$remoteId") |
|
| 234 | ); |
|
| 235 | ||
| 236 | self::assertHttpResponseCodeEquals($response, 200); |
|
| 237 | } |
|
| 238 | ||
| 239 | /** |
|
| 240 | * Covers GET /user/groups. |
|
| @@ 255-263 (lines=9) @@ | ||
| 252 | * @depends testCreateUserGroup |
|
| 253 | * Covers GET /user/groups?remoteId={groupRemoteId} |
|
| 254 | */ |
|
| 255 | public function testLoadUserGroupByRemoteId($groupHref) |
|
| 256 | { |
|
| 257 | $remoteId = $this->addTestSuffix('testCreateUserGroup'); |
|
| 258 | $response = $this->sendHttpRequest( |
|
| 259 | $this->createHttpRequest('GET', "/api/ezp/v2/user/groups?remoteId=$remoteId") |
|
| 260 | ); |
|
| 261 | ||
| 262 | self::assertHttpResponseCodeEquals($response, 200); |
|
| 263 | } |
|
| 264 | ||
| 265 | /** |
|
| 266 | * Covers GET /user/users/{userId}/drafts. |
|
| @@ 84-92 (lines=9) @@ | ||
| 81 | * @depends testPublishContent |
|
| 82 | * Covers GET /content/objects?remoteId=<remoteId> |
|
| 83 | */ |
|
| 84 | public function testRedirectContent($restContentHref) |
|
| 85 | { |
|
| 86 | $response = $this->sendHttpRequest( |
|
| 87 | $this->createHttpRequest('GET', '/api/ezp/v2/content/objects?remoteId=' . $this->addTestSuffix('testCreateContent')) |
|
| 88 | ); |
|
| 89 | ||
| 90 | self::assertHttpResponseCodeEquals($response, 307); |
|
| 91 | self::assertEquals($response->getHeader('Location'), $restContentHref); |
|
| 92 | } |
|
| 93 | ||
| 94 | /** |
|
| 95 | * @depends testPublishContent |
|
| @@ 133-143 (lines=11) @@ | ||
| 130 | * |
|
| 131 | * @return string ContentVersion REST ID |
|
| 132 | */ |
|
| 133 | public function testCreateDraftFromVersion($restContentHref) |
|
| 134 | { |
|
| 135 | $response = $this->sendHttpRequest( |
|
| 136 | $this->createHttpRequest('COPY', "{$restContentHref}/versions/1") |
|
| 137 | ); |
|
| 138 | ||
| 139 | self::assertHttpResponseCodeEquals($response, 201); |
|
| 140 | self::assertEquals($response->getHeader('Location'), "{$restContentHref}/versions/2"); |
|
| 141 | ||
| 142 | return $response->getHeader('Location'); |
|
| 143 | } |
|
| 144 | ||
| 145 | /** |
|
| 146 | * @depends testPublishContent |
|
| @@ 236-246 (lines=11) @@ | ||
| 233 | * |
|
| 234 | * @return string the ID of the created version (/content/objects/<contentId>/versions/<versionNumber> |
|
| 235 | */ |
|
| 236 | public function testCreateDraftFromCurrentVersion($restContentHref) |
|
| 237 | { |
|
| 238 | $response = $this->sendHttpRequest( |
|
| 239 | $this->createHttpRequest('COPY', "$restContentHref/currentversion") |
|
| 240 | ); |
|
| 241 | ||
| 242 | self::assertHttpResponseCodeEquals($response, 201); |
|
| 243 | self::assertHttpResponseHasHeader($response, 'Location'); |
|
| 244 | ||
| 245 | return $response->getHeader('Location'); |
|
| 246 | } |
|
| 247 | ||
| 248 | /** |
|
| 249 | * @depends testCreateDraftFromCurrentVersion |
|
| @@ 749-760 (lines=12) @@ | ||
| 746 | * |
|
| 747 | * @return string Content Version Draft REST resource link |
|
| 748 | */ |
|
| 749 | private function createDraftFromVersion($restContentVersionHref) |
|
| 750 | { |
|
| 751 | $response = $this->sendHttpRequest( |
|
| 752 | $this->createHttpRequest('COPY', "{$restContentVersionHref}") |
|
| 753 | ); |
|
| 754 | self::assertHttpResponseCodeEquals($response, 201); |
|
| 755 | ||
| 756 | $href = $response->getHeader('Location'); |
|
| 757 | self::assertNotEmpty($href); |
|
| 758 | ||
| 759 | return $href; |
|
| 760 | } |
|
| 761 | ||
| 762 | /** |
|
| 763 | * Publish Content Version Draft given by REST resource link. |
|
| @@ 21-27 (lines=7) @@ | ||
| 18 | parent::setUp(); |
|
| 19 | } |
|
| 20 | ||
| 21 | public function testCreateSessionBadCredentials() |
|
| 22 | { |
|
| 23 | $request = $this->createHttpRequest('POST', '/api/ezp/v2/user/sessions', 'SessionInput+json', 'Session+json'); |
|
| 24 | $this->setSessionInput($request, 'badpassword'); |
|
| 25 | $response = $this->sendHttpRequest($request); |
|
| 26 | self::assertHttpResponseCodeEquals($response, 401); |
|
| 27 | } |
|
| 28 | ||
| 29 | /** |
|
| 30 | * @return \stdClass The login request's response |
|