Code Duplication    Length = 22-24 lines in 2 locations

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

@@ 1568-1589 (lines=22) @@
1565
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
1566
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent
1567
     */
1568
    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.
@@ 1598-1621 (lines=24) @@
1595
     * @expectedException \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException
1596
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent
1597
     */
1598
    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.