Code Duplication    Length = 22-24 lines in 2 locations

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

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