Code Duplication    Length = 18-19 lines in 2 locations

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

@@ 346-364 (lines=19) @@
343
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
344
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent
345
     */
346
    public function testCreateContentThrowsInvalidArgumentExceptionOnFieldTypeNotAccept()
347
    {
348
        $repository = $this->getRepository();
349
350
        /* BEGIN: Use Case */
351
        $contentTypeService = $repository->getContentTypeService();
352
        $contentService = $repository->getContentService();
353
354
        $contentType = $contentTypeService->loadContentTypeByIdentifier('forum');
355
356
        $contentCreate = $contentService->newContentCreateStruct($contentType, 'eng-US');
357
        // The name field does only accept strings and null as its values
358
        $contentCreate->setField('name', new \stdClass());
359
360
        // Throws InvalidArgumentException since the name field is filled
361
        // improperly
362
        $draft = $contentService->createContent($contentCreate);
363
        /* END: Use Case */
364
    }
365
366
    /**
367
     * Test for the createContent() method.
@@ 401-418 (lines=18) @@
398
     * @expectedException \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException
399
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent
400
     */
401
    public function testCreateContentRequiredFieldMissing()
402
    {
403
        $repository = $this->getRepository();
404
405
        /* BEGIN: Use Case */
406
        $contentTypeService = $repository->getContentTypeService();
407
        $contentService = $repository->getContentService();
408
409
        $contentType = $contentTypeService->loadContentTypeByIdentifier('forum');
410
411
        $contentCreate1 = $contentService->newContentCreateStruct($contentType, 'eng-US');
412
        // Required field "name" is not set
413
414
        // Throws a ContentFieldValidationException, since a required field is
415
        // missing
416
        $draft = $contentService->createContent($contentCreate1);
417
        /* END: Use Case */
418
    }
419
420
    /**
421
     * Test for the createContent() method.