Code Duplication    Length = 18-19 lines in 2 locations

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

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