Code Duplication    Length = 18-19 lines in 2 locations

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

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