Code Duplication    Length = 22-24 lines in 2 locations

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

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