Code Duplication    Length = 22-24 lines in 2 locations

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

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