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

@@ 1378-1401 (lines=24) @@
1375
     * @see \eZ\Publish\API\Repository\LocationService::updateLocation()
1376
     * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation
1377
     */
1378
    public function testUpdateLocationTwice()
1379
    {
1380
        $repository = $this->getRepository();
1381
        $permissionResolver = $repository->getPermissionResolver();
1382
1383
        $locationId = $this->generateId('location', 5);
1384
        /* BEGIN: Use Case */
1385
        $locationService = $repository->getLocationService();
1386
        $permissionResolver->setCurrentUserReference($repository->getUserService()->loadUser(14));
1387
1388
        $originalLocation = $locationService->loadLocation($locationId);
1389
1390
        $updateStruct = $locationService->newLocationUpdateStruct();
1391
        $updateStruct->priority = 42;
1392
1393
        $updatedLocation = $locationService->updateLocation($originalLocation, $updateStruct);
1394
1395
        // Repeated update with the same, unchanged struct
1396
        $secondUpdatedLocation = $locationService->updateLocation($updatedLocation, $updateStruct);
1397
        /* END: Use Case */
1398
1399
        $this->assertEquals($updatedLocation->priority, 42);
1400
        $this->assertEquals($secondUpdatedLocation->priority, 42);
1401
    }
1402
1403
    /**
1404
     * Test for the swapLocation() method.