Code Duplication    Length = 18-25 lines in 5 locations

eZ/Publish/API/Repository/Tests/ContentServiceTest.php 1 location

@@ 1687-1711 (lines=25) @@
1684
     * @see \eZ\Publish\API\Repository\ContentService::publishVersion()
1685
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft
1686
     */
1687
    public function testPublishVersionFromOldContentDraftArchivesNewerVersionNo()
1688
    {
1689
        $repository = $this->getRepository();
1690
1691
        $contentService = $repository->getContentService();
1692
1693
        /* BEGIN: Use Case */
1694
        $content = $this->createContentVersion1();
1695
1696
        // Create a new draft with versionNo = 2
1697
        $draftedContentVersion2 = $contentService->createContentDraft($content->contentInfo);
1698
1699
        // Create another new draft with versionNo = 3
1700
        $draftedContentVersion3 = $contentService->createContentDraft($content->contentInfo);
1701
1702
        // Publish draft with versionNo = 3
1703
        $contentService->publishVersion($draftedContentVersion3->getVersionInfo());
1704
1705
        // Publish the first draft with versionNo = 2
1706
        // currentVersionNo is now 2, versionNo 3 will be archived
1707
        $publishedDraft = $contentService->publishVersion($draftedContentVersion2->getVersionInfo());
1708
        /* END: Use Case */
1709
1710
        $this->assertEquals(2, $publishedDraft->contentInfo->currentVersionNo);
1711
    }
1712
1713
    /**
1714
     * Test for the publishVersion() method, and that it creates limited archives.

eZ/Publish/API/Repository/Tests/FieldType/RichTextIntegrationTest.php 1 location

@@ 693-710 (lines=18) @@
690
     * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
691
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
692
     */
693
    public function testInternalLinkValidatorIgnoresMissingRelationOnNotUpdatedField()
694
    {
695
        $repository = $this->getRepository();
696
        $contentService = $repository->getContentService();
697
698
        list(, $contentB) = $this->prepareInternalLinkValidatorBrokenLinksTestCase($repository);
699
700
        // update field w/o erroneous link to trigger validation
701
        $contentUpdateStruct = $contentService->newContentUpdateStruct();
702
        $contentUpdateStruct->setField('data', $this->getValidUpdateFieldData(), 'eng-US');
703
704
        $contentDraftB = $contentService->updateContent(
705
            $contentService->createContentDraft($contentB->contentInfo)->versionInfo,
706
            $contentUpdateStruct
707
        );
708
709
        $contentService->publishVersion($contentDraftB->versionInfo);
710
    }
711
712
    /**
713
     * Test updating Content which contains links to deleted Location fails when updating broken field.

eZ/Publish/Core/Repository/Tests/Service/Integration/ContentBase.php 3 locations

@@ 1406-1429 (lines=24) @@
1403
     * @covers \eZ\Publish\Core\Repository\ContentService::updateContent
1404
     * @expectedException \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException
1405
     */
1406
    public function testUpdateContentThrowsContentFieldValidationException()
1407
    {
1408
        list($content, $contentType) = $this->createTestContent();
1409
1410
        /* BEGIN: Use Case */
1411
        $contentService = $this->repository->getContentService();
1412
1413
        $versionInfo = $contentService->loadVersionInfoById(
1414
            $content->id,
1415
            $content->getVersionInfo()->versionNo
1416
        );
1417
1418
        $contentUpdateStruct = $contentService->newContentUpdateStruct();
1419
        $contentUpdateStruct->initialLanguageCode = 'eng-US';
1420
        $contentUpdateStruct->setField(
1421
            'test_required_empty',
1422
            'a string that is too long and will not validate 12345678901234567890123456789012345678901234567890'
1423
        );
1424
1425
        // Throws an exception because "test_required_empty" field value is too long and fails
1426
        // field definition's string length validator
1427
        $updatedContent = $contentService->updateContent($versionInfo, $contentUpdateStruct);
1428
        /* END: Use Case */
1429
    }
1430
1431
    /**
1432
     * Test for the updateContent() method.
@@ 1437-1456 (lines=20) @@
1434
     * @covers \eZ\Publish\Core\Repository\ContentService::updateContent
1435
     * @expectedException \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException
1436
     */
1437
    public function testUpdateContentRequiredFieldEmpty()
1438
    {
1439
        list($content, $contentType) = $this->createTestContent();
1440
1441
        /* BEGIN: Use Case */
1442
        $contentService = $this->repository->getContentService();
1443
1444
        $versionInfo = $contentService->loadVersionInfoById(
1445
            $content->id,
1446
            $content->getVersionInfo()->versionNo
1447
        );
1448
1449
        $contentUpdateStruct = $contentService->newContentUpdateStruct();
1450
        $contentUpdateStruct->initialLanguageCode = 'eng-GB';
1451
        $contentUpdateStruct->setField('test_required_empty', '');
1452
1453
        // Throws an exception because required field is being updated with empty value
1454
        $updatedContent = $contentService->updateContent($versionInfo, $contentUpdateStruct);
1455
        /* END: Use Case */
1456
    }
1457
1458
    /**
1459
     * Test for the updateContent() method.
@@ 1464-1484 (lines=21) @@
1461
     * @covers \eZ\Publish\Core\Repository\ContentService::updateContent
1462
     * @expectedException \eZ\Publish\API\Repository\Exceptions\ContentValidationException
1463
     */
1464
    public function testUpdateContentThrowsContentValidationExceptionFieldDefinitionNonexistent()
1465
    {
1466
        list($content, $contentType) = $this->createTestContent();
1467
1468
        /* BEGIN: Use Case */
1469
        $contentService = $this->repository->getContentService();
1470
1471
        $versionInfo = $contentService->loadVersionInfoById(
1472
            $content->id,
1473
            $content->getVersionInfo()->versionNo
1474
        );
1475
1476
        $contentUpdateStruct = $contentService->newContentUpdateStruct();
1477
        $contentUpdateStruct->initialLanguageCode = 'eng-GB';
1478
        $contentUpdateStruct->setField('nonexistent_field_definition_identifier', 'eng-GB');
1479
1480
        // Throws an exception because field definition with identifier "nonexistent_field_definition_identifier"
1481
        // does not exist in content draft content type
1482
        $updatedContent = $contentService->updateContent($versionInfo, $contentUpdateStruct);
1483
        /* END: Use Case */
1484
    }
1485
1486
    /**
1487
     * Test for the updateContent() method.