Code Duplication    Length = 24-31 lines in 2 locations

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

@@ 126-156 (lines=31) @@
123
     *
124
     * @see \eZ\Publish\API\Repository\SectionService::loadSections()
125
     */
126
    public function testLoadSectionsLoadsEmptyListForAnonymousUser()
127
    {
128
        $repository = $this->getRepository();
129
130
        $anonymousUserId = $this->generateId('user', 10);
131
        /* BEGIN: Use Case */
132
        // $anonymousUserId is the ID of the "Anonymous" user in a eZ
133
        // Publish demo installation.
134
        $userService = $repository->getUserService();
135
        $sectionService = $repository->getSectionService();
136
137
        // Create some sections
138
        $sectionCreateOne = $sectionService->newSectionCreateStruct();
139
        $sectionCreateOne->name = 'Test section one';
140
        $sectionCreateOne->identifier = 'uniqueKeyOne';
141
142
        $sectionCreateTwo = $sectionService->newSectionCreateStruct();
143
        $sectionCreateTwo->name = 'Test section two';
144
        $sectionCreateTwo->identifier = 'uniqueKeyTwo';
145
146
        $sectionService->createSection($sectionCreateOne);
147
        $sectionService->createSection($sectionCreateTwo);
148
149
        // Set anonymous user
150
        $repository->getPermissionResolver()->setCurrentUserReference($userService->loadUser($anonymousUserId));
151
152
        $sections = $sectionService->loadSections();
153
        /* END: Use Case */
154
155
        $this->assertEquals([], $sections);
156
    }
157
158
    /**
159
     * Test for the loadSections() method.

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

@@ 1443-1466 (lines=24) @@
1440
     * @see \eZ\Publish\API\Repository\LocationService::updateLocation()
1441
     * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation
1442
     */
1443
    public function testUpdateLocationTwice()
1444
    {
1445
        $repository = $this->getRepository();
1446
        $permissionResolver = $repository->getPermissionResolver();
1447
1448
        $locationId = $this->generateId('location', 5);
1449
        /* BEGIN: Use Case */
1450
        $locationService = $repository->getLocationService();
1451
        $permissionResolver->setCurrentUserReference($repository->getUserService()->loadUser(14));
1452
1453
        $originalLocation = $locationService->loadLocation($locationId);
1454
1455
        $updateStruct = $locationService->newLocationUpdateStruct();
1456
        $updateStruct->priority = 42;
1457
1458
        $updatedLocation = $locationService->updateLocation($originalLocation, $updateStruct);
1459
1460
        // Repeated update with the same, unchanged struct
1461
        $secondUpdatedLocation = $locationService->updateLocation($updatedLocation, $updateStruct);
1462
        /* END: Use Case */
1463
1464
        $this->assertEquals($updatedLocation->priority, 42);
1465
        $this->assertEquals($secondUpdatedLocation->priority, 42);
1466
    }
1467
1468
    /**
1469
     * Test for the swapLocation() method.