Code Duplication    Length = 25-25 lines in 3 locations

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

@@ 172-196 (lines=25) @@
169
     * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testNewLocationCreateStruct
170
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
171
     */
172
    public function testCreateLocationThrowsInvalidArgumentExceptionContentAlreadyBelowParent()
173
    {
174
        $repository = $this->getRepository();
175
176
        $contentId = $this->generateId('object', 11);
177
        $parentLocationId = $this->generateId('location', 5);
178
        /* BEGIN: Use Case */
179
        // $contentId is the ID of an existing content object
180
        // $parentLocationId is the ID of an existing location which already
181
        // has the content assigned to one of its descendant locations
182
        $contentService = $repository->getContentService();
183
        $locationService = $repository->getLocationService();
184
185
        // ContentInfo for "How to use eZ Publish"
186
        $contentInfo = $contentService->loadContentInfo($contentId);
187
188
        $locationCreate = $locationService->newLocationCreateStruct($parentLocationId);
189
190
        // Throws exception, since content is already located at "/1/2/107/110/"
191
        $locationService->createLocation(
192
            $contentInfo,
193
            $locationCreate
194
        );
195
        /* END: Use Case */
196
    }
197
198
    /**
199
     * Test for the createLocation() method.
@@ 205-229 (lines=25) @@
202
     * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testNewLocationCreateStruct
203
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
204
     */
205
    public function testCreateLocationThrowsInvalidArgumentExceptionParentIsSubLocationOfContent()
206
    {
207
        $repository = $this->getRepository();
208
209
        $contentId = $this->generateId('object', 4);
210
        $parentLocationId = $this->generateId('location', 12);
211
        /* BEGIN: Use Case */
212
        // $contentId is the ID of an existing content object
213
        // $parentLocationId is the ID of an existing location which is below a
214
        // location that is assigned to the content
215
        $contentService = $repository->getContentService();
216
        $locationService = $repository->getLocationService();
217
218
        // ContentInfo for "How to use eZ Publish"
219
        $contentInfo = $contentService->loadContentInfo($contentId);
220
221
        $locationCreate = $locationService->newLocationCreateStruct($parentLocationId);
222
223
        // Throws exception, since content is already located at "/1/2/"
224
        $locationService->createLocation(
225
            $contentInfo,
226
            $locationCreate
227
        );
228
        /* END: Use Case */
229
    }
230
231
    /**
232
     * Test for the createLocation() method.
@@ 238-262 (lines=25) @@
235
     * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testNewLocationCreateStruct
236
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
237
     */
238
    public function testCreateLocationThrowsInvalidArgumentExceptionRemoteIdExists()
239
    {
240
        $repository = $this->getRepository();
241
242
        $contentId = $this->generateId('object', 41);
243
        $parentLocationId = $this->generateId('location', 5);
244
        /* BEGIN: Use Case */
245
        // $contentId is the ID of an existing content object
246
        $contentService = $repository->getContentService();
247
        $locationService = $repository->getLocationService();
248
249
        // ContentInfo for "How to use eZ Publish"
250
        $contentInfo = $contentService->loadContentInfo($contentId);
251
252
        $locationCreate = $locationService->newLocationCreateStruct($parentLocationId);
253
        // This remote ID already exists
254
        $locationCreate->remoteId = 'f3e90596361e31d496d4026eb624c983';
255
256
        // Throws exception, since remote ID is already in use
257
        $locationService->createLocation(
258
            $contentInfo,
259
            $locationCreate
260
        );
261
        /* END: Use Case */
262
    }
263
264
    /**
265
     * Test for the createLocation() method.