Code Duplication    Length = 28-35 lines in 2 locations

eZ/Publish/API/Repository/Tests/TrashServiceAuthorizationTest.php 1 location

@@ 141-168 (lines=28) @@
138
     * @depends eZ\Publish\API\Repository\Tests\TrashServiceTest::testRecover
139
     * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testLoadAnonymousUser
140
     */
141
    public function testRecoverThrowsUnauthorizedExceptionWithNewParentLocationParameter()
142
    {
143
        $repository = $this->getRepository();
144
        $trashService = $repository->getTrashService();
145
        $locationService = $repository->getLocationService();
146
147
        $homeLocationId = $this->generateId('location', 2);
148
        $anonymousUserId = $this->generateId('user', 10);
149
        /* BEGIN: Use Case */
150
        // $anonymousUserId is the ID of the "Anonymous" user
151
        // $homeLocationId is the ID of the "Home" location in an eZ Publish
152
        // demo installation
153
154
        $trashItem = $this->createTrashItem();
155
156
        // Get the new parent location
157
        $newParentLocation = $locationService->loadLocation($homeLocationId);
158
159
        // Load user service
160
        $userService = $repository->getUserService();
161
162
        // Set "Anonymous" as current user
163
        $repository->setCurrentUser($userService->loadUser($anonymousUserId));
164
165
        // This call will fail with an "UnauthorizedException"
166
        $trashService->recover($trashItem, $newParentLocation);
167
        /* END: Use Case */
168
    }
169
170
    /**
171
     * Test for the emptyTrash() method.

eZ/Publish/API/Repository/Tests/URLAliasServiceTest.php 1 location

@@ 803-837 (lines=35) @@
800
     *
801
     * @see \eZ\Publish\API\Repository\URLAliasService::removeAliases()
802
     */
803
    public function testRemoveAliases()
804
    {
805
        $repository = $this->getRepository();
806
807
        $locationService = $repository->getLocationService();
808
        $someLocation = $locationService->loadLocation(
809
            $this->generateId('location', 12)
810
        );
811
812
        /* BEGIN: Use Case */
813
        // $someLocation contains a location with automatically generated
814
        // aliases assigned
815
        $urlAliasService = $repository->getURLAliasService();
816
817
        $initialAliases = $urlAliasService->listLocationAliases($someLocation);
818
819
        // Creates a custom alias for $someLocation
820
        $urlAliasService->createUrlAlias(
821
            $someLocation,
822
            '/my/fancy/url/alias/sindelfingen',
823
            'eng-US'
824
        );
825
826
        $customAliases = $urlAliasService->listLocationAliases($someLocation);
827
828
        // The custom alias just created will be removed
829
        // the automatic aliases stay in tact
830
        $urlAliasService->removeAliases($customAliases);
831
        /* END: Use Case */
832
833
        $this->assertEquals(
834
            $initialAliases,
835
            $urlAliasService->listLocationAliases($someLocation)
836
        );
837
    }
838
839
    /**
840
     * Test for the removeAliases() method.