Code Duplication    Length = 18-19 lines in 2 locations

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

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