Code Duplication    Length = 22-24 lines in 2 locations

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

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