Code Duplication    Length = 18-19 lines in 2 locations

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

@@ 317-335 (lines=19) @@
314
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
315
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent
316
     */
317
    public function testCreateContentThrowsInvalidArgumentExceptionOnFieldTypeNotAccept()
318
    {
319
        $repository = $this->getRepository();
320
321
        /* BEGIN: Use Case */
322
        $contentTypeService = $repository->getContentTypeService();
323
        $contentService = $repository->getContentService();
324
325
        $contentType = $contentTypeService->loadContentTypeByIdentifier('forum');
326
327
        $contentCreate = $contentService->newContentCreateStruct($contentType, 'eng-US');
328
        // The name field does only accept strings and null as its values
329
        $contentCreate->setField('name', new \stdClass());
330
331
        // Throws InvalidArgumentException since the name field is filled
332
        // improperly
333
        $draft = $contentService->createContent($contentCreate);
334
        /* END: Use Case */
335
    }
336
337
    /**
338
     * Test for the createContent() method.
@@ 372-389 (lines=18) @@
369
     * @expectedException \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException
370
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent
371
     */
372
    public function testCreateContentRequiredFieldMissing()
373
    {
374
        $repository = $this->getRepository();
375
376
        /* BEGIN: Use Case */
377
        $contentTypeService = $repository->getContentTypeService();
378
        $contentService = $repository->getContentService();
379
380
        $contentType = $contentTypeService->loadContentTypeByIdentifier('forum');
381
382
        $contentCreate1 = $contentService->newContentCreateStruct($contentType, 'eng-US');
383
        // Required field "name" is not set
384
385
        // Throws a ContentFieldValidationException, since a required field is
386
        // missing
387
        $draft = $contentService->createContent($contentCreate1);
388
        /* END: Use Case */
389
    }
390
391
    /**
392
     * Test for the createContent() method.