Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like ContentServiceTest often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use ContentServiceTest, and based on these observations, apply Extract Interface, too.
| 1 | <?php  | 
            ||
| 35 | class ContentServiceTest extends BaseContentServiceTest  | 
            ||
| 36 | { | 
            ||
| 37 | const ENG_GB = 'eng-GB';  | 
            ||
| 38 | const ENG_US = 'eng-US';  | 
            ||
| 39 | |||
| 40 | /**  | 
            ||
| 41 | * Test for the newContentCreateStruct() method.  | 
            ||
| 42 | *  | 
            ||
| 43 | * @see \eZ\Publish\API\Repository\ContentService::newContentCreateStruct()  | 
            ||
| 44 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeByIdentifier  | 
            ||
| 45 | * @group user  | 
            ||
| 46 | * @group field-type  | 
            ||
| 47 | */  | 
            ||
| 48 | public function testNewContentCreateStruct()  | 
            ||
| 49 |     { | 
            ||
| 50 | $repository = $this->getRepository();  | 
            ||
| 51 | |||
| 52 | /* BEGIN: Use Case */  | 
            ||
| 53 | // Create a content type  | 
            ||
| 54 | $contentTypeService = $repository->getContentTypeService();  | 
            ||
| 55 | |||
| 56 |         $contentType = $contentTypeService->loadContentTypeByIdentifier('forum'); | 
            ||
| 57 | |||
| 58 | $contentService = $repository->getContentService();  | 
            ||
| 59 | |||
| 60 | $contentCreate = $contentService->newContentCreateStruct($contentType, 'eng-US');  | 
            ||
| 61 | /* END: Use Case */  | 
            ||
| 62 | |||
| 63 |         $this->assertInstanceOf('\\eZ\\Publish\\API\\Repository\\Values\\Content\\ContentCreateStruct', $contentCreate); | 
            ||
| 64 | }  | 
            ||
| 65 | |||
| 66 | /**  | 
            ||
| 67 | * Test for the createContent() method.  | 
            ||
| 68 | *  | 
            ||
| 69 | * @return \eZ\Publish\API\Repository\Values\Content\Content  | 
            ||
| 70 | *  | 
            ||
| 71 | * @see \eZ\Publish\API\Repository\ContentService::createContent()  | 
            ||
| 72 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testNewContentCreateStruct  | 
            ||
| 73 | * @group user  | 
            ||
| 74 | * @group field-type  | 
            ||
| 75 | */  | 
            ||
| 76 | public function testCreateContent()  | 
            ||
| 77 |     { | 
            ||
| 78 |         if ($this->isVersion4()) { | 
            ||
| 79 |             $this->markTestSkipped('This test requires eZ Publish 5'); | 
            ||
| 80 | }  | 
            ||
| 81 | |||
| 82 | $repository = $this->getRepository();  | 
            ||
| 83 | |||
| 84 | /* BEGIN: Use Case */  | 
            ||
| 85 | $contentTypeService = $repository->getContentTypeService();  | 
            ||
| 86 | |||
| 87 |         $contentType = $contentTypeService->loadContentTypeByIdentifier('forum'); | 
            ||
| 88 | |||
| 89 | $contentService = $repository->getContentService();  | 
            ||
| 90 | |||
| 91 | $contentCreate = $contentService->newContentCreateStruct($contentType, 'eng-US');  | 
            ||
| 92 |         $contentCreate->setField('name', 'My awesome forum'); | 
            ||
| 93 | |||
| 94 | $contentCreate->remoteId = 'abcdef0123456789abcdef0123456789';  | 
            ||
| 95 | $contentCreate->alwaysAvailable = true;  | 
            ||
| 96 | |||
| 97 | $content = $contentService->createContent($contentCreate);  | 
            ||
| 98 | /* END: Use Case */  | 
            ||
| 99 | |||
| 100 |         $this->assertInstanceOf('\\eZ\\Publish\\API\\Repository\\Values\\Content\\Content', $content); | 
            ||
| 101 | |||
| 102 | return $content;  | 
            ||
| 103 | }  | 
            ||
| 104 | |||
| 105 | /**  | 
            ||
| 106 | * Test for the createContent() method.  | 
            ||
| 107 | *  | 
            ||
| 108 | * Tests made for issue #EZP-20955 where Anonymous user is granted access to create content  | 
            ||
| 109 | * and should have access to do that.  | 
            ||
| 110 | *  | 
            ||
| 111 | * @return \eZ\Publish\API\Repository\Values\Content\Content  | 
            ||
| 112 | *  | 
            ||
| 113 | * @see \eZ\Publish\API\Repository\ContentService::createContent()  | 
            ||
| 114 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testNewContentCreateStruct  | 
            ||
| 115 | * @group user  | 
            ||
| 116 | * @group field-type  | 
            ||
| 117 | */  | 
            ||
| 118 | public function testCreateContentAndPublishWithPrivilegedAnonymousUser()  | 
            ||
| 119 |     { | 
            ||
| 120 |         if ($this->isVersion4()) { | 
            ||
| 121 |             $this->markTestSkipped('This test requires eZ Publish 5'); | 
            ||
| 122 | }  | 
            ||
| 123 | |||
| 124 |         $anonymousUserId = $this->generateId('user', 10); | 
            ||
| 125 | |||
| 126 | $repository = $this->getRepository();  | 
            ||
| 127 | $contentService = $repository->getContentService();  | 
            ||
| 128 | $contentTypeService = $repository->getContentTypeService();  | 
            ||
| 129 | $locationService = $repository->getLocationService();  | 
            ||
| 130 | $roleService = $repository->getRoleService();  | 
            ||
| 131 | |||
| 132 | // Give Anonymous user role additional rights  | 
            ||
| 133 |         $role = $roleService->loadRoleByIdentifier('Anonymous'); | 
            ||
| 134 | $roleDraft = $roleService->createRoleDraft($role);  | 
            ||
| 135 |         $policyCreateStruct = $roleService->newPolicyCreateStruct('content', 'create'); | 
            ||
| 136 | $policyCreateStruct->addLimitation(new SectionLimitation(['limitationValues' => [1]]));  | 
            ||
| 137 | $policyCreateStruct->addLimitation(new LocationLimitation(['limitationValues' => [2]]));  | 
            ||
| 138 | $policyCreateStruct->addLimitation(new ContentTypeLimitation(['limitationValues' => [1]]));  | 
            ||
| 139 | $roleDraft = $roleService->addPolicyByRoleDraft($roleDraft, $policyCreateStruct);  | 
            ||
| 140 | |||
| 141 |         $policyCreateStruct = $roleService->newPolicyCreateStruct('content', 'publish'); | 
            ||
| 142 | $policyCreateStruct->addLimitation(new SectionLimitation(['limitationValues' => [1]]));  | 
            ||
| 143 | $policyCreateStruct->addLimitation(new LocationLimitation(['limitationValues' => [2]]));  | 
            ||
| 144 | $policyCreateStruct->addLimitation(new ContentTypeLimitation(['limitationValues' => [1]]));  | 
            ||
| 145 | $roleDraft = $roleService->addPolicyByRoleDraft($roleDraft, $policyCreateStruct);  | 
            ||
| 146 | $roleService->publishRoleDraft($roleDraft);  | 
            ||
| 147 | |||
| 148 | // Set Anonymous user as current  | 
            ||
| 149 | $repository->getPermissionResolver()->setCurrentUserReference($repository->getUserService()->loadUser($anonymousUserId));  | 
            ||
| 150 | |||
| 151 | // Create a new content object:  | 
            ||
| 152 | $contentCreate = $contentService->newContentCreateStruct(  | 
            ||
| 153 |             $contentTypeService->loadContentTypeByIdentifier('folder'), | 
            ||
| 154 | 'eng-GB'  | 
            ||
| 155 | );  | 
            ||
| 156 | |||
| 157 |         $contentCreate->setField('name', 'Folder 1'); | 
            ||
| 158 | |||
| 159 | $content = $contentService->createContent(  | 
            ||
| 160 | $contentCreate,  | 
            ||
| 161 | [$locationService->newLocationCreateStruct(2)]  | 
            ||
| 162 | );  | 
            ||
| 163 | |||
| 164 | $contentService->publishVersion(  | 
            ||
| 165 | $content->getVersionInfo()  | 
            ||
| 166 | );  | 
            ||
| 167 | }  | 
            ||
| 168 | |||
| 169 | /**  | 
            ||
| 170 | * Test for the createContent() method.  | 
            ||
| 171 | *  | 
            ||
| 172 | * @param \eZ\Publish\API\Repository\Values\Content\Content $content  | 
            ||
| 173 | *  | 
            ||
| 174 | * @return \eZ\Publish\API\Repository\Values\Content\Content  | 
            ||
| 175 | *  | 
            ||
| 176 | * @see \eZ\Publish\API\Repository\ContentService::createContent()  | 
            ||
| 177 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent  | 
            ||
| 178 | */  | 
            ||
| 179 | public function testCreateContentSetsContentInfo($content)  | 
            ||
| 180 |     { | 
            ||
| 181 |         $this->assertInstanceOf('\\eZ\\Publish\\API\\Repository\\Values\\Content\\ContentInfo', $content->contentInfo); | 
            ||
| 182 | |||
| 183 | return $content;  | 
            ||
| 184 | }  | 
            ||
| 185 | |||
| 186 | /**  | 
            ||
| 187 | * Test for the createContent() method.  | 
            ||
| 188 | *  | 
            ||
| 189 | * @param \eZ\Publish\API\Repository\Values\Content\Content $content  | 
            ||
| 190 | *  | 
            ||
| 191 | * @see \eZ\Publish\API\Repository\ContentService::createContent()  | 
            ||
| 192 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentSetsContentInfo  | 
            ||
| 193 | */  | 
            ||
| 194 | public function testCreateContentSetsExpectedContentInfo($content)  | 
            ||
| 195 |     { | 
            ||
| 196 | $this->assertEquals(  | 
            ||
| 197 | [  | 
            ||
| 198 | $content->id,  | 
            ||
| 199 | 28, // id of content type "forum"  | 
            ||
| 200 | true,  | 
            ||
| 201 | 1,  | 
            ||
| 202 | 'abcdef0123456789abcdef0123456789',  | 
            ||
| 203 | 'eng-US',  | 
            ||
| 204 | $this->getRepository()->getCurrentUser()->id,  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 205 | false,  | 
            ||
| 206 | null,  | 
            ||
| 207 | // Main Location id for unpublished Content should be null  | 
            ||
| 208 | null,  | 
            ||
| 209 | ],  | 
            ||
| 210 | [  | 
            ||
| 211 | $content->contentInfo->id,  | 
            ||
| 212 | $content->contentInfo->contentTypeId,  | 
            ||
| 213 | $content->contentInfo->alwaysAvailable,  | 
            ||
| 214 | $content->contentInfo->currentVersionNo,  | 
            ||
| 215 | $content->contentInfo->remoteId,  | 
            ||
| 216 | $content->contentInfo->mainLanguageCode,  | 
            ||
| 217 | $content->contentInfo->ownerId,  | 
            ||
| 218 | $content->contentInfo->published,  | 
            ||
| 219 | $content->contentInfo->publishedDate,  | 
            ||
| 220 | $content->contentInfo->mainLocationId,  | 
            ||
| 221 | ]  | 
            ||
| 222 | );  | 
            ||
| 223 | }  | 
            ||
| 224 | |||
| 225 | /**  | 
            ||
| 226 | * Test for the createContent() method.  | 
            ||
| 227 | *  | 
            ||
| 228 | * @param \eZ\Publish\API\Repository\Values\Content\Content $content  | 
            ||
| 229 | *  | 
            ||
| 230 | * @return \eZ\Publish\API\Repository\Values\Content\Content  | 
            ||
| 231 | *  | 
            ||
| 232 | * @see \eZ\Publish\API\Repository\ContentService::createContent()  | 
            ||
| 233 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent  | 
            ||
| 234 | */  | 
            ||
| 235 | public function testCreateContentSetsVersionInfo($content)  | 
            ||
| 236 |     { | 
            ||
| 237 |         $this->assertInstanceOf('\\eZ\\Publish\\API\\Repository\\Values\\Content\\VersionInfo', $content->getVersionInfo()); | 
            ||
| 238 | |||
| 239 | return $content;  | 
            ||
| 240 | }  | 
            ||
| 241 | |||
| 242 | /**  | 
            ||
| 243 | * Test for the createContent() method.  | 
            ||
| 244 | *  | 
            ||
| 245 | * @param \eZ\Publish\API\Repository\Values\Content\Content $content  | 
            ||
| 246 | *  | 
            ||
| 247 | * @see \eZ\Publish\API\Repository\ContentService::createContent()  | 
            ||
| 248 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentSetsVersionInfo  | 
            ||
| 249 | */  | 
            ||
| 250 | public function testCreateContentSetsExpectedVersionInfo($content)  | 
            ||
| 251 |     { | 
            ||
| 252 | $this->assertEquals(  | 
            ||
| 253 | [  | 
            ||
| 254 | 'status' => VersionInfo::STATUS_DRAFT,  | 
            ||
| 255 | 'versionNo' => 1,  | 
            ||
| 256 | 'creatorId' => $this->getRepository()->getCurrentUser()->id,  | 
            ||
| 257 | 'initialLanguageCode' => 'eng-US',  | 
            ||
| 258 | ],  | 
            ||
| 259 | [  | 
            ||
| 260 | 'status' => $content->getVersionInfo()->status,  | 
            ||
| 261 | 'versionNo' => $content->getVersionInfo()->versionNo,  | 
            ||
| 262 | 'creatorId' => $content->getVersionInfo()->creatorId,  | 
            ||
| 263 | 'initialLanguageCode' => $content->getVersionInfo()->initialLanguageCode,  | 
            ||
| 264 | ]  | 
            ||
| 265 | );  | 
            ||
| 266 | $this->assertTrue($content->getVersionInfo()->isDraft());  | 
            ||
| 267 | $this->assertFalse($content->getVersionInfo()->isPublished());  | 
            ||
| 268 | $this->assertFalse($content->getVersionInfo()->isArchived());  | 
            ||
| 269 | }  | 
            ||
| 270 | |||
| 271 | /**  | 
            ||
| 272 | * Test for the createContent() method.  | 
            ||
| 273 | *  | 
            ||
| 274 | * @see \eZ\Publish\API\Repository\ContentService::createContent()  | 
            ||
| 275 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException  | 
            ||
| 276 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent  | 
            ||
| 277 | */  | 
            ||
| 278 | public function testCreateContentThrowsInvalidArgumentException()  | 
            ||
| 279 |     { | 
            ||
| 280 |         if ($this->isVersion4()) { | 
            ||
| 281 |             $this->markTestSkipped('This test requires eZ Publish 5'); | 
            ||
| 282 | }  | 
            ||
| 283 | |||
| 284 | $repository = $this->getRepository();  | 
            ||
| 285 | |||
| 286 | /* BEGIN: Use Case */  | 
            ||
| 287 | $contentTypeService = $repository->getContentTypeService();  | 
            ||
| 288 | $contentService = $repository->getContentService();  | 
            ||
| 289 | |||
| 290 |         $contentType = $contentTypeService->loadContentTypeByIdentifier('forum'); | 
            ||
| 291 | |||
| 292 | $contentCreate1 = $contentService->newContentCreateStruct($contentType, 'eng-US');  | 
            ||
| 293 |         $contentCreate1->setField('name', 'An awesome Sidelfingen forum'); | 
            ||
| 294 | |||
| 295 | $contentCreate1->remoteId = 'abcdef0123456789abcdef0123456789';  | 
            ||
| 296 | $contentCreate1->alwaysAvailable = true;  | 
            ||
| 297 | |||
| 298 | $draft = $contentService->createContent($contentCreate1);  | 
            ||
| 299 | $contentService->publishVersion($draft->versionInfo);  | 
            ||
| 300 | |||
| 301 | $contentCreate2 = $contentService->newContentCreateStruct($contentType, 'eng-GB');  | 
            ||
| 302 |         $contentCreate2->setField('name', 'An awesome Bielefeld forum'); | 
            ||
| 303 | |||
| 304 | $contentCreate2->remoteId = 'abcdef0123456789abcdef0123456789';  | 
            ||
| 305 | $contentCreate2->alwaysAvailable = false;  | 
            ||
| 306 | |||
| 307 | // This call will fail with an "InvalidArgumentException", because the  | 
            ||
| 308 | // remoteId is already in use.  | 
            ||
| 309 | $contentService->createContent($contentCreate2);  | 
            ||
| 310 | /* END: Use Case */  | 
            ||
| 311 | }  | 
            ||
| 312 | |||
| 313 | /**  | 
            ||
| 314 | * Test for the createContent() method.  | 
            ||
| 315 | *  | 
            ||
| 316 | * @see \eZ\Publish\API\Repository\ContentService::createContent()  | 
            ||
| 317 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException  | 
            ||
| 318 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent  | 
            ||
| 319 | */  | 
            ||
| 320 | View Code Duplication | public function testCreateContentThrowsInvalidArgumentExceptionOnFieldTypeNotAccept()  | 
            |
| 321 |     { | 
            ||
| 322 | $repository = $this->getRepository();  | 
            ||
| 323 | |||
| 324 | /* BEGIN: Use Case */  | 
            ||
| 325 | $contentTypeService = $repository->getContentTypeService();  | 
            ||
| 326 | $contentService = $repository->getContentService();  | 
            ||
| 327 | |||
| 328 |         $contentType = $contentTypeService->loadContentTypeByIdentifier('forum'); | 
            ||
| 329 | |||
| 330 | $contentCreate = $contentService->newContentCreateStruct($contentType, 'eng-US');  | 
            ||
| 331 | // The name field does only accept strings and null as its values  | 
            ||
| 332 |         $contentCreate->setField('name', new \stdClass()); | 
            ||
| 333 | |||
| 334 | // Throws InvalidArgumentException since the name field is filled  | 
            ||
| 335 | // improperly  | 
            ||
| 336 | $draft = $contentService->createContent($contentCreate);  | 
            ||
| 337 | /* END: Use Case */  | 
            ||
| 338 | }  | 
            ||
| 339 | |||
| 340 | /**  | 
            ||
| 341 | * Test for the createContent() method.  | 
            ||
| 342 | *  | 
            ||
| 343 | * @see \eZ\Publish\API\Repository\ContentService::createContent()  | 
            ||
| 344 | * @expectedException \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException  | 
            ||
| 345 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent  | 
            ||
| 346 | */  | 
            ||
| 347 | public function testCreateContentThrowsContentFieldValidationException()  | 
            ||
| 348 |     { | 
            ||
| 349 | $repository = $this->getRepository();  | 
            ||
| 350 | |||
| 351 | /* BEGIN: Use Case */  | 
            ||
| 352 | $contentTypeService = $repository->getContentTypeService();  | 
            ||
| 353 | $contentService = $repository->getContentService();  | 
            ||
| 354 | |||
| 355 |         $contentType = $contentTypeService->loadContentTypeByIdentifier('folder'); | 
            ||
| 356 | |||
| 357 | $contentCreate1 = $contentService->newContentCreateStruct($contentType, 'eng-US');  | 
            ||
| 358 |         $contentCreate1->setField('name', 'An awesome Sidelfingen folder'); | 
            ||
| 359 | // Violates string length constraint  | 
            ||
| 360 |         $contentCreate1->setField('short_name', str_repeat('a', 200)); | 
            ||
| 361 | |||
| 362 | // Throws ContentFieldValidationException, since short_name does not pass  | 
            ||
| 363 | // validation of the string length validator  | 
            ||
| 364 | $draft = $contentService->createContent($contentCreate1);  | 
            ||
| 365 | /* END: Use Case */  | 
            ||
| 366 | }  | 
            ||
| 367 | |||
| 368 | /**  | 
            ||
| 369 | * Test for the createContent() method.  | 
            ||
| 370 | *  | 
            ||
| 371 | * @see \eZ\Publish\API\Repository\ContentService::createContent()  | 
            ||
| 372 | * @expectedException \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException  | 
            ||
| 373 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent  | 
            ||
| 374 | */  | 
            ||
| 375 | View Code Duplication | public function testCreateContentRequiredFieldMissing()  | 
            |
| 376 |     { | 
            ||
| 377 | $repository = $this->getRepository();  | 
            ||
| 378 | |||
| 379 | /* BEGIN: Use Case */  | 
            ||
| 380 | $contentTypeService = $repository->getContentTypeService();  | 
            ||
| 381 | $contentService = $repository->getContentService();  | 
            ||
| 382 | |||
| 383 |         $contentType = $contentTypeService->loadContentTypeByIdentifier('forum'); | 
            ||
| 384 | |||
| 385 | $contentCreate1 = $contentService->newContentCreateStruct($contentType, 'eng-US');  | 
            ||
| 386 | // Required field "name" is not set  | 
            ||
| 387 | |||
| 388 | // Throws a ContentFieldValidationException, since a required field is  | 
            ||
| 389 | // missing  | 
            ||
| 390 | $draft = $contentService->createContent($contentCreate1);  | 
            ||
| 391 | /* END: Use Case */  | 
            ||
| 392 | }  | 
            ||
| 393 | |||
| 394 | /**  | 
            ||
| 395 | * Test for the createContent() method.  | 
            ||
| 396 | *  | 
            ||
| 397 | * NOTE: We have bidirectional dependencies between the ContentService and  | 
            ||
| 398 | * the LocationService, so that we cannot use PHPUnit's test dependencies  | 
            ||
| 399 | * here.  | 
            ||
| 400 | *  | 
            ||
| 401 | * @see \eZ\Publish\API\Repository\ContentService::createContent($contentCreateStruct, $locationCreateStructs)  | 
            ||
| 402 | * @depend(s) eZ\Publish\API\Repository\Tests\LocationServiceTest::testCreateLocation  | 
            ||
| 403 | * @depend(s) eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocationByRemoteId  | 
            ||
| 404 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent  | 
            ||
| 405 | * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException  | 
            ||
| 406 | * @group user  | 
            ||
| 407 | */  | 
            ||
| 408 | public function testCreateContentWithLocationCreateParameterDoesNotCreateLocationImmediately()  | 
            ||
| 409 |     { | 
            ||
| 410 | $repository = $this->getRepository();  | 
            ||
| 411 | |||
| 412 | $locationService = $repository->getLocationService();  | 
            ||
| 413 | |||
| 414 | /* BEGIN: Use Case */  | 
            ||
| 415 | $draft = $this->createContentDraftVersion1();  | 
            ||
| 416 | |||
| 417 | // The location will not have been created, yet, so this throws an  | 
            ||
| 418 | // exception  | 
            ||
| 419 | $location = $locationService->loadLocationByRemoteId(  | 
            ||
| 420 | '0123456789abcdef0123456789abcdef'  | 
            ||
| 421 | );  | 
            ||
| 422 | /* END: Use Case */  | 
            ||
| 423 | }  | 
            ||
| 424 | |||
| 425 | /**  | 
            ||
| 426 | * Test for the createContent() method.  | 
            ||
| 427 | *  | 
            ||
| 428 | * @see \eZ\Publish\API\Repository\ContentService::createContent($contentCreateStruct, $locationCreateStructs)  | 
            ||
| 429 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException  | 
            ||
| 430 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentWithLocationCreateParameterDoesNotCreateLocationImmediately  | 
            ||
| 431 | */  | 
            ||
| 432 | public function testCreateContentThrowsInvalidArgumentExceptionWithLocationCreateParameter()  | 
            ||
| 433 |     { | 
            ||
| 434 | $repository = $this->getRepository();  | 
            ||
| 435 | |||
| 436 |         $parentLocationId = $this->generateId('location', 56); | 
            ||
| 437 | /* BEGIN: Use Case */  | 
            ||
| 438 | // $parentLocationId is a valid location ID  | 
            ||
| 439 | |||
| 440 | $contentService = $repository->getContentService();  | 
            ||
| 441 | $contentTypeService = $repository->getContentTypeService();  | 
            ||
| 442 | $locationService = $repository->getLocationService();  | 
            ||
| 443 | |||
| 444 | // Load content type  | 
            ||
| 445 |         $contentType = $contentTypeService->loadContentTypeByIdentifier('forum'); | 
            ||
| 446 | |||
| 447 | // Configure new locations  | 
            ||
| 448 | $locationCreate1 = $locationService->newLocationCreateStruct($parentLocationId);  | 
            ||
| 449 | |||
| 450 | $locationCreate1->priority = 23;  | 
            ||
| 451 | $locationCreate1->hidden = true;  | 
            ||
| 452 | $locationCreate1->remoteId = '0123456789abcdef0123456789aaaaaa';  | 
            ||
| 453 | $locationCreate1->sortField = Location::SORT_FIELD_NODE_ID;  | 
            ||
| 454 | $locationCreate1->sortOrder = Location::SORT_ORDER_DESC;  | 
            ||
| 455 | |||
| 456 | $locationCreate2 = $locationService->newLocationCreateStruct($parentLocationId);  | 
            ||
| 457 | |||
| 458 | $locationCreate2->priority = 42;  | 
            ||
| 459 | $locationCreate2->hidden = true;  | 
            ||
| 460 | $locationCreate2->remoteId = '0123456789abcdef0123456789bbbbbb';  | 
            ||
| 461 | $locationCreate2->sortField = Location::SORT_FIELD_NODE_ID;  | 
            ||
| 462 | $locationCreate2->sortOrder = Location::SORT_ORDER_DESC;  | 
            ||
| 463 | |||
| 464 | // Configure new content object  | 
            ||
| 465 | $contentCreate = $contentService->newContentCreateStruct($contentType, 'eng-US');  | 
            ||
| 466 | |||
| 467 |         $contentCreate->setField('name', 'A awesome Sindelfingen forum'); | 
            ||
| 468 | $contentCreate->remoteId = 'abcdef0123456789abcdef0123456789';  | 
            ||
| 469 | $contentCreate->alwaysAvailable = true;  | 
            ||
| 470 | |||
| 471 | // Create new content object under the specified location  | 
            ||
| 472 | $draft = $contentService->createContent(  | 
            ||
| 473 | $contentCreate,  | 
            ||
| 474 | [$locationCreate1]  | 
            ||
| 475 | );  | 
            ||
| 476 | $contentService->publishVersion($draft->versionInfo);  | 
            ||
| 477 | |||
| 478 | // This call will fail with an "InvalidArgumentException", because the  | 
            ||
| 479 | // Content remoteId already exists,  | 
            ||
| 480 | $contentService->createContent(  | 
            ||
| 481 | $contentCreate,  | 
            ||
| 482 | [$locationCreate2]  | 
            ||
| 483 | );  | 
            ||
| 484 | /* END: Use Case */  | 
            ||
| 485 | }  | 
            ||
| 486 | |||
| 487 | /**  | 
            ||
| 488 | * Test for the loadContentInfo() method.  | 
            ||
| 489 | *  | 
            ||
| 490 | * @see \eZ\Publish\API\Repository\ContentService::loadContentInfo()  | 
            ||
| 491 | * @group user  | 
            ||
| 492 | */  | 
            ||
| 493 | View Code Duplication | public function testLoadContentInfo()  | 
            |
| 494 |     { | 
            ||
| 495 | $repository = $this->getRepository();  | 
            ||
| 496 | |||
| 497 |         $mediaFolderId = $this->generateId('object', 41); | 
            ||
| 498 | /* BEGIN: Use Case */  | 
            ||
| 499 | $contentService = $repository->getContentService();  | 
            ||
| 500 | |||
| 501 | // Load the ContentInfo for "Media" folder  | 
            ||
| 502 | $contentInfo = $contentService->loadContentInfo($mediaFolderId);  | 
            ||
| 503 | /* END: Use Case */  | 
            ||
| 504 | |||
| 505 | $this->assertInstanceOf(  | 
            ||
| 506 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\ContentInfo',  | 
            ||
| 507 | $contentInfo  | 
            ||
| 508 | );  | 
            ||
| 509 | |||
| 510 | return $contentInfo;  | 
            ||
| 511 | }  | 
            ||
| 512 | |||
| 513 | /**  | 
            ||
| 514 | * Test for the returned value of the loadContentInfo() method.  | 
            ||
| 515 | *  | 
            ||
| 516 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo  | 
            ||
| 517 | * @covers \eZ\Publish\API\Repository\ContentService::loadContentInfo  | 
            ||
| 518 | *  | 
            ||
| 519 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo  | 
            ||
| 520 | */  | 
            ||
| 521 | public function testLoadContentInfoSetsExpectedContentInfo(ContentInfo $contentInfo)  | 
            ||
| 522 |     { | 
            ||
| 523 | $this->assertPropertiesCorrectUnsorted(  | 
            ||
| 524 | $this->getExpectedMediaContentInfoProperties(),  | 
            ||
| 525 | $contentInfo  | 
            ||
| 526 | );  | 
            ||
| 527 | }  | 
            ||
| 528 | |||
| 529 | /**  | 
            ||
| 530 | * Test for the loadContentInfo() method.  | 
            ||
| 531 | *  | 
            ||
| 532 | * @see \eZ\Publish\API\Repository\ContentService::loadContentInfo()  | 
            ||
| 533 | * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException  | 
            ||
| 534 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo  | 
            ||
| 535 | */  | 
            ||
| 536 | View Code Duplication | public function testLoadContentInfoThrowsNotFoundException()  | 
            |
| 537 |     { | 
            ||
| 538 | $repository = $this->getRepository();  | 
            ||
| 539 | |||
| 540 |         $nonExistentContentId = $this->generateId('object', self::DB_INT_MAX); | 
            ||
| 541 | /* BEGIN: Use Case */  | 
            ||
| 542 | $contentService = $repository->getContentService();  | 
            ||
| 543 | |||
| 544 | // This call will fail with a NotFoundException  | 
            ||
| 545 | $contentService->loadContentInfo($nonExistentContentId);  | 
            ||
| 546 | /* END: Use Case */  | 
            ||
| 547 | }  | 
            ||
| 548 | |||
| 549 | /**  | 
            ||
| 550 | * Test for the loadContentInfoByRemoteId() method.  | 
            ||
| 551 | *  | 
            ||
| 552 | * @see \eZ\Publish\API\Repository\ContentService::loadContentInfoByRemoteId()  | 
            ||
| 553 | */  | 
            ||
| 554 | public function testLoadContentInfoByRemoteId()  | 
            ||
| 555 |     { | 
            ||
| 556 | $repository = $this->getRepository();  | 
            ||
| 557 | |||
| 558 | /* BEGIN: Use Case */  | 
            ||
| 559 | $contentService = $repository->getContentService();  | 
            ||
| 560 | |||
| 561 | // Load the ContentInfo for "Media" folder  | 
            ||
| 562 |         $contentInfo = $contentService->loadContentInfoByRemoteId('faaeb9be3bd98ed09f606fc16d144eca'); | 
            ||
| 563 | /* END: Use Case */  | 
            ||
| 564 | |||
| 565 |         $this->assertInstanceOf('\\eZ\\Publish\\API\\Repository\\Values\\Content\\ContentInfo', $contentInfo); | 
            ||
| 566 | |||
| 567 | return $contentInfo;  | 
            ||
| 568 | }  | 
            ||
| 569 | |||
| 570 | /**  | 
            ||
| 571 | * Test for the returned value of the loadContentInfoByRemoteId() method.  | 
            ||
| 572 | *  | 
            ||
| 573 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfoByRemoteId  | 
            ||
| 574 | * @covers \eZ\Publish\API\Repository\ContentService::loadContentInfoByRemoteId  | 
            ||
| 575 | *  | 
            ||
| 576 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo  | 
            ||
| 577 | */  | 
            ||
| 578 | View Code Duplication | public function testLoadContentInfoByRemoteIdSetsExpectedContentInfo(ContentInfo $contentInfo)  | 
            |
| 579 |     { | 
            ||
| 580 | $this->assertPropertiesCorrectUnsorted(  | 
            ||
| 581 | [  | 
            ||
| 582 | 'id' => 10,  | 
            ||
| 583 | 'contentTypeId' => 4,  | 
            ||
| 584 | 'name' => 'Anonymous User',  | 
            ||
| 585 | 'sectionId' => 2,  | 
            ||
| 586 | 'currentVersionNo' => 2,  | 
            ||
| 587 | 'published' => true,  | 
            ||
| 588 | 'ownerId' => 14,  | 
            ||
| 589 | 'modificationDate' => $this->createDateTime(1072180405),  | 
            ||
| 590 | 'publishedDate' => $this->createDateTime(1033920665),  | 
            ||
| 591 | 'alwaysAvailable' => 1,  | 
            ||
| 592 | 'remoteId' => 'faaeb9be3bd98ed09f606fc16d144eca',  | 
            ||
| 593 | 'mainLanguageCode' => 'eng-US',  | 
            ||
| 594 | 'mainLocationId' => 45,  | 
            ||
| 595 | ],  | 
            ||
| 596 | $contentInfo  | 
            ||
| 597 | );  | 
            ||
| 598 | }  | 
            ||
| 599 | |||
| 600 | /**  | 
            ||
| 601 | * Test for the loadContentInfoByRemoteId() method.  | 
            ||
| 602 | *  | 
            ||
| 603 | * @see \eZ\Publish\API\Repository\ContentService::loadContentInfoByRemoteId()  | 
            ||
| 604 | * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException  | 
            ||
| 605 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfoByRemoteId  | 
            ||
| 606 | */  | 
            ||
| 607 | public function testLoadContentInfoByRemoteIdThrowsNotFoundException()  | 
            ||
| 608 |     { | 
            ||
| 609 | $repository = $this->getRepository();  | 
            ||
| 610 | |||
| 611 | /* BEGIN: Use Case */  | 
            ||
| 612 | $contentService = $repository->getContentService();  | 
            ||
| 613 | |||
| 614 | // This call will fail with a NotFoundException  | 
            ||
| 615 |         $contentService->loadContentInfoByRemoteId('abcdefghijklmnopqrstuvwxyz0123456789'); | 
            ||
| 616 | /* END: Use Case */  | 
            ||
| 617 | }  | 
            ||
| 618 | |||
| 619 | /**  | 
            ||
| 620 | * Test for the loadVersionInfo() method.  | 
            ||
| 621 | *  | 
            ||
| 622 | * @see \eZ\Publish\API\Repository\ContentService::loadVersionInfo()  | 
            ||
| 623 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo  | 
            ||
| 624 | * @group user  | 
            ||
| 625 | */  | 
            ||
| 626 | View Code Duplication | public function testLoadVersionInfo()  | 
            |
| 627 |     { | 
            ||
| 628 | $repository = $this->getRepository();  | 
            ||
| 629 | |||
| 630 |         $mediaFolderId = $this->generateId('object', 41); | 
            ||
| 631 | /* BEGIN: Use Case */  | 
            ||
| 632 | // $mediaFolderId contains the ID of the "Media" folder  | 
            ||
| 633 | |||
| 634 | $contentService = $repository->getContentService();  | 
            ||
| 635 | |||
| 636 | // Load the ContentInfo for "Media" folder  | 
            ||
| 637 | $contentInfo = $contentService->loadContentInfo($mediaFolderId);  | 
            ||
| 638 | |||
| 639 | // Now load the current version info of the "Media" folder  | 
            ||
| 640 | $versionInfo = $contentService->loadVersionInfo($contentInfo);  | 
            ||
| 641 | /* END: Use Case */  | 
            ||
| 642 | |||
| 643 | $this->assertInstanceOf(  | 
            ||
| 644 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\VersionInfo',  | 
            ||
| 645 | $versionInfo  | 
            ||
| 646 | );  | 
            ||
| 647 | }  | 
            ||
| 648 | |||
| 649 | /**  | 
            ||
| 650 | * Test for the loadVersionInfoById() method.  | 
            ||
| 651 | *  | 
            ||
| 652 | * @see \eZ\Publish\API\Repository\ContentService::loadVersionInfoById()  | 
            ||
| 653 | */  | 
            ||
| 654 | View Code Duplication | public function testLoadVersionInfoById()  | 
            |
| 655 |     { | 
            ||
| 656 | $repository = $this->getRepository();  | 
            ||
| 657 | |||
| 658 |         $mediaFolderId = $this->generateId('object', 41); | 
            ||
| 659 | /* BEGIN: Use Case */  | 
            ||
| 660 | // $mediaFolderId contains the ID of the "Media" folder  | 
            ||
| 661 | |||
| 662 | $contentService = $repository->getContentService();  | 
            ||
| 663 | |||
| 664 | // Load the VersionInfo for "Media" folder  | 
            ||
| 665 | $versionInfo = $contentService->loadVersionInfoById($mediaFolderId);  | 
            ||
| 666 | /* END: Use Case */  | 
            ||
| 667 | |||
| 668 | $this->assertInstanceOf(  | 
            ||
| 669 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\VersionInfo',  | 
            ||
| 670 | $versionInfo  | 
            ||
| 671 | );  | 
            ||
| 672 | |||
| 673 | return $versionInfo;  | 
            ||
| 674 | }  | 
            ||
| 675 | |||
| 676 | /**  | 
            ||
| 677 | * Test for the returned value of the loadVersionInfoById() method.  | 
            ||
| 678 | *  | 
            ||
| 679 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadVersionInfoById  | 
            ||
| 680 | * @covers \eZ\Publish\Core\Repository\ContentService::loadVersionInfoById  | 
            ||
| 681 | *  | 
            ||
| 682 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo  | 
            ||
| 683 | */  | 
            ||
| 684 | public function testLoadVersionInfoByIdSetsExpectedVersionInfo(VersionInfo $versionInfo)  | 
            ||
| 685 |     { | 
            ||
| 686 | $this->assertPropertiesCorrect(  | 
            ||
| 687 | [  | 
            ||
| 688 | 'names' => [  | 
            ||
| 689 | 'eng-US' => 'Media',  | 
            ||
| 690 | ],  | 
            ||
| 691 | 'contentInfo' => new ContentInfo($this->getExpectedMediaContentInfoProperties()),  | 
            ||
| 692 | 'id' => 472,  | 
            ||
| 693 | 'versionNo' => 1,  | 
            ||
| 694 | 'modificationDate' => $this->createDateTime(1060695457),  | 
            ||
| 695 | 'creatorId' => 14,  | 
            ||
| 696 | 'creationDate' => $this->createDateTime(1060695450),  | 
            ||
| 697 | 'status' => VersionInfo::STATUS_PUBLISHED,  | 
            ||
| 698 | 'initialLanguageCode' => 'eng-US',  | 
            ||
| 699 | 'languageCodes' => [  | 
            ||
| 700 | 'eng-US',  | 
            ||
| 701 | ],  | 
            ||
| 702 | ],  | 
            ||
| 703 | $versionInfo  | 
            ||
| 704 | );  | 
            ||
| 705 | $this->assertTrue($versionInfo->isPublished());  | 
            ||
| 706 | $this->assertFalse($versionInfo->isDraft());  | 
            ||
| 707 | $this->assertFalse($versionInfo->isArchived());  | 
            ||
| 708 | }  | 
            ||
| 709 | |||
| 710 | /**  | 
            ||
| 711 | * Test for the loadVersionInfoById() method.  | 
            ||
| 712 | *  | 
            ||
| 713 | * @see \eZ\Publish\API\Repository\ContentService::loadVersionInfoById()  | 
            ||
| 714 | * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException  | 
            ||
| 715 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadVersionInfoById  | 
            ||
| 716 | */  | 
            ||
| 717 | View Code Duplication | public function testLoadVersionInfoByIdThrowsNotFoundException()  | 
            |
| 718 |     { | 
            ||
| 719 | $repository = $this->getRepository();  | 
            ||
| 720 | |||
| 721 |         $nonExistentContentId = $this->generateId('object', self::DB_INT_MAX); | 
            ||
| 722 | /* BEGIN: Use Case */  | 
            ||
| 723 | $contentService = $repository->getContentService();  | 
            ||
| 724 | |||
| 725 | // This call will fail with a "NotFoundException"  | 
            ||
| 726 | $contentService->loadVersionInfoById($nonExistentContentId);  | 
            ||
| 727 | /* END: Use Case */  | 
            ||
| 728 | }  | 
            ||
| 729 | |||
| 730 | /**  | 
            ||
| 731 | * Test for the loadContentByContentInfo() method.  | 
            ||
| 732 | *  | 
            ||
| 733 | * @see \eZ\Publish\API\Repository\ContentService::loadContentByContentInfo()  | 
            ||
| 734 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo  | 
            ||
| 735 | */  | 
            ||
| 736 | View Code Duplication | public function testLoadContentByContentInfo()  | 
            |
| 737 |     { | 
            ||
| 738 | $repository = $this->getRepository();  | 
            ||
| 739 | |||
| 740 |         $mediaFolderId = $this->generateId('object', 41); | 
            ||
| 741 | /* BEGIN: Use Case */  | 
            ||
| 742 | // $mediaFolderId contains the ID of the "Media" folder  | 
            ||
| 743 | |||
| 744 | $contentService = $repository->getContentService();  | 
            ||
| 745 | |||
| 746 | // Load the ContentInfo for "Media" folder  | 
            ||
| 747 | $contentInfo = $contentService->loadContentInfo($mediaFolderId);  | 
            ||
| 748 | |||
| 749 | // Now load the current content version for the info instance  | 
            ||
| 750 | $content = $contentService->loadContentByContentInfo($contentInfo);  | 
            ||
| 751 | /* END: Use Case */  | 
            ||
| 752 | |||
| 753 | $this->assertInstanceOf(  | 
            ||
| 754 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\Content',  | 
            ||
| 755 | $content  | 
            ||
| 756 | );  | 
            ||
| 757 | }  | 
            ||
| 758 | |||
| 759 | /**  | 
            ||
| 760 | * Test for the loadContentByVersionInfo() method.  | 
            ||
| 761 | *  | 
            ||
| 762 | * @see \eZ\Publish\API\Repository\ContentService::loadContentByVersionInfo()  | 
            ||
| 763 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadVersionInfo  | 
            ||
| 764 | */  | 
            ||
| 765 | public function testLoadContentByVersionInfo()  | 
            ||
| 766 |     { | 
            ||
| 767 | $repository = $this->getRepository();  | 
            ||
| 768 | |||
| 769 |         $mediaFolderId = $this->generateId('object', 41); | 
            ||
| 770 | /* BEGIN: Use Case */  | 
            ||
| 771 | // $mediaFolderId contains the ID of the "Media" folder  | 
            ||
| 772 | |||
| 773 | $contentService = $repository->getContentService();  | 
            ||
| 774 | |||
| 775 | // Load the ContentInfo for "Media" folder  | 
            ||
| 776 | $contentInfo = $contentService->loadContentInfo($mediaFolderId);  | 
            ||
| 777 | |||
| 778 | // Load the current VersionInfo  | 
            ||
| 779 | $versionInfo = $contentService->loadVersionInfo($contentInfo);  | 
            ||
| 780 | |||
| 781 | // Now load the current content version for the info instance  | 
            ||
| 782 | $content = $contentService->loadContentByVersionInfo($versionInfo);  | 
            ||
| 783 | /* END: Use Case */  | 
            ||
| 784 | |||
| 785 | $this->assertInstanceOf(  | 
            ||
| 786 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\Content',  | 
            ||
| 787 | $content  | 
            ||
| 788 | );  | 
            ||
| 789 | }  | 
            ||
| 790 | |||
| 791 | /**  | 
            ||
| 792 | * Test for the loadContent() method.  | 
            ||
| 793 | *  | 
            ||
| 794 | * @see \eZ\Publish\API\Repository\ContentService::loadContent()  | 
            ||
| 795 | * @group user  | 
            ||
| 796 | * @group field-type  | 
            ||
| 797 | */  | 
            ||
| 798 | View Code Duplication | public function testLoadContent()  | 
            |
| 799 |     { | 
            ||
| 800 | $repository = $this->getRepository();  | 
            ||
| 801 | |||
| 802 |         $mediaFolderId = $this->generateId('object', 41); | 
            ||
| 803 | /* BEGIN: Use Case */  | 
            ||
| 804 | // $mediaFolderId contains the ID of the "Media" folder  | 
            ||
| 805 | |||
| 806 | $contentService = $repository->getContentService();  | 
            ||
| 807 | |||
| 808 | // Load the Content for "Media" folder, any language and current version  | 
            ||
| 809 | $content = $contentService->loadContent($mediaFolderId);  | 
            ||
| 810 | /* END: Use Case */  | 
            ||
| 811 | |||
| 812 | $this->assertInstanceOf(  | 
            ||
| 813 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\Content',  | 
            ||
| 814 | $content  | 
            ||
| 815 | );  | 
            ||
| 816 | }  | 
            ||
| 817 | |||
| 818 | /**  | 
            ||
| 819 | * Test for the loadContent() method.  | 
            ||
| 820 | *  | 
            ||
| 821 | * @see \eZ\Publish\API\Repository\ContentService::loadContent()  | 
            ||
| 822 | * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException  | 
            ||
| 823 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContent  | 
            ||
| 824 | */  | 
            ||
| 825 | View Code Duplication | public function testLoadContentThrowsNotFoundException()  | 
            |
| 826 |     { | 
            ||
| 827 | $repository = $this->getRepository();  | 
            ||
| 828 | |||
| 829 |         $nonExistentContentId = $this->generateId('object', self::DB_INT_MAX); | 
            ||
| 830 | /* BEGIN: Use Case */  | 
            ||
| 831 | $contentService = $repository->getContentService();  | 
            ||
| 832 | |||
| 833 | // This call will fail with a "NotFoundException"  | 
            ||
| 834 | $contentService->loadContent($nonExistentContentId);  | 
            ||
| 835 | /* END: Use Case */  | 
            ||
| 836 | }  | 
            ||
| 837 | |||
| 838 | /**  | 
            ||
| 839 | * Data provider for testLoadContentByRemoteId().  | 
            ||
| 840 | *  | 
            ||
| 841 | * @return array  | 
            ||
| 842 | */  | 
            ||
| 843 | public function contentRemoteIdVersionLanguageProvider()  | 
            ||
| 844 |     { | 
            ||
| 845 | return [  | 
            ||
| 846 | ['f5c88a2209584891056f987fd965b0ba', null, null],  | 
            ||
| 847 | ['f5c88a2209584891056f987fd965b0ba', ['eng-US'], null],  | 
            ||
| 848 | ['f5c88a2209584891056f987fd965b0ba', null, 1],  | 
            ||
| 849 | ['f5c88a2209584891056f987fd965b0ba', ['eng-US'], 1],  | 
            ||
| 850 | ['a6e35cbcb7cd6ae4b691f3eee30cd262', null, null],  | 
            ||
| 851 | ['a6e35cbcb7cd6ae4b691f3eee30cd262', ['eng-US'], null],  | 
            ||
| 852 | ['a6e35cbcb7cd6ae4b691f3eee30cd262', null, 1],  | 
            ||
| 853 | ['a6e35cbcb7cd6ae4b691f3eee30cd262', ['eng-US'], 1],  | 
            ||
| 854 | ];  | 
            ||
| 855 | }  | 
            ||
| 856 | |||
| 857 | /**  | 
            ||
| 858 | * Test for the loadContentByRemoteId() method.  | 
            ||
| 859 | *  | 
            ||
| 860 | * @covers \eZ\Publish\API\Repository\ContentService::loadContentByRemoteId  | 
            ||
| 861 | * @dataProvider contentRemoteIdVersionLanguageProvider  | 
            ||
| 862 | *  | 
            ||
| 863 | * @param string $remoteId  | 
            ||
| 864 | * @param array|null $languages  | 
            ||
| 865 | * @param int $versionNo  | 
            ||
| 866 | */  | 
            ||
| 867 | public function testLoadContentByRemoteId($remoteId, $languages, $versionNo)  | 
            ||
| 868 |     { | 
            ||
| 869 | $repository = $this->getRepository();  | 
            ||
| 870 | |||
| 871 | $contentService = $repository->getContentService();  | 
            ||
| 872 | |||
| 873 | $content = $contentService->loadContentByRemoteId($remoteId, $languages, $versionNo);  | 
            ||
| 874 | |||
| 875 | $this->assertInstanceOf(  | 
            ||
| 876 | Content::class,  | 
            ||
| 877 | $content  | 
            ||
| 878 | );  | 
            ||
| 879 | |||
| 880 | $this->assertEquals($remoteId, $content->contentInfo->remoteId);  | 
            ||
| 881 |         if ($languages !== null) { | 
            ||
| 882 | $this->assertEquals($languages, $content->getVersionInfo()->languageCodes);  | 
            ||
| 883 | }  | 
            ||
| 884 | $this->assertEquals($versionNo ?: 1, $content->getVersionInfo()->versionNo);  | 
            ||
| 885 | }  | 
            ||
| 886 | |||
| 887 | /**  | 
            ||
| 888 | * Test for the loadContentByRemoteId() method.  | 
            ||
| 889 | *  | 
            ||
| 890 | * @see \eZ\Publish\API\Repository\ContentService::loadContentByRemoteId()  | 
            ||
| 891 | * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException  | 
            ||
| 892 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByRemoteId  | 
            ||
| 893 | */  | 
            ||
| 894 | public function testLoadContentByRemoteIdThrowsNotFoundException()  | 
            ||
| 895 |     { | 
            ||
| 896 | $repository = $this->getRepository();  | 
            ||
| 897 | |||
| 898 | /* BEGIN: Use Case */  | 
            ||
| 899 | $contentService = $repository->getContentService();  | 
            ||
| 900 | |||
| 901 | // This call will fail with a "NotFoundException", because no content  | 
            ||
| 902 | // object exists for the given remoteId  | 
            ||
| 903 |         $contentService->loadContentByRemoteId('a1b1c1d1e1f1a2b2c2d2e2f2a3b3c3d3'); | 
            ||
| 904 | /* END: Use Case */  | 
            ||
| 905 | }  | 
            ||
| 906 | |||
| 907 | /**  | 
            ||
| 908 | * Test for the publishVersion() method.  | 
            ||
| 909 | *  | 
            ||
| 910 | * @return \eZ\Publish\API\Repository\Values\Content\Content  | 
            ||
| 911 | *  | 
            ||
| 912 | * @see \eZ\Publish\API\Repository\ContentService::publishVersion()  | 
            ||
| 913 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContent  | 
            ||
| 914 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo  | 
            ||
| 915 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadVersionInfo  | 
            ||
| 916 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentWithLocationCreateParameterDoesNotCreateLocationImmediately  | 
            ||
| 917 | * @group user  | 
            ||
| 918 | * @group field-type  | 
            ||
| 919 | */  | 
            ||
| 920 | public function testPublishVersion()  | 
            ||
| 921 |     { | 
            ||
| 922 | $time = time();  | 
            ||
| 923 | /* BEGIN: Use Case */  | 
            ||
| 924 | $content = $this->createContentVersion1();  | 
            ||
| 925 | /* END: Use Case */  | 
            ||
| 926 | |||
| 927 | $this->assertInstanceOf(Content::class, $content);  | 
            ||
| 928 | $this->assertTrue($content->contentInfo->published);  | 
            ||
| 929 | $this->assertEquals(VersionInfo::STATUS_PUBLISHED, $content->versionInfo->status);  | 
            ||
| 930 | $this->assertGreaterThanOrEqual($time, $content->contentInfo->publishedDate->getTimestamp());  | 
            ||
| 931 | $this->assertGreaterThanOrEqual($time, $content->contentInfo->modificationDate->getTimestamp());  | 
            ||
| 932 | $this->assertTrue($content->versionInfo->isPublished());  | 
            ||
| 933 | $this->assertFalse($content->versionInfo->isDraft());  | 
            ||
| 934 | $this->assertFalse($content->versionInfo->isArchived());  | 
            ||
| 935 | |||
| 936 | return $content;  | 
            ||
| 937 | }  | 
            ||
| 938 | |||
| 939 | /**  | 
            ||
| 940 | * Test for the publishVersion() method.  | 
            ||
| 941 | *  | 
            ||
| 942 | * @param \eZ\Publish\API\Repository\Values\Content\Content $content  | 
            ||
| 943 | *  | 
            ||
| 944 | * @see \eZ\Publish\API\Repository\ContentService::publishVersion()  | 
            ||
| 945 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion  | 
            ||
| 946 | */  | 
            ||
| 947 | public function testPublishVersionSetsExpectedContentInfo($content)  | 
            ||
| 948 |     { | 
            ||
| 949 | $this->assertEquals(  | 
            ||
| 950 | [  | 
            ||
| 951 | $content->id,  | 
            ||
| 952 | true,  | 
            ||
| 953 | 1,  | 
            ||
| 954 | 'abcdef0123456789abcdef0123456789',  | 
            ||
| 955 | 'eng-US',  | 
            ||
| 956 | $this->getRepository()->getCurrentUser()->id,  | 
            ||
| 957 | true,  | 
            ||
| 958 | ],  | 
            ||
| 959 | [  | 
            ||
| 960 | $content->contentInfo->id,  | 
            ||
| 961 | $content->contentInfo->alwaysAvailable,  | 
            ||
| 962 | $content->contentInfo->currentVersionNo,  | 
            ||
| 963 | $content->contentInfo->remoteId,  | 
            ||
| 964 | $content->contentInfo->mainLanguageCode,  | 
            ||
| 965 | $content->contentInfo->ownerId,  | 
            ||
| 966 | $content->contentInfo->published,  | 
            ||
| 967 | ]  | 
            ||
| 968 | );  | 
            ||
| 969 | |||
| 970 | $this->assertNotNull($content->contentInfo->mainLocationId);  | 
            ||
| 971 |         $date = new \DateTime('1984/01/01'); | 
            ||
| 972 | $this->assertGreaterThan(  | 
            ||
| 973 | $date->getTimestamp(),  | 
            ||
| 974 | $content->contentInfo->publishedDate->getTimestamp()  | 
            ||
| 975 | );  | 
            ||
| 976 | }  | 
            ||
| 977 | |||
| 978 | /**  | 
            ||
| 979 | * Test for the publishVersion() method.  | 
            ||
| 980 | *  | 
            ||
| 981 | * @param \eZ\Publish\API\Repository\Values\Content\Content $content  | 
            ||
| 982 | *  | 
            ||
| 983 | * @see \eZ\Publish\API\Repository\ContentService::publishVersion()  | 
            ||
| 984 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion  | 
            ||
| 985 | */  | 
            ||
| 986 | public function testPublishVersionSetsExpectedVersionInfo($content)  | 
            ||
| 987 |     { | 
            ||
| 988 | $this->assertEquals(  | 
            ||
| 989 | [  | 
            ||
| 990 | $this->getRepository()->getCurrentUser()->id,  | 
            ||
| 991 | 'eng-US',  | 
            ||
| 992 | VersionInfo::STATUS_PUBLISHED,  | 
            ||
| 993 | 1,  | 
            ||
| 994 | ],  | 
            ||
| 995 | [  | 
            ||
| 996 | $content->getVersionInfo()->creatorId,  | 
            ||
| 997 | $content->getVersionInfo()->initialLanguageCode,  | 
            ||
| 998 | $content->getVersionInfo()->status,  | 
            ||
| 999 | $content->getVersionInfo()->versionNo,  | 
            ||
| 1000 | ]  | 
            ||
| 1001 | );  | 
            ||
| 1002 | |||
| 1003 |         $date = new \DateTime('1984/01/01'); | 
            ||
| 1004 | $this->assertGreaterThan(  | 
            ||
| 1005 | $date->getTimestamp(),  | 
            ||
| 1006 | $content->getVersionInfo()->modificationDate->getTimestamp()  | 
            ||
| 1007 | );  | 
            ||
| 1008 | |||
| 1009 | $this->assertNotNull($content->getVersionInfo()->modificationDate);  | 
            ||
| 1010 | $this->assertTrue($content->getVersionInfo()->isPublished());  | 
            ||
| 1011 | $this->assertFalse($content->getVersionInfo()->isDraft());  | 
            ||
| 1012 | $this->assertFalse($content->getVersionInfo()->isArchived());  | 
            ||
| 1013 | }  | 
            ||
| 1014 | |||
| 1015 | /**  | 
            ||
| 1016 | * Test for the publishVersion() method.  | 
            ||
| 1017 | *  | 
            ||
| 1018 | * @return \eZ\Publish\API\Repository\Values\Content\Content  | 
            ||
| 1019 | *  | 
            ||
| 1020 | * @see \eZ\Publish\API\Repository\ContentService::publishVersion()  | 
            ||
| 1021 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentWithLocationCreateParameterDoesNotCreateLocationImmediately  | 
            ||
| 1022 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion  | 
            ||
| 1023 | */  | 
            ||
| 1024 | public function testPublishVersionCreatesLocationsDefinedOnCreate()  | 
            ||
| 1025 |     { | 
            ||
| 1026 | $repository = $this->getRepository();  | 
            ||
| 1027 | |||
| 1028 | /* BEGIN: Use Case */  | 
            ||
| 1029 | $content = $this->createContentVersion1();  | 
            ||
| 1030 | /* END: Use Case */  | 
            ||
| 1031 | |||
| 1032 | $locationService = $repository->getLocationService();  | 
            ||
| 1033 | $location = $locationService->loadLocationByRemoteId(  | 
            ||
| 1034 | '0123456789abcdef0123456789abcdef'  | 
            ||
| 1035 | );  | 
            ||
| 1036 | |||
| 1037 | $this->assertEquals(  | 
            ||
| 1038 | $location->getContentInfo(),  | 
            ||
| 1039 | $content->getVersionInfo()->getContentInfo()  | 
            ||
| 1040 | );  | 
            ||
| 1041 | |||
| 1042 | return [$content, $location];  | 
            ||
| 1043 | }  | 
            ||
| 1044 | |||
| 1045 | /**  | 
            ||
| 1046 | * Test for the publishVersion() method.  | 
            ||
| 1047 | *  | 
            ||
| 1048 | * @see \eZ\Publish\API\Repository\ContentService::publishVersion()  | 
            ||
| 1049 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionCreatesLocationsDefinedOnCreate  | 
            ||
| 1050 | */  | 
            ||
| 1051 | public function testCreateContentWithLocationCreateParameterCreatesExpectedLocation(array $testData)  | 
            ||
| 1052 |     { | 
            ||
| 1053 | /** @var \eZ\Publish\API\Repository\Values\Content\Content $content */  | 
            ||
| 1054 | /** @var \eZ\Publish\API\Repository\Values\Content\Location $location */  | 
            ||
| 1055 | list($content, $location) = $testData;  | 
            ||
| 1056 | |||
| 1057 |         $parentLocationId = $this->generateId('location', 56); | 
            ||
| 1058 | $parentLocation = $this->getRepository()->getLocationService()->loadLocation($parentLocationId);  | 
            ||
| 1059 | $mainLocationId = $content->getVersionInfo()->getContentInfo()->mainLocationId;  | 
            ||
| 1060 | |||
| 1061 | $this->assertPropertiesCorrect(  | 
            ||
| 1062 | [  | 
            ||
| 1063 | 'id' => $mainLocationId,  | 
            ||
| 1064 | 'priority' => 23,  | 
            ||
| 1065 | 'hidden' => true,  | 
            ||
| 1066 | 'invisible' => true,  | 
            ||
| 1067 | 'remoteId' => '0123456789abcdef0123456789abcdef',  | 
            ||
| 1068 | 'parentLocationId' => $parentLocationId,  | 
            ||
| 1069 | 'pathString' => $parentLocation->pathString . $mainLocationId . '/',  | 
            ||
| 1070 | 'depth' => $parentLocation->depth + 1,  | 
            ||
| 1071 | 'sortField' => Location::SORT_FIELD_NODE_ID,  | 
            ||
| 1072 | 'sortOrder' => Location::SORT_ORDER_DESC,  | 
            ||
| 1073 | ],  | 
            ||
| 1074 | $location  | 
            ||
| 1075 | );  | 
            ||
| 1076 | }  | 
            ||
| 1077 | |||
| 1078 | /**  | 
            ||
| 1079 | * Test for the publishVersion() method.  | 
            ||
| 1080 | *  | 
            ||
| 1081 | * @see \eZ\Publish\API\Repository\ContentService::publishVersion()  | 
            ||
| 1082 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException  | 
            ||
| 1083 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion  | 
            ||
| 1084 | */  | 
            ||
| 1085 | View Code Duplication | public function testPublishVersionThrowsBadStateException()  | 
            |
| 1086 |     { | 
            ||
| 1087 | $repository = $this->getRepository();  | 
            ||
| 1088 | |||
| 1089 | $contentService = $repository->getContentService();  | 
            ||
| 1090 | |||
| 1091 | /* BEGIN: Use Case */  | 
            ||
| 1092 | $draft = $this->createContentDraftVersion1();  | 
            ||
| 1093 | |||
| 1094 | // Publish the content draft  | 
            ||
| 1095 | $contentService->publishVersion($draft->getVersionInfo());  | 
            ||
| 1096 | |||
| 1097 | // This call will fail with a "BadStateException", because the version  | 
            ||
| 1098 | // is already published.  | 
            ||
| 1099 | $contentService->publishVersion($draft->getVersionInfo());  | 
            ||
| 1100 | /* END: Use Case */  | 
            ||
| 1101 | }  | 
            ||
| 1102 | |||
| 1103 | /**  | 
            ||
| 1104 | * Test that publishVersion() does not affect publishedDate (assuming previous version exists).  | 
            ||
| 1105 | *  | 
            ||
| 1106 | * @covers \eZ\Publish\API\Repository\ContentService::publishVersion  | 
            ||
| 1107 | */  | 
            ||
| 1108 | public function testPublishVersionDoesNotChangePublishedDate()  | 
            ||
| 1109 |     { | 
            ||
| 1110 | $repository = $this->getRepository();  | 
            ||
| 1111 | |||
| 1112 | $contentService = $repository->getContentService();  | 
            ||
| 1113 | |||
| 1114 | $publishedContent = $this->createContentVersion1();  | 
            ||
| 1115 | |||
| 1116 | // force timestamps to differ  | 
            ||
| 1117 | sleep(1);  | 
            ||
| 1118 | |||
| 1119 | $contentDraft = $contentService->createContentDraft($publishedContent->contentInfo);  | 
            ||
| 1120 | $contentUpdateStruct = $contentService->newContentUpdateStruct();  | 
            ||
| 1121 |         $contentUpdateStruct->setField('name', 'New name'); | 
            ||
| 1122 | $contentDraft = $contentService->updateContent($contentDraft->versionInfo, $contentUpdateStruct);  | 
            ||
| 1123 | $republishedContent = $contentService->publishVersion($contentDraft->versionInfo);  | 
            ||
| 1124 | |||
| 1125 | $this->assertEquals(  | 
            ||
| 1126 | $publishedContent->contentInfo->publishedDate->getTimestamp(),  | 
            ||
| 1127 | $republishedContent->contentInfo->publishedDate->getTimestamp()  | 
            ||
| 1128 | );  | 
            ||
| 1129 | $this->assertGreaterThan(  | 
            ||
| 1130 | $publishedContent->contentInfo->modificationDate->getTimestamp(),  | 
            ||
| 1131 | $republishedContent->contentInfo->modificationDate->getTimestamp()  | 
            ||
| 1132 | );  | 
            ||
| 1133 | }  | 
            ||
| 1134 | |||
| 1135 | /**  | 
            ||
| 1136 | * Test for the createContentDraft() method.  | 
            ||
| 1137 | *  | 
            ||
| 1138 | * @return \eZ\Publish\API\Repository\Values\Content\Content  | 
            ||
| 1139 | *  | 
            ||
| 1140 | * @see \eZ\Publish\API\Repository\ContentService::createContentDraft()  | 
            ||
| 1141 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion  | 
            ||
| 1142 | * @group user  | 
            ||
| 1143 | */  | 
            ||
| 1144 | public function testCreateContentDraft()  | 
            ||
| 1145 |     { | 
            ||
| 1146 | $repository = $this->getRepository();  | 
            ||
| 1147 | |||
| 1148 | $contentService = $repository->getContentService();  | 
            ||
| 1149 | |||
| 1150 | /* BEGIN: Use Case */  | 
            ||
| 1151 | $content = $this->createContentVersion1();  | 
            ||
| 1152 | |||
| 1153 | // Now we create a new draft from the published content  | 
            ||
| 1154 | $draftedContent = $contentService->createContentDraft($content->contentInfo);  | 
            ||
| 1155 | /* END: Use Case */  | 
            ||
| 1156 | |||
| 1157 | $this->assertInstanceOf(  | 
            ||
| 1158 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\Content',  | 
            ||
| 1159 | $draftedContent  | 
            ||
| 1160 | );  | 
            ||
| 1161 | |||
| 1162 | return $draftedContent;  | 
            ||
| 1163 | }  | 
            ||
| 1164 | |||
| 1165 | /**  | 
            ||
| 1166 | * Test for the createContentDraft() method.  | 
            ||
| 1167 | *  | 
            ||
| 1168 | * Test that editor has access to edit own draft.  | 
            ||
| 1169 | * Note: Editors have access to version_read, which is needed to load content drafts.  | 
            ||
| 1170 | *  | 
            ||
| 1171 | * @see \eZ\Publish\API\Repository\ContentService::createContentDraft()  | 
            ||
| 1172 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion  | 
            ||
| 1173 | * @group user  | 
            ||
| 1174 | */  | 
            ||
| 1175 | View Code Duplication | public function testCreateContentDraftAndLoadAccess()  | 
            |
| 1176 |     { | 
            ||
| 1177 | $repository = $this->getRepository();  | 
            ||
| 1178 | |||
| 1179 | /* BEGIN: Use Case */  | 
            ||
| 1180 | $user = $this->createUserVersion1();  | 
            ||
| 1181 | |||
| 1182 | // Set new editor as user  | 
            ||
| 1183 | $repository->setCurrentUser($user);  | 
            ||
| 1184 | |||
| 1185 | // Create draft  | 
            ||
| 1186 | $draft = $this->createContentDraftVersion1(2, 'folder');  | 
            ||
| 1187 | |||
| 1188 | // Try to load the draft  | 
            ||
| 1189 | $contentService = $repository->getContentService();  | 
            ||
| 1190 | $loadedDraft = $contentService->loadContent($draft->id);  | 
            ||
| 1191 | |||
| 1192 | /* END: Use Case */  | 
            ||
| 1193 | |||
| 1194 | $this->assertEquals($draft->id, $loadedDraft->id);  | 
            ||
| 1195 | }  | 
            ||
| 1196 | |||
| 1197 | /**  | 
            ||
| 1198 | * Test for the createContentDraft() method.  | 
            ||
| 1199 | *  | 
            ||
| 1200 | * @param \eZ\Publish\API\Repository\Values\Content\Content $draft  | 
            ||
| 1201 | *  | 
            ||
| 1202 | * @see \eZ\Publish\API\Repository\ContentService::createContentDraft()  | 
            ||
| 1203 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraft  | 
            ||
| 1204 | */  | 
            ||
| 1205 | public function testCreateContentDraftSetsExpectedProperties($draft)  | 
            ||
| 1206 |     { | 
            ||
| 1207 | $this->assertEquals(  | 
            ||
| 1208 | [  | 
            ||
| 1209 | 'fieldCount' => 2,  | 
            ||
| 1210 | 'relationCount' => 0,  | 
            ||
| 1211 | ],  | 
            ||
| 1212 | [  | 
            ||
| 1213 | 'fieldCount' => count($draft->getFields()),  | 
            ||
| 1214 | 'relationCount' => count($this->getRepository()->getContentService()->loadRelations($draft->getVersionInfo())),  | 
            ||
| 1215 | ]  | 
            ||
| 1216 | );  | 
            ||
| 1217 | }  | 
            ||
| 1218 | |||
| 1219 | /**  | 
            ||
| 1220 | * Test for the createContentDraft() method.  | 
            ||
| 1221 | *  | 
            ||
| 1222 | * @param \eZ\Publish\API\Repository\Values\Content\Content $draft  | 
            ||
| 1223 | *  | 
            ||
| 1224 | * @see \eZ\Publish\API\Repository\ContentService::createContentDraft()  | 
            ||
| 1225 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraft  | 
            ||
| 1226 | */  | 
            ||
| 1227 | public function testCreateContentDraftSetsContentInfo($draft)  | 
            ||
| 1228 |     { | 
            ||
| 1229 | $contentInfo = $draft->contentInfo;  | 
            ||
| 1230 | |||
| 1231 | $this->assertEquals(  | 
            ||
| 1232 | [  | 
            ||
| 1233 | $draft->id,  | 
            ||
| 1234 | true,  | 
            ||
| 1235 | 1,  | 
            ||
| 1236 | 'eng-US',  | 
            ||
| 1237 | $this->getRepository()->getCurrentUser()->id,  | 
            ||
| 1238 | 'abcdef0123456789abcdef0123456789',  | 
            ||
| 1239 | 1,  | 
            ||
| 1240 | ],  | 
            ||
| 1241 | [  | 
            ||
| 1242 | $contentInfo->id,  | 
            ||
| 1243 | $contentInfo->alwaysAvailable,  | 
            ||
| 1244 | $contentInfo->currentVersionNo,  | 
            ||
| 1245 | $contentInfo->mainLanguageCode,  | 
            ||
| 1246 | $contentInfo->ownerId,  | 
            ||
| 1247 | $contentInfo->remoteId,  | 
            ||
| 1248 | $contentInfo->sectionId,  | 
            ||
| 1249 | ]  | 
            ||
| 1250 | );  | 
            ||
| 1251 | }  | 
            ||
| 1252 | |||
| 1253 | /**  | 
            ||
| 1254 | * Test for the createContentDraft() method.  | 
            ||
| 1255 | *  | 
            ||
| 1256 | * @param \eZ\Publish\API\Repository\Values\Content\Content $draft  | 
            ||
| 1257 | *  | 
            ||
| 1258 | * @see \eZ\Publish\API\Repository\ContentService::createContentDraft()  | 
            ||
| 1259 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraft  | 
            ||
| 1260 | */  | 
            ||
| 1261 | public function testCreateContentDraftSetsVersionInfo($draft)  | 
            ||
| 1262 |     { | 
            ||
| 1263 | $versionInfo = $draft->getVersionInfo();  | 
            ||
| 1264 | |||
| 1265 | $this->assertEquals(  | 
            ||
| 1266 | [  | 
            ||
| 1267 | 'creatorId' => $this->getRepository()->getCurrentUser()->id,  | 
            ||
| 1268 | 'initialLanguageCode' => 'eng-US',  | 
            ||
| 1269 | 'languageCodes' => [0 => 'eng-US'],  | 
            ||
| 1270 | 'status' => VersionInfo::STATUS_DRAFT,  | 
            ||
| 1271 | 'versionNo' => 2,  | 
            ||
| 1272 | ],  | 
            ||
| 1273 | [  | 
            ||
| 1274 | 'creatorId' => $versionInfo->creatorId,  | 
            ||
| 1275 | 'initialLanguageCode' => $versionInfo->initialLanguageCode,  | 
            ||
| 1276 | 'languageCodes' => $versionInfo->languageCodes,  | 
            ||
| 1277 | 'status' => $versionInfo->status,  | 
            ||
| 1278 | 'versionNo' => $versionInfo->versionNo,  | 
            ||
| 1279 | ]  | 
            ||
| 1280 | );  | 
            ||
| 1281 | $this->assertTrue($versionInfo->isDraft());  | 
            ||
| 1282 | $this->assertFalse($versionInfo->isPublished());  | 
            ||
| 1283 | $this->assertFalse($versionInfo->isArchived());  | 
            ||
| 1284 | }  | 
            ||
| 1285 | |||
| 1286 | /**  | 
            ||
| 1287 | * Test for the createContentDraft() method.  | 
            ||
| 1288 | *  | 
            ||
| 1289 | * @param \eZ\Publish\API\Repository\Values\Content\Content $draft  | 
            ||
| 1290 | *  | 
            ||
| 1291 | * @see \eZ\Publish\API\Repository\ContentService::createContentDraft()  | 
            ||
| 1292 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraft  | 
            ||
| 1293 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadVersionInfo  | 
            ||
| 1294 | */  | 
            ||
| 1295 | View Code Duplication | public function testCreateContentDraftLoadVersionInfoStillLoadsPublishedVersion($draft)  | 
            |
| 1296 |     { | 
            ||
| 1297 | $repository = $this->getRepository();  | 
            ||
| 1298 | |||
| 1299 | $contentService = $repository->getContentService();  | 
            ||
| 1300 | |||
| 1301 | /* BEGIN: Use Case */  | 
            ||
| 1302 | $content = $this->createContentVersion1();  | 
            ||
| 1303 | |||
| 1304 | // Now we create a new draft from the published content  | 
            ||
| 1305 | $contentService->createContentDraft($content->contentInfo);  | 
            ||
| 1306 | |||
| 1307 | // This call will still load the published version  | 
            ||
| 1308 | $versionInfoPublished = $contentService->loadVersionInfo($content->contentInfo);  | 
            ||
| 1309 | /* END: Use Case */  | 
            ||
| 1310 | |||
| 1311 | $this->assertEquals(1, $versionInfoPublished->versionNo);  | 
            ||
| 1312 | }  | 
            ||
| 1313 | |||
| 1314 | /**  | 
            ||
| 1315 | * Test for the createContentDraft() method.  | 
            ||
| 1316 | *  | 
            ||
| 1317 | * @see \eZ\Publish\API\Repository\ContentService::createContentDraft()  | 
            ||
| 1318 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContent  | 
            ||
| 1319 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraft  | 
            ||
| 1320 | */  | 
            ||
| 1321 | View Code Duplication | public function testCreateContentDraftLoadContentStillLoadsPublishedVersion()  | 
            |
| 1322 |     { | 
            ||
| 1323 | $repository = $this->getRepository();  | 
            ||
| 1324 | |||
| 1325 | $contentService = $repository->getContentService();  | 
            ||
| 1326 | |||
| 1327 | /* BEGIN: Use Case */  | 
            ||
| 1328 | $content = $this->createContentVersion1();  | 
            ||
| 1329 | |||
| 1330 | // Now we create a new draft from the published content  | 
            ||
| 1331 | $contentService->createContentDraft($content->contentInfo);  | 
            ||
| 1332 | |||
| 1333 | // This call will still load the published content version  | 
            ||
| 1334 | $contentPublished = $contentService->loadContent($content->id);  | 
            ||
| 1335 | /* END: Use Case */  | 
            ||
| 1336 | |||
| 1337 | $this->assertEquals(1, $contentPublished->getVersionInfo()->versionNo);  | 
            ||
| 1338 | }  | 
            ||
| 1339 | |||
| 1340 | /**  | 
            ||
| 1341 | * Test for the createContentDraft() method.  | 
            ||
| 1342 | *  | 
            ||
| 1343 | * @see \eZ\Publish\API\Repository\ContentService::createContentDraft()  | 
            ||
| 1344 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByRemoteId  | 
            ||
| 1345 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraft  | 
            ||
| 1346 | */  | 
            ||
| 1347 | View Code Duplication | public function testCreateContentDraftLoadContentByRemoteIdStillLoadsPublishedVersion()  | 
            |
| 1348 |     { | 
            ||
| 1349 | $repository = $this->getRepository();  | 
            ||
| 1350 | |||
| 1351 | $contentService = $repository->getContentService();  | 
            ||
| 1352 | |||
| 1353 | /* BEGIN: Use Case */  | 
            ||
| 1354 | $content = $this->createContentVersion1();  | 
            ||
| 1355 | |||
| 1356 | // Now we create a new draft from the published content  | 
            ||
| 1357 | $contentService->createContentDraft($content->contentInfo);  | 
            ||
| 1358 | |||
| 1359 | // This call will still load the published content version  | 
            ||
| 1360 |         $contentPublished = $contentService->loadContentByRemoteId('abcdef0123456789abcdef0123456789'); | 
            ||
| 1361 | /* END: Use Case */  | 
            ||
| 1362 | |||
| 1363 | $this->assertEquals(1, $contentPublished->getVersionInfo()->versionNo);  | 
            ||
| 1364 | }  | 
            ||
| 1365 | |||
| 1366 | /**  | 
            ||
| 1367 | * Test for the createContentDraft() method.  | 
            ||
| 1368 | *  | 
            ||
| 1369 | * @see \eZ\Publish\API\Repository\ContentService::createContentDraft()  | 
            ||
| 1370 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByContentInfo  | 
            ||
| 1371 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraft  | 
            ||
| 1372 | */  | 
            ||
| 1373 | View Code Duplication | public function testCreateContentDraftLoadContentByContentInfoStillLoadsPublishedVersion()  | 
            |
| 1374 |     { | 
            ||
| 1375 | $repository = $this->getRepository();  | 
            ||
| 1376 | |||
| 1377 | $contentService = $repository->getContentService();  | 
            ||
| 1378 | |||
| 1379 | /* BEGIN: Use Case */  | 
            ||
| 1380 | $content = $this->createContentVersion1();  | 
            ||
| 1381 | |||
| 1382 | // Now we create a new draft from the published content  | 
            ||
| 1383 | $contentService->createContentDraft($content->contentInfo);  | 
            ||
| 1384 | |||
| 1385 | // This call will still load the published content version  | 
            ||
| 1386 | $contentPublished = $contentService->loadContentByContentInfo($content->contentInfo);  | 
            ||
| 1387 | /* END: Use Case */  | 
            ||
| 1388 | |||
| 1389 | $this->assertEquals(1, $contentPublished->getVersionInfo()->versionNo);  | 
            ||
| 1390 | }  | 
            ||
| 1391 | |||
| 1392 | /**  | 
            ||
| 1393 | * Test for the newContentUpdateStruct() method.  | 
            ||
| 1394 | *  | 
            ||
| 1395 | * @covers \eZ\Publish\API\Repository\ContentService::newContentUpdateStruct  | 
            ||
| 1396 | * @group user  | 
            ||
| 1397 | */  | 
            ||
| 1398 | public function testNewContentUpdateStruct()  | 
            ||
| 1399 |     { | 
            ||
| 1400 | $repository = $this->getRepository();  | 
            ||
| 1401 | |||
| 1402 | /* BEGIN: Use Case */  | 
            ||
| 1403 | $contentService = $repository->getContentService();  | 
            ||
| 1404 | |||
| 1405 | $updateStruct = $contentService->newContentUpdateStruct();  | 
            ||
| 1406 | /* END: Use Case */  | 
            ||
| 1407 | |||
| 1408 | $this->assertInstanceOf(  | 
            ||
| 1409 | ContentUpdateStruct::class,  | 
            ||
| 1410 | $updateStruct  | 
            ||
| 1411 | );  | 
            ||
| 1412 | |||
| 1413 | $this->assertPropertiesCorrect(  | 
            ||
| 1414 | [  | 
            ||
| 1415 | 'initialLanguageCode' => null,  | 
            ||
| 1416 | 'fields' => [],  | 
            ||
| 1417 | ],  | 
            ||
| 1418 | $updateStruct  | 
            ||
| 1419 | );  | 
            ||
| 1420 | }  | 
            ||
| 1421 | |||
| 1422 | /**  | 
            ||
| 1423 | * Test for the updateContent() method.  | 
            ||
| 1424 | *  | 
            ||
| 1425 | * @return \eZ\Publish\API\Repository\Values\Content\Content  | 
            ||
| 1426 | *  | 
            ||
| 1427 | * @see \eZ\Publish\API\Repository\ContentService::updateContent()  | 
            ||
| 1428 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testNewContentUpdateStruct  | 
            ||
| 1429 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraft  | 
            ||
| 1430 | * @group user  | 
            ||
| 1431 | * @group field-type  | 
            ||
| 1432 | */  | 
            ||
| 1433 | public function testUpdateContent()  | 
            ||
| 1434 |     { | 
            ||
| 1435 | /* BEGIN: Use Case */  | 
            ||
| 1436 | $draftVersion2 = $this->createUpdatedDraftVersion2();  | 
            ||
| 1437 | /* END: Use Case */  | 
            ||
| 1438 | |||
| 1439 | $this->assertInstanceOf(  | 
            ||
| 1440 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\Content',  | 
            ||
| 1441 | $draftVersion2  | 
            ||
| 1442 | );  | 
            ||
| 1443 | |||
| 1444 | $this->assertEquals(  | 
            ||
| 1445 |             $this->generateId('user', 10), | 
            ||
| 1446 | $draftVersion2->versionInfo->creatorId,  | 
            ||
| 1447 | 'creatorId is not properly set on new Version'  | 
            ||
| 1448 | );  | 
            ||
| 1449 | |||
| 1450 | return $draftVersion2;  | 
            ||
| 1451 | }  | 
            ||
| 1452 | |||
| 1453 | /**  | 
            ||
| 1454 | * Test for the updateContent_WithDifferentUser() method.  | 
            ||
| 1455 | *  | 
            ||
| 1456 | * @return \eZ\Publish\API\Repository\Values\Content\Content  | 
            ||
| 1457 | *  | 
            ||
| 1458 | * @see \eZ\Publish\API\Repository\ContentService::updateContent()  | 
            ||
| 1459 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testNewContentUpdateStruct  | 
            ||
| 1460 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraft  | 
            ||
| 1461 | * @group user  | 
            ||
| 1462 | * @group field-type  | 
            ||
| 1463 | */  | 
            ||
| 1464 | public function testUpdateContentWithDifferentUser()  | 
            ||
| 1465 |     { | 
            ||
| 1466 | /* BEGIN: Use Case */  | 
            ||
| 1467 | $arrayWithDraftVersion2 = $this->createUpdatedDraftVersion2NotAdmin();  | 
            ||
| 1468 | /* END: Use Case */  | 
            ||
| 1469 | |||
| 1470 | $this->assertInstanceOf(  | 
            ||
| 1471 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\Content',  | 
            ||
| 1472 | $arrayWithDraftVersion2[0]  | 
            ||
| 1473 | );  | 
            ||
| 1474 | |||
| 1475 | $this->assertEquals(  | 
            ||
| 1476 |             $this->generateId('user', $arrayWithDraftVersion2[1]), | 
            ||
| 1477 | $arrayWithDraftVersion2[0]->versionInfo->creatorId,  | 
            ||
| 1478 | 'creatorId is not properly set on new Version'  | 
            ||
| 1479 | );  | 
            ||
| 1480 | |||
| 1481 | return $arrayWithDraftVersion2[0];  | 
            ||
| 1482 | }  | 
            ||
| 1483 | |||
| 1484 | /**  | 
            ||
| 1485 | * Test for the updateContent() method.  | 
            ||
| 1486 | *  | 
            ||
| 1487 | * @param \eZ\Publish\API\Repository\Values\Content\Content $content  | 
            ||
| 1488 | *  | 
            ||
| 1489 | * @see \eZ\Publish\API\Repository\ContentService::updateContent()  | 
            ||
| 1490 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent  | 
            ||
| 1491 | */  | 
            ||
| 1492 | public function testUpdateContentSetsExpectedFields($content)  | 
            ||
| 1493 |     { | 
            ||
| 1494 | $actual = $this->normalizeFields($content->getFields());  | 
            ||
| 1495 | |||
| 1496 | $expected = [  | 
            ||
| 1497 | new Field(  | 
            ||
| 1498 | [  | 
            ||
| 1499 | 'id' => 0,  | 
            ||
| 1500 | 'value' => true,  | 
            ||
| 1501 | 'languageCode' => 'eng-GB',  | 
            ||
| 1502 | 'fieldDefIdentifier' => 'description',  | 
            ||
| 1503 | 'fieldTypeIdentifier' => 'ezrichtext',  | 
            ||
| 1504 | ]  | 
            ||
| 1505 | ),  | 
            ||
| 1506 | new Field(  | 
            ||
| 1507 | [  | 
            ||
| 1508 | 'id' => 0,  | 
            ||
| 1509 | 'value' => true,  | 
            ||
| 1510 | 'languageCode' => 'eng-US',  | 
            ||
| 1511 | 'fieldDefIdentifier' => 'description',  | 
            ||
| 1512 | 'fieldTypeIdentifier' => 'ezrichtext',  | 
            ||
| 1513 | ]  | 
            ||
| 1514 | ),  | 
            ||
| 1515 | new Field(  | 
            ||
| 1516 | [  | 
            ||
| 1517 | 'id' => 0,  | 
            ||
| 1518 | 'value' => true,  | 
            ||
| 1519 | 'languageCode' => 'eng-GB',  | 
            ||
| 1520 | 'fieldDefIdentifier' => 'name',  | 
            ||
| 1521 | 'fieldTypeIdentifier' => 'ezstring',  | 
            ||
| 1522 | ]  | 
            ||
| 1523 | ),  | 
            ||
| 1524 | new Field(  | 
            ||
| 1525 | [  | 
            ||
| 1526 | 'id' => 0,  | 
            ||
| 1527 | 'value' => true,  | 
            ||
| 1528 | 'languageCode' => 'eng-US',  | 
            ||
| 1529 | 'fieldDefIdentifier' => 'name',  | 
            ||
| 1530 | 'fieldTypeIdentifier' => 'ezstring',  | 
            ||
| 1531 | ]  | 
            ||
| 1532 | ),  | 
            ||
| 1533 | ];  | 
            ||
| 1534 | |||
| 1535 | $this->assertEquals($expected, $actual);  | 
            ||
| 1536 | }  | 
            ||
| 1537 | |||
| 1538 | /**  | 
            ||
| 1539 | * Test for the updateContent() method.  | 
            ||
| 1540 | *  | 
            ||
| 1541 | * @see \eZ\Publish\API\Repository\ContentService::updateContent()  | 
            ||
| 1542 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException  | 
            ||
| 1543 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent  | 
            ||
| 1544 | */  | 
            ||
| 1545 | View Code Duplication | public function testUpdateContentThrowsBadStateException()  | 
            |
| 1546 |     { | 
            ||
| 1547 | $repository = $this->getRepository();  | 
            ||
| 1548 | |||
| 1549 | $contentService = $repository->getContentService();  | 
            ||
| 1550 | |||
| 1551 | /* BEGIN: Use Case */  | 
            ||
| 1552 | $content = $this->createContentVersion1();  | 
            ||
| 1553 | |||
| 1554 | // Now create an update struct and modify some fields  | 
            ||
| 1555 | $contentUpdateStruct = $contentService->newContentUpdateStruct();  | 
            ||
| 1556 |         $contentUpdateStruct->setField('title', 'An awesome² story about ezp.'); | 
            ||
| 1557 |         $contentUpdateStruct->setField('title', 'An awesome²³ story about ezp.', 'eng-GB'); | 
            ||
| 1558 | |||
| 1559 | $contentUpdateStruct->initialLanguageCode = 'eng-US';  | 
            ||
| 1560 | |||
| 1561 | // This call will fail with a "BadStateException", because $publishedContent  | 
            ||
| 1562 | // is not a draft.  | 
            ||
| 1563 | $contentService->updateContent(  | 
            ||
| 1564 | $content->getVersionInfo(),  | 
            ||
| 1565 | $contentUpdateStruct  | 
            ||
| 1566 | );  | 
            ||
| 1567 | /* END: Use Case */  | 
            ||
| 1568 | }  | 
            ||
| 1569 | |||
| 1570 | /**  | 
            ||
| 1571 | * Test for the updateContent() method.  | 
            ||
| 1572 | *  | 
            ||
| 1573 | * @see \eZ\Publish\API\Repository\ContentService::updateContent()  | 
            ||
| 1574 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException  | 
            ||
| 1575 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent  | 
            ||
| 1576 | */  | 
            ||
| 1577 | View Code Duplication | public function testUpdateContentThrowsInvalidArgumentExceptionWhenFieldTypeDoesNotAccept()  | 
            |
| 1578 |     { | 
            ||
| 1579 | $repository = $this->getRepository();  | 
            ||
| 1580 | |||
| 1581 | $contentService = $repository->getContentService();  | 
            ||
| 1582 | |||
| 1583 | /* BEGIN: Use Case */  | 
            ||
| 1584 | $draft = $this->createContentDraftVersion1();  | 
            ||
| 1585 | |||
| 1586 | // Now create an update struct and modify some fields  | 
            ||
| 1587 | $contentUpdateStruct = $contentService->newContentUpdateStruct();  | 
            ||
| 1588 | // The name field does not accept a stdClass object as its input  | 
            ||
| 1589 |         $contentUpdateStruct->setField('name', new \stdClass(), 'eng-US'); | 
            ||
| 1590 | |||
| 1591 | // Throws an InvalidArgumentException, since the value for field "name"  | 
            ||
| 1592 | // is not accepted  | 
            ||
| 1593 | $contentService->updateContent(  | 
            ||
| 1594 | $draft->getVersionInfo(),  | 
            ||
| 1595 | $contentUpdateStruct  | 
            ||
| 1596 | );  | 
            ||
| 1597 | /* END: Use Case */  | 
            ||
| 1598 | }  | 
            ||
| 1599 | |||
| 1600 | /**  | 
            ||
| 1601 | * Test for the updateContent() method.  | 
            ||
| 1602 | *  | 
            ||
| 1603 | * @see \eZ\Publish\API\Repository\ContentService::updateContent()  | 
            ||
| 1604 | * @expectedException \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException  | 
            ||
| 1605 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent  | 
            ||
| 1606 | */  | 
            ||
| 1607 | View Code Duplication | public function testUpdateContentWhenMandatoryFieldIsEmpty()  | 
            |
| 1608 |     { | 
            ||
| 1609 | $repository = $this->getRepository();  | 
            ||
| 1610 | |||
| 1611 | $contentService = $repository->getContentService();  | 
            ||
| 1612 | |||
| 1613 | /* BEGIN: Use Case */  | 
            ||
| 1614 | $draft = $this->createContentDraftVersion1();  | 
            ||
| 1615 | |||
| 1616 | // Now create an update struct and set a mandatory field to null  | 
            ||
| 1617 | $contentUpdateStruct = $contentService->newContentUpdateStruct();  | 
            ||
| 1618 |         $contentUpdateStruct->setField('name', null); | 
            ||
| 1619 | |||
| 1620 | // Don't set this, then the above call without languageCode will fail  | 
            ||
| 1621 | $contentUpdateStruct->initialLanguageCode = 'eng-US';  | 
            ||
| 1622 | |||
| 1623 | // This call will fail with a "ContentFieldValidationException", because the  | 
            ||
| 1624 | // mandatory "name" field is empty.  | 
            ||
| 1625 | $contentService->updateContent(  | 
            ||
| 1626 | $draft->getVersionInfo(),  | 
            ||
| 1627 | $contentUpdateStruct  | 
            ||
| 1628 | );  | 
            ||
| 1629 | /* END: Use Case */  | 
            ||
| 1630 | }  | 
            ||
| 1631 | |||
| 1632 | /**  | 
            ||
| 1633 | * Test for the updateContent() method.  | 
            ||
| 1634 | *  | 
            ||
| 1635 | * @see \eZ\Publish\API\Repository\ContentService::updateContent()  | 
            ||
| 1636 | * @expectedException \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException  | 
            ||
| 1637 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent  | 
            ||
| 1638 | */  | 
            ||
| 1639 | View Code Duplication | public function testUpdateContentThrowsContentFieldValidationException()  | 
            |
| 1640 |     { | 
            ||
| 1641 | $repository = $this->getRepository();  | 
            ||
| 1642 | |||
| 1643 | /* BEGIN: Use Case */  | 
            ||
| 1644 | $contentTypeService = $repository->getContentTypeService();  | 
            ||
| 1645 | $contentService = $repository->getContentService();  | 
            ||
| 1646 | |||
| 1647 |         $contentType = $contentTypeService->loadContentTypeByIdentifier('folder'); | 
            ||
| 1648 | |||
| 1649 | $contentCreate = $contentService->newContentCreateStruct($contentType, 'eng-US');  | 
            ||
| 1650 |         $contentCreate->setField('name', 'An awesome Sidelfingen folder'); | 
            ||
| 1651 | |||
| 1652 | $draft = $contentService->createContent($contentCreate);  | 
            ||
| 1653 | |||
| 1654 | $contentUpdate = $contentService->newContentUpdateStruct();  | 
            ||
| 1655 | // Violates string length constraint  | 
            ||
| 1656 |         $contentUpdate->setField('short_name', str_repeat('a', 200), 'eng-US'); | 
            ||
| 1657 | |||
| 1658 | // Throws ContentFieldValidationException because the string length  | 
            ||
| 1659 | // validation of the field "short_name" fails  | 
            ||
| 1660 | $contentService->updateContent($draft->getVersionInfo(), $contentUpdate);  | 
            ||
| 1661 | /* END: Use Case */  | 
            ||
| 1662 | }  | 
            ||
| 1663 | |||
| 1664 | /**  | 
            ||
| 1665 | * Test for the updateContent() method.  | 
            ||
| 1666 | *  | 
            ||
| 1667 | * @covers \eZ\Publish\API\Repository\ContentService::updateContent()  | 
            ||
| 1668 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent  | 
            ||
| 1669 | */  | 
            ||
| 1670 | public function testUpdateContentValidatorIgnoresRequiredFieldsOfNotUpdatedLanguages()  | 
            ||
| 1671 |     { | 
            ||
| 1672 | $repository = $this->getRepository();  | 
            ||
| 1673 | /* BEGIN: Use Case */  | 
            ||
| 1674 | $contentTypeService = $repository->getContentTypeService();  | 
            ||
| 1675 |         $contentType = $contentTypeService->loadContentTypeByIdentifier('folder'); | 
            ||
| 1676 | |||
| 1677 | // Create multilangual content  | 
            ||
| 1678 | $contentService = $repository->getContentService();  | 
            ||
| 1679 | $contentCreate = $contentService->newContentCreateStruct($contentType, 'eng-US');  | 
            ||
| 1680 |         $contentCreate->setField('name', 'An awesome Sidelfingen folder', 'eng-US'); | 
            ||
| 1681 |         $contentCreate->setField('name', 'An awesome Sidelfingen folder', 'eng-GB'); | 
            ||
| 1682 | |||
| 1683 | $contentDraft = $contentService->createContent($contentCreate);  | 
            ||
| 1684 | |||
| 1685 | // 2. Update content type definition  | 
            ||
| 1686 | $contentTypeDraft = $contentTypeService->createContentTypeDraft($contentType);  | 
            ||
| 1687 | |||
| 1688 |         $fieldDefinition = $contentType->getFieldDefinition('description'); | 
            ||
| 1689 | $fieldDefinitionUpdate = $contentTypeService->newFieldDefinitionUpdateStruct();  | 
            ||
| 1690 | $fieldDefinitionUpdate->identifier = 'description';  | 
            ||
| 1691 | $fieldDefinitionUpdate->isRequired = true;  | 
            ||
| 1692 | |||
| 1693 | $contentTypeService->updateFieldDefinition(  | 
            ||
| 1694 | $contentTypeDraft,  | 
            ||
| 1695 | $fieldDefinition,  | 
            ||
| 1696 | $fieldDefinitionUpdate  | 
            ||
| 1697 | );  | 
            ||
| 1698 | $contentTypeService->publishContentTypeDraft($contentTypeDraft);  | 
            ||
| 1699 | |||
| 1700 | // 3. Update only eng-US translation  | 
            ||
| 1701 | $description = new DOMDocument();  | 
            ||
| 1702 | $description->loadXML(<<<XML  | 
            ||
| 1703 | <?xml version="1.0" encoding="UTF-8"?>  | 
            ||
| 1704 | <section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ezxhtml="http://ez.no/xmlns/ezpublish/docbook/xhtml" xmlns:ezcustom="http://ez.no/xmlns/ezpublish/docbook/custom" version="5.0-variant ezpublish-1.0">  | 
            ||
| 1705 | <para>Lorem ipsum dolor</para>  | 
            ||
| 1706 | </section>  | 
            ||
| 1707 | XML  | 
            ||
| 1708 | );  | 
            ||
| 1709 | |||
| 1710 | $contentUpdate = $contentService->newContentUpdateStruct();  | 
            ||
| 1711 |         $contentUpdate->setField('name', 'An awesome Sidelfingen folder (updated)', 'eng-US'); | 
            ||
| 1712 |         $contentUpdate->setField('description', $description); | 
            ||
| 1713 | |||
| 1714 | $contentService->updateContent($contentDraft->getVersionInfo(), $contentUpdate);  | 
            ||
| 1715 | /* END: Use Case */  | 
            ||
| 1716 | }  | 
            ||
| 1717 | |||
| 1718 | /**  | 
            ||
| 1719 | * Test for the updateContent() method.  | 
            ||
| 1720 | *  | 
            ||
| 1721 | * @see \eZ\Publish\API\Repository\ContentService::updateContent()  | 
            ||
| 1722 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent  | 
            ||
| 1723 | */  | 
            ||
| 1724 | public function testUpdateContentWithNotUpdatingMandatoryField()  | 
            ||
| 1725 |     { | 
            ||
| 1726 | $repository = $this->getRepository();  | 
            ||
| 1727 | |||
| 1728 | $contentService = $repository->getContentService();  | 
            ||
| 1729 | |||
| 1730 | /* BEGIN: Use Case */  | 
            ||
| 1731 | $draft = $this->createContentDraftVersion1();  | 
            ||
| 1732 | |||
| 1733 | // Now create an update struct which does not overwrite mandatory  | 
            ||
| 1734 | // fields  | 
            ||
| 1735 | $contentUpdateStruct = $contentService->newContentUpdateStruct();  | 
            ||
| 1736 | $contentUpdateStruct->setField(  | 
            ||
| 1737 | 'description',  | 
            ||
| 1738 | '<?xml version="1.0" encoding="UTF-8"?><section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0-variant ezpublish-1.0"/>'  | 
            ||
| 1739 | );  | 
            ||
| 1740 | |||
| 1741 | // Don't set this, then the above call without languageCode will fail  | 
            ||
| 1742 | $contentUpdateStruct->initialLanguageCode = 'eng-US';  | 
            ||
| 1743 | |||
| 1744 | // This will only update the "description" field in the "eng-US"  | 
            ||
| 1745 | // language  | 
            ||
| 1746 | $updatedDraft = $contentService->updateContent(  | 
            ||
| 1747 | $draft->getVersionInfo(),  | 
            ||
| 1748 | $contentUpdateStruct  | 
            ||
| 1749 | );  | 
            ||
| 1750 | /* END: Use Case */  | 
            ||
| 1751 | |||
| 1752 |         foreach ($updatedDraft->getFields() as $field) { | 
            ||
| 1753 |             if ($field->languageCode === 'eng-US' && $field->fieldDefIdentifier === 'name' && $field->value !== null) { | 
            ||
| 1754 | // Found field  | 
            ||
| 1755 | return;  | 
            ||
| 1756 | }  | 
            ||
| 1757 | }  | 
            ||
| 1758 | $this->fail(  | 
            ||
| 1759 | 'Field with identifier "name" in language "eng-US" could not be found or has empty value.'  | 
            ||
| 1760 | );  | 
            ||
| 1761 | }  | 
            ||
| 1762 | |||
| 1763 | /**  | 
            ||
| 1764 | * Test for the createContentDraft() method.  | 
            ||
| 1765 | *  | 
            ||
| 1766 | * @see \eZ\Publish\API\Repository\ContentService::createContentDraft($contentInfo, $versionInfo)  | 
            ||
| 1767 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent  | 
            ||
| 1768 | */  | 
            ||
| 1769 | View Code Duplication | public function testCreateContentDraftWithSecondParameter()  | 
            |
| 1770 |     { | 
            ||
| 1771 | $repository = $this->getRepository();  | 
            ||
| 1772 | |||
| 1773 | $contentService = $repository->getContentService();  | 
            ||
| 1774 | |||
| 1775 | /* BEGIN: Use Case */  | 
            ||
| 1776 | $contentVersion2 = $this->createContentVersion2();  | 
            ||
| 1777 | |||
| 1778 | // Now we create a new draft from the initial version  | 
            ||
| 1779 | $draftedContentReloaded = $contentService->createContentDraft(  | 
            ||
| 1780 | $contentVersion2->contentInfo,  | 
            ||
| 1781 | $contentVersion2->getVersionInfo()  | 
            ||
| 1782 | );  | 
            ||
| 1783 | /* END: Use Case */  | 
            ||
| 1784 | |||
| 1785 | $this->assertEquals(3, $draftedContentReloaded->getVersionInfo()->versionNo);  | 
            ||
| 1786 | }  | 
            ||
| 1787 | |||
| 1788 | /**  | 
            ||
| 1789 | * Test for the createContentDraft() method with third parameter.  | 
            ||
| 1790 | *  | 
            ||
| 1791 | * @covers \eZ\Publish\Core\Repository\ContentService::createContentDraft  | 
            ||
| 1792 | */  | 
            ||
| 1793 | View Code Duplication | public function testCreateContentDraftWithThirdParameter()  | 
            |
| 1794 |     { | 
            ||
| 1795 | $repository = $this->getRepository();  | 
            ||
| 1796 | |||
| 1797 | $contentService = $repository->getContentService();  | 
            ||
| 1798 | |||
| 1799 | $content = $contentService->loadContent(4);  | 
            ||
| 1800 | $user = $this->createUserVersion1();  | 
            ||
| 1801 | |||
| 1802 | $draftContent = $contentService->createContentDraft(  | 
            ||
| 1803 | $content->contentInfo,  | 
            ||
| 1804 | $content->getVersionInfo(),  | 
            ||
| 1805 | $user  | 
            ||
| 1806 | );  | 
            ||
| 1807 | |||
| 1808 | $this->assertInstanceOf(  | 
            ||
| 1809 | Content::class,  | 
            ||
| 1810 | $draftContent  | 
            ||
| 1811 | );  | 
            ||
| 1812 | }  | 
            ||
| 1813 | |||
| 1814 | /**  | 
            ||
| 1815 | * Test for the publishVersion() method.  | 
            ||
| 1816 | *  | 
            ||
| 1817 | * @see \eZ\Publish\API\Repository\ContentService::publishVersion()  | 
            ||
| 1818 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion  | 
            ||
| 1819 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent  | 
            ||
| 1820 | */  | 
            ||
| 1821 | View Code Duplication | public function testPublishVersionFromContentDraft()  | 
            |
| 1822 |     { | 
            ||
| 1823 | $repository = $this->getRepository();  | 
            ||
| 1824 | |||
| 1825 | $contentService = $repository->getContentService();  | 
            ||
| 1826 | |||
| 1827 | /* BEGIN: Use Case */  | 
            ||
| 1828 | $contentVersion2 = $this->createContentVersion2();  | 
            ||
| 1829 | /* END: Use Case */  | 
            ||
| 1830 | |||
| 1831 | $versionInfo = $contentService->loadVersionInfo($contentVersion2->contentInfo);  | 
            ||
| 1832 | |||
| 1833 | $this->assertEquals(  | 
            ||
| 1834 | [  | 
            ||
| 1835 | 'status' => VersionInfo::STATUS_PUBLISHED,  | 
            ||
| 1836 | 'versionNo' => 2,  | 
            ||
| 1837 | ],  | 
            ||
| 1838 | [  | 
            ||
| 1839 | 'status' => $versionInfo->status,  | 
            ||
| 1840 | 'versionNo' => $versionInfo->versionNo,  | 
            ||
| 1841 | ]  | 
            ||
| 1842 | );  | 
            ||
| 1843 | $this->assertTrue($versionInfo->isPublished());  | 
            ||
| 1844 | $this->assertFalse($versionInfo->isDraft());  | 
            ||
| 1845 | $this->assertFalse($versionInfo->isArchived());  | 
            ||
| 1846 | }  | 
            ||
| 1847 | |||
| 1848 | /**  | 
            ||
| 1849 | * Test for the publishVersion() method.  | 
            ||
| 1850 | *  | 
            ||
| 1851 | * @see \eZ\Publish\API\Repository\ContentService::publishVersion()  | 
            ||
| 1852 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft  | 
            ||
| 1853 | */  | 
            ||
| 1854 | View Code Duplication | public function testPublishVersionFromContentDraftArchivesOldVersion()  | 
            |
| 1855 |     { | 
            ||
| 1856 | $repository = $this->getRepository();  | 
            ||
| 1857 | |||
| 1858 | $contentService = $repository->getContentService();  | 
            ||
| 1859 | |||
| 1860 | /* BEGIN: Use Case */  | 
            ||
| 1861 | $contentVersion2 = $this->createContentVersion2();  | 
            ||
| 1862 | /* END: Use Case */  | 
            ||
| 1863 | |||
| 1864 | $versionInfo = $contentService->loadVersionInfo($contentVersion2->contentInfo, 1);  | 
            ||
| 1865 | |||
| 1866 | $this->assertEquals(  | 
            ||
| 1867 | [  | 
            ||
| 1868 | 'status' => VersionInfo::STATUS_ARCHIVED,  | 
            ||
| 1869 | 'versionNo' => 1,  | 
            ||
| 1870 | ],  | 
            ||
| 1871 | [  | 
            ||
| 1872 | 'status' => $versionInfo->status,  | 
            ||
| 1873 | 'versionNo' => $versionInfo->versionNo,  | 
            ||
| 1874 | ]  | 
            ||
| 1875 | );  | 
            ||
| 1876 | $this->assertTrue($versionInfo->isArchived());  | 
            ||
| 1877 | $this->assertFalse($versionInfo->isDraft());  | 
            ||
| 1878 | $this->assertFalse($versionInfo->isPublished());  | 
            ||
| 1879 | }  | 
            ||
| 1880 | |||
| 1881 | /**  | 
            ||
| 1882 | * Test for the publishVersion() method.  | 
            ||
| 1883 | *  | 
            ||
| 1884 | * @see \eZ\Publish\API\Repository\ContentService::publishVersion()  | 
            ||
| 1885 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft  | 
            ||
| 1886 | */  | 
            ||
| 1887 | public function testPublishVersionFromContentDraftUpdatesContentInfoCurrentVersion()  | 
            ||
| 1888 |     { | 
            ||
| 1889 | /* BEGIN: Use Case */  | 
            ||
| 1890 | $contentVersion2 = $this->createContentVersion2();  | 
            ||
| 1891 | /* END: Use Case */  | 
            ||
| 1892 | |||
| 1893 | $this->assertEquals(2, $contentVersion2->contentInfo->currentVersionNo);  | 
            ||
| 1894 | }  | 
            ||
| 1895 | |||
| 1896 | /**  | 
            ||
| 1897 | * Test for the publishVersion() method.  | 
            ||
| 1898 | *  | 
            ||
| 1899 | * @see \eZ\Publish\API\Repository\ContentService::publishVersion()  | 
            ||
| 1900 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft  | 
            ||
| 1901 | */  | 
            ||
| 1902 | View Code Duplication | public function testPublishVersionFromOldContentDraftArchivesNewerVersionNo()  | 
            |
| 1903 |     { | 
            ||
| 1904 | $repository = $this->getRepository();  | 
            ||
| 1905 | |||
| 1906 | $contentService = $repository->getContentService();  | 
            ||
| 1907 | |||
| 1908 | /* BEGIN: Use Case */  | 
            ||
| 1909 | $content = $this->createContentVersion1();  | 
            ||
| 1910 | |||
| 1911 | // Create a new draft with versionNo = 2  | 
            ||
| 1912 | $draftedContentVersion2 = $contentService->createContentDraft($content->contentInfo);  | 
            ||
| 1913 | |||
| 1914 | // Create another new draft with versionNo = 3  | 
            ||
| 1915 | $draftedContentVersion3 = $contentService->createContentDraft($content->contentInfo);  | 
            ||
| 1916 | |||
| 1917 | // Publish draft with versionNo = 3  | 
            ||
| 1918 | $contentService->publishVersion($draftedContentVersion3->getVersionInfo());  | 
            ||
| 1919 | |||
| 1920 | // Publish the first draft with versionNo = 2  | 
            ||
| 1921 | // currentVersionNo is now 2, versionNo 3 will be archived  | 
            ||
| 1922 | $publishedDraft = $contentService->publishVersion($draftedContentVersion2->getVersionInfo());  | 
            ||
| 1923 | /* END: Use Case */  | 
            ||
| 1924 | |||
| 1925 | $this->assertEquals(2, $publishedDraft->contentInfo->currentVersionNo);  | 
            ||
| 1926 | }  | 
            ||
| 1927 | |||
| 1928 | /**  | 
            ||
| 1929 | * Test for the publishVersion() method, and that it creates limited archives.  | 
            ||
| 1930 | *  | 
            ||
| 1931 | * @todo Adapt this when per content type archive limited is added on repository Content Type model.  | 
            ||
| 1932 | * @see \eZ\Publish\API\Repository\ContentService::publishVersion()  | 
            ||
| 1933 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft  | 
            ||
| 1934 | */  | 
            ||
| 1935 | public function testPublishVersionNotCreatingUnlimitedArchives()  | 
            ||
| 1936 |     { | 
            ||
| 1937 | $repository = $this->getRepository();  | 
            ||
| 1938 | |||
| 1939 | $contentService = $repository->getContentService();  | 
            ||
| 1940 | |||
| 1941 | $content = $this->createContentVersion1();  | 
            ||
| 1942 | |||
| 1943 | // Create a new draft with versionNo = 2  | 
            ||
| 1944 | $draftedContentVersion = $contentService->createContentDraft($content->contentInfo);  | 
            ||
| 1945 | $contentService->publishVersion($draftedContentVersion->getVersionInfo());  | 
            ||
| 1946 | |||
| 1947 | // Create a new draft with versionNo = 3  | 
            ||
| 1948 | $draftedContentVersion = $contentService->createContentDraft($content->contentInfo);  | 
            ||
| 1949 | $contentService->publishVersion($draftedContentVersion->getVersionInfo());  | 
            ||
| 1950 | |||
| 1951 | // Create a new draft with versionNo = 4  | 
            ||
| 1952 | $draftedContentVersion = $contentService->createContentDraft($content->contentInfo);  | 
            ||
| 1953 | $contentService->publishVersion($draftedContentVersion->getVersionInfo());  | 
            ||
| 1954 | |||
| 1955 | // Create a new draft with versionNo = 5  | 
            ||
| 1956 | $draftedContentVersion = $contentService->createContentDraft($content->contentInfo);  | 
            ||
| 1957 | $contentService->publishVersion($draftedContentVersion->getVersionInfo());  | 
            ||
| 1958 | |||
| 1959 | // Create a new draft with versionNo = 6  | 
            ||
| 1960 | $draftedContentVersion = $contentService->createContentDraft($content->contentInfo);  | 
            ||
| 1961 | $contentService->publishVersion($draftedContentVersion->getVersionInfo());  | 
            ||
| 1962 | |||
| 1963 | // Create a new draft with versionNo = 7  | 
            ||
| 1964 | $draftedContentVersion = $contentService->createContentDraft($content->contentInfo);  | 
            ||
| 1965 | $contentService->publishVersion($draftedContentVersion->getVersionInfo());  | 
            ||
| 1966 | |||
| 1967 | $versionInfoList = $contentService->loadVersions($content->contentInfo);  | 
            ||
| 1968 | |||
| 1969 | $this->assertEquals(6, count($versionInfoList));  | 
            ||
| 1970 | $this->assertEquals(2, $versionInfoList[0]->versionNo);  | 
            ||
| 1971 | $this->assertEquals(7, $versionInfoList[5]->versionNo);  | 
            ||
| 1972 | |||
| 1973 | $this->assertEquals(  | 
            ||
| 1974 | [  | 
            ||
| 1975 | VersionInfo::STATUS_ARCHIVED,  | 
            ||
| 1976 | VersionInfo::STATUS_ARCHIVED,  | 
            ||
| 1977 | VersionInfo::STATUS_ARCHIVED,  | 
            ||
| 1978 | VersionInfo::STATUS_ARCHIVED,  | 
            ||
| 1979 | VersionInfo::STATUS_ARCHIVED,  | 
            ||
| 1980 | VersionInfo::STATUS_PUBLISHED,  | 
            ||
| 1981 | ],  | 
            ||
| 1982 | [  | 
            ||
| 1983 | $versionInfoList[0]->status,  | 
            ||
| 1984 | $versionInfoList[1]->status,  | 
            ||
| 1985 | $versionInfoList[2]->status,  | 
            ||
| 1986 | $versionInfoList[3]->status,  | 
            ||
| 1987 | $versionInfoList[4]->status,  | 
            ||
| 1988 | $versionInfoList[5]->status,  | 
            ||
| 1989 | ]  | 
            ||
| 1990 | );  | 
            ||
| 1991 | }  | 
            ||
| 1992 | |||
| 1993 | /**  | 
            ||
| 1994 | * Test for the newContentMetadataUpdateStruct() method.  | 
            ||
| 1995 | *  | 
            ||
| 1996 | * @covers \eZ\Publish\API\Repository\ContentService::newContentMetadataUpdateStruct  | 
            ||
| 1997 | * @group user  | 
            ||
| 1998 | */  | 
            ||
| 1999 | public function testNewContentMetadataUpdateStruct()  | 
            ||
| 2023 | |||
| 2024 | /**  | 
            ||
| 2025 | * Test for the updateContentMetadata() method.  | 
            ||
| 2026 | *  | 
            ||
| 2027 | * @return \eZ\Publish\API\Repository\Values\Content\Content  | 
            ||
| 2028 | *  | 
            ||
| 2029 | * @see \eZ\Publish\API\Repository\ContentService::updateContentMetadata()  | 
            ||
| 2030 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion  | 
            ||
| 2031 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testNewContentMetadataUpdateStruct  | 
            ||
| 2032 | * @group user  | 
            ||
| 2033 | */  | 
            ||
| 2034 | public function testUpdateContentMetadata()  | 
            ||
| 2066 | |||
| 2067 | /**  | 
            ||
| 2068 | * Test for the updateContentMetadata() method.  | 
            ||
| 2069 | *  | 
            ||
| 2070 | * @param \eZ\Publish\API\Repository\Values\Content\Content $content  | 
            ||
| 2071 | *  | 
            ||
| 2072 | * @see \eZ\Publish\API\Repository\ContentService::updateContentMetadata()  | 
            ||
| 2073 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContentMetadata  | 
            ||
| 2074 | */  | 
            ||
| 2075 | public function testUpdateContentMetadataSetsExpectedProperties($content)  | 
            ||
| 2104 | |||
| 2105 | /**  | 
            ||
| 2106 | * Test for the updateContentMetadata() method.  | 
            ||
| 2107 | *  | 
            ||
| 2108 | * @param \eZ\Publish\API\Repository\Values\Content\Content $content  | 
            ||
| 2109 | *  | 
            ||
| 2110 | * @see \eZ\Publish\API\Repository\ContentService::updateContentMetadata()  | 
            ||
| 2111 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContentMetadata  | 
            ||
| 2112 | */  | 
            ||
| 2113 | public function testUpdateContentMetadataNotUpdatesContentVersion($content)  | 
            ||
| 2117 | |||
| 2118 | /**  | 
            ||
| 2119 | * Test for the updateContentMetadata() method.  | 
            ||
| 2120 | *  | 
            ||
| 2121 | * @covers \eZ\Publish\API\Repository\ContentService::updateContentMetadata()  | 
            ||
| 2122 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException  | 
            ||
| 2123 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContentMetadata  | 
            ||
| 2124 | */  | 
            ||
| 2125 | public function testUpdateContentMetadataThrowsInvalidArgumentExceptionOnDuplicateRemoteId()  | 
            ||
| 2149 | |||
| 2150 | /**  | 
            ||
| 2151 | * Test for the updateContentMetadata() method.  | 
            ||
| 2152 | *  | 
            ||
| 2153 | * @covers \eZ\Publish\Core\Repository\ContentService::updateContentMetadata  | 
            ||
| 2154 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException  | 
            ||
| 2155 | */  | 
            ||
| 2156 | public function testUpdateContentMetadataThrowsInvalidArgumentExceptionOnNoMetadataPropertiesSet()  | 
            ||
| 2168 | |||
| 2169 | /**  | 
            ||
| 2170 | * @covers \eZ\Publish\API\Repository\ContentService::updateContentMetadata  | 
            ||
| 2171 | *  | 
            ||
| 2172 | * @throws \eZ\Publish\API\Repository\Exceptions\ForbiddenException  | 
            ||
| 2173 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException  | 
            ||
| 2174 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException  | 
            ||
| 2175 | */  | 
            ||
| 2176 | public function testUpdateContentAlwaysAvailable()  | 
            ||
| 2177 |     { | 
            ||
| 2178 | $repository = $this->getRepository();  | 
            ||
| 2179 | $contentService = $repository->getContentService();  | 
            ||
| 2180 | |||
| 2181 | $folder = $this->createFolder(['eng-GB' => 'Folder'], 2);  | 
            ||
| 2182 | |||
| 2183 | $contentMetadataUpdate = $contentService->newContentMetadataUpdateStruct();  | 
            ||
| 2184 | $contentMetadataUpdate->alwaysAvailable = !$folder->contentInfo->alwaysAvailable;  | 
            ||
| 2185 | $contentService->updateContentMetadata($folder->contentInfo, $contentMetadataUpdate);  | 
            ||
| 2186 | |||
| 2187 | $reloadedFolder = $contentService->loadContent($folder->id);  | 
            ||
| 2188 | self::assertEquals(  | 
            ||
| 2189 | $contentMetadataUpdate->alwaysAvailable,  | 
            ||
| 2190 | $reloadedFolder->contentInfo->alwaysAvailable  | 
            ||
| 2191 | );  | 
            ||
| 2192 | }  | 
            ||
| 2193 | |||
| 2194 | /**  | 
            ||
| 2195 | * @covers \eZ\Publish\API\Repository\ContentService::updateContentMetadata  | 
            ||
| 2196 | *  | 
            ||
| 2197 | * @throws \eZ\Publish\API\Repository\Exceptions\ForbiddenException  | 
            ||
| 2198 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException  | 
            ||
| 2199 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException  | 
            ||
| 2200 | */  | 
            ||
| 2201 | public function testUpdateContentMainTranslation()  | 
            ||
| 2202 |     { | 
            ||
| 2203 | $repository = $this->getRepository();  | 
            ||
| 2204 | $contentService = $repository->getContentService();  | 
            ||
| 2205 | $locationService = $repository->getLocationService();  | 
            ||
| 2206 | |||
| 2207 | // create a Content Type which is not always available by default  | 
            ||
| 2208 | $contentType = $this->createContentType(  | 
            ||
| 2209 | 'test_t',  | 
            ||
| 2210 | self::ENG_GB,  | 
            ||
| 2211 | [  | 
            ||
| 2212 | 'name' => 'ezstring',  | 
            ||
| 2213 | ],  | 
            ||
| 2214 | false  | 
            ||
| 2215 | );  | 
            ||
| 2216 | |||
| 2217 | $contentCreate = $contentService->newContentCreateStruct(  | 
            ||
| 2218 | $contentType,  | 
            ||
| 2219 | self::ENG_US  | 
            ||
| 2220 | );  | 
            ||
| 2221 |         $contentCreate->setField('name', 'My Content'); | 
            ||
| 2222 | $content = $contentService->publishVersion(  | 
            ||
| 2223 | $contentService->createContent(  | 
            ||
| 2224 | $contentCreate,  | 
            ||
| 2225 | [$locationService->newLocationCreateStruct(2)]  | 
            ||
| 2226 | )->getVersionInfo()  | 
            ||
| 2227 | );  | 
            ||
| 2228 | // perform sanity check  | 
            ||
| 2229 | self::assertFalse($content->contentInfo->alwaysAvailable);  | 
            ||
| 2230 | |||
| 2231 | $updateStruct = $contentService->newContentMetadataUpdateStruct();  | 
            ||
| 2232 | $updateStruct->mainLanguageCode = self::ENG_GB;  | 
            ||
| 2258 | |||
| 2259 | /**  | 
            ||
| 2260 | * Test for the deleteContent() method.  | 
            ||
| 2261 | *  | 
            ||
| 2262 | * @see \eZ\Publish\API\Repository\ContentService::deleteContent()  | 
            ||
| 2263 | * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException  | 
            ||
| 2264 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft  | 
            ||
| 2265 | */  | 
            ||
| 2266 | View Code Duplication | public function testDeleteContent()  | 
            |
| 2287 | |||
| 2288 | /**  | 
            ||
| 2289 | * Test for the deleteContent() method.  | 
            ||
| 2290 | *  | 
            ||
| 2291 | * Test for issue EZP-21057:  | 
            ||
| 2292 | * "contentService: Unable to delete a content with an empty file attribute"  | 
            ||
| 2293 | *  | 
            ||
| 2294 | * @see \eZ\Publish\API\Repository\ContentService::deleteContent()  | 
            ||
| 2295 | * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException  | 
            ||
| 2296 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft  | 
            ||
| 2297 | */  | 
            ||
| 2298 | View Code Duplication | public function testDeleteContentWithEmptyBinaryField()  | 
            |
| 2319 | |||
| 2320 | /**  | 
            ||
| 2321 | * Test for the loadContentDrafts() method.  | 
            ||
| 2322 | *  | 
            ||
| 2323 | * @see \eZ\Publish\API\Repository\ContentService::loadContentDrafts()  | 
            ||
| 2324 | */  | 
            ||
| 2325 | public function testLoadContentDraftsReturnsEmptyArrayByDefault()  | 
            ||
| 2337 | |||
| 2338 | /**  | 
            ||
| 2339 | * Test for the loadContentDrafts() method.  | 
            ||
| 2340 | *  | 
            ||
| 2341 | * @see \eZ\Publish\API\Repository\ContentService::loadContentDrafts()  | 
            ||
| 2342 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraft  | 
            ||
| 2343 | */  | 
            ||
| 2344 | public function testLoadContentDrafts()  | 
            ||
| 2388 | |||
| 2389 | /**  | 
            ||
| 2390 | * Test for the loadContentDrafts() method.  | 
            ||
| 2391 | *  | 
            ||
| 2392 | * @see \eZ\Publish\API\Repository\ContentService::loadContentDrafts($user)  | 
            ||
| 2393 | */  | 
            ||
| 2394 | public function testLoadContentDraftsWithFirstParameter()  | 
            ||
| 2442 | |||
| 2443 | /**  | 
            ||
| 2444 | * Test for the loadVersionInfo() method.  | 
            ||
| 2445 | *  | 
            ||
| 2446 | * @see \eZ\Publish\API\Repository\ContentService::loadVersionInfo($contentInfo, $versionNo)  | 
            ||
| 2447 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft  | 
            ||
| 2448 | */  | 
            ||
| 2449 | public function testLoadVersionInfoWithSecondParameter()  | 
            ||
| 2472 | |||
| 2473 | /**  | 
            ||
| 2474 | * Test for the loadVersionInfo() method.  | 
            ||
| 2475 | *  | 
            ||
| 2476 | * @see \eZ\Publish\API\Repository\ContentService::loadVersionInfo($contentInfo, $versionNo)  | 
            ||
| 2477 | * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException  | 
            ||
| 2478 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadVersionInfoWithSecondParameter  | 
            ||
| 2479 | */  | 
            ||
| 2480 | public function testLoadVersionInfoThrowsNotFoundExceptionWithSecondParameter()  | 
            ||
| 2494 | |||
| 2495 | /**  | 
            ||
| 2496 | * Test for the loadVersionInfoById() method.  | 
            ||
| 2497 | *  | 
            ||
| 2498 | * @see \eZ\Publish\API\Repository\ContentService::loadVersionInfoById($contentId, $versionNo)  | 
            ||
| 2499 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadVersionInfoWithSecondParameter  | 
            ||
| 2500 | */  | 
            ||
| 2501 | public function testLoadVersionInfoByIdWithSecondParameter()  | 
            ||
| 2529 | |||
| 2530 | /**  | 
            ||
| 2531 | * Test for the returned value of the loadVersionInfoById() method.  | 
            ||
| 2532 | *  | 
            ||
| 2533 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadVersionInfoByIdWithSecondParameter  | 
            ||
| 2534 | * @covers \eZ\Publish\API\Repository\ContentService::loadVersionInfoById  | 
            ||
| 2535 | *  | 
            ||
| 2536 | * @param array $data  | 
            ||
| 2537 | */  | 
            ||
| 2538 | public function testLoadVersionInfoByIdWithSecondParameterSetsExpectedVersionInfo(array $data)  | 
            ||
| 2579 | |||
| 2580 | /**  | 
            ||
| 2581 | * Test for the loadVersionInfoById() method.  | 
            ||
| 2582 | *  | 
            ||
| 2583 | * @see \eZ\Publish\API\Repository\ContentService::loadVersionInfoById($contentId, $versionNo)  | 
            ||
| 2584 | * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException  | 
            ||
| 2585 | */  | 
            ||
| 2586 | View Code Duplication | public function testLoadVersionInfoByIdThrowsNotFoundExceptionWithSecondParameter()  | 
            |
| 2600 | |||
| 2601 | /**  | 
            ||
| 2602 | * Test for the loadContentByVersionInfo() method.  | 
            ||
| 2603 | *  | 
            ||
| 2604 | * @see \eZ\Publish\API\Repository\ContentService::loadContentByVersionInfo($versionInfo, $languages)  | 
            ||
| 2605 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent  | 
            ||
| 2606 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByVersionInfo  | 
            ||
| 2607 | */  | 
            ||
| 2608 | public function testLoadContentByVersionInfoWithSecondParameter()  | 
            ||
| 2690 | |||
| 2691 | /**  | 
            ||
| 2692 | * Test for the loadContentByContentInfo() method.  | 
            ||
| 2693 | *  | 
            ||
| 2694 | * @see \eZ\Publish\API\Repository\ContentService::loadContentByContentInfo($contentInfo, $languages)  | 
            ||
| 2695 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByContentInfo  | 
            ||
| 2696 | */  | 
            ||
| 2697 | public function testLoadContentByContentInfoWithLanguageParameters()  | 
            ||
| 2832 | |||
| 2833 | /**  | 
            ||
| 2834 | * Test for the loadContentByContentInfo() method.  | 
            ||
| 2835 | *  | 
            ||
| 2836 | * @see \eZ\Publish\API\Repository\ContentService::loadContentByContentInfo($contentInfo, $languages, $versionNo)  | 
            ||
| 2837 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByContentInfo  | 
            ||
| 2838 | */  | 
            ||
| 2839 | View Code Duplication | public function testLoadContentByContentInfoWithVersionNumberParameter()  | 
            |
| 2869 | |||
| 2870 | /**  | 
            ||
| 2871 | * Test for the loadContentByContentInfo() method.  | 
            ||
| 2872 | *  | 
            ||
| 2873 | * @see \eZ\Publish\API\Repository\ContentService::loadContentByContentInfo($contentInfo, $languages, $versionNo)  | 
            ||
| 2874 | * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException  | 
            ||
| 2875 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByContentInfoWithVersionNumberParameter  | 
            ||
| 2876 | */  | 
            ||
| 2877 | View Code Duplication | public function testLoadContentByContentInfoThrowsNotFoundExceptionWithVersionNumberParameter()  | 
            |
| 2891 | |||
| 2892 | /**  | 
            ||
| 2893 | * Test for the loadContent() method.  | 
            ||
| 2894 | *  | 
            ||
| 2895 | * @see \eZ\Publish\API\Repository\ContentService::loadContent($contentId, $languages)  | 
            ||
| 2896 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft  | 
            ||
| 2897 | */  | 
            ||
| 2898 | View Code Duplication | public function testLoadContentWithSecondParameter()  | 
            |
| 2915 | |||
| 2916 | /**  | 
            ||
| 2917 | * Test for the loadContent() method using undefined translation.  | 
            ||
| 2918 | *  | 
            ||
| 2919 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentWithSecondParameter  | 
            ||
| 2920 | * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException  | 
            ||
| 2921 | *  | 
            ||
| 2922 | * @param \eZ\Publish\API\Repository\Values\Content\Content $contentDraft  | 
            ||
| 2923 | */  | 
            ||
| 2924 | public function testLoadContentWithSecondParameterThrowsNotFoundException(Content $contentDraft)  | 
            ||
| 2932 | |||
| 2933 | /**  | 
            ||
| 2934 | * Test for the loadContent() method.  | 
            ||
| 2935 | *  | 
            ||
| 2936 | * @see \eZ\Publish\API\Repository\ContentService::loadContent($contentId, $languages, $versionNo)  | 
            ||
| 2937 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft  | 
            ||
| 2938 | */  | 
            ||
| 2939 | View Code Duplication | public function testLoadContentWithThirdParameter()  | 
            |
| 2962 | |||
| 2963 | /**  | 
            ||
| 2964 | * Test for the loadContent() method.  | 
            ||
| 2965 | *  | 
            ||
| 2966 | * @see \eZ\Publish\API\Repository\ContentService::loadContent($contentId, $languages, $versionNo)  | 
            ||
| 2967 | * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException  | 
            ||
| 2968 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentWithThirdParameter  | 
            ||
| 2969 | */  | 
            ||
| 2970 | View Code Duplication | public function testLoadContentThrowsNotFoundExceptionWithThirdParameter()  | 
            |
| 2984 | |||
| 2985 | /**  | 
            ||
| 2986 | * Test for the loadContentByRemoteId() method.  | 
            ||
| 2987 | *  | 
            ||
| 2988 | * @see \eZ\Publish\API\Repository\ContentService::loadContentByRemoteId($remoteId, $languages)  | 
            ||
| 2989 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft  | 
            ||
| 2990 | */  | 
            ||
| 2991 | View Code Duplication | public function testLoadContentByRemoteIdWithSecondParameter()  | 
            |
| 3013 | |||
| 3014 | /**  | 
            ||
| 3015 | * Test for the loadContentByRemoteId() method.  | 
            ||
| 3016 | *  | 
            ||
| 3017 | * @see \eZ\Publish\API\Repository\ContentService::loadContentByRemoteId($remoteId, $languages, $versionNo)  | 
            ||
| 3018 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft  | 
            ||
| 3019 | */  | 
            ||
| 3020 | View Code Duplication | public function testLoadContentByRemoteIdWithThirdParameter()  | 
            |
| 3047 | |||
| 3048 | /**  | 
            ||
| 3049 | * Test for the loadContentByRemoteId() method.  | 
            ||
| 3050 | *  | 
            ||
| 3051 | * @see \eZ\Publish\API\Repository\ContentService::loadContentByRemoteId($remoteId, $languages, $versionNo)  | 
            ||
| 3052 | * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException  | 
            ||
| 3053 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByRemoteIdWithThirdParameter  | 
            ||
| 3054 | */  | 
            ||
| 3055 | public function testLoadContentByRemoteIdThrowsNotFoundExceptionWithThirdParameter()  | 
            ||
| 3073 | |||
| 3074 | /**  | 
            ||
| 3075 | * Test that retrieval of translated name field respects prioritized language list.  | 
            ||
| 3076 | *  | 
            ||
| 3077 | * @dataProvider getPrioritizedLanguageList  | 
            ||
| 3078 | * @param string[]|null $languageCodes  | 
            ||
| 3079 | */  | 
            ||
| 3080 | public function testLoadContentWithPrioritizedLanguagesList($languageCodes)  | 
            ||
| 3100 | |||
| 3101 | /**  | 
            ||
| 3102 | * @return array  | 
            ||
| 3103 | */  | 
            ||
| 3104 | public function getPrioritizedLanguageList()  | 
            ||
| 3113 | |||
| 3114 | /**  | 
            ||
| 3115 | * Test for the deleteVersion() method.  | 
            ||
| 3116 | *  | 
            ||
| 3117 | * @see \eZ\Publish\API\Repository\ContentService::deleteVersion()  | 
            ||
| 3118 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContent  | 
            ||
| 3119 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent  | 
            ||
| 3120 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion  | 
            ||
| 3121 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraft  | 
            ||
| 3122 | */  | 
            ||
| 3123 | public function testDeleteVersion()  | 
            ||
| 3149 | |||
| 3150 | /**  | 
            ||
| 3151 | * Test for the deleteVersion() method.  | 
            ||
| 3152 | *  | 
            ||
| 3153 | * @see \eZ\Publish\API\Repository\ContentService::deleteVersion()  | 
            ||
| 3154 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException  | 
            ||
| 3155 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContent  | 
            ||
| 3156 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent  | 
            ||
| 3157 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion  | 
            ||
| 3158 | */  | 
            ||
| 3159 | public function testDeleteVersionThrowsBadStateExceptionOnPublishedVersion()  | 
            ||
| 3173 | |||
| 3174 | /**  | 
            ||
| 3175 | * Test for the deleteVersion() method.  | 
            ||
| 3176 | *  | 
            ||
| 3177 | * @see \eZ\Publish\API\Repository\ContentService::deleteVersion()  | 
            ||
| 3178 | * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException  | 
            ||
| 3179 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContent  | 
            ||
| 3180 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent  | 
            ||
| 3181 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion  | 
            ||
| 3182 | */  | 
            ||
| 3183 | public function testDeleteVersionWorksIfOnlyVersionIsDraft()  | 
            ||
| 3199 | |||
| 3200 | /**  | 
            ||
| 3201 | * Test for the loadVersions() method.  | 
            ||
| 3202 | *  | 
            ||
| 3203 | * @see \eZ\Publish\API\Repository\ContentService::loadVersions()  | 
            ||
| 3204 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion  | 
            ||
| 3205 | *  | 
            ||
| 3206 | * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo[]  | 
            ||
| 3207 | */  | 
            ||
| 3208 | public function testLoadVersions()  | 
            ||
| 3230 | |||
| 3231 | /**  | 
            ||
| 3232 | * Test for the loadVersions() method.  | 
            ||
| 3233 | *  | 
            ||
| 3234 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadVersions  | 
            ||
| 3235 | * @covers \eZ\Publish\Core\Repository\ContentService::loadVersions  | 
            ||
| 3236 | *  | 
            ||
| 3237 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo[] $versions  | 
            ||
| 3238 | */  | 
            ||
| 3239 | public function testLoadVersionsSetsExpectedVersionInfo(array $versions)  | 
            ||
| 3282 | |||
| 3283 | /**  | 
            ||
| 3284 | * Test for the copyContent() method.  | 
            ||
| 3285 | *  | 
            ||
| 3286 | * @see \eZ\Publish\API\Repository\ContentService::copyContent()  | 
            ||
| 3287 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft  | 
            ||
| 3288 | * @group field-type  | 
            ||
| 3289 | */  | 
            ||
| 3290 | View Code Duplication | public function testCopyContent()  | 
            |
| 3349 | |||
| 3350 | /**  | 
            ||
| 3351 | * Test for the copyContent() method with ezsettings.default.content.retain_owner_on_copy set to false  | 
            ||
| 3352 | * See settings/test/integration_legacy.yml for service override.  | 
            ||
| 3353 | *  | 
            ||
| 3354 | * @see \eZ\Publish\API\Repository\ContentService::copyContent()  | 
            ||
| 3355 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft  | 
            ||
| 3356 | * @group field-type  | 
            ||
| 3357 | */  | 
            ||
| 3358 | public function testCopyContentWithNewOwner()  | 
            ||
| 3403 | |||
| 3404 | /**  | 
            ||
| 3405 | * Test for the copyContent() method.  | 
            ||
| 3406 | *  | 
            ||
| 3407 | * @see \eZ\Publish\API\Repository\ContentService::copyContent($contentInfo, $destinationLocationCreateStruct, $versionInfo)  | 
            ||
| 3408 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCopyContent  | 
            ||
| 3409 | *  | 
            ||
| 3410 | * @todo Fix to more descriptive name  | 
            ||
| 3411 | */  | 
            ||
| 3412 | View Code Duplication | public function testCopyContentWithThirdParameter()  | 
            |
| 3468 | |||
| 3469 | /**  | 
            ||
| 3470 | * Test for the addRelation() method.  | 
            ||
| 3471 | *  | 
            ||
| 3472 | * @return \eZ\Publish\API\Repository\Values\Content\Content  | 
            ||
| 3473 | *  | 
            ||
| 3474 | * @see \eZ\Publish\API\Repository\ContentService::addRelation()  | 
            ||
| 3475 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft  | 
            ||
| 3476 | */  | 
            ||
| 3477 | public function testAddRelation()  | 
            ||
| 3505 | |||
| 3506 | /**  | 
            ||
| 3507 | * Test for the addRelation() method.  | 
            ||
| 3508 | *  | 
            ||
| 3509 | * @param \eZ\Publish\API\Repository\Values\Content\Relation[] $relations  | 
            ||
| 3510 | *  | 
            ||
| 3511 | * @see \eZ\Publish\API\Repository\ContentService::addRelation()  | 
            ||
| 3512 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation  | 
            ||
| 3513 | */  | 
            ||
| 3514 | public function testAddRelationAddsRelationToContent($relations)  | 
            ||
| 3521 | |||
| 3522 | /**  | 
            ||
| 3523 | * @param \eZ\Publish\API\Repository\Values\Content\Relation[] $relations  | 
            ||
| 3524 | */  | 
            ||
| 3525 | protected function assertExpectedRelations($relations)  | 
            ||
| 3542 | |||
| 3543 | /**  | 
            ||
| 3544 | * Test for the addRelation() method.  | 
            ||
| 3545 | *  | 
            ||
| 3546 | * @param \eZ\Publish\API\Repository\Values\Content\Relation[] $relations  | 
            ||
| 3547 | *  | 
            ||
| 3548 | * @see \eZ\Publish\API\Repository\ContentService::addRelation()  | 
            ||
| 3549 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation  | 
            ||
| 3550 | */  | 
            ||
| 3551 | public function testAddRelationSetsExpectedRelations($relations)  | 
            ||
| 3555 | |||
| 3556 | /**  | 
            ||
| 3557 | * Test for the createContentDraft() method.  | 
            ||
| 3558 | *  | 
            ||
| 3559 | * @return \eZ\Publish\API\Repository\Values\Content\Relation[]  | 
            ||
| 3560 | *  | 
            ||
| 3561 | * @see \eZ\Publish\API\Repository\ContentService::createContentDraft()  | 
            ||
| 3562 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelationSetsExpectedRelations  | 
            ||
| 3563 | */  | 
            ||
| 3564 | public function testCreateContentDraftWithRelations()  | 
            ||
| 3586 | |||
| 3587 | /**  | 
            ||
| 3588 | * Test for the createContentDraft() method.  | 
            ||
| 3589 | *  | 
            ||
| 3590 | * @param \eZ\Publish\API\Repository\Values\Content\Relation[] $relations  | 
            ||
| 3591 | *  | 
            ||
| 3592 | * @return \eZ\Publish\API\Repository\Values\Content\Relation[]  | 
            ||
| 3593 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraftWithRelations  | 
            ||
| 3594 | */  | 
            ||
| 3595 | public function testCreateContentDraftWithRelationsCreatesRelations($relations)  | 
            ||
| 3604 | |||
| 3605 | /**  | 
            ||
| 3606 | * Test for the createContentDraft() method.  | 
            ||
| 3607 | *  | 
            ||
| 3608 | * @param \eZ\Publish\API\Repository\Values\Content\Relation[] $relations  | 
            ||
| 3609 | *  | 
            ||
| 3610 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraftWithRelationsCreatesRelations  | 
            ||
| 3611 | */  | 
            ||
| 3612 | public function testCreateContentDraftWithRelationsCreatesExpectedRelations($relations)  | 
            ||
| 3616 | |||
| 3617 | /**  | 
            ||
| 3618 | * Test for the addRelation() method.  | 
            ||
| 3619 | *  | 
            ||
| 3620 | * @see \eZ\Publish\API\Repository\ContentService::addRelation()  | 
            ||
| 3621 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException  | 
            ||
| 3622 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation  | 
            ||
| 3623 | */  | 
            ||
| 3624 | View Code Duplication | public function testAddRelationThrowsBadStateException()  | 
            |
| 3646 | |||
| 3647 | /**  | 
            ||
| 3648 | * Test for the loadRelations() method.  | 
            ||
| 3649 | *  | 
            ||
| 3650 | * @see \eZ\Publish\API\Repository\ContentService::loadRelations()  | 
            ||
| 3651 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation  | 
            ||
| 3652 | */  | 
            ||
| 3653 | public function testLoadRelations()  | 
            ||
| 3720 | |||
| 3721 | /**  | 
            ||
| 3722 | * Test for the loadRelations() method.  | 
            ||
| 3723 | *  | 
            ||
| 3724 | * @see \eZ\Publish\API\Repository\ContentService::loadRelations()  | 
            ||
| 3725 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation  | 
            ||
| 3726 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadRelations  | 
            ||
| 3727 | */  | 
            ||
| 3728 | public function testLoadRelationsSkipsArchivedContent()  | 
            ||
| 3786 | |||
| 3787 | /**  | 
            ||
| 3788 | * Test for the loadRelations() method.  | 
            ||
| 3789 | *  | 
            ||
| 3790 | * @see \eZ\Publish\API\Repository\ContentService::loadRelations()  | 
            ||
| 3791 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation  | 
            ||
| 3792 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadRelations  | 
            ||
| 3793 | */  | 
            ||
| 3794 | public function testLoadRelationsSkipsDraftContent()  | 
            ||
| 3848 | |||
| 3849 | /**  | 
            ||
| 3850 | * Test for the loadReverseRelations() method.  | 
            ||
| 3851 | *  | 
            ||
| 3852 | * @see \eZ\Publish\API\Repository\ContentService::loadReverseRelations()  | 
            ||
| 3853 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation  | 
            ||
| 3854 | */  | 
            ||
| 3855 | public function testLoadReverseRelations()  | 
            ||
| 3941 | |||
| 3942 | /**  | 
            ||
| 3943 | * Test for the loadReverseRelations() method.  | 
            ||
| 3944 | *  | 
            ||
| 3945 | * @see \eZ\Publish\API\Repository\ContentService::loadReverseRelations()  | 
            ||
| 3946 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation  | 
            ||
| 3947 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadReverseRelations  | 
            ||
| 3948 | */  | 
            ||
| 3949 | public function testLoadReverseRelationsSkipsArchivedContent()  | 
            ||
| 4025 | |||
| 4026 | /**  | 
            ||
| 4027 | * Test for the loadReverseRelations() method.  | 
            ||
| 4028 | *  | 
            ||
| 4029 | * @see \eZ\Publish\API\Repository\ContentService::loadReverseRelations()  | 
            ||
| 4030 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation  | 
            ||
| 4031 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadReverseRelations  | 
            ||
| 4032 | */  | 
            ||
| 4033 | public function testLoadReverseRelationsSkipsDraftContent()  | 
            ||
| 4101 | |||
| 4102 | /**  | 
            ||
| 4103 | * Test for the deleteRelation() method.  | 
            ||
| 4104 | *  | 
            ||
| 4105 | * @see \eZ\Publish\API\Repository\ContentService::deleteRelation()  | 
            ||
| 4106 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadRelations  | 
            ||
| 4107 | */  | 
            ||
| 4108 | public function testDeleteRelation()  | 
            ||
| 4138 | |||
| 4139 | /**  | 
            ||
| 4140 | * Test for the deleteRelation() method.  | 
            ||
| 4141 | *  | 
            ||
| 4142 | * @see \eZ\Publish\API\Repository\ContentService::deleteRelation()  | 
            ||
| 4143 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException  | 
            ||
| 4144 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteRelation  | 
            ||
| 4145 | */  | 
            ||
| 4146 | public function testDeleteRelationThrowsBadStateException()  | 
            ||
| 4180 | |||
| 4181 | /**  | 
            ||
| 4182 | * Test for the deleteRelation() method.  | 
            ||
| 4183 | *  | 
            ||
| 4184 | * @see \eZ\Publish\API\Repository\ContentService::deleteRelation()  | 
            ||
| 4185 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException  | 
            ||
| 4186 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteRelation  | 
            ||
| 4187 | */  | 
            ||
| 4188 | View Code Duplication | public function testDeleteRelationThrowsInvalidArgumentException()  | 
            |
| 4211 | |||
| 4212 | /**  | 
            ||
| 4213 | * Test for the createContent() method.  | 
            ||
| 4214 | *  | 
            ||
| 4215 | * @see \eZ\Publish\API\Repository\ContentService::createContent()  | 
            ||
| 4216 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent  | 
            ||
| 4217 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContent  | 
            ||
| 4218 | */  | 
            ||
| 4219 | public function testCreateContentInTransactionWithRollback()  | 
            ||
| 4266 | |||
| 4267 | /**  | 
            ||
| 4268 | * Test for the createContent() method.  | 
            ||
| 4269 | *  | 
            ||
| 4270 | * @see \eZ\Publish\API\Repository\ContentService::createContent()  | 
            ||
| 4271 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent  | 
            ||
| 4272 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContent  | 
            ||
| 4273 | */  | 
            ||
| 4274 | public function testCreateContentInTransactionWithCommit()  | 
            ||
| 4316 | |||
| 4317 | /**  | 
            ||
| 4318 | * Test for the createContent() method.  | 
            ||
| 4319 | *  | 
            ||
| 4320 | * @see \eZ\Publish\API\Repository\ContentService::createContent($contentCreateStruct, $locationCreateStructs)  | 
            ||
| 4321 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentWithLocationCreateParameterDoesNotCreateLocationImmediately  | 
            ||
| 4322 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentThrowsNotFoundException  | 
            ||
| 4323 | */  | 
            ||
| 4324 | View Code Duplication | public function testCreateContentWithLocationCreateParameterInTransactionWithRollback()  | 
            |
| 4357 | |||
| 4358 | /**  | 
            ||
| 4359 | * Test for the createContent() method.  | 
            ||
| 4360 | *  | 
            ||
| 4361 | * @see \eZ\Publish\API\Repository\ContentService::createContent($contentCreateStruct, $locationCreateStructs)  | 
            ||
| 4362 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentWithLocationCreateParameterDoesNotCreateLocationImmediately  | 
            ||
| 4363 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentThrowsNotFoundException  | 
            ||
| 4364 | */  | 
            ||
| 4365 | View Code Duplication | public function testCreateContentWithLocationCreateParameterInTransactionWithCommit()  | 
            |
| 4394 | |||
| 4395 | /**  | 
            ||
| 4396 | * Test for the createContentDraft() method.  | 
            ||
| 4397 | *  | 
            ||
| 4398 | * @see \eZ\Publish\API\Repository\ContentService::createContentDraft()  | 
            ||
| 4399 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraft  | 
            ||
| 4400 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContent  | 
            ||
| 4401 | */  | 
            ||
| 4402 | public function testCreateContentDraftInTransactionWithRollback()  | 
            ||
| 4444 | |||
| 4445 | /**  | 
            ||
| 4446 | * Test for the createContentDraft() method.  | 
            ||
| 4447 | *  | 
            ||
| 4448 | * @see \eZ\Publish\API\Repository\ContentService::createContentDraft()  | 
            ||
| 4449 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraft  | 
            ||
| 4450 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContent  | 
            ||
| 4451 | */  | 
            ||
| 4452 | View Code Duplication | public function testCreateContentDraftInTransactionWithCommit()  | 
            |
| 4492 | |||
| 4493 | /**  | 
            ||
| 4494 | * Test for the publishVersion() method.  | 
            ||
| 4495 | *  | 
            ||
| 4496 | * @see \eZ\Publish\API\Repository\ContentService::publishVersion()  | 
            ||
| 4497 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion  | 
            ||
| 4498 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContent  | 
            ||
| 4499 | */  | 
            ||
| 4500 | View Code Duplication | public function testPublishVersionInTransactionWithRollback()  | 
            |
| 4544 | |||
| 4545 | /**  | 
            ||
| 4546 | * Test for the publishVersion() method.  | 
            ||
| 4547 | *  | 
            ||
| 4548 | * @see \eZ\Publish\API\Repository\ContentService::publishVersion()  | 
            ||
| 4549 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion  | 
            ||
| 4550 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadVersionInfo  | 
            ||
| 4551 | */  | 
            ||
| 4552 | View Code Duplication | public function testPublishVersionInTransactionWithCommit()  | 
            |
| 4592 | |||
| 4593 | /**  | 
            ||
| 4594 | * Test for the updateContent() method.  | 
            ||
| 4595 | *  | 
            ||
| 4596 | * @see \eZ\Publish\API\Repository\ContentService::updateContent()  | 
            ||
| 4597 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent  | 
            ||
| 4598 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContent  | 
            ||
| 4599 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo  | 
            ||
| 4600 | */  | 
            ||
| 4601 | View Code Duplication | public function testUpdateContentInTransactionWithRollback()  | 
            |
| 4648 | |||
| 4649 | /**  | 
            ||
| 4650 | * Test for the updateContent() method.  | 
            ||
| 4651 | *  | 
            ||
| 4652 | * @see \eZ\Publish\API\Repository\ContentService::updateContent()  | 
            ||
| 4653 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent  | 
            ||
| 4654 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContent  | 
            ||
| 4655 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo  | 
            ||
| 4656 | */  | 
            ||
| 4657 | View Code Duplication | public function testUpdateContentInTransactionWithCommit()  | 
            |
| 4704 | |||
| 4705 | /**  | 
            ||
| 4706 | * Test for the updateContentMetadata() method.  | 
            ||
| 4707 | *  | 
            ||
| 4708 | * @see \eZ\Publish\API\Repository\ContentService::updateContentMetadata()  | 
            ||
| 4709 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContentMetadata  | 
            ||
| 4710 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo  | 
            ||
| 4711 | */  | 
            ||
| 4712 | View Code Duplication | public function testUpdateContentMetadataInTransactionWithRollback()  | 
            |
| 4757 | |||
| 4758 | /**  | 
            ||
| 4759 | * Test for the updateContentMetadata() method.  | 
            ||
| 4760 | *  | 
            ||
| 4761 | * @see \eZ\Publish\API\Repository\ContentService::updateContentMetadata()  | 
            ||
| 4762 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContentMetadata  | 
            ||
| 4763 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo  | 
            ||
| 4764 | */  | 
            ||
| 4765 | View Code Duplication | public function testUpdateContentMetadataInTransactionWithCommit()  | 
            |
| 4810 | |||
| 4811 | /**  | 
            ||
| 4812 | * Test for the updateContentMetadata() method, and how cache + transactions play together.  | 
            ||
| 4813 | *  | 
            ||
| 4814 | * @see \eZ\Publish\API\Repository\ContentService::updateContentMetadata()  | 
            ||
| 4815 | * @depends testUpdateContentMetadata  | 
            ||
| 4816 | * @depends testLoadContentInfo  | 
            ||
| 4817 | */  | 
            ||
| 4818 | View Code Duplication | public function testUpdateContentMetadataCheckWithinTransaction()  | 
            |
| 4856 | |||
| 4857 | /**  | 
            ||
| 4858 | * Test for the deleteVersion() method.  | 
            ||
| 4859 | *  | 
            ||
| 4860 | * @see \eZ\Publish\API\Repository\ContentService::deleteVersion()  | 
            ||
| 4861 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent  | 
            ||
| 4862 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo  | 
            ||
| 4863 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentDrafts  | 
            ||
| 4864 | */  | 
            ||
| 4865 | View Code Duplication | public function testDeleteVersionInTransactionWithRollback()  | 
            |
| 4901 | |||
| 4902 | /**  | 
            ||
| 4903 | * Test for the deleteVersion() method.  | 
            ||
| 4904 | *  | 
            ||
| 4905 | * @see \eZ\Publish\API\Repository\ContentService::deleteVersion()  | 
            ||
| 4906 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent  | 
            ||
| 4907 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo  | 
            ||
| 4908 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentDrafts  | 
            ||
| 4909 | */  | 
            ||
| 4910 | View Code Duplication | public function testDeleteVersionInTransactionWithCommit()  | 
            |
| 4946 | |||
| 4947 | /**  | 
            ||
| 4948 | * Test for the deleteContent() method.  | 
            ||
| 4949 | *  | 
            ||
| 4950 | * @see \eZ\Publish\API\Repository\ContentService::deleteContent()  | 
            ||
| 4951 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteContent  | 
            ||
| 4952 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo  | 
            ||
| 4953 | */  | 
            ||
| 4954 | View Code Duplication | public function testDeleteContentInTransactionWithRollback()  | 
            |
| 4990 | |||
| 4991 | /**  | 
            ||
| 4992 | * Test for the deleteContent() method.  | 
            ||
| 4993 | *  | 
            ||
| 4994 | * @see \eZ\Publish\API\Repository\ContentService::deleteContent()  | 
            ||
| 4995 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteContent  | 
            ||
| 4996 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo  | 
            ||
| 4997 | */  | 
            ||
| 4998 | View Code Duplication | public function testDeleteContentInTransactionWithCommit()  | 
            |
| 5038 | |||
| 5039 | /**  | 
            ||
| 5040 | * Test for the copyContent() method.  | 
            ||
| 5041 | *  | 
            ||
| 5042 | * @see \eZ\Publish\API\Repository\ContentService::copyContent()  | 
            ||
| 5043 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCopyContent  | 
            ||
| 5044 | * @depend(s) eZ\Publish\API\Repository\Tests\LocationServiceTest::testNewLocationCreateStruct  | 
            ||
| 5045 | * @depend(s) eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocationChildren  | 
            ||
| 5046 | * @depend(s) eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation  | 
            ||
| 5047 | */  | 
            ||
| 5048 | View Code Duplication | public function testCopyContentInTransactionWithRollback()  | 
            |
| 5098 | |||
| 5099 | /**  | 
            ||
| 5100 | * Test for the copyContent() method.  | 
            ||
| 5101 | *  | 
            ||
| 5102 | * @see \eZ\Publish\API\Repository\ContentService::copyContent()  | 
            ||
| 5103 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCopyContent  | 
            ||
| 5104 | * @depend(s) eZ\Publish\API\Repository\Tests\LocationServiceTest::testNewLocationCreateStruct  | 
            ||
| 5105 | * @depend(s) eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocationChildren  | 
            ||
| 5106 | * @depend(s) eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation  | 
            ||
| 5107 | */  | 
            ||
| 5108 | View Code Duplication | public function testCopyContentInTransactionWithCommit()  | 
            |
| 5158 | |||
| 5159 | public function testURLAliasesCreatedForNewContent()  | 
            ||
| 5195 | |||
| 5196 | public function testURLAliasesCreatedForUpdatedContent()  | 
            ||
| 5268 | |||
| 5269 | public function testCustomURLAliasesNotHistorizedOnUpdatedContent()  | 
            ||
| 5328 | |||
| 5329 | /**  | 
            ||
| 5330 | * Test to ensure that old versions are not affected by updates to newer  | 
            ||
| 5331 | * drafts.  | 
            ||
| 5332 | */  | 
            ||
| 5333 | public function testUpdatingDraftDoesNotUpdateOldVersions()  | 
            ||
| 5349 | |||
| 5350 | /**  | 
            ||
| 5351 | * Test scenario with writer and publisher users.  | 
            ||
| 5352 | * Writer can only create content. Publisher can publish this content.  | 
            ||
| 5353 | */  | 
            ||
| 5354 | public function testPublishWorkflow()  | 
            ||
| 5392 | |||
| 5393 | /**  | 
            ||
| 5394 | * Test publish / content policy is required to be able to publish content.  | 
            ||
| 5395 | *  | 
            ||
| 5396 | * @expectedException \eZ\Publish\Core\Base\Exceptions\UnauthorizedException  | 
            ||
| 5397 | * @expectedExceptionMessageRegExp /User does not have access to 'publish' 'content'/  | 
            ||
| 5398 | */  | 
            ||
| 5399 | public function testPublishContentWithoutPublishPolicyThrowsException()  | 
            ||
| 5418 | |||
| 5419 | /**  | 
            ||
| 5420 | * Test removal of the specific translation from all the Versions of a Content Object.  | 
            ||
| 5421 | *  | 
            ||
| 5422 | * @covers \eZ\Publish\Core\Repository\ContentService::deleteTranslation  | 
            ||
| 5423 | */  | 
            ||
| 5424 | View Code Duplication | public function testDeleteTranslation()  | 
            |
| 5445 | |||
| 5446 | /**  | 
            ||
| 5447 | * Test deleting a Translation which is initial for some Version, updates initialLanguageCode  | 
            ||
| 5448 | * with mainLanguageCode (assuming they are different).  | 
            ||
| 5449 | */  | 
            ||
| 5450 | public function testDeleteTranslationUpdatesInitialLanguageCodeVersion()  | 
            ||
| 5481 | |||
| 5482 | /**  | 
            ||
| 5483 | * Test removal of the specific translation properly updates languages of the URL alias.  | 
            ||
| 5484 | *  | 
            ||
| 5485 | * @covers \eZ\Publish\Core\Repository\ContentService::deleteTranslation  | 
            ||
| 5486 | */  | 
            ||
| 5487 | public function testDeleteTranslationUpdatesUrlAlias()  | 
            ||
| 5524 | |||
| 5525 | /**  | 
            ||
| 5526 | * Test removal of a main translation throws BadStateException.  | 
            ||
| 5527 | *  | 
            ||
| 5528 | * @covers \eZ\Publish\Core\Repository\ContentService::deleteTranslation  | 
            ||
| 5529 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException  | 
            ||
| 5530 | * @expectedExceptionMessage Specified translation is the main translation of the Content Object  | 
            ||
| 5531 | */  | 
            ||
| 5532 | public function testDeleteTranslationMainLanguageThrowsBadStateException()  | 
            ||
| 5544 | |||
| 5545 | /**  | 
            ||
| 5546 | * Test removal of a Translation is possible when some archived Versions have only this Translation.  | 
            ||
| 5547 | *  | 
            ||
| 5548 | * @covers \eZ\Publish\Core\Repository\ContentService::deleteTranslation  | 
            ||
| 5549 | */  | 
            ||
| 5550 | public function testDeleteTranslationDeletesSingleTranslationVersions()  | 
            ||
| 5574 | |||
| 5575 | /**  | 
            ||
| 5576 | * Test removal of the translation by the user who is not allowed to delete a content  | 
            ||
| 5577 | * throws UnauthorizedException.  | 
            ||
| 5578 | *  | 
            ||
| 5579 | * @covers \eZ\Publish\Core\Repository\ContentService::deleteTranslation  | 
            ||
| 5580 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException  | 
            ||
| 5581 | * @expectedExceptionMessage User does not have access to 'remove' 'content'  | 
            ||
| 5582 | */  | 
            ||
| 5583 | public function testDeleteTranslationThrowsUnauthorizedException()  | 
            ||
| 5606 | |||
| 5607 | /**  | 
            ||
| 5608 | * Test removal of a non-existent translation throws InvalidArgumentException.  | 
            ||
| 5609 | *  | 
            ||
| 5610 | * @covers \eZ\Publish\Core\Repository\ContentService::deleteTranslation  | 
            ||
| 5611 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException  | 
            ||
| 5612 | * @expectedExceptionMessage Argument '$languageCode' is invalid: ger-DE does not exist in the Content item  | 
            ||
| 5613 | */  | 
            ||
| 5614 | public function testDeleteTranslationThrowsInvalidArgumentException()  | 
            ||
| 5622 | |||
| 5623 | /**  | 
            ||
| 5624 | * Test deleting a Translation from Draft.  | 
            ||
| 5625 | *  | 
            ||
| 5626 | * @covers \eZ\Publish\Core\Repository\ContentService::deleteTranslationFromDraft  | 
            ||
| 5627 | */  | 
            ||
| 5628 | public function testDeleteTranslationFromDraft()  | 
            ||
| 5643 | |||
| 5644 | /**  | 
            ||
| 5645 | * Get values for multilingual field.  | 
            ||
| 5646 | *  | 
            ||
| 5647 | * @return array  | 
            ||
| 5648 | */  | 
            ||
| 5649 | public function providerForDeleteTranslationFromDraftRemovesUrlAliasOnPublishing()  | 
            ||
| 5660 | |||
| 5661 | /**  | 
            ||
| 5662 | * Test deleting a Translation from Draft removes previously stored URL aliases for published Content.  | 
            ||
| 5663 | *  | 
            ||
| 5664 | * @covers \eZ\Publish\Core\Repository\ContentService::deleteTranslationFromDraft  | 
            ||
| 5665 | *  | 
            ||
| 5666 | * @dataProvider providerForDeleteTranslationFromDraftRemovesUrlAliasOnPublishing  | 
            ||
| 5667 | *  | 
            ||
| 5668 | * @param string[] $fieldValues translated field values  | 
            ||
| 5669 | *  | 
            ||
| 5670 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException  | 
            ||
| 5671 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException  | 
            ||
| 5672 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException  | 
            ||
| 5673 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException  | 
            ||
| 5674 | */  | 
            ||
| 5675 | public function testDeleteTranslationFromDraftRemovesUrlAliasOnPublishing(array $fieldValues)  | 
            ||
| 5735 | |||
| 5736 | /**  | 
            ||
| 5737 | * Test that URL aliases for deleted Translations are properly archived.  | 
            ||
| 5738 | */  | 
            ||
| 5739 | public function testDeleteTranslationFromDraftArchivesUrlAliasOnPublishing()  | 
            ||
| 5794 | |||
| 5795 | /**  | 
            ||
| 5796 | * Test deleting a Translation from Draft which has single Translation throws BadStateException.  | 
            ||
| 5797 | *  | 
            ||
| 5798 | * @covers \eZ\Publish\Core\Repository\ContentService::deleteTranslationFromDraft  | 
            ||
| 5799 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException  | 
            ||
| 5800 | * @expectedExceptionMessage Specified Translation is the only one Content Object Version has  | 
            ||
| 5801 | */  | 
            ||
| 5802 | public function testDeleteTranslationFromDraftThrowsBadStateExceptionOnSingleTranslation()  | 
            ||
| 5833 | |||
| 5834 | /**  | 
            ||
| 5835 | * Test deleting the Main Translation from Draft throws BadStateException.  | 
            ||
| 5836 | *  | 
            ||
| 5837 | * @covers \eZ\Publish\Core\Repository\ContentService::deleteTranslationFromDraft  | 
            ||
| 5838 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException  | 
            ||
| 5839 | * @expectedExceptionMessage Specified Translation is the main Translation of the Content Object  | 
            ||
| 5840 | */  | 
            ||
| 5841 | public function testDeleteTranslationFromDraftThrowsBadStateExceptionOnMainTranslation()  | 
            ||
| 5860 | |||
| 5861 | /**  | 
            ||
| 5862 | * Test deleting the Translation from Published Version throws BadStateException.  | 
            ||
| 5863 | *  | 
            ||
| 5864 | * @covers \eZ\Publish\Core\Repository\ContentService::deleteTranslationFromDraft  | 
            ||
| 5865 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException  | 
            ||
| 5866 | * @expectedExceptionMessage Version is not a draft  | 
            ||
| 5867 | */  | 
            ||
| 5868 | View Code Duplication | public function testDeleteTranslationFromDraftThrowsBadStateExceptionOnPublishedVersion()  | 
            |
| 5879 | |||
| 5880 | /**  | 
            ||
| 5881 | * Test deleting a Translation from Draft throws UnauthorizedException if user cannot edit Content.  | 
            ||
| 5882 | *  | 
            ||
| 5883 | * @covers \eZ\Publish\Core\Repository\ContentService::deleteTranslationFromDraft  | 
            ||
| 5884 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException  | 
            ||
| 5885 | * @expectedExceptionMessage User does not have access to 'edit' 'content'  | 
            ||
| 5886 | */  | 
            ||
| 5887 | public function testDeleteTranslationFromDraftThrowsUnauthorizedException()  | 
            ||
| 5913 | |||
| 5914 | /**  | 
            ||
| 5915 | * Test deleting a non-existent Translation from Draft throws InvalidArgumentException.  | 
            ||
| 5916 | *  | 
            ||
| 5917 | * @covers \eZ\Publish\Core\Repository\ContentService::deleteTranslationFromDraft  | 
            ||
| 5918 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException  | 
            ||
| 5919 | * @expectedExceptionMessageRegExp /The Version \(ContentId=\d+, VersionNo=\d+\) is not translated into ger-DE/  | 
            ||
| 5920 | */  | 
            ||
| 5921 | public function testDeleteTranslationFromDraftThrowsInvalidArgumentException()  | 
            ||
| 5931 | |||
| 5932 | /**  | 
            ||
| 5933 | * Test for the newTranslationInfo() method.  | 
            ||
| 5934 | *  | 
            ||
| 5935 | * @covers \eZ\Publish\Core\Repository\ContentService::newTranslationInfo  | 
            ||
| 5936 | */  | 
            ||
| 5937 | public function testNewTranslationInfo()  | 
            ||
| 5953 | |||
| 5954 | /**  | 
            ||
| 5955 | * Test loading list of Content items.  | 
            ||
| 5956 | */  | 
            ||
| 5957 | public function testLoadContentListByContentInfo()  | 
            ||
| 5984 | |||
| 5985 | /**  | 
            ||
| 5986 | * Asserts that all aliases defined in $expectedAliasProperties with the  | 
            ||
| 5987 | * given properties are available in $actualAliases and not more.  | 
            ||
| 5988 | *  | 
            ||
| 5989 | * @param array $expectedAliasProperties  | 
            ||
| 5990 | * @param array $actualAliases  | 
            ||
| 5991 | */  | 
            ||
| 5992 | private function assertAliasesCorrect(array $expectedAliasProperties, array $actualAliases)  | 
            ||
| 6030 | |||
| 6031 | /**  | 
            ||
| 6032 | * Asserts that the given fields are equal to the default fields fixture.  | 
            ||
| 6033 | *  | 
            ||
| 6034 | * @param \eZ\Publish\API\Repository\Values\Content\Field[] $fields  | 
            ||
| 6035 | */  | 
            ||
| 6036 | private function assertAllFieldsEquals(array $fields)  | 
            ||
| 6043 | |||
| 6044 | /**  | 
            ||
| 6045 | * Asserts that the given fields are equal to a language filtered set of the  | 
            ||
| 6046 | * default fields fixture.  | 
            ||
| 6047 | *  | 
            ||
| 6048 | * @param \eZ\Publish\API\Repository\Values\Content\Field[] $fields  | 
            ||
| 6049 | * @param string $languageCode  | 
            ||
| 6050 | */  | 
            ||
| 6051 | private function assertLocaleFieldsEquals(array $fields, $languageCode)  | 
            ||
| 6065 | |||
| 6066 | /**  | 
            ||
| 6067 | * This method normalizes a set of fields and returns a normalized set.  | 
            ||
| 6068 | *  | 
            ||
| 6069 | * Normalization means it resets the storage specific field id to zero and  | 
            ||
| 6070 | * it sorts the field by their identifier and their language code. In  | 
            ||
| 6071 | * addition, the field value is removed, since this one depends on the  | 
            ||
| 6072 | * specific FieldType, which is tested in a dedicated integration test.  | 
            ||
| 6073 | *  | 
            ||
| 6074 | * @param \eZ\Publish\API\Repository\Values\Content\Field[] $fields  | 
            ||
| 6075 | *  | 
            ||
| 6076 | * @return \eZ\Publish\API\Repository\Values\Content\Field[]  | 
            ||
| 6077 | */  | 
            ||
| 6078 | private function normalizeFields(array $fields)  | 
            ||
| 6105 | |||
| 6106 | /**  | 
            ||
| 6107 | * Returns a filtered set of the default fields fixture.  | 
            ||
| 6108 | *  | 
            ||
| 6109 | * @param string $languageCode  | 
            ||
| 6110 | *  | 
            ||
| 6111 | * @return \eZ\Publish\API\Repository\Values\Content\Field[]  | 
            ||
| 6112 | */  | 
            ||
| 6113 | private function createLocaleFieldsFixture($languageCode)  | 
            ||
| 6124 | |||
| 6125 | /**  | 
            ||
| 6126 | * Asserts that given Content has default ContentStates.  | 
            ||
| 6127 | *  | 
            ||
| 6128 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo  | 
            ||
| 6129 | */  | 
            ||
| 6130 | View Code Duplication | private function assertDefaultContentStates(ContentInfo $contentInfo)  | 
            |
| 6149 | |||
| 6150 | /**  | 
            ||
| 6151 | * Assert that given Content has no references to a translation specified by the $languageCode.  | 
            ||
| 6152 | *  | 
            ||
| 6153 | * @param string $languageCode  | 
            ||
| 6154 | * @param int $contentId  | 
            ||
| 6155 | */  | 
            ||
| 6156 | private function assertTranslationDoesNotExist($languageCode, $contentId)  | 
            ||
| 6178 | |||
| 6179 | /**  | 
            ||
| 6180 | * Returns the default fixture of fields used in most tests.  | 
            ||
| 6181 | *  | 
            ||
| 6182 | * @return \eZ\Publish\API\Repository\Values\Content\Field[]  | 
            ||
| 6183 | */  | 
            ||
| 6184 | private function createFieldsFixture()  | 
            ||
| 6225 | |||
| 6226 | /**  | 
            ||
| 6227 | * Gets expected property values for the "Media" ContentInfo ValueObject.  | 
            ||
| 6228 | *  | 
            ||
| 6229 | * @return array  | 
            ||
| 6230 | */  | 
            ||
| 6231 | View Code Duplication | private function getExpectedMediaContentInfoProperties()  | 
            |
| 6250 | }  | 
            ||
| 6251 | 
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.