Code Duplication    Length = 22-24 lines in 2 locations

eZ/Publish/API/Repository/Tests/ContentServiceTest.php 2 locations

@@ 1554-1575 (lines=22) @@
1551
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
1552
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent
1553
     */
1554
    public function testUpdateContentThrowsInvalidArgumentExceptionWhenFieldTypeDoesNotAccept()
1555
    {
1556
        $repository = $this->getRepository();
1557
1558
        $contentService = $repository->getContentService();
1559
1560
        /* BEGIN: Use Case */
1561
        $draft = $this->createContentDraftVersion1();
1562
1563
        // Now create an update struct and modify some fields
1564
        $contentUpdateStruct = $contentService->newContentUpdateStruct();
1565
        // The name field does not accept a stdClass object as its input
1566
        $contentUpdateStruct->setField('name', new \stdClass(), 'eng-US');
1567
1568
        // Throws an InvalidArgumentException, since the value for field "name"
1569
        // is not accepted
1570
        $contentService->updateContent(
1571
            $draft->getVersionInfo(),
1572
            $contentUpdateStruct
1573
        );
1574
        /* END: Use Case */
1575
    }
1576
1577
    /**
1578
     * Test for the updateContent() method.
@@ 1584-1607 (lines=24) @@
1581
     * @expectedException \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException
1582
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent
1583
     */
1584
    public function testUpdateContentWhenMandatoryFieldIsEmpty()
1585
    {
1586
        $repository = $this->getRepository();
1587
1588
        $contentService = $repository->getContentService();
1589
1590
        /* BEGIN: Use Case */
1591
        $draft = $this->createContentDraftVersion1();
1592
1593
        // Now create an update struct and set a mandatory field to null
1594
        $contentUpdateStruct = $contentService->newContentUpdateStruct();
1595
        $contentUpdateStruct->setField('name', null);
1596
1597
        // Don't set this, then the above call without languageCode will fail
1598
        $contentUpdateStruct->initialLanguageCode = 'eng-US';
1599
1600
        // This call will fail with a "ContentFieldValidationException", because the
1601
        // mandatory "name" field is empty.
1602
        $contentService->updateContent(
1603
            $draft->getVersionInfo(),
1604
            $contentUpdateStruct
1605
        );
1606
        /* END: Use Case */
1607
    }
1608
1609
    /**
1610
     * Test for the updateContent() method.