Code Duplication    Length = 16-18 lines in 3 locations

eZ/Publish/API/Repository/Tests/ContentTypeServiceTest.php 3 locations

@@ 3440-3457 (lines=18) @@
3437
     * @see \eZ\Publish\API\Repository\ContentTypeService::assignContentTypeGroup()
3438
     * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testAssignContentTypeGroup
3439
     */
3440
    public function testAssignContentTypeGroupThrowsInvalidArgumentException()
3441
    {
3442
        $this->expectException(\eZ\Publish\API\Repository\Exceptions\InvalidArgumentException::class);
3443
3444
        $repository = $this->getRepository();
3445
3446
        /* BEGIN: Use Case */
3447
        $contentTypeService = $repository->getContentTypeService();
3448
3449
        $folderType = $contentTypeService->loadContentTypeByIdentifier('folder');
3450
        $assignedGroups = $folderType->contentTypeGroups;
3451
3452
        foreach ($assignedGroups as $assignedGroup) {
3453
            // Throws an exception, since group is already assigned
3454
            $contentTypeService->assignContentTypeGroup($folderType, $assignedGroup);
3455
        }
3456
        /* END: Use Case */
3457
    }
3458
3459
    /**
3460
     * Test for the unassignContentTypeGroup() method.
@@ 3503-3518 (lines=16) @@
3500
     * @see \eZ\Publish\API\Repository\ContentTypeService::unassignContentTypeGroup()
3501
     * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testUnassignContentTypeGroup
3502
     */
3503
    public function testUnassignContentTypeGroupThrowsInvalidArgumentException()
3504
    {
3505
        $this->expectException(\eZ\Publish\API\Repository\Exceptions\InvalidArgumentException::class);
3506
3507
        $repository = $this->getRepository();
3508
3509
        /* BEGIN: Use Case */
3510
        $contentTypeService = $repository->getContentTypeService();
3511
3512
        $folderType = $contentTypeService->loadContentTypeByIdentifier('folder');
3513
        $notAssignedGroup = $contentTypeService->loadContentTypeGroupByIdentifier('Media');
3514
3515
        // Throws an exception, since "Media" group is not assigned to "folder"
3516
        $contentTypeService->unassignContentTypeGroup($folderType, $notAssignedGroup);
3517
        /* END: Use Case */
3518
    }
3519
3520
    /**
3521
     * Test for the unassignContentTypeGroup() method.
@@ 3526-3543 (lines=18) @@
3523
     * @see \eZ\Publish\API\Repository\ContentTypeService::unassignContentTypeGroup()
3524
     * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testUnassignContentTypeGroup
3525
     */
3526
    public function testUnassignContentTypeGroupThrowsBadStateException()
3527
    {
3528
        $this->expectException(\eZ\Publish\API\Repository\Exceptions\BadStateException::class);
3529
3530
        $repository = $this->getRepository();
3531
3532
        /* BEGIN: Use Case */
3533
        $contentTypeService = $repository->getContentTypeService();
3534
3535
        $folderType = $contentTypeService->loadContentTypeByIdentifier('folder');
3536
        $assignedGroups = $folderType->contentTypeGroups;
3537
3538
        foreach ($assignedGroups as $assignedGroup) {
3539
            // Throws an exception, when last group is to be removed
3540
            $contentTypeService->unassignContentTypeGroup($folderType, $assignedGroup);
3541
        }
3542
        /* END: Use Case */
3543
    }
3544
3545
    /**
3546
     * Test for the createContentTypeGroup() method.