Code Duplication    Length = 17-19 lines in 4 locations

eZ/Publish/API/Repository/Tests/LocationServiceAuthorizationTest.php 2 locations

@@ 130-147 (lines=18) @@
127
     * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
128
     * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation
129
     */
130
    public function testLoadLocationThrowsUnauthorizedException()
131
    {
132
        $repository = $this->getRepository();
133
134
        $editorsGroupId = $this->generateId('group', 13);
135
136
        /* BEGIN: Use Case */
137
        $locationService = $repository->getLocationService();
138
139
        $user = $this->createUserVersion1();
140
141
        // Set current user to newly created user
142
        $repository->setCurrentUser($user);
143
144
        // This call will fail with an "UnauthorizedException"
145
        $locationService->loadLocation($editorsGroupId);
146
        /* END: Use Case */
147
    }
148
149
    /**
150
     * Test for the loadLocationByRemoteId() method.
@@ 156-174 (lines=19) @@
153
     * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
154
     * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocationByRemoteId
155
     */
156
    public function testLoadLocationByRemoteIdThrowsUnauthorizedException()
157
    {
158
        $repository = $this->getRepository();
159
160
        /* BEGIN: Use Case */
161
        // remoteId of the "Editors" location in an eZ Publish demo installation
162
        $editorsRemoteId = 'f7dda2854fc68f7c8455d9cb14bd04a9';
163
164
        $locationService = $repository->getLocationService();
165
166
        $user = $this->createUserVersion1();
167
168
        // Set current user to newly created user
169
        $repository->setCurrentUser($user);
170
171
        // This call will fail with an "UnauthorizedException"
172
        $locationService->loadLocationByRemoteId($editorsRemoteId);
173
        /* END: Use Case */
174
    }
175
176
    /**
177
     * Test for the loadLocations() method.

eZ/Publish/API/Repository/Tests/LocationServiceTest.php 2 locations

@@ 317-335 (lines=19) @@
314
     * @see \eZ\Publish\API\Repository\LocationService::loadLocation()
315
     * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testCreateLocation
316
     */
317
    public function testLoadLocation()
318
    {
319
        $repository = $this->getRepository();
320
321
        $locationId = $this->generateId('location', 5);
322
        /* BEGIN: Use Case */
323
        // $locationId is the ID of an existing location
324
        $locationService = $repository->getLocationService();
325
326
        $location = $locationService->loadLocation($locationId);
327
        /* END: Use Case */
328
329
        $this->assertInstanceOf(
330
            '\\eZ\\Publish\\API\\Repository\\Values\\Content\\Location',
331
            $location
332
        );
333
334
        return $location;
335
    }
336
337
    /**
338
     * Test for the loadLocation() method.
@@ 452-468 (lines=17) @@
449
     * @see \eZ\Publish\API\Repository\LocationService::loadLocationByRemoteId()
450
     * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation
451
     */
452
    public function testLoadLocationByRemoteId()
453
    {
454
        $repository = $this->getRepository();
455
456
        /* BEGIN: Use Case */
457
        $locationService = $repository->getLocationService();
458
459
        $location = $locationService->loadLocationByRemoteId(
460
            '3f6d92f8044aed134f32153517850f5a'
461
        );
462
        /* END: Use Case */
463
464
        $this->assertEquals(
465
            $locationService->loadLocation($this->generateId('location', 5)),
466
            $location
467
        );
468
    }
469
470
    /**
471
     * Test for the loadLocationByRemoteId() method.