Code Duplication    Length = 31-32 lines in 2 locations

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

@@ 238-269 (lines=32) @@
235
     * @see \eZ\Publish\API\Repository\LocationService::updateLocation()
236
     * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testUpdateLocation
237
     */
238
    public function testUpdateLocationThrowsUnauthorizedException()
239
    {
240
        $this->expectException(\eZ\Publish\API\Repository\Exceptions\UnauthorizedException::class);
241
242
        $repository = $this->getRepository();
243
        $permissionResolver = $repository->getPermissionResolver();
244
245
        $editorsGroupId = $this->generateId('group', 13);
246
247
        /* BEGIN: Use Case */
248
        $user = $this->createUserVersion1();
249
250
        $locationService = $repository->getLocationService();
251
252
        $originalLocation = $locationService->loadLocation($editorsGroupId);
253
254
        $locationUpdateStruct = $locationService->newLocationUpdateStruct();
255
        $locationUpdateStruct->priority = 3;
256
        $locationUpdateStruct->remoteId = 'c7adcbf1e96bc29bca28c2d809d0c7ef69272651';
257
        $locationUpdateStruct->sortField = Location::SORT_FIELD_PRIORITY;
258
        $locationUpdateStruct->sortOrder = Location::SORT_ORDER_DESC;
259
260
        // Set current user to newly created user
261
        $permissionResolver->setCurrentUserReference($user);
262
263
        // This call will fail with an "UnauthorizedException"
264
        $locationService->updateLocation(
265
            $originalLocation,
266
            $locationUpdateStruct
267
        );
268
        /* END: Use Case */
269
    }
270
271
    /**
272
     * Test for the swapLocation() method.

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

@@ 310-340 (lines=31) @@
307
     * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testNewLocationCreateStruct
308
     * @dataProvider dataProviderForOutOfRangeLocationPriority
309
     */
310
    public function testCreateLocationThrowsInvalidArgumentExceptionPriorityIsOutOfRange($priority)
311
    {
312
        $this->expectException(\eZ\Publish\API\Repository\Exceptions\InvalidArgumentException::class);
313
314
        $repository = $this->getRepository();
315
316
        $contentId = $this->generateId('object', 41);
317
        $parentLocationId = $this->generateId('location', 5);
318
        /* BEGIN: Use Case */
319
        // $contentId is the ID of an existing content object
320
        // $parentLocationId is the ID of an existing location
321
        $contentService = $repository->getContentService();
322
        $locationService = $repository->getLocationService();
323
324
        // ContentInfo for "How to use eZ Publish"
325
        $contentInfo = $contentService->loadContentInfo($contentId);
326
327
        $locationCreate = $locationService->newLocationCreateStruct($parentLocationId);
328
        $locationCreate->priority = $priority;
329
        $locationCreate->hidden = true;
330
        $locationCreate->remoteId = 'sindelfingen';
331
        $locationCreate->sortField = Location::SORT_FIELD_NODE_ID;
332
        $locationCreate->sortOrder = Location::SORT_ORDER_DESC;
333
334
        // Throws exception, since priority is out of range
335
        $locationService->createLocation(
336
            $contentInfo,
337
            $locationCreate
338
        );
339
        /* END: Use Case */
340
    }
341
342
    public function dataProviderForOutOfRangeLocationPriority()
343
    {