Code Duplication    Length = 24-31 lines in 2 locations

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

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

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

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