Code Duplication    Length = 22-24 lines in 2 locations

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

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