Code Duplication    Length = 22-24 lines in 2 locations

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

@@ 1393-1414 (lines=22) @@
1390
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
1391
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent
1392
     */
1393
    public function testUpdateContentThrowsInvalidArgumentExceptionWhenFieldTypeDoesNotAccept()
1394
    {
1395
        $repository = $this->getRepository();
1396
1397
        $contentService = $repository->getContentService();
1398
1399
        /* BEGIN: Use Case */
1400
        $draft = $this->createContentDraftVersion1();
1401
1402
        // Now create an update struct and modify some fields
1403
        $contentUpdateStruct = $contentService->newContentUpdateStruct();
1404
        // The name field does not accept a stdClass object as its input
1405
        $contentUpdateStruct->setField('name', new \stdClass(), 'eng-US');
1406
1407
        // Throws an InvalidArgumentException, since the value for field "name"
1408
        // is not accepted
1409
        $contentService->updateContent(
1410
            $draft->getVersionInfo(),
1411
            $contentUpdateStruct
1412
        );
1413
        /* END: Use Case */
1414
    }
1415
1416
    /**
1417
     * Test for the updateContent() method.
@@ 1423-1446 (lines=24) @@
1420
     * @expectedException \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException
1421
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent
1422
     */
1423
    public function testUpdateContentWhenMandatoryFieldIsEmpty()
1424
    {
1425
        $repository = $this->getRepository();
1426
1427
        $contentService = $repository->getContentService();
1428
1429
        /* BEGIN: Use Case */
1430
        $draft = $this->createContentDraftVersion1();
1431
1432
        // Now create an update struct and set a mandatory field to null
1433
        $contentUpdateStruct = $contentService->newContentUpdateStruct();
1434
        $contentUpdateStruct->setField('name', null);
1435
1436
        // Don't set this, then the above call without languageCode will fail
1437
        $contentUpdateStruct->initialLanguageCode = 'eng-US';
1438
1439
        // This call will fail with a "ContentFieldValidationException", because the
1440
        // mandatory "name" field is empty.
1441
        $contentService->updateContent(
1442
            $draft->getVersionInfo(),
1443
            $contentUpdateStruct
1444
        );
1445
        /* END: Use Case */
1446
    }
1447
1448
    /**
1449
     * Test for the updateContent() method.