Code Duplication    Length = 18-19 lines in 2 locations

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

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