Code Duplication    Length = 28-35 lines in 2 locations

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.

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

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