Code Duplication    Length = 29-32 lines in 2 locations

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

@@ 31-62 (lines=32) @@
28
     * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
29
     * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testCreateLocation
30
     */
31
    public function testCreateLocationThrowsUnauthorizedException()
32
    {
33
        $repository = $this->getRepository();
34
35
        $editorsGroupId = $this->generateId('group', 13);
36
37
        /* BEGIN: Use Case */
38
        $contentService = $repository->getContentService();
39
        $locationService = $repository->getLocationService();
40
41
        $user = $this->createUserVersion1();
42
43
        // ContentInfo for "Editors" user group
44
        $contentInfo = $contentService->loadContentInfo($editorsGroupId);
45
46
        // Set current user to newly created user
47
        $repository->setCurrentUser($user);
48
49
        $locationCreate = $locationService->newLocationCreateStruct(1);
50
        $locationCreate->priority = 23;
51
        $locationCreate->hidden = true;
52
        $locationCreate->remoteId = 'sindelfingen';
53
        $locationCreate->sortField = Location::SORT_FIELD_NODE_ID;
54
        $locationCreate->sortOrder = Location::SORT_ORDER_DESC;
55
56
        // This call will fail with an "UnauthorizedException"
57
        $locationService->createLocation(
58
            $contentInfo,
59
            $locationCreate
60
        );
61
        /* END: Use Case */
62
    }
63
64
    /**
65
     * Test for the loadLocation() method.

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

@@ 267-295 (lines=29) @@
264
     * @dataProvider dataProviderForOutOfRangeLocationPriority
265
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
266
     */
267
    public function testCreateLocationThrowsInvalidArgumentExceptionPriorityIsOutOfRange($priority)
268
    {
269
        $repository = $this->getRepository();
270
271
        $contentId = $this->generateId('object', 41);
272
        $parentLocationId = $this->generateId('location', 5);
273
        /* BEGIN: Use Case */
274
        // $contentId is the ID of an existing content object
275
        // $parentLocationId is the ID of an existing location
276
        $contentService = $repository->getContentService();
277
        $locationService = $repository->getLocationService();
278
279
        // ContentInfo for "How to use eZ Publish"
280
        $contentInfo = $contentService->loadContentInfo($contentId);
281
282
        $locationCreate = $locationService->newLocationCreateStruct($parentLocationId);
283
        $locationCreate->priority = $priority;
284
        $locationCreate->hidden = true;
285
        $locationCreate->remoteId = 'sindelfingen';
286
        $locationCreate->sortField = Location::SORT_FIELD_NODE_ID;
287
        $locationCreate->sortOrder = Location::SORT_ORDER_DESC;
288
289
        // Throws exception, since priority is out of range
290
        $locationService->createLocation(
291
            $contentInfo,
292
            $locationCreate
293
        );
294
        /* END: Use Case */
295
    }
296
297
    public function dataProviderForOutOfRangeLocationPriority()
298
    {