Code Duplication    Length = 18-19 lines in 2 locations

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

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