Code Duplication    Length = 18-19 lines in 2 locations

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

@@ 300-318 (lines=19) @@
297
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
298
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent
299
     */
300
    public function testCreateContentThrowsInvalidArgumentExceptionOnFieldTypeNotAccept()
301
    {
302
        $repository = $this->getRepository();
303
304
        /* BEGIN: Use Case */
305
        $contentTypeService = $repository->getContentTypeService();
306
        $contentService = $repository->getContentService();
307
308
        $contentType = $contentTypeService->loadContentTypeByIdentifier('forum');
309
310
        $contentCreate = $contentService->newContentCreateStruct($contentType, 'eng-US');
311
        // The name field does only accept strings and null as its values
312
        $contentCreate->setField('name', new \stdClass());
313
314
        // Throws InvalidArgumentException since the name field is filled
315
        // improperly
316
        $draft = $contentService->createContent($contentCreate);
317
        /* END: Use Case */
318
    }
319
320
    /**
321
     * Test for the createContent() method.
@@ 355-372 (lines=18) @@
352
     * @expectedException \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException
353
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent
354
     */
355
    public function testCreateContentRequiredFieldMissing()
356
    {
357
        $repository = $this->getRepository();
358
359
        /* BEGIN: Use Case */
360
        $contentTypeService = $repository->getContentTypeService();
361
        $contentService = $repository->getContentService();
362
363
        $contentType = $contentTypeService->loadContentTypeByIdentifier('forum');
364
365
        $contentCreate1 = $contentService->newContentCreateStruct($contentType, 'eng-US');
366
        // Required field "name" is not set
367
368
        // Throws a ContentFieldValidationException, since a required field is
369
        // missing
370
        $draft = $contentService->createContent($contentCreate1);
371
        /* END: Use Case */
372
    }
373
374
    /**
375
     * Test for the createContent() method.