Code Duplication    Length = 22-24 lines in 2 locations

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

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