Code Duplication    Length = 25-25 lines in 3 locations

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

@@ 209-233 (lines=25) @@
206
     * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testNewLocationCreateStruct
207
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
208
     */
209
    public function testCreateLocationThrowsInvalidArgumentExceptionContentAlreadyBelowParent()
210
    {
211
        $repository = $this->getRepository();
212
213
        $contentId = $this->generateId('object', 11);
214
        $parentLocationId = $this->generateId('location', 5);
215
        /* BEGIN: Use Case */
216
        // $contentId is the ID of an existing content object
217
        // $parentLocationId is the ID of an existing location which already
218
        // has the content assigned to one of its descendant locations
219
        $contentService = $repository->getContentService();
220
        $locationService = $repository->getLocationService();
221
222
        // ContentInfo for "How to use eZ Publish"
223
        $contentInfo = $contentService->loadContentInfo($contentId);
224
225
        $locationCreate = $locationService->newLocationCreateStruct($parentLocationId);
226
227
        // Throws exception, since content is already located at "/1/2/107/110/"
228
        $locationService->createLocation(
229
            $contentInfo,
230
            $locationCreate
231
        );
232
        /* END: Use Case */
233
    }
234
235
    /**
236
     * Test for the createLocation() method.
@@ 242-266 (lines=25) @@
239
     * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testNewLocationCreateStruct
240
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
241
     */
242
    public function testCreateLocationThrowsInvalidArgumentExceptionParentIsSubLocationOfContent()
243
    {
244
        $repository = $this->getRepository();
245
246
        $contentId = $this->generateId('object', 4);
247
        $parentLocationId = $this->generateId('location', 12);
248
        /* BEGIN: Use Case */
249
        // $contentId is the ID of an existing content object
250
        // $parentLocationId is the ID of an existing location which is below a
251
        // location that is assigned to the content
252
        $contentService = $repository->getContentService();
253
        $locationService = $repository->getLocationService();
254
255
        // ContentInfo for "How to use eZ Publish"
256
        $contentInfo = $contentService->loadContentInfo($contentId);
257
258
        $locationCreate = $locationService->newLocationCreateStruct($parentLocationId);
259
260
        // Throws exception, since content is already located at "/1/2/"
261
        $locationService->createLocation(
262
            $contentInfo,
263
            $locationCreate
264
        );
265
        /* END: Use Case */
266
    }
267
268
    /**
269
     * Test for the createLocation() method.
@@ 275-299 (lines=25) @@
272
     * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testNewLocationCreateStruct
273
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
274
     */
275
    public function testCreateLocationThrowsInvalidArgumentExceptionRemoteIdExists()
276
    {
277
        $repository = $this->getRepository();
278
279
        $contentId = $this->generateId('object', 41);
280
        $parentLocationId = $this->generateId('location', 5);
281
        /* BEGIN: Use Case */
282
        // $contentId is the ID of an existing content object
283
        $contentService = $repository->getContentService();
284
        $locationService = $repository->getLocationService();
285
286
        // ContentInfo for "How to use eZ Publish"
287
        $contentInfo = $contentService->loadContentInfo($contentId);
288
289
        $locationCreate = $locationService->newLocationCreateStruct($parentLocationId);
290
        // This remote ID already exists
291
        $locationCreate->remoteId = 'f3e90596361e31d496d4026eb624c983';
292
293
        // Throws exception, since remote ID is already in use
294
        $locationService->createLocation(
295
            $contentInfo,
296
            $locationCreate
297
        );
298
        /* END: Use Case */
299
    }
300
301
    /**
302
     * Test for the createLocation() method.