| @@ 111-127 (lines=17) @@ | ||
| 108 | /** |
|
| 109 | * @depends testPublishContent |
|
| 110 | */ |
|
| 111 | public function testUpdateContentMetadata($restContentHref) |
|
| 112 | { |
|
| 113 | $string = $this->addTestSuffix(__FUNCTION__); |
|
| 114 | $content = <<< XML |
|
| 115 | <?xml version="1.0" encoding="UTF-8"?> |
|
| 116 | <ContentUpdate> |
|
| 117 | <Owner href="/api/ezp/v2/user/users/10"/> |
|
| 118 | <remoteId>{$string}</remoteId> |
|
| 119 | </ContentUpdate> |
|
| 120 | XML; |
|
| 121 | $request = $this->createHttpRequest('PATCH', $restContentHref, 'ContentUpdate+xml', 'ContentInfo+json'); |
|
| 122 | $request->setContent($content); |
|
| 123 | $response = $this->sendHttpRequest($request); |
|
| 124 | self::assertHttpResponseCodeEquals($response, 200); |
|
| 125 | ||
| 126 | // @todo test data |
|
| 127 | } |
|
| 128 | ||
| 129 | /** |
|
| 130 | * @depends testPublishContent |
|
| @@ 270-291 (lines=22) @@ | ||
| 267 | * |
|
| 268 | * @param string $restContentVersionHref /content/objects/<contentId>/versions>/<versionNumber> |
|
| 269 | */ |
|
| 270 | public function testUpdateVersion($restContentVersionHref) |
|
| 271 | { |
|
| 272 | $xml = <<< XML |
|
| 273 | <VersionUpdate> |
|
| 274 | <fields> |
|
| 275 | <field> |
|
| 276 | <fieldDefinitionIdentifier>name</fieldDefinitionIdentifier> |
|
| 277 | <languageCode>eng-GB</languageCode> |
|
| 278 | <fieldValue>testUpdateVersion</fieldValue> |
|
| 279 | </field> |
|
| 280 | </fields> |
|
| 281 | </VersionUpdate> |
|
| 282 | XML; |
|
| 283 | ||
| 284 | $request = $this->createHttpRequest('PATCH', $restContentVersionHref, 'VersionUpdate+xml', 'Version+json'); |
|
| 285 | $request->setContent($xml); |
|
| 286 | $response = $this->sendHttpRequest( |
|
| 287 | $request |
|
| 288 | ); |
|
| 289 | ||
| 290 | self::assertHttpResponseCodeEquals($response, 200); |
|
| 291 | } |
|
| 292 | ||
| 293 | /** |
|
| 294 | * @depends testPublishContent |
|
| @@ 394-418 (lines=25) @@ | ||
| 391 | return $array['Content']; |
|
| 392 | } |
|
| 393 | ||
| 394 | public function testCreateView() |
|
| 395 | { |
|
| 396 | $body = <<< XML |
|
| 397 | <?xml version="1.0" encoding="UTF-8"?> |
|
| 398 | <ViewInput> |
|
| 399 | <identifier>testCreateView</identifier> |
|
| 400 | <Query> |
|
| 401 | <Criteria> |
|
| 402 | <ContentTypeIdentifierCriterion>folder</ContentTypeIdentifierCriterion> |
|
| 403 | </Criteria> |
|
| 404 | <limit>10</limit> |
|
| 405 | <offset>0</offset> |
|
| 406 | </Query> |
|
| 407 | </ViewInput> |
|
| 408 | XML; |
|
| 409 | $request = $this->createHttpRequest('POST', '/api/ezp/v2/content/views', 'ViewInput+xml', 'View+json'); |
|
| 410 | $request->setContent($body); |
|
| 411 | $response = $this->sendHttpRequest( |
|
| 412 | $request |
|
| 413 | ); |
|
| 414 | ||
| 415 | // Returns 301 since 6.0 (deprecated in favour of /views) |
|
| 416 | self::assertHttpResponseCodeEquals($response, 301); |
|
| 417 | self::assertHttpResponseHasHeader($response, 'Location'); |
|
| 418 | } |
|
| 419 | } |
|
| 420 | ||
| @@ 47-63 (lines=17) @@ | ||
| 44 | * |
|
| 45 | * @return string the updated content type href |
|
| 46 | */ |
|
| 47 | public function testUpdateContentTypeGroup($contentTypeGroupHref) |
|
| 48 | { |
|
| 49 | $body = <<< XML |
|
| 50 | <?xml version="1.0" encoding="UTF-8"?> |
|
| 51 | <ContentTypeGroupInput> |
|
| 52 | <identifier>testUpdateContentTypeGroup</identifier> |
|
| 53 | </ContentTypeGroupInput> |
|
| 54 | XML; |
|
| 55 | ||
| 56 | $request = $this->createHttpRequest('PATCH', $contentTypeGroupHref, 'ContentTypeGroupInput+xml', 'ContentTypeGroup+json'); |
|
| 57 | $request->setContent($body); |
|
| 58 | $response = $this->sendHttpRequest($request); |
|
| 59 | ||
| 60 | self::assertHttpResponseCodeEquals($response, 200); |
|
| 61 | ||
| 62 | return $contentTypeGroupHref; |
|
| 63 | } |
|
| 64 | ||
| 65 | /** |
|
| 66 | * @depends testCreateContentTypeGroup |
|
| @@ 338-356 (lines=19) @@ | ||
| 335 | * @depends testCreateContentTypeDraft |
|
| 336 | * @covers PATCH /content/types/<contentTypeId>/draft |
|
| 337 | */ |
|
| 338 | public function testUpdateContentTypeDraft($contentTypeDraftHref) |
|
| 339 | { |
|
| 340 | $content = <<< XML |
|
| 341 | <?xml version="1.0" encoding="UTF-8"?> |
|
| 342 | <ContentTypeUpdate> |
|
| 343 | <names> |
|
| 344 | <value languageCode="eng-GB">testUpdateContentTypeDraft</value> |
|
| 345 | </names> |
|
| 346 | </ContentTypeUpdate> |
|
| 347 | XML; |
|
| 348 | ||
| 349 | $request = $this->createHttpRequest('PATCH', $contentTypeDraftHref, 'ContentTypeUpdate+xml', 'ContentTypeInfo+json'); |
|
| 350 | $request->setContent($content); |
|
| 351 | $response = $this->sendHttpRequest( |
|
| 352 | $request |
|
| 353 | ); |
|
| 354 | ||
| 355 | self::assertHttpResponseCodeEquals($response, 200); |
|
| 356 | } |
|
| 357 | ||
| 358 | /** |
|
| 359 | * @covers POST /content/types/<contentTypeId>/draft/fielddefinitions |
|
| @@ 437-460 (lines=24) @@ | ||
| 434 | * |
|
| 435 | * @todo the spec says PUT... |
|
| 436 | */ |
|
| 437 | public function testUpdateContentTypeDraftFieldDefinition($fieldDefinitionHref) |
|
| 438 | { |
|
| 439 | $body = <<< XML |
|
| 440 | <?xml version="1.0" encoding="UTF-8"?> |
|
| 441 | <FieldDefinitionUpdate> |
|
| 442 | <identifier>updated_secondtext</identifier> |
|
| 443 | <names> |
|
| 444 | <value languageCode="eng-GB">Updated second text</value> |
|
| 445 | </names> |
|
| 446 | <defaultValue>Updated default value</defaultValue> |
|
| 447 | </FieldDefinitionUpdate> |
|
| 448 | XML; |
|
| 449 | ||
| 450 | $request = $this->createHttpRequest( |
|
| 451 | 'PATCH', |
|
| 452 | $fieldDefinitionHref, |
|
| 453 | 'FieldDefinitionUpdate+xml', |
|
| 454 | 'FieldDefinition+json' |
|
| 455 | ); |
|
| 456 | $request->setContent($body); |
|
| 457 | ||
| 458 | $response = $this->sendHttpRequest($request); |
|
| 459 | self::assertHttpResponseCodeEquals($response, 200); |
|
| 460 | } |
|
| 461 | ||
| 462 | /** |
|
| 463 | * @covers DELETE /content/types/<contentTypeId>/draft/fieldDefinitions/<fieldDefinitionId> |
|
| @@ 169-185 (lines=17) @@ | ||
| 166 | * @covers PATCH /content/locations/{locationPath} |
|
| 167 | * @depends testCreateLocation |
|
| 168 | */ |
|
| 169 | public function testUpdateLocation($locationHref) |
|
| 170 | { |
|
| 171 | $body = <<< XML |
|
| 172 | <LocationUpdate> |
|
| 173 | <priority>3</priority> |
|
| 174 | <sortField>PATH</sortField> |
|
| 175 | <sortOrder>ASC</sortOrder> |
|
| 176 | </LocationUpdate> |
|
| 177 | XML; |
|
| 178 | ||
| 179 | $request = $this->createHttpRequest('PATCH', $locationHref, 'LocationUpdate+xml', 'Location+json'); |
|
| 180 | $request->setContent($body); |
|
| 181 | ||
| 182 | $response = $this->sendHttpRequest($request); |
|
| 183 | ||
| 184 | self::assertHttpResponseCodeEquals($response, 200); |
|
| 185 | } |
|
| 186 | ||
| 187 | /** |
|
| 188 | * @depends testCreateLocation |
|
| @@ 194-215 (lines=22) @@ | ||
| 191 | * @covers PATCH /content/objectstategroups/{objectStateGroupId}/objectstates/{objectStateId} |
|
| 192 | * @depends testCreateObjectState |
|
| 193 | */ |
|
| 194 | public function testUpdateObjectState($objectStateHref) |
|
| 195 | { |
|
| 196 | $body = <<< XML |
|
| 197 | <?xml version="1.0" encoding="UTF-8"?> |
|
| 198 | <ObjectStateUpdate> |
|
| 199 | <identifier>testUpdateObjectState</identifier> |
|
| 200 | <defaultLanguageCode>eng-GB</defaultLanguageCode> |
|
| 201 | <names> |
|
| 202 | <value languageCode="eng-GB">testUpdateObjectState</value> |
|
| 203 | </names> |
|
| 204 | <descriptions> |
|
| 205 | <value languageCode="eng-GB">testUpdateObjectState description</value> |
|
| 206 | </descriptions> |
|
| 207 | </ObjectStateUpdate> |
|
| 208 | XML; |
|
| 209 | $request = $this->createHttpRequest('PATCH', $objectStateHref, 'ObjectStateUpdate+xml', 'ObjectState+json'); |
|
| 210 | $request->setContent($body); |
|
| 211 | ||
| 212 | $response = $this->sendHttpRequest($request); |
|
| 213 | ||
| 214 | self::assertHttpResponseCodeEquals($response, 200); |
|
| 215 | } |
|
| 216 | ||
| 217 | /** |
|
| 218 | * @covers PATCH /content/objectstategroups/{objectStateGroupId} |
|
| @@ 221-242 (lines=22) @@ | ||
| 218 | * @covers PATCH /content/objectstategroups/{objectStateGroupId} |
|
| 219 | * @depends testCreateObjectStateGroup |
|
| 220 | */ |
|
| 221 | public function testUpdateObjectStateGroup($objectStateGroupHref) |
|
| 222 | { |
|
| 223 | $body = <<< XML |
|
| 224 | <?xml version="1.0" encoding="UTF-8"?> |
|
| 225 | <ObjectStateGroupUpdate> |
|
| 226 | <identifier>testUpdateObjectStateGroup</identifier> |
|
| 227 | <defaultLanguageCode>eng-GB</defaultLanguageCode> |
|
| 228 | <names> |
|
| 229 | <value languageCode="eng-GB">testUpdateObjectStateGroup</value> |
|
| 230 | </names> |
|
| 231 | <descriptions> |
|
| 232 | <value languageCode="eng-GB">testUpdateObjectStateGroup description</value> |
|
| 233 | </descriptions> |
|
| 234 | </ObjectStateGroupUpdate> |
|
| 235 | XML; |
|
| 236 | $request = $this->createHttpRequest('PATCH', $objectStateGroupHref, 'ObjectStateGroupUpdate+xml', 'ObjectStateGroup+json'); |
|
| 237 | $request->setContent($body); |
|
| 238 | ||
| 239 | $response = $this->sendHttpRequest($request); |
|
| 240 | ||
| 241 | self::assertHttpResponseCodeEquals($response, 200); |
|
| 242 | } |
|
| 243 | ||
| 244 | /** |
|
| 245 | * @covers DELETE |
|
| @@ 60-73 (lines=14) @@ | ||
| 57 | * @depends testCreateSection |
|
| 58 | * @covers PATCH /content/sections/{sectionId} |
|
| 59 | */ |
|
| 60 | public function testUpdateSection($sectionHref) |
|
| 61 | { |
|
| 62 | $xml = <<< XML |
|
| 63 | <SectionInput> |
|
| 64 | <identifier>testUpdateSection</identifier> |
|
| 65 | <name>testUpdateSection</name> |
|
| 66 | </SectionInput> |
|
| 67 | XML; |
|
| 68 | $request = $this->createHttpRequest('PATCH', $sectionHref, 'SectionInput+xml', 'Section+json'); |
|
| 69 | $request->setContent($xml); |
|
| 70 | $response = $this->sendHttpRequest($request); |
|
| 71 | ||
| 72 | self::assertHttpResponseCodeEquals($response, 200); |
|
| 73 | } |
|
| 74 | ||
| 75 | /** |
|
| 76 | * @covers GET /content/sections/{sectionId} |
|
| @@ 92-118 (lines=27) @@ | ||
| 89 | * @covers PATCH /user/groups/{groupPath} |
|
| 90 | * @depends testCreateUserGroup |
|
| 91 | */ |
|
| 92 | public function testUpdateUserGroup($groupHref) |
|
| 93 | { |
|
| 94 | $text = $this->addTestSuffix(__FUNCTION__); |
|
| 95 | $xml = <<< XML |
|
| 96 | <?xml version="1.0" encoding="UTF-8"?> |
|
| 97 | <UserGroupUpdate> |
|
| 98 | <fields> |
|
| 99 | <field> |
|
| 100 | <fieldDefinitionIdentifier>description</fieldDefinitionIdentifier> |
|
| 101 | <languageCode>eng-GB</languageCode> |
|
| 102 | <fieldValue>{$text}</fieldValue> |
|
| 103 | </field> |
|
| 104 | </fields> |
|
| 105 | </UserGroupUpdate> |
|
| 106 | XML; |
|
| 107 | $request = $this->createHttpRequest( |
|
| 108 | 'PATCH', |
|
| 109 | $groupHref, |
|
| 110 | 'UserGroupUpdate+xml', |
|
| 111 | 'UserGroup+json' |
|
| 112 | ); |
|
| 113 | $request->setContent($xml); |
|
| 114 | ||
| 115 | $response = $this->sendHttpRequest($request); |
|
| 116 | ||
| 117 | self::assertHttpResponseCodeEquals($response, 200); |
|
| 118 | } |
|
| 119 | ||
| 120 | /** |
|
| 121 | * @depends testCreateUserGroup |
|
| @@ 187-213 (lines=27) @@ | ||
| 184 | * @depends testCreateUser |
|
| 185 | * @covers PATCH /user/users/{userId} |
|
| 186 | */ |
|
| 187 | public function testUpdateUser($userHref) |
|
| 188 | { |
|
| 189 | $text = $this->addTestSuffix(__FUNCTION__); |
|
| 190 | $xml = <<< XML |
|
| 191 | <?xml version="1.0" encoding="UTF-8"?> |
|
| 192 | <UserUpdate> |
|
| 193 | <fields> |
|
| 194 | <field> |
|
| 195 | <fieldDefinitionIdentifier>first_name</fieldDefinitionIdentifier> |
|
| 196 | <languageCode>eng-GB</languageCode> |
|
| 197 | <fieldValue>john john</fieldValue> |
|
| 198 | </field> |
|
| 199 | </fields> |
|
| 200 | </UserUpdate> |
|
| 201 | XML; |
|
| 202 | $request = $this->createHttpRequest( |
|
| 203 | 'PATCH', |
|
| 204 | $userHref, |
|
| 205 | 'UserUpdate+xml', |
|
| 206 | 'User+json' |
|
| 207 | ); |
|
| 208 | $request->setContent($xml); |
|
| 209 | ||
| 210 | $response = $this->sendHttpRequest($request); |
|
| 211 | ||
| 212 | self::assertHttpResponseCodeEquals($response, 200); |
|
| 213 | } |
|
| 214 | ||
| 215 | /** |
|
| 216 | * @covers GET /user/users |
|
| @@ 174-196 (lines=23) @@ | ||
| 171 | * @depends testCreateRole |
|
| 172 | * @covers PATCH /user/roles/{roleId} |
|
| 173 | */ |
|
| 174 | public function testUpdateRole($roleHref) |
|
| 175 | { |
|
| 176 | $xml = <<< XML |
|
| 177 | <?xml version="1.0" encoding="UTF-8"?> |
|
| 178 | <RoleInput> |
|
| 179 | <identifier>testUpdateRole</identifier> |
|
| 180 | <mainLanguageCode>eng-GB</mainLanguageCode> |
|
| 181 | <names> |
|
| 182 | <value languageCode="eng-GB">testUpdateRole</value> |
|
| 183 | </names> |
|
| 184 | <descriptions> |
|
| 185 | <value languageCode="eng-GB">testUpdateRole description</value> |
|
| 186 | </descriptions> |
|
| 187 | </RoleInput> |
|
| 188 | XML; |
|
| 189 | ||
| 190 | $request = $this->createHttpRequest('PATCH', $roleHref, 'RoleInput+xml', 'Role+json'); |
|
| 191 | $request->setContent($xml); |
|
| 192 | $response = $this->sendHttpRequest($request); |
|
| 193 | ||
| 194 | // @todo Fix failure Notice: Trying to get property of non-object in \/home\/bertrand\/www\/ezpublish-kernel\/eZ\/Publish\/Core\/Persistence\/Cache\/UserHandler.php line 174 |
|
| 195 | self::assertHttpResponseCodeEquals($response, 200); |
|
| 196 | } |
|
| 197 | ||
| 198 | /** |
|
| 199 | * @depends testCreateRoleDraft |
|
| @@ 202-223 (lines=22) @@ | ||
| 199 | * @depends testCreateRoleDraft |
|
| 200 | * @covers PATCH /user/roles/{roleId}/draft |
|
| 201 | */ |
|
| 202 | public function testUpdateRoleDraft($roleDraftHref) |
|
| 203 | { |
|
| 204 | $xml = <<< XML |
|
| 205 | <?xml version="1.0" encoding="UTF-8"?> |
|
| 206 | <RoleInput> |
|
| 207 | <identifier>testUpdateRoleDraft</identifier> |
|
| 208 | <mainLanguageCode>eng-GB</mainLanguageCode> |
|
| 209 | <names> |
|
| 210 | <value languageCode="eng-GB">testUpdateRoleDraft</value> |
|
| 211 | </names> |
|
| 212 | <descriptions> |
|
| 213 | <value languageCode="eng-GB">testUpdateRoleDraft description</value> |
|
| 214 | </descriptions> |
|
| 215 | </RoleInput> |
|
| 216 | XML; |
|
| 217 | ||
| 218 | $request = $this->createHttpRequest('PATCH', $roleDraftHref, 'RoleInput+xml', 'RoleDraft+json'); |
|
| 219 | $request->setContent($xml); |
|
| 220 | $response = $this->sendHttpRequest($request); |
|
| 221 | ||
| 222 | self::assertHttpResponseCodeEquals($response, 200); |
|
| 223 | } |
|
| 224 | ||
| 225 | /** |
|
| 226 | * @covers POST /user/roles/{roleId}/policies |
|
| @@ 331-351 (lines=21) @@ | ||
| 328 | * @covers PATCH /user/roles/{roleId}/policies/{policyId} |
|
| 329 | * @depends testAddPolicy |
|
| 330 | */ |
|
| 331 | public function testUpdatePolicy($policyHref) |
|
| 332 | { |
|
| 333 | $xml = <<< XML |
|
| 334 | <?xml version="1.0" encoding="UTF-8"?> |
|
| 335 | <PolicyUpdate> |
|
| 336 | <limitations> |
|
| 337 | <limitation identifier="Class"> |
|
| 338 | <values> |
|
| 339 | <ref href="1"/> |
|
| 340 | </values> |
|
| 341 | </limitation> |
|
| 342 | </limitations> |
|
| 343 | </PolicyUpdate> |
|
| 344 | XML; |
|
| 345 | ||
| 346 | $request = $this->createHttpRequest('PATCH', $policyHref, 'PolicyUpdate+xml', 'Policy+json'); |
|
| 347 | $request->setContent($xml); |
|
| 348 | $response = $this->sendHttpRequest($request); |
|
| 349 | ||
| 350 | self::assertHttpResponseCodeEquals($response, 200); |
|
| 351 | } |
|
| 352 | ||
| 353 | /** |
|
| 354 | * @covers PATCH /user/roles/{roleId}/policies/{policyId} |
|
| @@ 357-377 (lines=21) @@ | ||
| 354 | * @covers PATCH /user/roles/{roleId}/policies/{policyId} |
|
| 355 | * @depends testAddPolicyByRoleDraft |
|
| 356 | */ |
|
| 357 | public function testUpdatePolicyByRoleDraft($policyHref) |
|
| 358 | { |
|
| 359 | $xml = <<< XML |
|
| 360 | <?xml version="1.0" encoding="UTF-8"?> |
|
| 361 | <PolicyUpdate> |
|
| 362 | <limitations> |
|
| 363 | <limitation identifier="Class"> |
|
| 364 | <values> |
|
| 365 | <ref href="1"/> |
|
| 366 | </values> |
|
| 367 | </limitation> |
|
| 368 | </limitations> |
|
| 369 | </PolicyUpdate> |
|
| 370 | XML; |
|
| 371 | ||
| 372 | $request = $this->createHttpRequest('PATCH', $policyHref, 'PolicyUpdate+xml', 'Policy+json'); |
|
| 373 | $request->setContent($xml); |
|
| 374 | $response = $this->sendHttpRequest($request); |
|
| 375 | ||
| 376 | self::assertHttpResponseCodeEquals($response, 200); |
|
| 377 | } |
|
| 378 | ||
| 379 | /** |
|
| 380 | * @depends testCreateRole |
|