Code Duplication    Length = 18-19 lines in 2 locations

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

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