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 |
||
33 | class ContentServiceTest extends BaseContentServiceTest |
||
34 | { |
||
35 | /** |
||
36 | * Test for the newContentCreateStruct() method. |
||
37 | * |
||
38 | * @see \eZ\Publish\API\Repository\ContentService::newContentCreateStruct() |
||
39 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeByIdentifier |
||
40 | * @group user |
||
41 | * @group field-type |
||
42 | */ |
||
43 | public function testNewContentCreateStruct() |
||
60 | |||
61 | /** |
||
62 | * Test for the createContent() method. |
||
63 | * |
||
64 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
65 | * |
||
66 | * @see \eZ\Publish\API\Repository\ContentService::createContent() |
||
67 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testNewContentCreateStruct |
||
68 | * @group user |
||
69 | * @group field-type |
||
70 | */ |
||
71 | public function testCreateContent() |
||
99 | |||
100 | /** |
||
101 | * Test for the createContent() method. |
||
102 | * |
||
103 | * Tests made for issue #EZP-20955 where Anonymous user is granted access to create content |
||
104 | * and should have access to do that. |
||
105 | * |
||
106 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
107 | * |
||
108 | * @see \eZ\Publish\API\Repository\ContentService::createContent() |
||
109 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testNewContentCreateStruct |
||
110 | * @group user |
||
111 | * @group field-type |
||
112 | */ |
||
113 | public function testCreateContentAndPublishWithPrivilegedAnonymousUser() |
||
163 | |||
164 | /** |
||
165 | * Test for the createContent() method. |
||
166 | * |
||
167 | * @param \eZ\Publish\API\Repository\Values\Content\Content $content |
||
168 | * |
||
169 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
170 | * |
||
171 | * @see \eZ\Publish\API\Repository\ContentService::createContent() |
||
172 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent |
||
173 | */ |
||
174 | public function testCreateContentSetsContentInfo($content) |
||
180 | |||
181 | /** |
||
182 | * Test for the createContent() method. |
||
183 | * |
||
184 | * @param \eZ\Publish\API\Repository\Values\Content\Content $content |
||
185 | * |
||
186 | * @see \eZ\Publish\API\Repository\ContentService::createContent() |
||
187 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentSetsContentInfo |
||
188 | */ |
||
189 | public function testCreateContentSetsExpectedContentInfo($content) |
||
219 | |||
220 | /** |
||
221 | * Test for the createContent() method. |
||
222 | * |
||
223 | * @param \eZ\Publish\API\Repository\Values\Content\Content $content |
||
224 | * |
||
225 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
226 | * |
||
227 | * @see \eZ\Publish\API\Repository\ContentService::createContent() |
||
228 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent |
||
229 | */ |
||
230 | public function testCreateContentSetsVersionInfo($content) |
||
236 | |||
237 | /** |
||
238 | * Test for the createContent() method. |
||
239 | * |
||
240 | * @param \eZ\Publish\API\Repository\Values\Content\Content $content |
||
241 | * |
||
242 | * @see \eZ\Publish\API\Repository\ContentService::createContent() |
||
243 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentSetsVersionInfo |
||
244 | */ |
||
245 | public function testCreateContentSetsExpectedVersionInfo($content) |
||
246 | { |
||
247 | $this->assertEquals( |
||
248 | array( |
||
249 | 'status' => VersionInfo::STATUS_DRAFT, |
||
250 | 'versionNo' => 1, |
||
251 | 'creatorId' => $this->getRepository()->getCurrentUser()->id, |
||
252 | 'initialLanguageCode' => 'eng-US', |
||
253 | ), |
||
254 | array( |
||
255 | 'status' => $content->getVersionInfo()->status, |
||
256 | 'versionNo' => $content->getVersionInfo()->versionNo, |
||
257 | 'creatorId' => $content->getVersionInfo()->creatorId, |
||
258 | 'initialLanguageCode' => $content->getVersionInfo()->initialLanguageCode, |
||
259 | ) |
||
260 | ); |
||
261 | $this->assertTrue($content->getVersionInfo()->isDraft()); |
||
262 | $this->assertFalse($content->getVersionInfo()->isPublished()); |
||
263 | $this->assertFalse($content->getVersionInfo()->isArchived()); |
||
264 | } |
||
265 | |||
266 | /** |
||
267 | * Test for the createContent() method. |
||
268 | * |
||
269 | * @see \eZ\Publish\API\Repository\ContentService::createContent() |
||
270 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
||
271 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent |
||
272 | */ |
||
273 | public function testCreateContentThrowsInvalidArgumentException() |
||
274 | { |
||
275 | if ($this->isVersion4()) { |
||
276 | $this->markTestSkipped('This test requires eZ Publish 5'); |
||
277 | } |
||
278 | |||
279 | $repository = $this->getRepository(); |
||
280 | |||
281 | /* BEGIN: Use Case */ |
||
282 | $contentTypeService = $repository->getContentTypeService(); |
||
283 | $contentService = $repository->getContentService(); |
||
284 | |||
285 | $contentType = $contentTypeService->loadContentTypeByIdentifier('forum'); |
||
286 | |||
287 | $contentCreate1 = $contentService->newContentCreateStruct($contentType, 'eng-US'); |
||
288 | $contentCreate1->setField('name', 'An awesome Sidelfingen forum'); |
||
289 | |||
290 | $contentCreate1->remoteId = 'abcdef0123456789abcdef0123456789'; |
||
291 | $contentCreate1->alwaysAvailable = true; |
||
292 | |||
293 | $draft = $contentService->createContent($contentCreate1); |
||
294 | $contentService->publishVersion($draft->versionInfo); |
||
295 | |||
296 | $contentCreate2 = $contentService->newContentCreateStruct($contentType, 'eng-GB'); |
||
297 | $contentCreate2->setField('name', 'An awesome Bielefeld forum'); |
||
298 | |||
299 | $contentCreate2->remoteId = 'abcdef0123456789abcdef0123456789'; |
||
300 | $contentCreate2->alwaysAvailable = false; |
||
301 | |||
302 | // This call will fail with an "InvalidArgumentException", because the |
||
303 | // remoteId is already in use. |
||
304 | $contentService->createContent($contentCreate2); |
||
305 | /* END: Use Case */ |
||
306 | } |
||
307 | |||
308 | /** |
||
309 | * Test for the createContent() method. |
||
310 | * |
||
311 | * @see \eZ\Publish\API\Repository\ContentService::createContent() |
||
312 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
||
313 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent |
||
314 | */ |
||
315 | View Code Duplication | public function testCreateContentThrowsInvalidArgumentExceptionOnFieldTypeNotAccept() |
|
316 | { |
||
317 | $repository = $this->getRepository(); |
||
318 | |||
319 | /* BEGIN: Use Case */ |
||
320 | $contentTypeService = $repository->getContentTypeService(); |
||
321 | $contentService = $repository->getContentService(); |
||
322 | |||
323 | $contentType = $contentTypeService->loadContentTypeByIdentifier('forum'); |
||
324 | |||
325 | $contentCreate = $contentService->newContentCreateStruct($contentType, 'eng-US'); |
||
326 | // The name field does only accept strings and null as its values |
||
327 | $contentCreate->setField('name', new \stdClass()); |
||
328 | |||
329 | // Throws InvalidArgumentException since the name field is filled |
||
330 | // improperly |
||
331 | $draft = $contentService->createContent($contentCreate); |
||
332 | /* END: Use Case */ |
||
333 | } |
||
334 | |||
335 | /** |
||
336 | * Test for the createContent() method. |
||
337 | * |
||
338 | * @see \eZ\Publish\API\Repository\ContentService::createContent() |
||
339 | * @expectedException \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException |
||
340 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent |
||
341 | */ |
||
342 | public function testCreateContentThrowsContentFieldValidationException() |
||
343 | { |
||
344 | $repository = $this->getRepository(); |
||
345 | |||
346 | /* BEGIN: Use Case */ |
||
347 | $contentTypeService = $repository->getContentTypeService(); |
||
348 | $contentService = $repository->getContentService(); |
||
349 | |||
350 | $contentType = $contentTypeService->loadContentTypeByIdentifier('folder'); |
||
351 | |||
352 | $contentCreate1 = $contentService->newContentCreateStruct($contentType, 'eng-US'); |
||
353 | $contentCreate1->setField('name', 'An awesome Sidelfingen folder'); |
||
354 | // Violates string length constraint |
||
355 | $contentCreate1->setField('short_name', str_repeat('a', 200)); |
||
356 | |||
357 | // Throws ContentFieldValidationException, since short_name does not pass |
||
358 | // validation of the string length validator |
||
359 | $draft = $contentService->createContent($contentCreate1); |
||
360 | /* END: Use Case */ |
||
361 | } |
||
362 | |||
363 | /** |
||
364 | * Test for the createContent() method. |
||
365 | * |
||
366 | * @see \eZ\Publish\API\Repository\ContentService::createContent() |
||
367 | * @expectedException \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException |
||
368 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent |
||
369 | */ |
||
370 | View Code Duplication | public function testCreateContentRequiredFieldMissing() |
|
371 | { |
||
372 | $repository = $this->getRepository(); |
||
373 | |||
374 | /* BEGIN: Use Case */ |
||
375 | $contentTypeService = $repository->getContentTypeService(); |
||
376 | $contentService = $repository->getContentService(); |
||
377 | |||
378 | $contentType = $contentTypeService->loadContentTypeByIdentifier('forum'); |
||
379 | |||
380 | $contentCreate1 = $contentService->newContentCreateStruct($contentType, 'eng-US'); |
||
381 | // Required field "name" is not set |
||
382 | |||
383 | // Throws a ContentFieldValidationException, since a required field is |
||
384 | // missing |
||
385 | $draft = $contentService->createContent($contentCreate1); |
||
386 | /* END: Use Case */ |
||
387 | } |
||
388 | |||
389 | /** |
||
390 | * Test for the createContent() method. |
||
391 | * |
||
392 | * NOTE: We have bidirectional dependencies between the ContentService and |
||
393 | * the LocationService, so that we cannot use PHPUnit's test dependencies |
||
394 | * here. |
||
395 | * |
||
396 | * @see \eZ\Publish\API\Repository\ContentService::createContent($contentCreateStruct, $locationCreateStructs) |
||
397 | * @depend(s) eZ\Publish\API\Repository\Tests\LocationServiceTest::testCreateLocation |
||
398 | * @depend(s) eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocationByRemoteId |
||
399 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent |
||
400 | * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException |
||
401 | * @group user |
||
402 | */ |
||
403 | public function testCreateContentWithLocationCreateParameterDoesNotCreateLocationImmediately() |
||
404 | { |
||
405 | $repository = $this->getRepository(); |
||
406 | |||
407 | $locationService = $repository->getLocationService(); |
||
408 | |||
409 | /* BEGIN: Use Case */ |
||
410 | $draft = $this->createContentDraftVersion1(); |
||
411 | |||
412 | // The location will not have been created, yet, so this throws an |
||
413 | // exception |
||
414 | $location = $locationService->loadLocationByRemoteId( |
||
415 | '0123456789abcdef0123456789abcdef' |
||
416 | ); |
||
417 | /* END: Use Case */ |
||
418 | } |
||
419 | |||
420 | /** |
||
421 | * Test for the createContent() method. |
||
422 | * |
||
423 | * @see \eZ\Publish\API\Repository\ContentService::createContent($contentCreateStruct, $locationCreateStructs) |
||
424 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
||
425 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentWithLocationCreateParameterDoesNotCreateLocationImmediately |
||
426 | */ |
||
427 | public function testCreateContentThrowsInvalidArgumentExceptionWithLocationCreateParameter() |
||
428 | { |
||
429 | $repository = $this->getRepository(); |
||
430 | |||
431 | $parentLocationId = $this->generateId('location', 56); |
||
432 | /* BEGIN: Use Case */ |
||
433 | // $parentLocationId is a valid location ID |
||
434 | |||
435 | $contentService = $repository->getContentService(); |
||
436 | $contentTypeService = $repository->getContentTypeService(); |
||
437 | $locationService = $repository->getLocationService(); |
||
438 | |||
439 | // Load content type |
||
440 | $contentType = $contentTypeService->loadContentTypeByIdentifier('forum'); |
||
441 | |||
442 | // Configure new locations |
||
443 | $locationCreate1 = $locationService->newLocationCreateStruct($parentLocationId); |
||
444 | |||
445 | $locationCreate1->priority = 23; |
||
446 | $locationCreate1->hidden = true; |
||
447 | $locationCreate1->remoteId = '0123456789abcdef0123456789aaaaaa'; |
||
448 | $locationCreate1->sortField = Location::SORT_FIELD_NODE_ID; |
||
449 | $locationCreate1->sortOrder = Location::SORT_ORDER_DESC; |
||
450 | |||
451 | $locationCreate2 = $locationService->newLocationCreateStruct($parentLocationId); |
||
452 | |||
453 | $locationCreate2->priority = 42; |
||
454 | $locationCreate2->hidden = true; |
||
455 | $locationCreate2->remoteId = '0123456789abcdef0123456789bbbbbb'; |
||
456 | $locationCreate2->sortField = Location::SORT_FIELD_NODE_ID; |
||
457 | $locationCreate2->sortOrder = Location::SORT_ORDER_DESC; |
||
458 | |||
459 | // Configure new content object |
||
460 | $contentCreate = $contentService->newContentCreateStruct($contentType, 'eng-US'); |
||
461 | |||
462 | $contentCreate->setField('name', 'A awesome Sindelfingen forum'); |
||
463 | $contentCreate->remoteId = 'abcdef0123456789abcdef0123456789'; |
||
464 | $contentCreate->alwaysAvailable = true; |
||
465 | |||
466 | // Create new content object under the specified location |
||
467 | $draft = $contentService->createContent( |
||
468 | $contentCreate, |
||
469 | array($locationCreate1) |
||
470 | ); |
||
471 | $contentService->publishVersion($draft->versionInfo); |
||
472 | |||
473 | // This call will fail with an "InvalidArgumentException", because the |
||
474 | // Content remoteId already exists, |
||
475 | $contentService->createContent( |
||
476 | $contentCreate, |
||
477 | array($locationCreate2) |
||
478 | ); |
||
479 | /* END: Use Case */ |
||
480 | } |
||
481 | |||
482 | /** |
||
483 | * Test for the loadContentInfo() method. |
||
484 | * |
||
485 | * @see \eZ\Publish\API\Repository\ContentService::loadContentInfo() |
||
486 | * @group user |
||
487 | */ |
||
488 | View Code Duplication | public function testLoadContentInfo() |
|
489 | { |
||
490 | $repository = $this->getRepository(); |
||
491 | |||
492 | $mediaFolderId = $this->generateId('object', 41); |
||
493 | /* BEGIN: Use Case */ |
||
494 | $contentService = $repository->getContentService(); |
||
495 | |||
496 | // Load the ContentInfo for "Media" folder |
||
497 | $contentInfo = $contentService->loadContentInfo($mediaFolderId); |
||
498 | /* END: Use Case */ |
||
499 | |||
500 | $this->assertInstanceOf( |
||
501 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\ContentInfo', |
||
502 | $contentInfo |
||
503 | ); |
||
504 | |||
505 | return $contentInfo; |
||
506 | } |
||
507 | |||
508 | /** |
||
509 | * Test for the returned value of the loadContentInfo() method. |
||
510 | * |
||
511 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo |
||
512 | * @covers \eZ\Publish\API\Repository\ContentService::loadContentInfo |
||
513 | * |
||
514 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
515 | */ |
||
516 | public function testLoadContentInfoSetsExpectedContentInfo(ContentInfo $contentInfo) |
||
517 | { |
||
518 | $this->assertPropertiesCorrectUnsorted( |
||
519 | $this->getExpectedMediaContentInfoProperties(), |
||
520 | $contentInfo |
||
521 | ); |
||
522 | } |
||
523 | |||
524 | /** |
||
525 | * Test for the loadContentInfo() method. |
||
526 | * |
||
527 | * @see \eZ\Publish\API\Repository\ContentService::loadContentInfo() |
||
528 | * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException |
||
529 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo |
||
530 | */ |
||
531 | View Code Duplication | public function testLoadContentInfoThrowsNotFoundException() |
|
532 | { |
||
533 | $repository = $this->getRepository(); |
||
534 | |||
535 | $nonExistentContentId = $this->generateId('object', self::DB_INT_MAX); |
||
536 | /* BEGIN: Use Case */ |
||
537 | $contentService = $repository->getContentService(); |
||
538 | |||
539 | // This call will fail with a NotFoundException |
||
540 | $contentService->loadContentInfo($nonExistentContentId); |
||
541 | /* END: Use Case */ |
||
542 | } |
||
543 | |||
544 | /** |
||
545 | * Test for the loadContentInfoByRemoteId() method. |
||
546 | * |
||
547 | * @see \eZ\Publish\API\Repository\ContentService::loadContentInfoByRemoteId() |
||
548 | */ |
||
549 | public function testLoadContentInfoByRemoteId() |
||
550 | { |
||
551 | $repository = $this->getRepository(); |
||
552 | |||
553 | /* BEGIN: Use Case */ |
||
554 | $contentService = $repository->getContentService(); |
||
555 | |||
556 | // Load the ContentInfo for "Media" folder |
||
557 | $contentInfo = $contentService->loadContentInfoByRemoteId('faaeb9be3bd98ed09f606fc16d144eca'); |
||
558 | /* END: Use Case */ |
||
559 | |||
560 | $this->assertInstanceOf('\\eZ\\Publish\\API\\Repository\\Values\\Content\\ContentInfo', $contentInfo); |
||
561 | |||
562 | return $contentInfo; |
||
563 | } |
||
564 | |||
565 | /** |
||
566 | * Test for the returned value of the loadContentInfoByRemoteId() method. |
||
567 | * |
||
568 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfoByRemoteId |
||
569 | * @covers \eZ\Publish\API\Repository\ContentService::loadContentInfoByRemoteId |
||
570 | * |
||
571 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
572 | */ |
||
573 | View Code Duplication | public function testLoadContentInfoByRemoteIdSetsExpectedContentInfo(ContentInfo $contentInfo) |
|
574 | { |
||
575 | $this->assertPropertiesCorrectUnsorted( |
||
576 | [ |
||
577 | 'id' => 10, |
||
578 | 'contentTypeId' => 4, |
||
579 | 'name' => 'Anonymous User', |
||
580 | 'sectionId' => 2, |
||
581 | 'currentVersionNo' => 2, |
||
582 | 'published' => true, |
||
583 | 'ownerId' => 14, |
||
584 | 'modificationDate' => $this->createDateTime(1072180405), |
||
585 | 'publishedDate' => $this->createDateTime(1033920665), |
||
586 | 'alwaysAvailable' => 1, |
||
587 | 'remoteId' => 'faaeb9be3bd98ed09f606fc16d144eca', |
||
588 | 'mainLanguageCode' => 'eng-US', |
||
589 | 'mainLocationId' => 45, |
||
590 | ], |
||
591 | $contentInfo |
||
592 | ); |
||
593 | } |
||
594 | |||
595 | /** |
||
596 | * Test for the loadContentInfoByRemoteId() method. |
||
597 | * |
||
598 | * @see \eZ\Publish\API\Repository\ContentService::loadContentInfoByRemoteId() |
||
599 | * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException |
||
600 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfoByRemoteId |
||
601 | */ |
||
602 | public function testLoadContentInfoByRemoteIdThrowsNotFoundException() |
||
603 | { |
||
604 | $repository = $this->getRepository(); |
||
605 | |||
606 | /* BEGIN: Use Case */ |
||
607 | $contentService = $repository->getContentService(); |
||
608 | |||
609 | // This call will fail with a NotFoundException |
||
610 | $contentService->loadContentInfoByRemoteId('abcdefghijklmnopqrstuvwxyz0123456789'); |
||
611 | /* END: Use Case */ |
||
612 | } |
||
613 | |||
614 | /** |
||
615 | * Test for the loadVersionInfo() method. |
||
616 | * |
||
617 | * @see \eZ\Publish\API\Repository\ContentService::loadVersionInfo() |
||
618 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo |
||
619 | * @group user |
||
620 | */ |
||
621 | public function testLoadVersionInfo() |
||
622 | { |
||
623 | $repository = $this->getRepository(); |
||
624 | |||
625 | $mediaFolderId = $this->generateId('object', 41); |
||
626 | /* BEGIN: Use Case */ |
||
627 | // $mediaFolderId contains the ID of the "Media" folder |
||
628 | |||
629 | $contentService = $repository->getContentService(); |
||
630 | |||
631 | // Load the ContentInfo for "Media" folder |
||
632 | $contentInfo = $contentService->loadContentInfo($mediaFolderId); |
||
633 | |||
634 | // Now load the current version info of the "Media" folder |
||
635 | $versionInfo = $contentService->loadVersionInfo($contentInfo); |
||
636 | /* END: Use Case */ |
||
637 | |||
638 | $this->assertInstanceOf( |
||
639 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\VersionInfo', |
||
640 | $versionInfo |
||
641 | ); |
||
642 | } |
||
643 | |||
644 | /** |
||
645 | * Test for the loadVersionInfoById() method. |
||
646 | * |
||
647 | * @see \eZ\Publish\API\Repository\ContentService::loadVersionInfoById() |
||
648 | */ |
||
649 | View Code Duplication | public function testLoadVersionInfoById() |
|
650 | { |
||
651 | $repository = $this->getRepository(); |
||
652 | |||
653 | $mediaFolderId = $this->generateId('object', 41); |
||
654 | /* BEGIN: Use Case */ |
||
655 | // $mediaFolderId contains the ID of the "Media" folder |
||
656 | |||
657 | $contentService = $repository->getContentService(); |
||
658 | |||
659 | // Load the VersionInfo for "Media" folder |
||
660 | $versionInfo = $contentService->loadVersionInfoById($mediaFolderId); |
||
661 | /* END: Use Case */ |
||
662 | |||
663 | $this->assertInstanceOf( |
||
664 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\VersionInfo', |
||
665 | $versionInfo |
||
666 | ); |
||
667 | |||
668 | return $versionInfo; |
||
669 | } |
||
670 | |||
671 | /** |
||
672 | * Test for the returned value of the loadVersionInfoById() method. |
||
673 | * |
||
674 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadVersionInfoById |
||
675 | * @covers \eZ\Publish\Core\Repository\ContentService::loadVersionInfoById |
||
676 | * |
||
677 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
678 | */ |
||
679 | public function testLoadVersionInfoByIdSetsExpectedVersionInfo(VersionInfo $versionInfo) |
||
680 | { |
||
681 | $this->assertPropertiesCorrect( |
||
682 | [ |
||
683 | 'names' => [ |
||
684 | 'eng-US' => 'Media', |
||
685 | ], |
||
686 | 'contentInfo' => new ContentInfo($this->getExpectedMediaContentInfoProperties()), |
||
687 | 'id' => 472, |
||
688 | 'versionNo' => 1, |
||
689 | 'modificationDate' => $this->createDateTime(1060695457), |
||
690 | 'creatorId' => 14, |
||
691 | 'creationDate' => $this->createDateTime(1060695450), |
||
692 | 'status' => VersionInfo::STATUS_PUBLISHED, |
||
693 | 'initialLanguageCode' => 'eng-US', |
||
694 | 'languageCodes' => [ |
||
695 | 'eng-US', |
||
696 | ], |
||
697 | ], |
||
698 | $versionInfo |
||
699 | ); |
||
700 | $this->assertTrue($versionInfo->isPublished()); |
||
701 | $this->assertFalse($versionInfo->isDraft()); |
||
702 | $this->assertFalse($versionInfo->isArchived()); |
||
703 | } |
||
704 | |||
705 | /** |
||
706 | * Test for the loadVersionInfoById() method. |
||
707 | * |
||
708 | * @see \eZ\Publish\API\Repository\ContentService::loadVersionInfoById() |
||
709 | * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException |
||
710 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadVersionInfoById |
||
711 | */ |
||
712 | View Code Duplication | public function testLoadVersionInfoByIdThrowsNotFoundException() |
|
713 | { |
||
714 | $repository = $this->getRepository(); |
||
715 | |||
716 | $nonExistentContentId = $this->generateId('object', self::DB_INT_MAX); |
||
717 | /* BEGIN: Use Case */ |
||
718 | $contentService = $repository->getContentService(); |
||
719 | |||
720 | // This call will fail with a "NotFoundException" |
||
721 | $contentService->loadVersionInfoById($nonExistentContentId); |
||
722 | /* END: Use Case */ |
||
723 | } |
||
724 | |||
725 | /** |
||
726 | * Test for the loadContentByContentInfo() method. |
||
727 | * |
||
728 | * @see \eZ\Publish\API\Repository\ContentService::loadContentByContentInfo() |
||
729 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo |
||
730 | */ |
||
731 | public function testLoadContentByContentInfo() |
||
732 | { |
||
733 | $repository = $this->getRepository(); |
||
734 | |||
735 | $mediaFolderId = $this->generateId('object', 41); |
||
736 | /* BEGIN: Use Case */ |
||
737 | // $mediaFolderId contains the ID of the "Media" folder |
||
738 | |||
739 | $contentService = $repository->getContentService(); |
||
740 | |||
741 | // Load the ContentInfo for "Media" folder |
||
742 | $contentInfo = $contentService->loadContentInfo($mediaFolderId); |
||
743 | |||
744 | // Now load the current content version for the info instance |
||
745 | $content = $contentService->loadContentByContentInfo($contentInfo); |
||
746 | /* END: Use Case */ |
||
747 | |||
748 | $this->assertInstanceOf( |
||
749 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\Content', |
||
750 | $content |
||
751 | ); |
||
752 | } |
||
753 | |||
754 | /** |
||
755 | * Test for the loadContentByVersionInfo() method. |
||
756 | * |
||
757 | * @see \eZ\Publish\API\Repository\ContentService::loadContentByVersionInfo() |
||
758 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadVersionInfo |
||
759 | */ |
||
760 | public function testLoadContentByVersionInfo() |
||
761 | { |
||
762 | $repository = $this->getRepository(); |
||
763 | |||
764 | $mediaFolderId = $this->generateId('object', 41); |
||
765 | /* BEGIN: Use Case */ |
||
766 | // $mediaFolderId contains the ID of the "Media" folder |
||
767 | |||
768 | $contentService = $repository->getContentService(); |
||
769 | |||
770 | // Load the ContentInfo for "Media" folder |
||
771 | $contentInfo = $contentService->loadContentInfo($mediaFolderId); |
||
772 | |||
773 | // Load the current VersionInfo |
||
774 | $versionInfo = $contentService->loadVersionInfo($contentInfo); |
||
775 | |||
776 | // Now load the current content version for the info instance |
||
777 | $content = $contentService->loadContentByVersionInfo($versionInfo); |
||
778 | /* END: Use Case */ |
||
779 | |||
780 | $this->assertInstanceOf( |
||
781 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\Content', |
||
782 | $content |
||
783 | ); |
||
784 | } |
||
785 | |||
786 | /** |
||
787 | * Test for the loadContent() method. |
||
788 | * |
||
789 | * @see \eZ\Publish\API\Repository\ContentService::loadContent() |
||
790 | * @group user |
||
791 | * @group field-type |
||
792 | */ |
||
793 | View Code Duplication | public function testLoadContent() |
|
794 | { |
||
795 | $repository = $this->getRepository(); |
||
796 | |||
797 | $mediaFolderId = $this->generateId('object', 41); |
||
798 | /* BEGIN: Use Case */ |
||
799 | // $mediaFolderId contains the ID of the "Media" folder |
||
800 | |||
801 | $contentService = $repository->getContentService(); |
||
802 | |||
803 | // Load the Content for "Media" folder, any language and current version |
||
804 | $content = $contentService->loadContent($mediaFolderId); |
||
805 | /* END: Use Case */ |
||
806 | |||
807 | $this->assertInstanceOf( |
||
808 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\Content', |
||
809 | $content |
||
810 | ); |
||
811 | } |
||
812 | |||
813 | /** |
||
814 | * Test for the loadContent() method. |
||
815 | * |
||
816 | * @see \eZ\Publish\API\Repository\ContentService::loadContent() |
||
817 | * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException |
||
818 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContent |
||
819 | */ |
||
820 | View Code Duplication | public function testLoadContentThrowsNotFoundException() |
|
821 | { |
||
822 | $repository = $this->getRepository(); |
||
823 | |||
824 | $nonExistentContentId = $this->generateId('object', self::DB_INT_MAX); |
||
825 | /* BEGIN: Use Case */ |
||
826 | $contentService = $repository->getContentService(); |
||
827 | |||
828 | // This call will fail with a "NotFoundException" |
||
829 | $contentService->loadContent($nonExistentContentId); |
||
830 | /* END: Use Case */ |
||
831 | } |
||
832 | |||
833 | /** |
||
834 | * Data provider for testLoadContentByRemoteId(). |
||
835 | * |
||
836 | * @return array |
||
837 | */ |
||
838 | public function contentRemoteIdVersionLanguageProvider() |
||
839 | { |
||
840 | return [ |
||
841 | ['f5c88a2209584891056f987fd965b0ba', null, null], |
||
842 | ['f5c88a2209584891056f987fd965b0ba', ['eng-US'], null], |
||
843 | ['f5c88a2209584891056f987fd965b0ba', null, 1], |
||
844 | ['f5c88a2209584891056f987fd965b0ba', ['eng-US'], 1], |
||
845 | ['a6e35cbcb7cd6ae4b691f3eee30cd262', null, null], |
||
846 | ['a6e35cbcb7cd6ae4b691f3eee30cd262', ['eng-US'], null], |
||
847 | ['a6e35cbcb7cd6ae4b691f3eee30cd262', null, 1], |
||
848 | ['a6e35cbcb7cd6ae4b691f3eee30cd262', ['eng-US'], 1], |
||
849 | ]; |
||
850 | } |
||
851 | |||
852 | /** |
||
853 | * Test for the loadContentByRemoteId() method. |
||
854 | * |
||
855 | * @covers \eZ\Publish\API\Repository\ContentService::loadContentByRemoteId |
||
856 | * @dataProvider contentRemoteIdVersionLanguageProvider |
||
857 | * |
||
858 | * @param string $remoteId |
||
859 | * @param array|null $languages |
||
860 | * @param int $versionNo |
||
861 | */ |
||
862 | public function testLoadContentByRemoteId($remoteId, $languages, $versionNo) |
||
863 | { |
||
864 | $repository = $this->getRepository(); |
||
865 | |||
866 | $contentService = $repository->getContentService(); |
||
867 | |||
868 | $content = $contentService->loadContentByRemoteId($remoteId, $languages, $versionNo); |
||
869 | |||
870 | $this->assertInstanceOf( |
||
871 | Content::class, |
||
872 | $content |
||
873 | ); |
||
874 | |||
875 | $this->assertEquals($remoteId, $content->contentInfo->remoteId); |
||
876 | if ($languages !== null) { |
||
877 | $this->assertEquals($languages, $content->getVersionInfo()->languageCodes); |
||
878 | } |
||
879 | $this->assertEquals($versionNo ?: 1, $content->getVersionInfo()->versionNo); |
||
880 | } |
||
881 | |||
882 | /** |
||
883 | * Test for the loadContentByRemoteId() method. |
||
884 | * |
||
885 | * @see \eZ\Publish\API\Repository\ContentService::loadContentByRemoteId() |
||
886 | * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException |
||
887 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByRemoteId |
||
888 | */ |
||
889 | public function testLoadContentByRemoteIdThrowsNotFoundException() |
||
890 | { |
||
891 | $repository = $this->getRepository(); |
||
892 | |||
893 | /* BEGIN: Use Case */ |
||
894 | $contentService = $repository->getContentService(); |
||
895 | |||
896 | // This call will fail with a "NotFoundException", because no content |
||
897 | // object exists for the given remoteId |
||
898 | $contentService->loadContentByRemoteId('a1b1c1d1e1f1a2b2c2d2e2f2a3b3c3d3'); |
||
899 | /* END: Use Case */ |
||
900 | } |
||
901 | |||
902 | /** |
||
903 | * Test for the publishVersion() method. |
||
904 | * |
||
905 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
906 | * |
||
907 | * @see \eZ\Publish\API\Repository\ContentService::publishVersion() |
||
908 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContent |
||
909 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo |
||
910 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadVersionInfo |
||
911 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentWithLocationCreateParameterDoesNotCreateLocationImmediately |
||
912 | * @group user |
||
913 | * @group field-type |
||
914 | */ |
||
915 | public function testPublishVersion() |
||
916 | { |
||
917 | $time = time(); |
||
918 | /* BEGIN: Use Case */ |
||
919 | $content = $this->createContentVersion1(); |
||
920 | /* END: Use Case */ |
||
921 | |||
922 | $this->assertInstanceOf(Content::class, $content); |
||
923 | $this->assertTrue($content->contentInfo->published); |
||
924 | $this->assertEquals(VersionInfo::STATUS_PUBLISHED, $content->versionInfo->status); |
||
925 | $this->assertGreaterThanOrEqual($time, $content->contentInfo->publishedDate->getTimestamp()); |
||
926 | $this->assertGreaterThanOrEqual($time, $content->contentInfo->modificationDate->getTimestamp()); |
||
927 | $this->assertTrue($content->versionInfo->isPublished()); |
||
928 | $this->assertFalse($content->versionInfo->isDraft()); |
||
929 | $this->assertFalse($content->versionInfo->isArchived()); |
||
930 | |||
931 | return $content; |
||
932 | } |
||
933 | |||
934 | /** |
||
935 | * Test for the publishVersion() method. |
||
936 | * |
||
937 | * @param \eZ\Publish\API\Repository\Values\Content\Content $content |
||
938 | * |
||
939 | * @see \eZ\Publish\API\Repository\ContentService::publishVersion() |
||
940 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion |
||
941 | */ |
||
942 | public function testPublishVersionSetsExpectedContentInfo($content) |
||
943 | { |
||
944 | $this->assertEquals( |
||
945 | array( |
||
946 | $content->id, |
||
947 | true, |
||
948 | 1, |
||
949 | 'abcdef0123456789abcdef0123456789', |
||
950 | 'eng-US', |
||
951 | $this->getRepository()->getCurrentUser()->id, |
||
952 | true, |
||
953 | ), |
||
954 | array( |
||
955 | $content->contentInfo->id, |
||
956 | $content->contentInfo->alwaysAvailable, |
||
957 | $content->contentInfo->currentVersionNo, |
||
958 | $content->contentInfo->remoteId, |
||
959 | $content->contentInfo->mainLanguageCode, |
||
960 | $content->contentInfo->ownerId, |
||
961 | $content->contentInfo->published, |
||
962 | ) |
||
963 | ); |
||
964 | |||
965 | $this->assertNotNull($content->contentInfo->mainLocationId); |
||
966 | $date = new \DateTime('1984/01/01'); |
||
967 | $this->assertGreaterThan( |
||
968 | $date->getTimestamp(), |
||
969 | $content->contentInfo->publishedDate->getTimestamp() |
||
970 | ); |
||
971 | } |
||
972 | |||
973 | /** |
||
974 | * Test for the publishVersion() method. |
||
975 | * |
||
976 | * @param \eZ\Publish\API\Repository\Values\Content\Content $content |
||
977 | * |
||
978 | * @see \eZ\Publish\API\Repository\ContentService::publishVersion() |
||
979 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion |
||
980 | */ |
||
981 | public function testPublishVersionSetsExpectedVersionInfo($content) |
||
982 | { |
||
983 | $this->assertEquals( |
||
984 | array( |
||
985 | $this->getRepository()->getCurrentUser()->id, |
||
986 | 'eng-US', |
||
987 | VersionInfo::STATUS_PUBLISHED, |
||
988 | 1, |
||
989 | ), |
||
990 | array( |
||
991 | $content->getVersionInfo()->creatorId, |
||
992 | $content->getVersionInfo()->initialLanguageCode, |
||
993 | $content->getVersionInfo()->status, |
||
994 | $content->getVersionInfo()->versionNo, |
||
995 | ) |
||
996 | ); |
||
997 | |||
998 | $date = new \DateTime('1984/01/01'); |
||
999 | $this->assertGreaterThan( |
||
1000 | $date->getTimestamp(), |
||
1001 | $content->getVersionInfo()->modificationDate->getTimestamp() |
||
1002 | ); |
||
1003 | |||
1004 | $this->assertNotNull($content->getVersionInfo()->modificationDate); |
||
1005 | $this->assertTrue($content->getVersionInfo()->isPublished()); |
||
1006 | $this->assertFalse($content->getVersionInfo()->isDraft()); |
||
1007 | $this->assertFalse($content->getVersionInfo()->isArchived()); |
||
1008 | } |
||
1009 | |||
1010 | /** |
||
1011 | * Test for the publishVersion() method. |
||
1012 | * |
||
1013 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
1014 | * |
||
1015 | * @see \eZ\Publish\API\Repository\ContentService::publishVersion() |
||
1016 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentWithLocationCreateParameterDoesNotCreateLocationImmediately |
||
1017 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion |
||
1018 | */ |
||
1019 | public function testPublishVersionCreatesLocationsDefinedOnCreate() |
||
1020 | { |
||
1021 | $repository = $this->getRepository(); |
||
1022 | |||
1023 | /* BEGIN: Use Case */ |
||
1024 | $content = $this->createContentVersion1(); |
||
1025 | /* END: Use Case */ |
||
1026 | |||
1027 | $locationService = $repository->getLocationService(); |
||
1028 | $location = $locationService->loadLocationByRemoteId( |
||
1029 | '0123456789abcdef0123456789abcdef' |
||
1030 | ); |
||
1031 | |||
1032 | $this->assertEquals( |
||
1033 | $location->getContentInfo(), |
||
1034 | $content->getVersionInfo()->getContentInfo() |
||
1035 | ); |
||
1036 | |||
1037 | return array($content, $location); |
||
1038 | } |
||
1039 | |||
1040 | /** |
||
1041 | * Test for the publishVersion() method. |
||
1042 | * |
||
1043 | * @see \eZ\Publish\API\Repository\ContentService::publishVersion() |
||
1044 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionCreatesLocationsDefinedOnCreate |
||
1045 | */ |
||
1046 | public function testCreateContentWithLocationCreateParameterCreatesExpectedLocation(array $testData) |
||
1047 | { |
||
1048 | /** @var \eZ\Publish\API\Repository\Values\Content\Content $content */ |
||
1049 | /** @var \eZ\Publish\API\Repository\Values\Content\Location $location */ |
||
1050 | list($content, $location) = $testData; |
||
1051 | |||
1052 | $parentLocationId = $this->generateId('location', 56); |
||
1053 | $parentLocation = $this->getRepository()->getLocationService()->loadLocation($parentLocationId); |
||
1054 | $mainLocationId = $content->getVersionInfo()->getContentInfo()->mainLocationId; |
||
1055 | |||
1056 | $this->assertPropertiesCorrect( |
||
1057 | array( |
||
1058 | 'id' => $mainLocationId, |
||
1059 | 'priority' => 23, |
||
1060 | 'hidden' => true, |
||
1061 | 'invisible' => true, |
||
1062 | 'remoteId' => '0123456789abcdef0123456789abcdef', |
||
1063 | 'parentLocationId' => $parentLocationId, |
||
1064 | 'pathString' => $parentLocation->pathString . $mainLocationId . '/', |
||
1065 | 'depth' => $parentLocation->depth + 1, |
||
1066 | 'sortField' => Location::SORT_FIELD_NODE_ID, |
||
1067 | 'sortOrder' => Location::SORT_ORDER_DESC, |
||
1068 | ), |
||
1069 | $location |
||
1070 | ); |
||
1071 | } |
||
1072 | |||
1073 | /** |
||
1074 | * Test for the publishVersion() method. |
||
1075 | * |
||
1076 | * @see \eZ\Publish\API\Repository\ContentService::publishVersion() |
||
1077 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
||
1078 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion |
||
1079 | */ |
||
1080 | View Code Duplication | public function testPublishVersionThrowsBadStateException() |
|
1081 | { |
||
1082 | $repository = $this->getRepository(); |
||
1083 | |||
1084 | $contentService = $repository->getContentService(); |
||
1085 | |||
1086 | /* BEGIN: Use Case */ |
||
1087 | $draft = $this->createContentDraftVersion1(); |
||
1088 | |||
1089 | // Publish the content draft |
||
1090 | $contentService->publishVersion($draft->getVersionInfo()); |
||
1091 | |||
1092 | // This call will fail with a "BadStateException", because the version |
||
1093 | // is already published. |
||
1094 | $contentService->publishVersion($draft->getVersionInfo()); |
||
1095 | /* END: Use Case */ |
||
1096 | } |
||
1097 | |||
1098 | /** |
||
1099 | * Test that publishVersion() does not affect publishedDate (assuming previous version exists). |
||
1100 | * |
||
1101 | * @covers \eZ\Publish\API\Repository\ContentService::publishVersion |
||
1102 | */ |
||
1103 | public function testPublishVersionDoesNotChangePublishedDate() |
||
1104 | { |
||
1105 | $repository = $this->getRepository(); |
||
1106 | |||
1107 | $contentService = $repository->getContentService(); |
||
1108 | |||
1109 | $publishedContent = $this->createContentVersion1(); |
||
1110 | |||
1111 | // force timestamps to differ |
||
1112 | sleep(1); |
||
1113 | |||
1114 | $contentDraft = $contentService->createContentDraft($publishedContent->contentInfo); |
||
1115 | $contentUpdateStruct = $contentService->newContentUpdateStruct(); |
||
1116 | $contentUpdateStruct->setField('name', 'New name'); |
||
1117 | $contentDraft = $contentService->updateContent($contentDraft->versionInfo, $contentUpdateStruct); |
||
1118 | $republishedContent = $contentService->publishVersion($contentDraft->versionInfo); |
||
1119 | |||
1120 | $this->assertEquals( |
||
1121 | $publishedContent->contentInfo->publishedDate->getTimestamp(), |
||
1122 | $republishedContent->contentInfo->publishedDate->getTimestamp() |
||
1123 | ); |
||
1124 | $this->assertGreaterThan( |
||
1125 | $publishedContent->contentInfo->modificationDate->getTimestamp(), |
||
1126 | $republishedContent->contentInfo->modificationDate->getTimestamp() |
||
1127 | ); |
||
1128 | } |
||
1129 | |||
1130 | /** |
||
1131 | * Test for the createContentDraft() method. |
||
1132 | * |
||
1133 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
1134 | * |
||
1135 | * @see \eZ\Publish\API\Repository\ContentService::createContentDraft() |
||
1136 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion |
||
1137 | * @group user |
||
1138 | */ |
||
1139 | public function testCreateContentDraft() |
||
1140 | { |
||
1141 | $repository = $this->getRepository(); |
||
1142 | |||
1143 | $contentService = $repository->getContentService(); |
||
1144 | |||
1145 | /* BEGIN: Use Case */ |
||
1146 | $content = $this->createContentVersion1(); |
||
1147 | |||
1148 | // Now we create a new draft from the published content |
||
1149 | $draftedContent = $contentService->createContentDraft($content->contentInfo); |
||
1150 | /* END: Use Case */ |
||
1151 | |||
1152 | $this->assertInstanceOf( |
||
1153 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\Content', |
||
1154 | $draftedContent |
||
1155 | ); |
||
1156 | |||
1157 | return $draftedContent; |
||
1158 | } |
||
1159 | |||
1160 | /** |
||
1161 | * Test for the createContentDraft() method. |
||
1162 | * |
||
1163 | * Test that editor has access to edit own draft. |
||
1164 | * Note: Editors have access to version_read, which is needed to load content drafts. |
||
1165 | * |
||
1166 | * @see \eZ\Publish\API\Repository\ContentService::createContentDraft() |
||
1167 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion |
||
1168 | * @group user |
||
1169 | */ |
||
1170 | View Code Duplication | public function testCreateContentDraftAndLoadAccess() |
|
1171 | { |
||
1172 | $repository = $this->getRepository(); |
||
1173 | |||
1174 | /* BEGIN: Use Case */ |
||
1175 | $user = $this->createUserVersion1(); |
||
1176 | |||
1177 | // Set new editor as user |
||
1178 | $repository->setCurrentUser($user); |
||
1179 | |||
1180 | // Create draft |
||
1181 | $draft = $this->createContentDraftVersion1(2, 'folder'); |
||
1182 | |||
1183 | // Try to load the draft |
||
1184 | $contentService = $repository->getContentService(); |
||
1185 | $loadedDraft = $contentService->loadContent($draft->id); |
||
1186 | |||
1187 | /* END: Use Case */ |
||
1188 | |||
1189 | $this->assertEquals($draft->id, $loadedDraft->id); |
||
1190 | } |
||
1191 | |||
1192 | /** |
||
1193 | * Test for the createContentDraft() method. |
||
1194 | * |
||
1195 | * @param \eZ\Publish\API\Repository\Values\Content\Content $draft |
||
1196 | * |
||
1197 | * @see \eZ\Publish\API\Repository\ContentService::createContentDraft() |
||
1198 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraft |
||
1199 | */ |
||
1200 | public function testCreateContentDraftSetsExpectedProperties($draft) |
||
1201 | { |
||
1202 | $this->assertEquals( |
||
1203 | array( |
||
1204 | 'fieldCount' => 2, |
||
1205 | 'relationCount' => 0, |
||
1206 | ), |
||
1207 | array( |
||
1208 | 'fieldCount' => count($draft->getFields()), |
||
1209 | 'relationCount' => count($this->getRepository()->getContentService()->loadRelations($draft->getVersionInfo())), |
||
1210 | ) |
||
1211 | ); |
||
1212 | } |
||
1213 | |||
1214 | /** |
||
1215 | * Test for the createContentDraft() method. |
||
1216 | * |
||
1217 | * @param \eZ\Publish\API\Repository\Values\Content\Content $draft |
||
1218 | * |
||
1219 | * @see \eZ\Publish\API\Repository\ContentService::createContentDraft() |
||
1220 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraft |
||
1221 | */ |
||
1222 | public function testCreateContentDraftSetsContentInfo($draft) |
||
1223 | { |
||
1224 | $contentInfo = $draft->contentInfo; |
||
1225 | |||
1226 | $this->assertEquals( |
||
1227 | array( |
||
1228 | $draft->id, |
||
1229 | true, |
||
1230 | 1, |
||
1231 | 'eng-US', |
||
1232 | $this->getRepository()->getCurrentUser()->id, |
||
1233 | 'abcdef0123456789abcdef0123456789', |
||
1234 | 1, |
||
1235 | ), |
||
1236 | array( |
||
1237 | $contentInfo->id, |
||
1238 | $contentInfo->alwaysAvailable, |
||
1239 | $contentInfo->currentVersionNo, |
||
1240 | $contentInfo->mainLanguageCode, |
||
1241 | $contentInfo->ownerId, |
||
1242 | $contentInfo->remoteId, |
||
1243 | $contentInfo->sectionId, |
||
1244 | ) |
||
1245 | ); |
||
1246 | } |
||
1247 | |||
1248 | /** |
||
1249 | * Test for the createContentDraft() method. |
||
1250 | * |
||
1251 | * @param \eZ\Publish\API\Repository\Values\Content\Content $draft |
||
1252 | * |
||
1253 | * @see \eZ\Publish\API\Repository\ContentService::createContentDraft() |
||
1254 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraft |
||
1255 | */ |
||
1256 | public function testCreateContentDraftSetsVersionInfo($draft) |
||
1257 | { |
||
1258 | $versionInfo = $draft->getVersionInfo(); |
||
1259 | |||
1260 | $this->assertEquals( |
||
1261 | array( |
||
1262 | 'creatorId' => $this->getRepository()->getCurrentUser()->id, |
||
1263 | 'initialLanguageCode' => 'eng-US', |
||
1264 | 'languageCodes' => array(0 => 'eng-US'), |
||
1265 | 'status' => VersionInfo::STATUS_DRAFT, |
||
1266 | 'versionNo' => 2, |
||
1267 | ), |
||
1268 | array( |
||
1269 | 'creatorId' => $versionInfo->creatorId, |
||
1270 | 'initialLanguageCode' => $versionInfo->initialLanguageCode, |
||
1271 | 'languageCodes' => $versionInfo->languageCodes, |
||
1272 | 'status' => $versionInfo->status, |
||
1273 | 'versionNo' => $versionInfo->versionNo, |
||
1274 | ) |
||
1275 | ); |
||
1276 | $this->assertTrue($versionInfo->isDraft()); |
||
1277 | $this->assertFalse($versionInfo->isPublished()); |
||
1278 | $this->assertFalse($versionInfo->isArchived()); |
||
1279 | } |
||
1280 | |||
1281 | /** |
||
1282 | * Test for the createContentDraft() method. |
||
1283 | * |
||
1284 | * @param \eZ\Publish\API\Repository\Values\Content\Content $draft |
||
1285 | * |
||
1286 | * @see \eZ\Publish\API\Repository\ContentService::createContentDraft() |
||
1287 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraft |
||
1288 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadVersionInfo |
||
1289 | */ |
||
1290 | public function testCreateContentDraftLoadVersionInfoStillLoadsPublishedVersion($draft) |
||
1291 | { |
||
1292 | $repository = $this->getRepository(); |
||
1293 | |||
1294 | $contentService = $repository->getContentService(); |
||
1295 | |||
1296 | /* BEGIN: Use Case */ |
||
1297 | $content = $this->createContentVersion1(); |
||
1298 | |||
1299 | // Now we create a new draft from the published content |
||
1300 | $contentService->createContentDraft($content->contentInfo); |
||
1301 | |||
1302 | // This call will still load the published version |
||
1303 | $versionInfoPublished = $contentService->loadVersionInfo($content->contentInfo); |
||
1304 | /* END: Use Case */ |
||
1305 | |||
1306 | $this->assertEquals(1, $versionInfoPublished->versionNo); |
||
1307 | } |
||
1308 | |||
1309 | /** |
||
1310 | * Test for the createContentDraft() method. |
||
1311 | * |
||
1312 | * @see \eZ\Publish\API\Repository\ContentService::createContentDraft() |
||
1313 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContent |
||
1314 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraft |
||
1315 | */ |
||
1316 | public function testCreateContentDraftLoadContentStillLoadsPublishedVersion() |
||
1317 | { |
||
1318 | $repository = $this->getRepository(); |
||
1319 | |||
1320 | $contentService = $repository->getContentService(); |
||
1321 | |||
1322 | /* BEGIN: Use Case */ |
||
1323 | $content = $this->createContentVersion1(); |
||
1324 | |||
1325 | // Now we create a new draft from the published content |
||
1326 | $contentService->createContentDraft($content->contentInfo); |
||
1327 | |||
1328 | // This call will still load the published content version |
||
1329 | $contentPublished = $contentService->loadContent($content->id); |
||
1330 | /* END: Use Case */ |
||
1331 | |||
1332 | $this->assertEquals(1, $contentPublished->getVersionInfo()->versionNo); |
||
1333 | } |
||
1334 | |||
1335 | /** |
||
1336 | * Test for the createContentDraft() method. |
||
1337 | * |
||
1338 | * @see \eZ\Publish\API\Repository\ContentService::createContentDraft() |
||
1339 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByRemoteId |
||
1340 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraft |
||
1341 | */ |
||
1342 | public function testCreateContentDraftLoadContentByRemoteIdStillLoadsPublishedVersion() |
||
1343 | { |
||
1344 | $repository = $this->getRepository(); |
||
1345 | |||
1346 | $contentService = $repository->getContentService(); |
||
1347 | |||
1348 | /* BEGIN: Use Case */ |
||
1349 | $content = $this->createContentVersion1(); |
||
1350 | |||
1351 | // Now we create a new draft from the published content |
||
1352 | $contentService->createContentDraft($content->contentInfo); |
||
1353 | |||
1354 | // This call will still load the published content version |
||
1355 | $contentPublished = $contentService->loadContentByRemoteId('abcdef0123456789abcdef0123456789'); |
||
1356 | /* END: Use Case */ |
||
1357 | |||
1358 | $this->assertEquals(1, $contentPublished->getVersionInfo()->versionNo); |
||
1359 | } |
||
1360 | |||
1361 | /** |
||
1362 | * Test for the createContentDraft() method. |
||
1363 | * |
||
1364 | * @see \eZ\Publish\API\Repository\ContentService::createContentDraft() |
||
1365 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByContentInfo |
||
1366 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraft |
||
1367 | */ |
||
1368 | public function testCreateContentDraftLoadContentByContentInfoStillLoadsPublishedVersion() |
||
1369 | { |
||
1370 | $repository = $this->getRepository(); |
||
1371 | |||
1372 | $contentService = $repository->getContentService(); |
||
1373 | |||
1374 | /* BEGIN: Use Case */ |
||
1375 | $content = $this->createContentVersion1(); |
||
1376 | |||
1377 | // Now we create a new draft from the published content |
||
1378 | $contentService->createContentDraft($content->contentInfo); |
||
1379 | |||
1380 | // This call will still load the published content version |
||
1381 | $contentPublished = $contentService->loadContentByContentInfo($content->contentInfo); |
||
1382 | /* END: Use Case */ |
||
1383 | |||
1384 | $this->assertEquals(1, $contentPublished->getVersionInfo()->versionNo); |
||
1385 | } |
||
1386 | |||
1387 | /** |
||
1388 | * Test for the newContentUpdateStruct() method. |
||
1389 | * |
||
1390 | * @covers \eZ\Publish\API\Repository\ContentService::newContentUpdateStruct |
||
1391 | * @group user |
||
1392 | */ |
||
1393 | public function testNewContentUpdateStruct() |
||
1394 | { |
||
1395 | $repository = $this->getRepository(); |
||
1396 | |||
1397 | /* BEGIN: Use Case */ |
||
1398 | $contentService = $repository->getContentService(); |
||
1399 | |||
1400 | $updateStruct = $contentService->newContentUpdateStruct(); |
||
1401 | /* END: Use Case */ |
||
1402 | |||
1403 | $this->assertInstanceOf( |
||
1404 | ContentUpdateStruct::class, |
||
1405 | $updateStruct |
||
1406 | ); |
||
1407 | |||
1408 | $this->assertPropertiesCorrect( |
||
1409 | [ |
||
1410 | 'initialLanguageCode' => null, |
||
1411 | 'fields' => [], |
||
1412 | ], |
||
1413 | $updateStruct |
||
1414 | ); |
||
1415 | } |
||
1416 | |||
1417 | /** |
||
1418 | * Test for the updateContent() method. |
||
1419 | * |
||
1420 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
1421 | * |
||
1422 | * @see \eZ\Publish\API\Repository\ContentService::updateContent() |
||
1423 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testNewContentUpdateStruct |
||
1424 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraft |
||
1425 | * @group user |
||
1426 | * @group field-type |
||
1427 | */ |
||
1428 | public function testUpdateContent() |
||
1429 | { |
||
1430 | /* BEGIN: Use Case */ |
||
1431 | $draftVersion2 = $this->createUpdatedDraftVersion2(); |
||
1432 | /* END: Use Case */ |
||
1433 | |||
1434 | $this->assertInstanceOf( |
||
1435 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\Content', |
||
1436 | $draftVersion2 |
||
1437 | ); |
||
1438 | |||
1439 | $this->assertEquals( |
||
1440 | $this->generateId('user', 10), |
||
1441 | $draftVersion2->versionInfo->creatorId, |
||
1442 | 'creatorId is not properly set on new Version' |
||
1443 | ); |
||
1444 | |||
1445 | return $draftVersion2; |
||
1446 | } |
||
1447 | |||
1448 | /** |
||
1449 | * Test for the updateContent_WithDifferentUser() method. |
||
1450 | * |
||
1451 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
1452 | * |
||
1453 | * @see \eZ\Publish\API\Repository\ContentService::updateContent() |
||
1454 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testNewContentUpdateStruct |
||
1455 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraft |
||
1456 | * @group user |
||
1457 | * @group field-type |
||
1458 | */ |
||
1459 | public function testUpdateContentWithDifferentUser() |
||
1460 | { |
||
1461 | /* BEGIN: Use Case */ |
||
1462 | $arrayWithDraftVersion2 = $this->createUpdatedDraftVersion2NotAdmin(); |
||
1463 | /* END: Use Case */ |
||
1464 | |||
1465 | $this->assertInstanceOf( |
||
1466 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\Content', |
||
1467 | $arrayWithDraftVersion2[0] |
||
1468 | ); |
||
1469 | |||
1470 | $this->assertEquals( |
||
1471 | $this->generateId('user', $arrayWithDraftVersion2[1]), |
||
1472 | $arrayWithDraftVersion2[0]->versionInfo->creatorId, |
||
1473 | 'creatorId is not properly set on new Version' |
||
1474 | ); |
||
1475 | |||
1476 | return $arrayWithDraftVersion2[0]; |
||
1477 | } |
||
1478 | |||
1479 | /** |
||
1480 | * Test for the updateContent() method. |
||
1481 | * |
||
1482 | * @param \eZ\Publish\API\Repository\Values\Content\Content $content |
||
1483 | * |
||
1484 | * @see \eZ\Publish\API\Repository\ContentService::updateContent() |
||
1485 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent |
||
1486 | */ |
||
1487 | public function testUpdateContentSetsExpectedFields($content) |
||
1488 | { |
||
1489 | $actual = $this->normalizeFields($content->getFields()); |
||
1490 | |||
1491 | $expected = array( |
||
1492 | new Field( |
||
1493 | array( |
||
1494 | 'id' => 0, |
||
1495 | 'value' => true, |
||
1496 | 'languageCode' => 'eng-GB', |
||
1497 | 'fieldDefIdentifier' => 'description', |
||
1498 | ) |
||
1499 | ), |
||
1500 | new Field( |
||
1501 | array( |
||
1502 | 'id' => 0, |
||
1503 | 'value' => true, |
||
1504 | 'languageCode' => 'eng-US', |
||
1505 | 'fieldDefIdentifier' => 'description', |
||
1506 | ) |
||
1507 | ), |
||
1508 | new Field( |
||
1509 | array( |
||
1510 | 'id' => 0, |
||
1511 | 'value' => true, |
||
1512 | 'languageCode' => 'eng-GB', |
||
1513 | 'fieldDefIdentifier' => 'name', |
||
1514 | ) |
||
1515 | ), |
||
1516 | new Field( |
||
1517 | array( |
||
1518 | 'id' => 0, |
||
1519 | 'value' => true, |
||
1520 | 'languageCode' => 'eng-US', |
||
1521 | 'fieldDefIdentifier' => 'name', |
||
1522 | ) |
||
1523 | ), |
||
1524 | ); |
||
1525 | |||
1526 | $this->assertEquals($expected, $actual); |
||
1527 | } |
||
1528 | |||
1529 | /** |
||
1530 | * Test for the updateContent() method. |
||
1531 | * |
||
1532 | * @see \eZ\Publish\API\Repository\ContentService::updateContent() |
||
1533 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
||
1534 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent |
||
1535 | */ |
||
1536 | public function testUpdateContentThrowsBadStateException() |
||
1537 | { |
||
1538 | $repository = $this->getRepository(); |
||
1539 | |||
1540 | $contentService = $repository->getContentService(); |
||
1541 | |||
1542 | /* BEGIN: Use Case */ |
||
1543 | $content = $this->createContentVersion1(); |
||
1544 | |||
1545 | // Now create an update struct and modify some fields |
||
1546 | $contentUpdateStruct = $contentService->newContentUpdateStruct(); |
||
1547 | $contentUpdateStruct->setField('title', 'An awesome² story about ezp.'); |
||
1548 | $contentUpdateStruct->setField('title', 'An awesome²³ story about ezp.', 'eng-GB'); |
||
1549 | |||
1550 | $contentUpdateStruct->initialLanguageCode = 'eng-US'; |
||
1551 | |||
1552 | // This call will fail with a "BadStateException", because $publishedContent |
||
1553 | // is not a draft. |
||
1554 | $contentService->updateContent( |
||
1555 | $content->getVersionInfo(), |
||
1556 | $contentUpdateStruct |
||
1557 | ); |
||
1558 | /* END: Use Case */ |
||
1559 | } |
||
1560 | |||
1561 | /** |
||
1562 | * Test for the updateContent() method. |
||
1563 | * |
||
1564 | * @see \eZ\Publish\API\Repository\ContentService::updateContent() |
||
1565 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
||
1566 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent |
||
1567 | */ |
||
1568 | View Code Duplication | public function testUpdateContentThrowsInvalidArgumentExceptionWhenFieldTypeDoesNotAccept() |
|
1569 | { |
||
1570 | $repository = $this->getRepository(); |
||
1571 | |||
1572 | $contentService = $repository->getContentService(); |
||
1573 | |||
1574 | /* BEGIN: Use Case */ |
||
1575 | $draft = $this->createContentDraftVersion1(); |
||
1576 | |||
1577 | // Now create an update struct and modify some fields |
||
1578 | $contentUpdateStruct = $contentService->newContentUpdateStruct(); |
||
1579 | // The name field does not accept a stdClass object as its input |
||
1580 | $contentUpdateStruct->setField('name', new \stdClass(), 'eng-US'); |
||
1581 | |||
1582 | // Throws an InvalidArgumentException, since the value for field "name" |
||
1583 | // is not accepted |
||
1584 | $contentService->updateContent( |
||
1585 | $draft->getVersionInfo(), |
||
1586 | $contentUpdateStruct |
||
1587 | ); |
||
1588 | /* END: Use Case */ |
||
1589 | } |
||
1590 | |||
1591 | /** |
||
1592 | * Test for the updateContent() method. |
||
1593 | * |
||
1594 | * @see \eZ\Publish\API\Repository\ContentService::updateContent() |
||
1595 | * @expectedException \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException |
||
1596 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent |
||
1597 | */ |
||
1598 | View Code Duplication | public function testUpdateContentWhenMandatoryFieldIsEmpty() |
|
1599 | { |
||
1600 | $repository = $this->getRepository(); |
||
1601 | |||
1602 | $contentService = $repository->getContentService(); |
||
1603 | |||
1604 | /* BEGIN: Use Case */ |
||
1605 | $draft = $this->createContentDraftVersion1(); |
||
1606 | |||
1607 | // Now create an update struct and set a mandatory field to null |
||
1608 | $contentUpdateStruct = $contentService->newContentUpdateStruct(); |
||
1609 | $contentUpdateStruct->setField('name', null); |
||
1610 | |||
1611 | // Don't set this, then the above call without languageCode will fail |
||
1612 | $contentUpdateStruct->initialLanguageCode = 'eng-US'; |
||
1613 | |||
1614 | // This call will fail with a "ContentFieldValidationException", because the |
||
1615 | // mandatory "name" field is empty. |
||
1616 | $contentService->updateContent( |
||
1617 | $draft->getVersionInfo(), |
||
1618 | $contentUpdateStruct |
||
1619 | ); |
||
1620 | /* END: Use Case */ |
||
1621 | } |
||
1622 | |||
1623 | /** |
||
1624 | * Test for the updateContent() method. |
||
1625 | * |
||
1626 | * @see \eZ\Publish\API\Repository\ContentService::updateContent() |
||
1627 | * @expectedException \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException |
||
1628 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent |
||
1629 | */ |
||
1630 | public function testUpdateContentThrowsContentFieldValidationException() |
||
1631 | { |
||
1632 | $repository = $this->getRepository(); |
||
1633 | |||
1634 | /* BEGIN: Use Case */ |
||
1635 | $contentTypeService = $repository->getContentTypeService(); |
||
1636 | $contentService = $repository->getContentService(); |
||
1637 | |||
1638 | $contentType = $contentTypeService->loadContentTypeByIdentifier('folder'); |
||
1639 | |||
1640 | $contentCreate = $contentService->newContentCreateStruct($contentType, 'eng-US'); |
||
1641 | $contentCreate->setField('name', 'An awesome Sidelfingen folder'); |
||
1642 | |||
1643 | $draft = $contentService->createContent($contentCreate); |
||
1644 | |||
1645 | $contentUpdate = $contentService->newContentUpdateStruct(); |
||
1646 | // Violates string length constraint |
||
1647 | $contentUpdate->setField('short_name', str_repeat('a', 200), 'eng-US'); |
||
1648 | |||
1649 | // Throws ContentFieldValidationException because the string length |
||
1650 | // validation of the field "short_name" fails |
||
1651 | $contentService->updateContent($draft->getVersionInfo(), $contentUpdate); |
||
1652 | /* END: Use Case */ |
||
1653 | } |
||
1654 | |||
1655 | /** |
||
1656 | * Test for the updateContent() method. |
||
1657 | * |
||
1658 | * @see \eZ\Publish\API\Repository\ContentService::updateContent() |
||
1659 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent |
||
1660 | */ |
||
1661 | public function testUpdateContentWithNotUpdatingMandatoryField() |
||
1662 | { |
||
1663 | $repository = $this->getRepository(); |
||
1664 | |||
1665 | $contentService = $repository->getContentService(); |
||
1666 | |||
1667 | /* BEGIN: Use Case */ |
||
1668 | $draft = $this->createContentDraftVersion1(); |
||
1669 | |||
1670 | // Now create an update struct which does not overwrite mandatory |
||
1671 | // fields |
||
1672 | $contentUpdateStruct = $contentService->newContentUpdateStruct(); |
||
1673 | $contentUpdateStruct->setField( |
||
1674 | 'description', |
||
1675 | '<?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"/>' |
||
1676 | ); |
||
1677 | |||
1678 | // Don't set this, then the above call without languageCode will fail |
||
1679 | $contentUpdateStruct->initialLanguageCode = 'eng-US'; |
||
1680 | |||
1681 | // This will only update the "description" field in the "eng-US" |
||
1682 | // language |
||
1683 | $updatedDraft = $contentService->updateContent( |
||
1684 | $draft->getVersionInfo(), |
||
1685 | $contentUpdateStruct |
||
1686 | ); |
||
1687 | /* END: Use Case */ |
||
1688 | |||
1689 | foreach ($updatedDraft->getFields() as $field) { |
||
1690 | if ($field->languageCode === 'eng-US' && $field->fieldDefIdentifier === 'name' && $field->value !== null) { |
||
1691 | // Found field |
||
1692 | return; |
||
1693 | } |
||
1694 | } |
||
1695 | $this->fail( |
||
1696 | 'Field with identifier "name" in language "eng-US" could not be found or has empty value.' |
||
1697 | ); |
||
1698 | } |
||
1699 | |||
1700 | /** |
||
1701 | * Test for the createContentDraft() method. |
||
1702 | * |
||
1703 | * @see \eZ\Publish\API\Repository\ContentService::createContentDraft($contentInfo, $versionInfo) |
||
1704 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent |
||
1705 | */ |
||
1706 | public function testCreateContentDraftWithSecondParameter() |
||
1707 | { |
||
1708 | $repository = $this->getRepository(); |
||
1709 | |||
1710 | $contentService = $repository->getContentService(); |
||
1711 | |||
1712 | /* BEGIN: Use Case */ |
||
1713 | $contentVersion2 = $this->createContentVersion2(); |
||
1714 | |||
1715 | // Now we create a new draft from the initial version |
||
1716 | $draftedContentReloaded = $contentService->createContentDraft( |
||
1717 | $contentVersion2->contentInfo, |
||
1718 | $contentVersion2->getVersionInfo() |
||
1719 | ); |
||
1720 | /* END: Use Case */ |
||
1721 | |||
1722 | $this->assertEquals(3, $draftedContentReloaded->getVersionInfo()->versionNo); |
||
1723 | } |
||
1724 | |||
1725 | /** |
||
1726 | * Test for the createContentDraft() method with third parameter. |
||
1727 | * |
||
1728 | * @covers \eZ\Publish\Core\Repository\ContentService::createContentDraft |
||
1729 | */ |
||
1730 | View Code Duplication | public function testCreateContentDraftWithThirdParameter() |
|
1731 | { |
||
1732 | $repository = $this->getRepository(); |
||
1733 | |||
1734 | $contentService = $repository->getContentService(); |
||
1735 | |||
1736 | $content = $contentService->loadContent(4); |
||
1737 | $user = $this->createUserVersion1(); |
||
1738 | |||
1739 | $draftContent = $contentService->createContentDraft( |
||
1740 | $content->contentInfo, |
||
1741 | $content->getVersionInfo(), |
||
1742 | $user |
||
1743 | ); |
||
1744 | |||
1745 | $this->assertInstanceOf( |
||
1746 | Content::class, |
||
1747 | $draftContent |
||
1748 | ); |
||
1749 | } |
||
1750 | |||
1751 | /** |
||
1752 | * Test for the publishVersion() method. |
||
1753 | * |
||
1754 | * @see \eZ\Publish\API\Repository\ContentService::publishVersion() |
||
1755 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion |
||
1756 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent |
||
1757 | */ |
||
1758 | View Code Duplication | public function testPublishVersionFromContentDraft() |
|
1759 | { |
||
1760 | $repository = $this->getRepository(); |
||
1761 | |||
1762 | $contentService = $repository->getContentService(); |
||
1763 | |||
1764 | /* BEGIN: Use Case */ |
||
1765 | $contentVersion2 = $this->createContentVersion2(); |
||
1766 | /* END: Use Case */ |
||
1767 | |||
1768 | $versionInfo = $contentService->loadVersionInfo($contentVersion2->contentInfo); |
||
1769 | |||
1770 | $this->assertEquals( |
||
1771 | array( |
||
1772 | 'status' => VersionInfo::STATUS_PUBLISHED, |
||
1773 | 'versionNo' => 2, |
||
1774 | ), |
||
1775 | array( |
||
1776 | 'status' => $versionInfo->status, |
||
1777 | 'versionNo' => $versionInfo->versionNo, |
||
1778 | ) |
||
1779 | ); |
||
1780 | $this->assertTrue($versionInfo->isPublished()); |
||
1781 | $this->assertFalse($versionInfo->isDraft()); |
||
1782 | $this->assertFalse($versionInfo->isArchived()); |
||
1783 | } |
||
1784 | |||
1785 | /** |
||
1786 | * Test for the publishVersion() method. |
||
1787 | * |
||
1788 | * @see \eZ\Publish\API\Repository\ContentService::publishVersion() |
||
1789 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft |
||
1790 | */ |
||
1791 | View Code Duplication | public function testPublishVersionFromContentDraftArchivesOldVersion() |
|
1792 | { |
||
1793 | $repository = $this->getRepository(); |
||
1794 | |||
1795 | $contentService = $repository->getContentService(); |
||
1796 | |||
1797 | /* BEGIN: Use Case */ |
||
1798 | $contentVersion2 = $this->createContentVersion2(); |
||
1799 | /* END: Use Case */ |
||
1800 | |||
1801 | $versionInfo = $contentService->loadVersionInfo($contentVersion2->contentInfo, 1); |
||
1802 | |||
1803 | $this->assertEquals( |
||
1804 | array( |
||
1805 | 'status' => VersionInfo::STATUS_ARCHIVED, |
||
1806 | 'versionNo' => 1, |
||
1807 | ), |
||
1808 | array( |
||
1809 | 'status' => $versionInfo->status, |
||
1810 | 'versionNo' => $versionInfo->versionNo, |
||
1811 | ) |
||
1812 | ); |
||
1813 | $this->assertTrue($versionInfo->isArchived()); |
||
1814 | $this->assertFalse($versionInfo->isDraft()); |
||
1815 | $this->assertFalse($versionInfo->isPublished()); |
||
1816 | } |
||
1817 | |||
1818 | /** |
||
1819 | * Test for the publishVersion() method. |
||
1820 | * |
||
1821 | * @see \eZ\Publish\API\Repository\ContentService::publishVersion() |
||
1822 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft |
||
1823 | */ |
||
1824 | public function testPublishVersionFromContentDraftUpdatesContentInfoCurrentVersion() |
||
1825 | { |
||
1826 | /* BEGIN: Use Case */ |
||
1827 | $contentVersion2 = $this->createContentVersion2(); |
||
1828 | /* END: Use Case */ |
||
1829 | |||
1830 | $this->assertEquals(2, $contentVersion2->contentInfo->currentVersionNo); |
||
1831 | } |
||
1832 | |||
1833 | /** |
||
1834 | * Test for the publishVersion() method. |
||
1835 | * |
||
1836 | * @see \eZ\Publish\API\Repository\ContentService::publishVersion() |
||
1837 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft |
||
1838 | */ |
||
1839 | public function testPublishVersionFromOldContentDraftArchivesNewerVersionNo() |
||
1840 | { |
||
1841 | $repository = $this->getRepository(); |
||
1842 | |||
1843 | $contentService = $repository->getContentService(); |
||
1844 | |||
1845 | /* BEGIN: Use Case */ |
||
1846 | $content = $this->createContentVersion1(); |
||
1847 | |||
1848 | // Create a new draft with versionNo = 2 |
||
1849 | $draftedContentVersion2 = $contentService->createContentDraft($content->contentInfo); |
||
1850 | |||
1851 | // Create another new draft with versionNo = 3 |
||
1852 | $draftedContentVersion3 = $contentService->createContentDraft($content->contentInfo); |
||
1853 | |||
1854 | // Publish draft with versionNo = 3 |
||
1855 | $contentService->publishVersion($draftedContentVersion3->getVersionInfo()); |
||
1856 | |||
1857 | // Publish the first draft with versionNo = 2 |
||
1858 | // currentVersionNo is now 2, versionNo 3 will be archived |
||
1859 | $publishedDraft = $contentService->publishVersion($draftedContentVersion2->getVersionInfo()); |
||
1860 | /* END: Use Case */ |
||
1861 | |||
1862 | $this->assertEquals(2, $publishedDraft->contentInfo->currentVersionNo); |
||
1863 | } |
||
1864 | |||
1865 | /** |
||
1866 | * Test for the publishVersion() method, and that it creates limited archives. |
||
1867 | * |
||
1868 | * @todo Adapt this when per content type archive limited is added on repository Content Type model. |
||
1869 | * @see \eZ\Publish\API\Repository\ContentService::publishVersion() |
||
1870 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft |
||
1871 | */ |
||
1872 | public function testPublishVersionNotCreatingUnlimitedArchives() |
||
1873 | { |
||
1874 | $repository = $this->getRepository(); |
||
1875 | |||
1876 | $contentService = $repository->getContentService(); |
||
1877 | |||
1878 | $content = $this->createContentVersion1(); |
||
1879 | |||
1880 | // Create a new draft with versionNo = 2 |
||
1881 | $draftedContentVersion = $contentService->createContentDraft($content->contentInfo); |
||
1882 | $contentService->publishVersion($draftedContentVersion->getVersionInfo()); |
||
1883 | |||
1884 | // Create a new draft with versionNo = 3 |
||
1885 | $draftedContentVersion = $contentService->createContentDraft($content->contentInfo); |
||
1886 | $contentService->publishVersion($draftedContentVersion->getVersionInfo()); |
||
1887 | |||
1888 | // Create a new draft with versionNo = 4 |
||
1889 | $draftedContentVersion = $contentService->createContentDraft($content->contentInfo); |
||
1890 | $contentService->publishVersion($draftedContentVersion->getVersionInfo()); |
||
1891 | |||
1892 | // Create a new draft with versionNo = 5 |
||
1893 | $draftedContentVersion = $contentService->createContentDraft($content->contentInfo); |
||
1894 | $contentService->publishVersion($draftedContentVersion->getVersionInfo()); |
||
1895 | |||
1896 | // Create a new draft with versionNo = 6 |
||
1897 | $draftedContentVersion = $contentService->createContentDraft($content->contentInfo); |
||
1898 | $contentService->publishVersion($draftedContentVersion->getVersionInfo()); |
||
1899 | |||
1900 | // Create a new draft with versionNo = 7 |
||
1901 | $draftedContentVersion = $contentService->createContentDraft($content->contentInfo); |
||
1902 | $contentService->publishVersion($draftedContentVersion->getVersionInfo()); |
||
1903 | |||
1904 | $versionInfoList = $contentService->loadVersions($content->contentInfo); |
||
1905 | |||
1906 | $this->assertEquals(6, count($versionInfoList)); |
||
1907 | $this->assertEquals(2, $versionInfoList[0]->versionNo); |
||
1908 | $this->assertEquals(7, $versionInfoList[5]->versionNo); |
||
1909 | |||
1910 | $this->assertEquals( |
||
1911 | [ |
||
1912 | VersionInfo::STATUS_ARCHIVED, |
||
1913 | VersionInfo::STATUS_ARCHIVED, |
||
1914 | VersionInfo::STATUS_ARCHIVED, |
||
1915 | VersionInfo::STATUS_ARCHIVED, |
||
1916 | VersionInfo::STATUS_ARCHIVED, |
||
1917 | VersionInfo::STATUS_PUBLISHED, |
||
1918 | ], |
||
1919 | [ |
||
1920 | $versionInfoList[0]->status, |
||
1921 | $versionInfoList[1]->status, |
||
1922 | $versionInfoList[2]->status, |
||
1923 | $versionInfoList[3]->status, |
||
1924 | $versionInfoList[4]->status, |
||
1925 | $versionInfoList[5]->status, |
||
1926 | ] |
||
1927 | ); |
||
1928 | } |
||
1929 | |||
1930 | /** |
||
1931 | * Test for the newContentMetadataUpdateStruct() method. |
||
1932 | * |
||
1933 | * @covers \eZ\Publish\API\Repository\ContentService::newContentMetadataUpdateStruct |
||
1934 | * @group user |
||
1935 | */ |
||
1936 | public function testNewContentMetadataUpdateStruct() |
||
1937 | { |
||
1938 | $repository = $this->getRepository(); |
||
1939 | |||
1940 | /* BEGIN: Use Case */ |
||
1941 | $contentService = $repository->getContentService(); |
||
1942 | |||
1943 | // Creates a new metadata update struct |
||
1944 | $metadataUpdate = $contentService->newContentMetadataUpdateStruct(); |
||
1945 | |||
1946 | foreach ($metadataUpdate as $propertyName => $propertyValue) { |
||
1947 | $this->assertNull($propertyValue, "Property '{$propertyName}' initial value should be null'"); |
||
1948 | } |
||
1949 | |||
1950 | $metadataUpdate->remoteId = 'aaaabbbbccccddddeeeeffff11112222'; |
||
1951 | $metadataUpdate->mainLanguageCode = 'eng-GB'; |
||
1952 | $metadataUpdate->alwaysAvailable = false; |
||
1953 | /* END: Use Case */ |
||
1954 | |||
1955 | $this->assertInstanceOf( |
||
1956 | ContentMetadataUpdateStruct::class, |
||
1957 | $metadataUpdate |
||
1958 | ); |
||
1959 | } |
||
1960 | |||
1961 | /** |
||
1962 | * Test for the updateContentMetadata() method. |
||
1963 | * |
||
1964 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
1965 | * |
||
1966 | * @see \eZ\Publish\API\Repository\ContentService::updateContentMetadata() |
||
1967 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion |
||
1968 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testNewContentMetadataUpdateStruct |
||
1969 | * @group user |
||
1970 | */ |
||
1971 | public function testUpdateContentMetadata() |
||
1972 | { |
||
1973 | $repository = $this->getRepository(); |
||
1974 | |||
1975 | $contentService = $repository->getContentService(); |
||
1976 | |||
1977 | /* BEGIN: Use Case */ |
||
1978 | $content = $this->createContentVersion1(); |
||
1979 | |||
1980 | // Creates a metadata update struct |
||
1981 | $metadataUpdate = $contentService->newContentMetadataUpdateStruct(); |
||
1982 | |||
1983 | $metadataUpdate->remoteId = 'aaaabbbbccccddddeeeeffff11112222'; |
||
1984 | $metadataUpdate->mainLanguageCode = 'eng-GB'; |
||
1985 | $metadataUpdate->alwaysAvailable = false; |
||
1986 | $metadataUpdate->publishedDate = $this->createDateTime(441759600); // 1984/01/01 |
||
1987 | $metadataUpdate->modificationDate = $this->createDateTime(441759600); // 1984/01/01 |
||
1988 | |||
1989 | // Update the metadata of the published content object |
||
1990 | $content = $contentService->updateContentMetadata( |
||
1991 | $content->contentInfo, |
||
1992 | $metadataUpdate |
||
1993 | ); |
||
1994 | /* END: Use Case */ |
||
1995 | |||
1996 | $this->assertInstanceOf( |
||
1997 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\Content', |
||
1998 | $content |
||
1999 | ); |
||
2000 | |||
2001 | return $content; |
||
2002 | } |
||
2003 | |||
2004 | /** |
||
2005 | * Test for the updateContentMetadata() method. |
||
2006 | * |
||
2007 | * @param \eZ\Publish\API\Repository\Values\Content\Content $content |
||
2008 | * |
||
2009 | * @see \eZ\Publish\API\Repository\ContentService::updateContentMetadata() |
||
2010 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContentMetadata |
||
2011 | */ |
||
2012 | public function testUpdateContentMetadataSetsExpectedProperties($content) |
||
2013 | { |
||
2014 | $contentInfo = $content->contentInfo; |
||
2015 | |||
2016 | $this->assertEquals( |
||
2017 | array( |
||
2018 | 'remoteId' => 'aaaabbbbccccddddeeeeffff11112222', |
||
2019 | 'sectionId' => $this->generateId('section', 1), |
||
2020 | 'alwaysAvailable' => false, |
||
2021 | 'currentVersionNo' => 1, |
||
2022 | 'mainLanguageCode' => 'eng-GB', |
||
2023 | 'modificationDate' => $this->createDateTime(441759600), |
||
2024 | 'ownerId' => $this->getRepository()->getCurrentUser()->id, |
||
2025 | 'published' => true, |
||
2026 | 'publishedDate' => $this->createDateTime(441759600), |
||
2027 | ), |
||
2028 | array( |
||
2029 | 'remoteId' => $contentInfo->remoteId, |
||
2030 | 'sectionId' => $contentInfo->sectionId, |
||
2031 | 'alwaysAvailable' => $contentInfo->alwaysAvailable, |
||
2032 | 'currentVersionNo' => $contentInfo->currentVersionNo, |
||
2033 | 'mainLanguageCode' => $contentInfo->mainLanguageCode, |
||
2034 | 'modificationDate' => $contentInfo->modificationDate, |
||
2035 | 'ownerId' => $contentInfo->ownerId, |
||
2036 | 'published' => $contentInfo->published, |
||
2037 | 'publishedDate' => $contentInfo->publishedDate, |
||
2038 | ) |
||
2039 | ); |
||
2040 | } |
||
2041 | |||
2042 | /** |
||
2043 | * Test for the updateContentMetadata() method. |
||
2044 | * |
||
2045 | * @param \eZ\Publish\API\Repository\Values\Content\Content $content |
||
2046 | * |
||
2047 | * @see \eZ\Publish\API\Repository\ContentService::updateContentMetadata() |
||
2048 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContentMetadata |
||
2049 | */ |
||
2050 | public function testUpdateContentMetadataNotUpdatesContentVersion($content) |
||
2051 | { |
||
2052 | $this->assertEquals(1, $content->getVersionInfo()->versionNo); |
||
2053 | } |
||
2054 | |||
2055 | /** |
||
2056 | * Test for the updateContentMetadata() method. |
||
2057 | * |
||
2058 | * @covers \eZ\Publish\API\Repository\ContentService::updateContentMetadata() |
||
2059 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
||
2060 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContentMetadata |
||
2061 | */ |
||
2062 | public function testUpdateContentMetadataThrowsInvalidArgumentExceptionOnDuplicateRemoteId() |
||
2063 | { |
||
2064 | $repository = $this->getRepository(); |
||
2065 | |||
2066 | $contentService = $repository->getContentService(); |
||
2067 | |||
2068 | /* BEGIN: Use Case */ |
||
2069 | // RemoteId of the "Media" page of an eZ Publish demo installation |
||
2070 | $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262'; |
||
2071 | |||
2072 | $content = $this->createContentVersion1(); |
||
2073 | |||
2074 | // Creates a metadata update struct |
||
2075 | $metadataUpdate = $contentService->newContentMetadataUpdateStruct(); |
||
2076 | $metadataUpdate->remoteId = $mediaRemoteId; |
||
2077 | |||
2078 | // This call will fail with an "InvalidArgumentException", because the |
||
2079 | // specified remoteId is already used by the "Media" page. |
||
2080 | $contentService->updateContentMetadata( |
||
2081 | $content->contentInfo, |
||
2082 | $metadataUpdate |
||
2083 | ); |
||
2084 | /* END: Use Case */ |
||
2085 | } |
||
2086 | |||
2087 | /** |
||
2088 | * Test for the updateContentMetadata() method. |
||
2089 | * |
||
2090 | * @covers \eZ\Publish\Core\Repository\ContentService::updateContentMetadata |
||
2091 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
||
2092 | */ |
||
2093 | public function testUpdateContentMetadataThrowsInvalidArgumentExceptionOnNoMetadataPropertiesSet() |
||
2094 | { |
||
2095 | $repository = $this->getRepository(); |
||
2096 | |||
2097 | $contentService = $repository->getContentService(); |
||
2098 | |||
2099 | $contentInfo = $contentService->loadContentInfo(4); |
||
2100 | $contentMetadataUpdateStruct = $contentService->newContentMetadataUpdateStruct(); |
||
2101 | |||
2102 | // Throws an exception because no properties are set in $contentMetadataUpdateStruct |
||
2103 | $contentService->updateContentMetadata($contentInfo, $contentMetadataUpdateStruct); |
||
2104 | } |
||
2105 | |||
2106 | /** |
||
2107 | * Test for the deleteContent() method. |
||
2108 | * |
||
2109 | * @see \eZ\Publish\API\Repository\ContentService::deleteContent() |
||
2110 | * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException |
||
2111 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft |
||
2112 | */ |
||
2113 | View Code Duplication | public function testDeleteContent() |
|
2114 | { |
||
2115 | $repository = $this->getRepository(); |
||
2116 | |||
2117 | $contentService = $repository->getContentService(); |
||
2118 | $locationService = $repository->getLocationService(); |
||
2119 | |||
2120 | /* BEGIN: Use Case */ |
||
2121 | $contentVersion2 = $this->createContentVersion2(); |
||
2122 | |||
2123 | // Load the locations for this content object |
||
2124 | $locations = $locationService->loadLocations($contentVersion2->contentInfo); |
||
2125 | |||
2126 | // This will delete the content, all versions and the associated locations |
||
2127 | $contentService->deleteContent($contentVersion2->contentInfo); |
||
2128 | /* END: Use Case */ |
||
2129 | |||
2130 | foreach ($locations as $location) { |
||
2131 | $locationService->loadLocation($location->id); |
||
2132 | } |
||
2133 | } |
||
2134 | |||
2135 | /** |
||
2136 | * Test for the deleteContent() method. |
||
2137 | * |
||
2138 | * Test for issue EZP-21057: |
||
2139 | * "contentService: Unable to delete a content with an empty file attribute" |
||
2140 | * |
||
2141 | * @see \eZ\Publish\API\Repository\ContentService::deleteContent() |
||
2142 | * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException |
||
2143 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft |
||
2144 | */ |
||
2145 | View Code Duplication | public function testDeleteContentWithEmptyBinaryField() |
|
2146 | { |
||
2147 | $repository = $this->getRepository(); |
||
2148 | |||
2149 | $contentService = $repository->getContentService(); |
||
2150 | $locationService = $repository->getLocationService(); |
||
2151 | |||
2152 | /* BEGIN: Use Case */ |
||
2153 | $contentVersion = $this->createContentVersion1EmptyBinaryField(); |
||
2154 | |||
2155 | // Load the locations for this content object |
||
2156 | $locations = $locationService->loadLocations($contentVersion->contentInfo); |
||
2157 | |||
2158 | // This will delete the content, all versions and the associated locations |
||
2159 | $contentService->deleteContent($contentVersion->contentInfo); |
||
2160 | /* END: Use Case */ |
||
2161 | |||
2162 | foreach ($locations as $location) { |
||
2163 | $locationService->loadLocation($location->id); |
||
2164 | } |
||
2165 | } |
||
2166 | |||
2167 | /** |
||
2168 | * Test for the loadContentDrafts() method. |
||
2169 | * |
||
2170 | * @see \eZ\Publish\API\Repository\ContentService::loadContentDrafts() |
||
2171 | */ |
||
2172 | public function testLoadContentDraftsReturnsEmptyArrayByDefault() |
||
2173 | { |
||
2174 | $repository = $this->getRepository(); |
||
2175 | |||
2176 | /* BEGIN: Use Case */ |
||
2177 | $contentService = $repository->getContentService(); |
||
2178 | |||
2179 | $contentDrafts = $contentService->loadContentDrafts(); |
||
2180 | /* END: Use Case */ |
||
2181 | |||
2182 | $this->assertSame(array(), $contentDrafts); |
||
2183 | } |
||
2184 | |||
2185 | /** |
||
2186 | * Test for the loadContentDrafts() method. |
||
2187 | * |
||
2188 | * @see \eZ\Publish\API\Repository\ContentService::loadContentDrafts() |
||
2189 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraft |
||
2190 | */ |
||
2191 | public function testLoadContentDrafts() |
||
2192 | { |
||
2193 | $repository = $this->getRepository(); |
||
2194 | |||
2195 | /* BEGIN: Use Case */ |
||
2196 | // Remote ids of the "Media" and the "eZ Publish Demo Design ..." page |
||
2197 | // of a eZ Publish demo installation. |
||
2198 | $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262'; |
||
2199 | $demoDesignRemoteId = '8b8b22fe3c6061ed500fbd2b377b885f'; |
||
2200 | |||
2201 | $contentService = $repository->getContentService(); |
||
2202 | |||
2203 | // "Media" content object |
||
2204 | $mediaContentInfo = $contentService->loadContentInfoByRemoteId($mediaRemoteId); |
||
2205 | |||
2206 | // "eZ Publish Demo Design ..." content object |
||
2207 | $demoDesignContentInfo = $contentService->loadContentInfoByRemoteId($demoDesignRemoteId); |
||
2208 | |||
2209 | // Create some drafts |
||
2210 | $contentService->createContentDraft($mediaContentInfo); |
||
2211 | $contentService->createContentDraft($demoDesignContentInfo); |
||
2212 | |||
2213 | // Now $contentDrafts should contain two drafted versions |
||
2214 | $draftedVersions = $contentService->loadContentDrafts(); |
||
2215 | /* END: Use Case */ |
||
2216 | |||
2217 | $actual = array( |
||
2218 | $draftedVersions[0]->status, |
||
2219 | $draftedVersions[0]->getContentInfo()->remoteId, |
||
2220 | $draftedVersions[1]->status, |
||
2221 | $draftedVersions[1]->getContentInfo()->remoteId, |
||
2222 | ); |
||
2223 | sort($actual, SORT_STRING); |
||
2224 | |||
2225 | $this->assertEquals( |
||
2226 | array( |
||
2227 | VersionInfo::STATUS_DRAFT, |
||
2228 | VersionInfo::STATUS_DRAFT, |
||
2229 | $demoDesignRemoteId, |
||
2230 | $mediaRemoteId, |
||
2231 | ), |
||
2232 | $actual |
||
2233 | ); |
||
2234 | } |
||
2235 | |||
2236 | /** |
||
2237 | * Test for the loadContentDrafts() method. |
||
2238 | * |
||
2239 | * @see \eZ\Publish\API\Repository\ContentService::loadContentDrafts($user) |
||
2240 | */ |
||
2241 | public function testLoadContentDraftsWithFirstParameter() |
||
2242 | { |
||
2243 | $repository = $this->getRepository(); |
||
2244 | |||
2245 | /* BEGIN: Use Case */ |
||
2246 | $user = $this->createUserVersion1(); |
||
2247 | |||
2248 | // Get current user |
||
2249 | $oldCurrentUser = $repository->getCurrentUser(); |
||
2250 | |||
2251 | // Set new editor as user |
||
2252 | $repository->setCurrentUser($user); |
||
2253 | |||
2254 | // Remote id of the "Media" content object in an eZ Publish demo installation. |
||
2255 | $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262'; |
||
2256 | |||
2257 | $contentService = $repository->getContentService(); |
||
2258 | |||
2259 | // "Media" content object |
||
2260 | $mediaContentInfo = $contentService->loadContentInfoByRemoteId($mediaRemoteId); |
||
2261 | |||
2262 | // Create a content draft |
||
2263 | $contentService->createContentDraft($mediaContentInfo); |
||
2264 | |||
2265 | // Reset to previous current user |
||
2266 | $repository->setCurrentUser($oldCurrentUser); |
||
2267 | |||
2268 | // Now $contentDrafts for the previous current user and the new user |
||
2269 | $newCurrentUserDrafts = $contentService->loadContentDrafts($user); |
||
2270 | $oldCurrentUserDrafts = $contentService->loadContentDrafts($oldCurrentUser); |
||
2271 | /* END: Use Case */ |
||
2272 | |||
2273 | $this->assertSame(array(), $oldCurrentUserDrafts); |
||
2274 | |||
2275 | $this->assertEquals( |
||
2276 | array( |
||
2277 | VersionInfo::STATUS_DRAFT, |
||
2278 | $mediaRemoteId, |
||
2279 | ), |
||
2280 | array( |
||
2281 | $newCurrentUserDrafts[0]->status, |
||
2282 | $newCurrentUserDrafts[0]->getContentInfo()->remoteId, |
||
2283 | ) |
||
2284 | ); |
||
2285 | $this->assertTrue($newCurrentUserDrafts[0]->isDraft()); |
||
2286 | $this->assertFalse($newCurrentUserDrafts[0]->isArchived()); |
||
2287 | $this->assertFalse($newCurrentUserDrafts[0]->isPublished()); |
||
2288 | } |
||
2289 | |||
2290 | /** |
||
2291 | * Test for the loadVersionInfo() method. |
||
2292 | * |
||
2293 | * @see \eZ\Publish\API\Repository\ContentService::loadVersionInfo($contentInfo, $versionNo) |
||
2294 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft |
||
2295 | */ |
||
2296 | public function testLoadVersionInfoWithSecondParameter() |
||
2297 | { |
||
2298 | $repository = $this->getRepository(); |
||
2299 | |||
2300 | $contentService = $repository->getContentService(); |
||
2301 | |||
2302 | /* BEGIN: Use Case */ |
||
2303 | $publishedContent = $this->createContentVersion1(); |
||
2304 | |||
2305 | $draftContent = $contentService->createContentDraft($publishedContent->contentInfo); |
||
2306 | |||
2307 | // Will return the VersionInfo of the $draftContent |
||
2308 | $versionInfo = $contentService->loadVersionInfoById($publishedContent->id, 2); |
||
2309 | /* END: Use Case */ |
||
2310 | |||
2311 | $this->assertEquals(2, $versionInfo->versionNo); |
||
2312 | |||
2313 | // Check that ContentInfo contained in VersionInfo has correct main Location id set |
||
2314 | $this->assertEquals( |
||
2315 | $publishedContent->getVersionInfo()->getContentInfo()->mainLocationId, |
||
2316 | $versionInfo->getContentInfo()->mainLocationId |
||
2317 | ); |
||
2318 | } |
||
2319 | |||
2320 | /** |
||
2321 | * Test for the loadVersionInfo() method. |
||
2322 | * |
||
2323 | * @see \eZ\Publish\API\Repository\ContentService::loadVersionInfo($contentInfo, $versionNo) |
||
2324 | * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException |
||
2325 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadVersionInfoWithSecondParameter |
||
2326 | */ |
||
2327 | public function testLoadVersionInfoThrowsNotFoundExceptionWithSecondParameter() |
||
2328 | { |
||
2329 | $repository = $this->getRepository(); |
||
2330 | |||
2331 | $contentService = $repository->getContentService(); |
||
2332 | |||
2333 | /* BEGIN: Use Case */ |
||
2334 | $draft = $this->createContentDraftVersion1(); |
||
2335 | |||
2336 | // This call will fail with a "NotFoundException", because not versionNo |
||
2337 | // 2 exists for this content object. |
||
2338 | $contentService->loadVersionInfo($draft->contentInfo, 2); |
||
2339 | /* END: Use Case */ |
||
2340 | } |
||
2341 | |||
2342 | /** |
||
2343 | * Test for the loadVersionInfoById() method. |
||
2344 | * |
||
2345 | * @see \eZ\Publish\API\Repository\ContentService::loadVersionInfoById($contentId, $versionNo) |
||
2346 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadVersionInfoWithSecondParameter |
||
2347 | */ |
||
2348 | public function testLoadVersionInfoByIdWithSecondParameter() |
||
2349 | { |
||
2350 | $repository = $this->getRepository(); |
||
2351 | |||
2352 | $contentService = $repository->getContentService(); |
||
2353 | |||
2354 | /* BEGIN: Use Case */ |
||
2355 | $publishedContent = $this->createContentVersion1(); |
||
2356 | |||
2357 | $draftContent = $contentService->createContentDraft($publishedContent->contentInfo); |
||
2358 | |||
2359 | // Will return the VersionInfo of the $draftContent |
||
2360 | $versionInfo = $contentService->loadVersionInfoById($publishedContent->id, 2); |
||
2361 | /* END: Use Case */ |
||
2362 | |||
2363 | $this->assertEquals(2, $versionInfo->versionNo); |
||
2364 | |||
2365 | // Check that ContentInfo contained in VersionInfo has correct main Location id set |
||
2366 | $this->assertEquals( |
||
2367 | $publishedContent->getVersionInfo()->getContentInfo()->mainLocationId, |
||
2368 | $versionInfo->getContentInfo()->mainLocationId |
||
2369 | ); |
||
2370 | |||
2371 | return [ |
||
2372 | 'versionInfo' => $versionInfo, |
||
2373 | 'draftContent' => $draftContent, |
||
2374 | ]; |
||
2375 | } |
||
2376 | |||
2377 | /** |
||
2378 | * Test for the returned value of the loadVersionInfoById() method. |
||
2379 | * |
||
2380 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadVersionInfoByIdWithSecondParameter |
||
2381 | * @covers \eZ\Publish\API\Repository\ContentService::loadVersionInfoById |
||
2382 | * |
||
2383 | * @param array $data |
||
2384 | */ |
||
2385 | public function testLoadVersionInfoByIdWithSecondParameterSetsExpectedVersionInfo(array $data) |
||
2386 | { |
||
2387 | /** @var \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo */ |
||
2388 | $versionInfo = $data['versionInfo']; |
||
2389 | /** @var \eZ\Publish\API\Repository\Values\Content\Content $draftContent */ |
||
2390 | $draftContent = $data['draftContent']; |
||
2391 | |||
2392 | $this->assertPropertiesCorrect( |
||
2393 | [ |
||
2394 | 'names' => [ |
||
2395 | 'eng-US' => 'An awesome forum', |
||
2396 | ], |
||
2397 | 'contentInfo' => new ContentInfo([ |
||
2398 | 'id' => $draftContent->contentInfo->id, |
||
2399 | 'contentTypeId' => 28, |
||
2400 | 'name' => 'An awesome forum', |
||
2401 | 'sectionId' => 1, |
||
2402 | 'currentVersionNo' => 1, |
||
2403 | 'published' => true, |
||
2404 | 'ownerId' => 14, |
||
2405 | // this Content Object is created at the test runtime |
||
2406 | 'modificationDate' => $versionInfo->contentInfo->modificationDate, |
||
2407 | 'publishedDate' => $versionInfo->contentInfo->publishedDate, |
||
2408 | 'alwaysAvailable' => 1, |
||
2409 | 'remoteId' => 'abcdef0123456789abcdef0123456789', |
||
2410 | 'mainLanguageCode' => 'eng-US', |
||
2411 | 'mainLocationId' => $draftContent->contentInfo->mainLocationId, |
||
2412 | ]), |
||
2413 | 'id' => $draftContent->versionInfo->id, |
||
2414 | 'versionNo' => 2, |
||
2415 | 'creatorId' => 14, |
||
2416 | 'status' => 0, |
||
2417 | 'initialLanguageCode' => 'eng-US', |
||
2418 | 'languageCodes' => [ |
||
2419 | 'eng-US', |
||
2420 | ], |
||
2421 | ], |
||
2422 | $versionInfo |
||
2423 | ); |
||
2424 | } |
||
2425 | |||
2426 | /** |
||
2427 | * Test for the loadVersionInfoById() method. |
||
2428 | * |
||
2429 | * @see \eZ\Publish\API\Repository\ContentService::loadVersionInfoById($contentId, $versionNo) |
||
2430 | * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException |
||
2431 | */ |
||
2432 | View Code Duplication | public function testLoadVersionInfoByIdThrowsNotFoundExceptionWithSecondParameter() |
|
2433 | { |
||
2434 | $repository = $this->getRepository(); |
||
2435 | |||
2436 | $contentService = $repository->getContentService(); |
||
2437 | |||
2438 | /* BEGIN: Use Case */ |
||
2439 | $content = $this->createContentVersion1(); |
||
2440 | |||
2441 | // This call will fail with a "NotFoundException", because not versionNo |
||
2442 | // 2 exists for this content object. |
||
2443 | $contentService->loadVersionInfoById($content->id, 2); |
||
2444 | /* END: Use Case */ |
||
2445 | } |
||
2446 | |||
2447 | /** |
||
2448 | * Test for the loadContentByVersionInfo() method. |
||
2449 | * |
||
2450 | * @see \eZ\Publish\API\Repository\ContentService::loadContentByVersionInfo($versionInfo, $languages) |
||
2451 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent |
||
2452 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByVersionInfo |
||
2453 | */ |
||
2454 | public function testLoadContentByVersionInfoWithSecondParameter() |
||
2455 | { |
||
2456 | $repository = $this->getRepository(); |
||
2457 | |||
2458 | $sectionId = $this->generateId('section', 1); |
||
2459 | /* BEGIN: Use Case */ |
||
2460 | $contentTypeService = $repository->getContentTypeService(); |
||
2461 | |||
2462 | $contentType = $contentTypeService->loadContentTypeByIdentifier('forum'); |
||
2463 | |||
2464 | $contentService = $repository->getContentService(); |
||
2465 | |||
2466 | $contentCreateStruct = $contentService->newContentCreateStruct($contentType, 'eng-US'); |
||
2467 | |||
2468 | $contentCreateStruct->setField('name', 'Sindelfingen forum²'); |
||
2469 | |||
2470 | $contentCreateStruct->setField('name', 'Sindelfingen forum²³', 'eng-GB'); |
||
2471 | |||
2472 | $contentCreateStruct->remoteId = 'abcdef0123456789abcdef0123456789'; |
||
2473 | // $sectionId contains the ID of section 1 |
||
2474 | $contentCreateStruct->sectionId = $sectionId; |
||
2475 | $contentCreateStruct->alwaysAvailable = true; |
||
2476 | |||
2477 | // Create a new content draft |
||
2478 | $content = $contentService->createContent($contentCreateStruct); |
||
2479 | |||
2480 | // Now publish this draft |
||
2481 | $publishedContent = $contentService->publishVersion($content->getVersionInfo()); |
||
2482 | |||
2483 | // Will return a content instance with fields in "eng-US" |
||
2484 | $reloadedContent = $contentService->loadContentByVersionInfo( |
||
2485 | $publishedContent->getVersionInfo(), |
||
2486 | array( |
||
2487 | 'eng-GB', |
||
2488 | ), |
||
2489 | false |
||
2490 | ); |
||
2491 | /* END: Use Case */ |
||
2492 | |||
2493 | $actual = array(); |
||
2494 | View Code Duplication | foreach ($reloadedContent->getFields() as $field) { |
|
2495 | $actual[] = new Field( |
||
2496 | array( |
||
2497 | 'id' => 0, |
||
2498 | 'value' => ($field->value !== null ? true : null), // Actual value tested by FieldType integration tests |
||
2499 | 'languageCode' => $field->languageCode, |
||
2500 | 'fieldDefIdentifier' => $field->fieldDefIdentifier, |
||
2501 | ) |
||
2502 | ); |
||
2503 | } |
||
2504 | usort( |
||
2505 | $actual, |
||
2506 | View Code Duplication | function ($field1, $field2) { |
|
2507 | if (0 === ($return = strcasecmp($field1->fieldDefIdentifier, $field2->fieldDefIdentifier))) { |
||
2508 | return strcasecmp($field1->languageCode, $field2->languageCode); |
||
2509 | } |
||
2510 | |||
2511 | return $return; |
||
2512 | } |
||
2513 | ); |
||
2514 | |||
2515 | $expected = array( |
||
2516 | new Field( |
||
2517 | array( |
||
2518 | 'id' => 0, |
||
2519 | 'value' => true, |
||
2520 | 'languageCode' => 'eng-GB', |
||
2521 | 'fieldDefIdentifier' => 'description', |
||
2522 | ) |
||
2523 | ), |
||
2524 | new Field( |
||
2525 | array( |
||
2526 | 'id' => 0, |
||
2527 | 'value' => true, |
||
2528 | 'languageCode' => 'eng-GB', |
||
2529 | 'fieldDefIdentifier' => 'name', |
||
2530 | ) |
||
2531 | ), |
||
2532 | ); |
||
2533 | |||
2534 | $this->assertEquals($expected, $actual); |
||
2535 | } |
||
2536 | |||
2537 | /** |
||
2538 | * Test for the loadContentByContentInfo() method. |
||
2539 | * |
||
2540 | * @see \eZ\Publish\API\Repository\ContentService::loadContentByContentInfo($contentInfo, $languages) |
||
2541 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByContentInfo |
||
2542 | */ |
||
2543 | public function testLoadContentByContentInfoWithLanguageParameters() |
||
2544 | { |
||
2545 | $repository = $this->getRepository(); |
||
2546 | |||
2547 | $sectionId = $this->generateId('section', 1); |
||
2548 | /* BEGIN: Use Case */ |
||
2549 | $contentTypeService = $repository->getContentTypeService(); |
||
2550 | |||
2551 | $contentType = $contentTypeService->loadContentTypeByIdentifier('forum'); |
||
2552 | |||
2553 | $contentService = $repository->getContentService(); |
||
2554 | |||
2555 | $contentCreateStruct = $contentService->newContentCreateStruct($contentType, 'eng-US'); |
||
2556 | |||
2557 | $contentCreateStruct->setField('name', 'Sindelfingen forum²'); |
||
2558 | |||
2559 | $contentCreateStruct->setField('name', 'Sindelfingen forum²³', 'eng-GB'); |
||
2560 | |||
2561 | $contentCreateStruct->remoteId = 'abcdef0123456789abcdef0123456789'; |
||
2562 | // $sectionId contains the ID of section 1 |
||
2563 | $contentCreateStruct->sectionId = $sectionId; |
||
2564 | $contentCreateStruct->alwaysAvailable = true; |
||
2565 | |||
2566 | // Create a new content draft |
||
2567 | $content = $contentService->createContent($contentCreateStruct); |
||
2568 | |||
2569 | // Now publish this draft |
||
2570 | $publishedContent = $contentService->publishVersion($content->getVersionInfo()); |
||
2571 | |||
2572 | // Will return a content instance with fields in "eng-US" |
||
2573 | $reloadedContent = $contentService->loadContentByContentInfo( |
||
2574 | $publishedContent->contentInfo, |
||
2575 | array( |
||
2576 | 'eng-US', |
||
2577 | ), |
||
2578 | null, |
||
2579 | false |
||
2580 | ); |
||
2581 | /* END: Use Case */ |
||
2582 | |||
2583 | $actual = $this->normalizeFields($reloadedContent->getFields()); |
||
2584 | |||
2585 | $expected = array( |
||
2586 | new Field( |
||
2587 | array( |
||
2588 | 'id' => 0, |
||
2589 | 'value' => true, |
||
2590 | 'languageCode' => 'eng-US', |
||
2591 | 'fieldDefIdentifier' => 'description', |
||
2592 | ) |
||
2593 | ), |
||
2594 | new Field( |
||
2595 | array( |
||
2596 | 'id' => 0, |
||
2597 | 'value' => true, |
||
2598 | 'languageCode' => 'eng-US', |
||
2599 | 'fieldDefIdentifier' => 'name', |
||
2600 | ) |
||
2601 | ), |
||
2602 | ); |
||
2603 | |||
2604 | $this->assertEquals($expected, $actual); |
||
2605 | |||
2606 | // Will return a content instance with fields in "eng-GB" (versions prior to 6.0.0-beta9 returned "eng-US" also) |
||
2607 | $reloadedContent = $contentService->loadContentByContentInfo( |
||
2608 | $publishedContent->contentInfo, |
||
2609 | array( |
||
2610 | 'eng-GB', |
||
2611 | ), |
||
2612 | null, |
||
2613 | true |
||
2614 | ); |
||
2615 | |||
2616 | $actual = $this->normalizeFields($reloadedContent->getFields()); |
||
2617 | |||
2618 | $expected = array( |
||
2619 | new Field( |
||
2620 | array( |
||
2621 | 'id' => 0, |
||
2622 | 'value' => true, |
||
2623 | 'languageCode' => 'eng-GB', |
||
2624 | 'fieldDefIdentifier' => 'description', |
||
2625 | ) |
||
2626 | ), |
||
2627 | new Field( |
||
2628 | array( |
||
2629 | 'id' => 0, |
||
2630 | 'value' => true, |
||
2631 | 'languageCode' => 'eng-GB', |
||
2632 | 'fieldDefIdentifier' => 'name', |
||
2633 | ) |
||
2634 | ), |
||
2635 | ); |
||
2636 | |||
2637 | $this->assertEquals($expected, $actual); |
||
2638 | |||
2639 | // Will return a content instance with fields in main language "eng-US", as "fre-FR" does not exists |
||
2640 | $reloadedContent = $contentService->loadContentByContentInfo( |
||
2641 | $publishedContent->contentInfo, |
||
2642 | array( |
||
2643 | 'fre-FR', |
||
2644 | ), |
||
2645 | null, |
||
2646 | true |
||
2647 | ); |
||
2648 | |||
2649 | $actual = $this->normalizeFields($reloadedContent->getFields()); |
||
2650 | |||
2651 | $expected = array( |
||
2652 | new Field( |
||
2653 | array( |
||
2654 | 'id' => 0, |
||
2655 | 'value' => true, |
||
2656 | 'languageCode' => 'eng-US', |
||
2657 | 'fieldDefIdentifier' => 'description', |
||
2658 | ) |
||
2659 | ), |
||
2660 | new Field( |
||
2661 | array( |
||
2662 | 'id' => 0, |
||
2663 | 'value' => true, |
||
2664 | 'languageCode' => 'eng-US', |
||
2665 | 'fieldDefIdentifier' => 'name', |
||
2666 | ) |
||
2667 | ), |
||
2668 | ); |
||
2669 | |||
2670 | $this->assertEquals($expected, $actual); |
||
2671 | } |
||
2672 | |||
2673 | /** |
||
2674 | * Test for the loadContentByContentInfo() method. |
||
2675 | * |
||
2676 | * @see \eZ\Publish\API\Repository\ContentService::loadContentByContentInfo($contentInfo, $languages, $versionNo) |
||
2677 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByContentInfo |
||
2678 | */ |
||
2679 | View Code Duplication | public function testLoadContentByContentInfoWithVersionNumberParameter() |
|
2680 | { |
||
2681 | $repository = $this->getRepository(); |
||
2682 | |||
2683 | $contentService = $repository->getContentService(); |
||
2684 | |||
2685 | /* BEGIN: Use Case */ |
||
2686 | $publishedContent = $this->createContentVersion1(); |
||
2687 | |||
2688 | $draftContent = $contentService->createContentDraft($publishedContent->contentInfo); |
||
2689 | |||
2690 | // This content instance is identical to $draftContent |
||
2691 | $draftContentReloaded = $contentService->loadContentByContentInfo( |
||
2692 | $publishedContent->contentInfo, |
||
2693 | null, |
||
2694 | 2 |
||
2695 | ); |
||
2696 | /* END: Use Case */ |
||
2697 | |||
2698 | $this->assertEquals( |
||
2699 | 2, |
||
2700 | $draftContentReloaded->getVersionInfo()->versionNo |
||
2701 | ); |
||
2702 | |||
2703 | // Check that ContentInfo contained in reloaded draft Content has correct main Location id set |
||
2704 | $this->assertEquals( |
||
2705 | $publishedContent->versionInfo->contentInfo->mainLocationId, |
||
2706 | $draftContentReloaded->versionInfo->contentInfo->mainLocationId |
||
2707 | ); |
||
2708 | } |
||
2709 | |||
2710 | /** |
||
2711 | * Test for the loadContentByContentInfo() method. |
||
2712 | * |
||
2713 | * @see \eZ\Publish\API\Repository\ContentService::loadContentByContentInfo($contentInfo, $languages, $versionNo) |
||
2714 | * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException |
||
2715 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByContentInfoWithVersionNumberParameter |
||
2716 | */ |
||
2717 | View Code Duplication | public function testLoadContentByContentInfoThrowsNotFoundExceptionWithVersionNumberParameter() |
|
2718 | { |
||
2719 | $repository = $this->getRepository(); |
||
2720 | |||
2721 | $contentService = $repository->getContentService(); |
||
2722 | |||
2723 | /* BEGIN: Use Case */ |
||
2724 | $content = $this->createContentVersion1(); |
||
2725 | |||
2726 | // This call will fail with a "NotFoundException", because no content |
||
2727 | // with versionNo = 2 exists. |
||
2728 | $contentService->loadContentByContentInfo($content->contentInfo, null, 2); |
||
2729 | /* END: Use Case */ |
||
2730 | } |
||
2731 | |||
2732 | /** |
||
2733 | * Test for the loadContent() method. |
||
2734 | * |
||
2735 | * @see \eZ\Publish\API\Repository\ContentService::loadContent($contentId, $languages) |
||
2736 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft |
||
2737 | */ |
||
2738 | View Code Duplication | public function testLoadContentWithSecondParameter() |
|
2739 | { |
||
2740 | $repository = $this->getRepository(); |
||
2741 | |||
2742 | $contentService = $repository->getContentService(); |
||
2743 | |||
2744 | /* BEGIN: Use Case */ |
||
2745 | $draft = $this->createMultipleLanguageDraftVersion1(); |
||
2746 | |||
2747 | // This draft contains those fields localized with "eng-GB" |
||
2748 | $draftLocalized = $contentService->loadContent($draft->id, array('eng-GB'), null, false); |
||
2749 | /* END: Use Case */ |
||
2750 | |||
2751 | $this->assertLocaleFieldsEquals($draftLocalized->getFields(), 'eng-GB'); |
||
2752 | |||
2753 | return $draft; |
||
2754 | } |
||
2755 | |||
2756 | /** |
||
2757 | * Test for the loadContent() method using undefined translation. |
||
2758 | * |
||
2759 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentWithSecondParameter |
||
2760 | * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException |
||
2761 | * |
||
2762 | * @param \eZ\Publish\API\Repository\Values\Content\Content $contentDraft |
||
2763 | */ |
||
2764 | public function testLoadContentWithSecondParameterThrowsNotFoundException(Content $contentDraft) |
||
2765 | { |
||
2766 | $repository = $this->getRepository(); |
||
2767 | |||
2768 | $contentService = $repository->getContentService(); |
||
2769 | |||
2770 | $contentService->loadContent($contentDraft->id, array('ger-DE'), null, false); |
||
2771 | } |
||
2772 | |||
2773 | /** |
||
2774 | * Test for the loadContent() method. |
||
2775 | * |
||
2776 | * @see \eZ\Publish\API\Repository\ContentService::loadContent($contentId, $languages, $versionNo) |
||
2777 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft |
||
2778 | */ |
||
2779 | View Code Duplication | public function testLoadContentWithThirdParameter() |
|
2780 | { |
||
2781 | $repository = $this->getRepository(); |
||
2782 | |||
2783 | $contentService = $repository->getContentService(); |
||
2784 | |||
2785 | /* BEGIN: Use Case */ |
||
2786 | $publishedContent = $this->createContentVersion1(); |
||
2787 | |||
2788 | $draftContent = $contentService->createContentDraft($publishedContent->contentInfo); |
||
2789 | |||
2790 | // This content instance is identical to $draftContent |
||
2791 | $draftContentReloaded = $contentService->loadContent($publishedContent->id, null, 2); |
||
2792 | /* END: Use Case */ |
||
2793 | |||
2794 | $this->assertEquals(2, $draftContentReloaded->getVersionInfo()->versionNo); |
||
2795 | |||
2796 | // Check that ContentInfo contained in reloaded draft Content has correct main Location id set |
||
2797 | $this->assertEquals( |
||
2798 | $publishedContent->versionInfo->contentInfo->mainLocationId, |
||
2799 | $draftContentReloaded->versionInfo->contentInfo->mainLocationId |
||
2800 | ); |
||
2801 | } |
||
2802 | |||
2803 | /** |
||
2804 | * Test for the loadContent() method. |
||
2805 | * |
||
2806 | * @see \eZ\Publish\API\Repository\ContentService::loadContent($contentId, $languages, $versionNo) |
||
2807 | * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException |
||
2808 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentWithThirdParameter |
||
2809 | */ |
||
2810 | View Code Duplication | public function testLoadContentThrowsNotFoundExceptionWithThirdParameter() |
|
2811 | { |
||
2812 | $repository = $this->getRepository(); |
||
2813 | |||
2814 | $contentService = $repository->getContentService(); |
||
2815 | |||
2816 | /* BEGIN: Use Case */ |
||
2817 | $content = $this->createContentVersion1(); |
||
2818 | |||
2819 | // This call will fail with a "NotFoundException", because for this |
||
2820 | // content object no versionNo=2 exists. |
||
2821 | $contentService->loadContent($content->id, null, 2); |
||
2822 | /* END: Use Case */ |
||
2823 | } |
||
2824 | |||
2825 | /** |
||
2826 | * Test for the loadContentByRemoteId() method. |
||
2827 | * |
||
2828 | * @see \eZ\Publish\API\Repository\ContentService::loadContentByRemoteId($remoteId, $languages) |
||
2829 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft |
||
2830 | */ |
||
2831 | View Code Duplication | public function testLoadContentByRemoteIdWithSecondParameter() |
|
2832 | { |
||
2833 | $repository = $this->getRepository(); |
||
2834 | |||
2835 | $contentService = $repository->getContentService(); |
||
2836 | |||
2837 | /* BEGIN: Use Case */ |
||
2838 | $draft = $this->createMultipleLanguageDraftVersion1(); |
||
2839 | |||
2840 | $contentService->publishVersion($draft->versionInfo); |
||
2841 | |||
2842 | // This draft contains those fields localized with "eng-GB" |
||
2843 | $draftLocalized = $contentService->loadContentByRemoteId( |
||
2844 | $draft->contentInfo->remoteId, |
||
2845 | array('eng-GB'), |
||
2846 | null, |
||
2847 | false |
||
2848 | ); |
||
2849 | /* END: Use Case */ |
||
2850 | |||
2851 | $this->assertLocaleFieldsEquals($draftLocalized->getFields(), 'eng-GB'); |
||
2852 | } |
||
2853 | |||
2854 | /** |
||
2855 | * Test for the loadContentByRemoteId() method. |
||
2856 | * |
||
2857 | * @see \eZ\Publish\API\Repository\ContentService::loadContentByRemoteId($remoteId, $languages, $versionNo) |
||
2858 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft |
||
2859 | */ |
||
2860 | View Code Duplication | public function testLoadContentByRemoteIdWithThirdParameter() |
|
2861 | { |
||
2862 | $repository = $this->getRepository(); |
||
2863 | |||
2864 | $contentService = $repository->getContentService(); |
||
2865 | |||
2866 | /* BEGIN: Use Case */ |
||
2867 | $publishedContent = $this->createContentVersion1(); |
||
2868 | |||
2869 | $draftContent = $contentService->createContentDraft($publishedContent->contentInfo); |
||
2870 | |||
2871 | // This content instance is identical to $draftContent |
||
2872 | $draftContentReloaded = $contentService->loadContentByRemoteId( |
||
2873 | $publishedContent->contentInfo->remoteId, |
||
2874 | null, |
||
2875 | 2 |
||
2876 | ); |
||
2877 | /* END: Use Case */ |
||
2878 | |||
2879 | $this->assertEquals(2, $draftContentReloaded->getVersionInfo()->versionNo); |
||
2880 | |||
2881 | // Check that ContentInfo contained in reloaded draft Content has correct main Location id set |
||
2882 | $this->assertEquals( |
||
2883 | $publishedContent->versionInfo->contentInfo->mainLocationId, |
||
2884 | $draftContentReloaded->versionInfo->contentInfo->mainLocationId |
||
2885 | ); |
||
2886 | } |
||
2887 | |||
2888 | /** |
||
2889 | * Test for the loadContentByRemoteId() method. |
||
2890 | * |
||
2891 | * @see \eZ\Publish\API\Repository\ContentService::loadContentByRemoteId($remoteId, $languages, $versionNo) |
||
2892 | * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException |
||
2893 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByRemoteIdWithThirdParameter |
||
2894 | */ |
||
2895 | public function testLoadContentByRemoteIdThrowsNotFoundExceptionWithThirdParameter() |
||
2896 | { |
||
2897 | $repository = $this->getRepository(); |
||
2898 | |||
2899 | $contentService = $repository->getContentService(); |
||
2900 | |||
2901 | /* BEGIN: Use Case */ |
||
2902 | $content = $this->createContentVersion1(); |
||
2903 | |||
2904 | // This call will fail with a "NotFoundException", because for this |
||
2905 | // content object no versionNo=2 exists. |
||
2906 | $contentService->loadContentByRemoteId( |
||
2907 | $content->contentInfo->remoteId, |
||
2908 | null, |
||
2909 | 2 |
||
2910 | ); |
||
2911 | /* END: Use Case */ |
||
2912 | } |
||
2913 | |||
2914 | /** |
||
2915 | * Test that retrieval of translated name field respects prioritized language list. |
||
2916 | * |
||
2917 | * @dataProvider getPrioritizedLanguageList |
||
2918 | * @param string[]|null $languageCodes |
||
2919 | */ |
||
2920 | public function testLoadContentWithPrioritizedLanguagesList($languageCodes) |
||
2921 | { |
||
2922 | $repository = $this->getRepository(); |
||
2923 | |||
2924 | $contentService = $repository->getContentService(); |
||
2925 | |||
2926 | $content = $this->createContentVersion2(); |
||
2927 | |||
2928 | $content = $contentService->loadContent($content->id, $languageCodes); |
||
2929 | |||
2930 | $expectedName = $content->getVersionInfo()->getName( |
||
2931 | isset($languageCodes[0]) ? $languageCodes[0] : null |
||
2932 | ); |
||
2933 | $nameValue = $content->getFieldValue('name'); |
||
2934 | /** @var \eZ\Publish\Core\FieldType\TextLine\Value $nameValue */ |
||
2935 | self::assertEquals($expectedName, $nameValue->text); |
||
2936 | self::assertEquals($expectedName, $content->getVersionInfo()->getName()); |
||
2937 | // Also check value on shortcut method on content |
||
2938 | self::assertEquals($expectedName, $content->getName()); |
||
2939 | } |
||
2940 | |||
2941 | /** |
||
2942 | * @return array |
||
2943 | */ |
||
2944 | public function getPrioritizedLanguageList() |
||
2953 | |||
2954 | /** |
||
2955 | * Test for the deleteVersion() method. |
||
2956 | * |
||
2957 | * @see \eZ\Publish\API\Repository\ContentService::deleteVersion() |
||
2958 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContent |
||
2959 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent |
||
2960 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion |
||
2961 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraft |
||
2962 | */ |
||
2963 | public function testDeleteVersion() |
||
2989 | |||
2990 | /** |
||
2991 | * Test for the deleteVersion() method. |
||
2992 | * |
||
2993 | * @see \eZ\Publish\API\Repository\ContentService::deleteVersion() |
||
2994 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
||
2995 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContent |
||
2996 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent |
||
2997 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion |
||
2998 | */ |
||
2999 | public function testDeleteVersionThrowsBadStateExceptionOnPublishedVersion() |
||
3013 | |||
3014 | /** |
||
3015 | * Test for the deleteVersion() method. |
||
3016 | * |
||
3017 | * @see \eZ\Publish\API\Repository\ContentService::deleteVersion() |
||
3018 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
||
3019 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContent |
||
3020 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent |
||
3021 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion |
||
3022 | */ |
||
3023 | View Code Duplication | public function testDeleteVersionThrowsBadStateExceptionOnLastVersion() |
|
3037 | |||
3038 | /** |
||
3039 | * Test for the loadVersions() method. |
||
3040 | * |
||
3041 | * @see \eZ\Publish\API\Repository\ContentService::loadVersions() |
||
3042 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion |
||
3043 | * |
||
3044 | * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo[] |
||
3045 | */ |
||
3046 | public function testLoadVersions() |
||
3068 | |||
3069 | /** |
||
3070 | * Test for the loadVersions() method. |
||
3071 | * |
||
3072 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadVersions |
||
3073 | * @covers \eZ\Publish\Core\Repository\ContentService::loadVersions |
||
3074 | * |
||
3075 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo[] $versions |
||
3076 | */ |
||
3077 | public function testLoadVersionsSetsExpectedVersionInfo(array $versions) |
||
3120 | |||
3121 | /** |
||
3122 | * Test for the copyContent() method. |
||
3123 | * |
||
3124 | * @see \eZ\Publish\API\Repository\ContentService::copyContent() |
||
3125 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft |
||
3126 | * @group field-type |
||
3127 | */ |
||
3128 | View Code Duplication | public function testCopyContent() |
|
3187 | |||
3188 | /** |
||
3189 | * Test for the copyContent() method. |
||
3190 | * |
||
3191 | * @see \eZ\Publish\API\Repository\ContentService::copyContent($contentInfo, $destinationLocationCreateStruct, $versionInfo) |
||
3192 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCopyContent |
||
3193 | * |
||
3194 | * @todo Fix to more descriptive name |
||
3195 | */ |
||
3196 | View Code Duplication | public function testCopyContentWithThirdParameter() |
|
3252 | |||
3253 | /** |
||
3254 | * Test for the addRelation() method. |
||
3255 | * |
||
3256 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
3257 | * |
||
3258 | * @see \eZ\Publish\API\Repository\ContentService::addRelation() |
||
3259 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft |
||
3260 | */ |
||
3261 | public function testAddRelation() |
||
3289 | |||
3290 | /** |
||
3291 | * Test for the addRelation() method. |
||
3292 | * |
||
3293 | * @param \eZ\Publish\API\Repository\Values\Content\Relation[] $relations |
||
3294 | * |
||
3295 | * @see \eZ\Publish\API\Repository\ContentService::addRelation() |
||
3296 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation |
||
3297 | */ |
||
3298 | public function testAddRelationAddsRelationToContent($relations) |
||
3305 | |||
3306 | /** |
||
3307 | * @param \eZ\Publish\API\Repository\Values\Content\Relation[] $relations |
||
3308 | */ |
||
3309 | protected function assertExpectedRelations($relations) |
||
3326 | |||
3327 | /** |
||
3328 | * Test for the addRelation() method. |
||
3329 | * |
||
3330 | * @param \eZ\Publish\API\Repository\Values\Content\Relation[] $relations |
||
3331 | * |
||
3332 | * @see \eZ\Publish\API\Repository\ContentService::addRelation() |
||
3333 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation |
||
3334 | */ |
||
3335 | public function testAddRelationSetsExpectedRelations($relations) |
||
3339 | |||
3340 | /** |
||
3341 | * Test for the createContentDraft() method. |
||
3342 | * |
||
3343 | * @return \eZ\Publish\API\Repository\Values\Content\Relation[] |
||
3344 | * |
||
3345 | * @see \eZ\Publish\API\Repository\ContentService::createContentDraft() |
||
3346 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelationSetsExpectedRelations |
||
3347 | */ |
||
3348 | View Code Duplication | public function testCreateContentDraftWithRelations() |
|
3370 | |||
3371 | /** |
||
3372 | * Test for the createContentDraft() method. |
||
3373 | * |
||
3374 | * @param \eZ\Publish\API\Repository\Values\Content\Relation[] $relations |
||
3375 | * |
||
3376 | * @return \eZ\Publish\API\Repository\Values\Content\Relation[] |
||
3377 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraftWithRelations |
||
3378 | */ |
||
3379 | public function testCreateContentDraftWithRelationsCreatesRelations($relations) |
||
3388 | |||
3389 | /** |
||
3390 | * Test for the createContentDraft() method. |
||
3391 | * |
||
3392 | * @param \eZ\Publish\API\Repository\Values\Content\Relation[] $relations |
||
3393 | * |
||
3394 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraftWithRelationsCreatesRelations |
||
3395 | */ |
||
3396 | public function testCreateContentDraftWithRelationsCreatesExpectedRelations($relations) |
||
3400 | |||
3401 | /** |
||
3402 | * Test for the addRelation() method. |
||
3403 | * |
||
3404 | * @see \eZ\Publish\API\Repository\ContentService::addRelation() |
||
3405 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
||
3406 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation |
||
3407 | */ |
||
3408 | View Code Duplication | public function testAddRelationThrowsBadStateException() |
|
3430 | |||
3431 | /** |
||
3432 | * Test for the loadRelations() method. |
||
3433 | * |
||
3434 | * @see \eZ\Publish\API\Repository\ContentService::loadRelations() |
||
3435 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation |
||
3436 | */ |
||
3437 | public function testLoadRelations() |
||
3504 | |||
3505 | /** |
||
3506 | * Test for the loadRelations() method. |
||
3507 | * |
||
3508 | * @see \eZ\Publish\API\Repository\ContentService::loadRelations() |
||
3509 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation |
||
3510 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadRelations |
||
3511 | */ |
||
3512 | public function testLoadRelationsSkipsArchivedContent() |
||
3570 | |||
3571 | /** |
||
3572 | * Test for the loadRelations() method. |
||
3573 | * |
||
3574 | * @see \eZ\Publish\API\Repository\ContentService::loadRelations() |
||
3575 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation |
||
3576 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadRelations |
||
3577 | */ |
||
3578 | public function testLoadRelationsSkipsDraftContent() |
||
3632 | |||
3633 | /** |
||
3634 | * Test for the loadReverseRelations() method. |
||
3635 | * |
||
3636 | * @see \eZ\Publish\API\Repository\ContentService::loadReverseRelations() |
||
3637 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation |
||
3638 | */ |
||
3639 | public function testLoadReverseRelations() |
||
3725 | |||
3726 | /** |
||
3727 | * Test for the loadReverseRelations() method. |
||
3728 | * |
||
3729 | * @see \eZ\Publish\API\Repository\ContentService::loadReverseRelations() |
||
3730 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation |
||
3731 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadReverseRelations |
||
3732 | */ |
||
3733 | public function testLoadReverseRelationsSkipsArchivedContent() |
||
3809 | |||
3810 | /** |
||
3811 | * Test for the loadReverseRelations() method. |
||
3812 | * |
||
3813 | * @see \eZ\Publish\API\Repository\ContentService::loadReverseRelations() |
||
3814 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation |
||
3815 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadReverseRelations |
||
3816 | */ |
||
3817 | public function testLoadReverseRelationsSkipsDraftContent() |
||
3885 | |||
3886 | /** |
||
3887 | * Test for the deleteRelation() method. |
||
3888 | * |
||
3889 | * @see \eZ\Publish\API\Repository\ContentService::deleteRelation() |
||
3890 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadRelations |
||
3891 | */ |
||
3892 | public function testDeleteRelation() |
||
3922 | |||
3923 | /** |
||
3924 | * Test for the deleteRelation() method. |
||
3925 | * |
||
3926 | * @see \eZ\Publish\API\Repository\ContentService::deleteRelation() |
||
3927 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
||
3928 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteRelation |
||
3929 | */ |
||
3930 | View Code Duplication | public function testDeleteRelationThrowsBadStateException() |
|
3964 | |||
3965 | /** |
||
3966 | * Test for the deleteRelation() method. |
||
3967 | * |
||
3968 | * @see \eZ\Publish\API\Repository\ContentService::deleteRelation() |
||
3969 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
||
3970 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteRelation |
||
3971 | */ |
||
3972 | View Code Duplication | public function testDeleteRelationThrowsInvalidArgumentException() |
|
3995 | |||
3996 | /** |
||
3997 | * Test for the createContent() method. |
||
3998 | * |
||
3999 | * @see \eZ\Publish\API\Repository\ContentService::createContent() |
||
4000 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent |
||
4001 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContent |
||
4002 | */ |
||
4003 | public function testCreateContentInTransactionWithRollback() |
||
4050 | |||
4051 | /** |
||
4052 | * Test for the createContent() method. |
||
4053 | * |
||
4054 | * @see \eZ\Publish\API\Repository\ContentService::createContent() |
||
4055 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent |
||
4056 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContent |
||
4057 | */ |
||
4058 | public function testCreateContentInTransactionWithCommit() |
||
4100 | |||
4101 | /** |
||
4102 | * Test for the createContent() method. |
||
4103 | * |
||
4104 | * @see \eZ\Publish\API\Repository\ContentService::createContent($contentCreateStruct, $locationCreateStructs) |
||
4105 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentWithLocationCreateParameterDoesNotCreateLocationImmediately |
||
4106 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentThrowsNotFoundException |
||
4107 | */ |
||
4108 | public function testCreateContentWithLocationCreateParameterInTransactionWithRollback() |
||
4141 | |||
4142 | /** |
||
4143 | * Test for the createContent() method. |
||
4144 | * |
||
4145 | * @see \eZ\Publish\API\Repository\ContentService::createContent($contentCreateStruct, $locationCreateStructs) |
||
4146 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentWithLocationCreateParameterDoesNotCreateLocationImmediately |
||
4147 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentThrowsNotFoundException |
||
4148 | */ |
||
4149 | View Code Duplication | public function testCreateContentWithLocationCreateParameterInTransactionWithCommit() |
|
4178 | |||
4179 | /** |
||
4180 | * Test for the createContentDraft() method. |
||
4181 | * |
||
4182 | * @see \eZ\Publish\API\Repository\ContentService::createContentDraft() |
||
4183 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraft |
||
4184 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContent |
||
4185 | */ |
||
4186 | public function testCreateContentDraftInTransactionWithRollback() |
||
4228 | |||
4229 | /** |
||
4230 | * Test for the createContentDraft() method. |
||
4231 | * |
||
4232 | * @see \eZ\Publish\API\Repository\ContentService::createContentDraft() |
||
4233 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraft |
||
4234 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContent |
||
4235 | */ |
||
4236 | View Code Duplication | public function testCreateContentDraftInTransactionWithCommit() |
|
4276 | |||
4277 | /** |
||
4278 | * Test for the publishVersion() method. |
||
4279 | * |
||
4280 | * @see \eZ\Publish\API\Repository\ContentService::publishVersion() |
||
4281 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion |
||
4282 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContent |
||
4283 | */ |
||
4284 | View Code Duplication | public function testPublishVersionInTransactionWithRollback() |
|
4328 | |||
4329 | /** |
||
4330 | * Test for the publishVersion() method. |
||
4331 | * |
||
4332 | * @see \eZ\Publish\API\Repository\ContentService::publishVersion() |
||
4333 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion |
||
4334 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadVersionInfo |
||
4335 | */ |
||
4336 | View Code Duplication | public function testPublishVersionInTransactionWithCommit() |
|
4376 | |||
4377 | /** |
||
4378 | * Test for the updateContent() method. |
||
4379 | * |
||
4380 | * @see \eZ\Publish\API\Repository\ContentService::updateContent() |
||
4381 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent |
||
4382 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContent |
||
4383 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo |
||
4384 | */ |
||
4385 | View Code Duplication | public function testUpdateContentInTransactionWithRollback() |
|
4432 | |||
4433 | /** |
||
4434 | * Test for the updateContent() method. |
||
4435 | * |
||
4436 | * @see \eZ\Publish\API\Repository\ContentService::updateContent() |
||
4437 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent |
||
4438 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContent |
||
4439 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo |
||
4440 | */ |
||
4441 | View Code Duplication | public function testUpdateContentInTransactionWithCommit() |
|
4488 | |||
4489 | /** |
||
4490 | * Test for the updateContentMetadata() method. |
||
4491 | * |
||
4492 | * @see \eZ\Publish\API\Repository\ContentService::updateContentMetadata() |
||
4493 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContentMetadata |
||
4494 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo |
||
4495 | */ |
||
4496 | View Code Duplication | public function testUpdateContentMetadataInTransactionWithRollback() |
|
4541 | |||
4542 | /** |
||
4543 | * Test for the updateContentMetadata() method. |
||
4544 | * |
||
4545 | * @see \eZ\Publish\API\Repository\ContentService::updateContentMetadata() |
||
4546 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContentMetadata |
||
4547 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo |
||
4548 | */ |
||
4549 | View Code Duplication | public function testUpdateContentMetadataInTransactionWithCommit() |
|
4594 | |||
4595 | /** |
||
4596 | * Test for the deleteVersion() method. |
||
4597 | * |
||
4598 | * @see \eZ\Publish\API\Repository\ContentService::deleteVersion() |
||
4599 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent |
||
4600 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo |
||
4601 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentDrafts |
||
4602 | */ |
||
4603 | public function testDeleteVersionInTransactionWithRollback() |
||
4639 | |||
4640 | /** |
||
4641 | * Test for the deleteVersion() method. |
||
4642 | * |
||
4643 | * @see \eZ\Publish\API\Repository\ContentService::deleteVersion() |
||
4644 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent |
||
4645 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo |
||
4646 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentDrafts |
||
4647 | */ |
||
4648 | public function testDeleteVersionInTransactionWithCommit() |
||
4684 | |||
4685 | /** |
||
4686 | * Test for the deleteContent() method. |
||
4687 | * |
||
4688 | * @see \eZ\Publish\API\Repository\ContentService::deleteContent() |
||
4689 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteContent |
||
4690 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo |
||
4691 | */ |
||
4692 | public function testDeleteContentInTransactionWithRollback() |
||
4728 | |||
4729 | /** |
||
4730 | * Test for the deleteContent() method. |
||
4731 | * |
||
4732 | * @see \eZ\Publish\API\Repository\ContentService::deleteContent() |
||
4733 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteContent |
||
4734 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo |
||
4735 | */ |
||
4736 | public function testDeleteContentInTransactionWithCommit() |
||
4776 | |||
4777 | /** |
||
4778 | * Test for the copyContent() method. |
||
4779 | * |
||
4780 | * @see \eZ\Publish\API\Repository\ContentService::copyContent() |
||
4781 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCopyContent |
||
4782 | * @depend(s) eZ\Publish\API\Repository\Tests\LocationServiceTest::testNewLocationCreateStruct |
||
4783 | * @depend(s) eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocationChildren |
||
4784 | * @depend(s) eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation |
||
4785 | */ |
||
4786 | View Code Duplication | public function testCopyContentInTransactionWithRollback() |
|
4836 | |||
4837 | /** |
||
4838 | * Test for the copyContent() method. |
||
4839 | * |
||
4840 | * @see \eZ\Publish\API\Repository\ContentService::copyContent() |
||
4841 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCopyContent |
||
4842 | * @depend(s) eZ\Publish\API\Repository\Tests\LocationServiceTest::testNewLocationCreateStruct |
||
4843 | * @depend(s) eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocationChildren |
||
4844 | * @depend(s) eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation |
||
4845 | */ |
||
4846 | View Code Duplication | public function testCopyContentInTransactionWithCommit() |
|
4896 | |||
4897 | public function testURLAliasesCreatedForNewContent() |
||
4933 | |||
4934 | public function testURLAliasesCreatedForUpdatedContent() |
||
5006 | |||
5007 | public function testCustomURLAliasesNotHistorizedOnUpdatedContent() |
||
5066 | |||
5067 | /** |
||
5068 | * Test to ensure that old versions are not affected by updates to newer |
||
5069 | * drafts. |
||
5070 | */ |
||
5071 | public function testUpdatingDraftDoesNotUpdateOldVersions() |
||
5072 | { |
||
5073 | $repository = $this->getRepository(); |
||
5074 | |||
5075 | $contentService = $repository->getContentService(); |
||
5076 | |||
5077 | $contentVersion2 = $this->createContentVersion2(); |
||
5078 | |||
5079 | $loadedContent1 = $contentService->loadContent($contentVersion2->id, null, 1); |
||
5080 | $loadedContent2 = $contentService->loadContent($contentVersion2->id, null, 2); |
||
5081 | |||
5082 | $this->assertNotEquals( |
||
5083 | $loadedContent1->getFieldValue('name', 'eng-US'), |
||
5084 | $loadedContent2->getFieldValue('name', 'eng-US') |
||
5085 | ); |
||
5086 | } |
||
5087 | |||
5088 | /** |
||
5089 | * Test scenario with writer and publisher users. |
||
5090 | * Writer can only create content. Publisher can publish this content. |
||
5091 | */ |
||
5092 | public function testPublishWorkflow() |
||
5093 | { |
||
5094 | $repository = $this->getRepository(); |
||
5095 | $contentService = $repository->getContentService(); |
||
5096 | |||
5097 | $this->createRoleWithPolicies('Publisher', [ |
||
5098 | ['content', 'read'], |
||
5099 | ['content', 'create'], |
||
5100 | ['content', 'publish'], |
||
5101 | ]); |
||
5102 | |||
5103 | $this->createRoleWithPolicies('Writer', [ |
||
5104 | ['content', 'read'], |
||
5105 | ['content', 'create'], |
||
5106 | ]); |
||
5107 | |||
5108 | $writerUser = $this->createCustomUserWithLogin( |
||
5109 | 'writer', |
||
5110 | '[email protected]', |
||
5111 | 'Writers', |
||
5112 | 'Writer' |
||
5113 | ); |
||
5114 | |||
5115 | $publisherUser = $this->createCustomUserWithLogin( |
||
5116 | 'publisher', |
||
5117 | '[email protected]', |
||
5118 | 'Publishers', |
||
5119 | 'Publisher' |
||
5120 | ); |
||
5121 | |||
5122 | $repository->getPermissionResolver()->setCurrentUserReference($writerUser); |
||
5123 | $draft = $this->createContentDraftVersion1(); |
||
5124 | |||
5125 | $repository->getPermissionResolver()->setCurrentUserReference($publisherUser); |
||
5126 | $content = $contentService->publishVersion($draft->versionInfo); |
||
5127 | |||
5128 | $contentService->loadContent($content->id); |
||
5129 | } |
||
5130 | |||
5131 | /** |
||
5132 | * Test publish / content policy is required to be able to publish content. |
||
5133 | * |
||
5134 | * @expectedException \eZ\Publish\Core\Base\Exceptions\UnauthorizedException |
||
5135 | * @expectedExceptionMessageRegExp /User does not have access to 'publish' 'content'/ |
||
5136 | */ |
||
5137 | public function testPublishContentWithoutPublishPolicyThrowsException() |
||
5138 | { |
||
5139 | $repository = $this->getRepository(); |
||
5140 | |||
5141 | $this->createRoleWithPolicies('Writer', [ |
||
5142 | ['content', 'read'], |
||
5143 | ['content', 'create'], |
||
5144 | ['content', 'edit'], |
||
5145 | ]); |
||
5146 | $writerUser = $this->createCustomUserWithLogin( |
||
5147 | 'writer', |
||
5148 | '[email protected]', |
||
5149 | 'Writers', |
||
5150 | 'Writer' |
||
5151 | ); |
||
5152 | $repository->getPermissionResolver()->setCurrentUserReference($writerUser); |
||
5156 | |||
5157 | /** |
||
5158 | * Test removal of the specific translation from all the Versions of a Content Object. |
||
5159 | * |
||
5160 | * @covers \eZ\Publish\Core\Repository\ContentService::deleteTranslation |
||
5161 | */ |
||
5162 | View Code Duplication | public function testDeleteTranslation() |
|
5183 | |||
5184 | /** |
||
5185 | * Test deleting a Translation which is initial for some Version, updates initialLanguageCode |
||
5186 | * with mainLanguageCode (assuming they are different). |
||
5187 | */ |
||
5188 | public function testDeleteTranslationUpdatesInitialLanguageCodeVersion() |
||
5219 | |||
5220 | /** |
||
5221 | * Test removal of the specific translation properly updates languages of the URL alias. |
||
5222 | * |
||
5223 | * @covers \eZ\Publish\Core\Repository\ContentService::deleteTranslation |
||
5224 | */ |
||
5225 | public function testDeleteTranslationUpdatesUrlAlias() |
||
5262 | |||
5263 | /** |
||
5264 | * Test removal of a main translation throws BadStateException. |
||
5265 | * |
||
5266 | * @covers \eZ\Publish\Core\Repository\ContentService::deleteTranslation |
||
5267 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
||
5268 | * @expectedExceptionMessage Specified translation is the main translation of the Content Object |
||
5269 | */ |
||
5270 | public function testDeleteTranslationMainLanguageThrowsBadStateException() |
||
5282 | |||
5283 | /** |
||
5284 | * Test removal of a Translation is possible when some archived Versions have only this Translation. |
||
5285 | * |
||
5286 | * @covers \eZ\Publish\Core\Repository\ContentService::deleteTranslation |
||
5287 | */ |
||
5288 | public function testDeleteTranslationDeletesSingleTranslationVersions() |
||
5312 | |||
5313 | /** |
||
5314 | * Test removal of the translation by the user who is not allowed to delete a content |
||
5315 | * throws UnauthorizedException. |
||
5316 | * |
||
5317 | * @covers \eZ\Publish\Core\Repository\ContentService::deleteTranslation |
||
5318 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
5319 | * @expectedExceptionMessage User does not have access to 'remove' 'content' |
||
5320 | */ |
||
5321 | public function testDeleteTranslationThrowsUnauthorizedException() |
||
5344 | |||
5345 | /** |
||
5346 | * Test removal of a non-existent translation throws InvalidArgumentException. |
||
5347 | * |
||
5348 | * @covers \eZ\Publish\Core\Repository\ContentService::deleteTranslation |
||
5349 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
||
5350 | * @expectedExceptionMessage Argument '$languageCode' is invalid: ger-DE does not exist in the Content item |
||
5351 | */ |
||
5352 | public function testDeleteTranslationThrowsInvalidArgumentException() |
||
5360 | |||
5361 | /** |
||
5362 | * Test deleting a Translation from Draft. |
||
5363 | * |
||
5364 | * @covers \eZ\Publish\Core\Repository\ContentService::deleteTranslationFromDraft |
||
5365 | */ |
||
5366 | public function testDeleteTranslationFromDraft() |
||
5381 | |||
5382 | /** |
||
5383 | * Get values for multilingual field. |
||
5384 | * |
||
5385 | * @return array |
||
5386 | */ |
||
5387 | public function providerForDeleteTranslationFromDraftRemovesUrlAliasOnPublishing() |
||
5398 | |||
5399 | /** |
||
5400 | * Test deleting a Translation from Draft removes previously stored URL aliases for published Content. |
||
5401 | * |
||
5402 | * @covers \eZ\Publish\Core\Repository\ContentService::deleteTranslationFromDraft |
||
5403 | * |
||
5404 | * @dataProvider providerForDeleteTranslationFromDraftRemovesUrlAliasOnPublishing |
||
5405 | * |
||
5406 | * @param string[] $fieldValues translated field values |
||
5407 | */ |
||
5408 | public function testDeleteTranslationFromDraftRemovesUrlAliasOnPublishing(array $fieldValues) |
||
5468 | |||
5469 | /** |
||
5470 | * Test deleting a Translation from Draft which has single Translation throws BadStateException. |
||
5471 | * |
||
5472 | * @covers \eZ\Publish\Core\Repository\ContentService::deleteTranslationFromDraft |
||
5473 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
||
5474 | * @expectedExceptionMessage Specified Translation is the only one Content Object Version has |
||
5475 | */ |
||
5476 | public function testDeleteTranslationFromDraftThrowsBadStateExceptionOnSingleTranslation() |
||
5507 | |||
5508 | /** |
||
5509 | * Test deleting the Main Translation from Draft throws BadStateException. |
||
5510 | * |
||
5511 | * @covers \eZ\Publish\Core\Repository\ContentService::deleteTranslationFromDraft |
||
5512 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
||
5513 | * @expectedExceptionMessage Specified Translation is the main Translation of the Content Object |
||
5514 | */ |
||
5515 | public function testDeleteTranslationFromDraftThrowsBadStateExceptionOnMainTranslation() |
||
5534 | |||
5535 | /** |
||
5536 | * Test deleting the Translation from Published Version throws BadStateException. |
||
5537 | * |
||
5538 | * @covers \eZ\Publish\Core\Repository\ContentService::deleteTranslationFromDraft |
||
5539 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
||
5540 | * @expectedExceptionMessage Version is not a draft |
||
5541 | */ |
||
5542 | View Code Duplication | public function testDeleteTranslationFromDraftThrowsBadStateExceptionOnPublishedVersion() |
|
5553 | |||
5554 | /** |
||
5555 | * Test deleting a Translation from Draft throws UnauthorizedException if user cannot edit Content. |
||
5556 | * |
||
5557 | * @covers \eZ\Publish\Core\Repository\ContentService::deleteTranslationFromDraft |
||
5558 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
5559 | * @expectedExceptionMessage User does not have access to 'edit' 'content' |
||
5560 | */ |
||
5561 | public function testDeleteTranslationFromDraftThrowsUnauthorizedException() |
||
5587 | |||
5588 | /** |
||
5589 | * Test deleting a non-existent Translation from Draft throws InvalidArgumentException. |
||
5590 | * |
||
5591 | * @covers \eZ\Publish\Core\Repository\ContentService::deleteTranslationFromDraft |
||
5592 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
||
5593 | * @expectedExceptionMessageRegExp /The Version \(ContentId=\d+, VersionNo=\d+\) is not translated into ger-DE/ |
||
5594 | */ |
||
5595 | public function testDeleteTranslationFromDraftThrowsInvalidArgumentException() |
||
5605 | |||
5606 | /** |
||
5607 | * Test for the newTranslationInfo() method. |
||
5608 | * |
||
5609 | * @covers \eZ\Publish\Core\Repository\ContentService::newTranslationInfo |
||
5610 | */ |
||
5611 | public function testNewTranslationInfo() |
||
5627 | |||
5628 | /** |
||
5629 | * Simplify creating custom role with limited set of policies. |
||
5630 | * |
||
5631 | * @param $roleName |
||
5632 | * @param array $policies e.g. [ ['content', 'create'], ['content', 'edit'], ] |
||
5633 | */ |
||
5634 | private function createRoleWithPolicies($roleName, array $policies) |
||
5648 | |||
5649 | /** |
||
5650 | * Asserts that all aliases defined in $expectedAliasProperties with the |
||
5651 | * given properties are available in $actualAliases and not more. |
||
5652 | * |
||
5653 | * @param array $expectedAliasProperties |
||
5654 | * @param array $actualAliases |
||
5655 | */ |
||
5656 | private function assertAliasesCorrect(array $expectedAliasProperties, array $actualAliases) |
||
5694 | |||
5695 | /** |
||
5696 | * Asserts that the given fields are equal to the default fields fixture. |
||
5697 | * |
||
5698 | * @param \eZ\Publish\API\Repository\Values\Content\Field[] $fields |
||
5699 | */ |
||
5700 | private function assertAllFieldsEquals(array $fields) |
||
5707 | |||
5708 | /** |
||
5709 | * Asserts that the given fields are equal to a language filtered set of the |
||
5710 | * default fields fixture. |
||
5711 | * |
||
5712 | * @param \eZ\Publish\API\Repository\Values\Content\Field[] $fields |
||
5713 | * @param string $languageCode |
||
5714 | */ |
||
5715 | private function assertLocaleFieldsEquals(array $fields, $languageCode) |
||
5729 | |||
5730 | /** |
||
5731 | * This method normalizes a set of fields and returns a normalized set. |
||
5732 | * |
||
5733 | * Normalization means it resets the storage specific field id to zero and |
||
5734 | * it sorts the field by their identifier and their language code. In |
||
5735 | * addition, the field value is removed, since this one depends on the |
||
5736 | * specific FieldType, which is tested in a dedicated integration test. |
||
5737 | * |
||
5738 | * @param \eZ\Publish\API\Repository\Values\Content\Field[] $fields |
||
5739 | * |
||
5740 | * @return \eZ\Publish\API\Repository\Values\Content\Field[] |
||
5741 | */ |
||
5742 | private function normalizeFields(array $fields) |
||
5768 | |||
5769 | /** |
||
5770 | * Returns a filtered set of the default fields fixture. |
||
5771 | * |
||
5772 | * @param string $languageCode |
||
5773 | * |
||
5774 | * @return \eZ\Publish\API\Repository\Values\Content\Field[] |
||
5775 | */ |
||
5776 | private function createLocaleFieldsFixture($languageCode) |
||
5787 | |||
5788 | /** |
||
5789 | * Asserts that given Content has default ContentStates. |
||
5790 | * |
||
5791 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
5792 | */ |
||
5793 | View Code Duplication | private function assertDefaultContentStates(ContentInfo $contentInfo) |
|
5812 | |||
5813 | /** |
||
5814 | * Assert that given Content has no references to a translation specified by the $languageCode. |
||
5815 | * |
||
5816 | * @param string $languageCode |
||
5817 | * @param int $contentId |
||
5818 | */ |
||
5819 | private function assertTranslationDoesNotExist($languageCode, $contentId) |
||
5841 | |||
5842 | /** |
||
5843 | * Returns the default fixture of fields used in most tests. |
||
5844 | * |
||
5845 | * @return \eZ\Publish\API\Repository\Values\Content\Field[] |
||
5846 | */ |
||
5847 | private function createFieldsFixture() |
||
5884 | |||
5885 | /** |
||
5886 | * Gets expected property values for the "Media" ContentInfo ValueObject. |
||
5887 | * |
||
5888 | * @return array |
||
5889 | */ |
||
5890 | View Code Duplication | private function getExpectedMediaContentInfoProperties() |
|
5908 | } |
||
5909 |
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.