Code Duplication    Length = 11-13 lines in 4 locations

eZ/Publish/API/Repository/Tests/ContentServiceAuthorizationTest.php 4 locations

@@ 290-300 (lines=11) @@
287
     * @see \eZ\Publish\API\Repository\ContentService::loadContentByContentInfo($contentInfo, $languages)
288
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByContentInfoWithLanguageParameters
289
     */
290
    public function testLoadContentByContentInfoThrowsUnauthorizedExceptionWithSecondParameter()
291
    {
292
        $contentInfo = $this->getContentInfoForAnonymousUser();
293
294
        $this->setRestrictedEditorUser();
295
296
        $this->expectException(UnauthorizedException::class);
297
        $this->expectExceptionMessageMatches('/\'read\' \'content\'/');
298
299
        $this->contentService->loadContentByContentInfo($contentInfo, ['eng-US']);
300
    }
301
302
    /**
303
     * Test for the loadContentByContentInfo() method.
@@ 308-318 (lines=11) @@
305
     * @see \eZ\Publish\API\Repository\ContentService::loadContentByContentInfo($contentInfo, $languages, $versionNo)
306
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByContentInfoWithVersionNumberParameter
307
     */
308
    public function testLoadContentByContentInfoThrowsUnauthorizedExceptionWithThirdParameter()
309
    {
310
        $contentInfo = $this->getContentInfoForAnonymousUser();
311
312
        $this->setRestrictedEditorUser();
313
314
        $this->expectException(UnauthorizedException::class);
315
        $this->expectExceptionMessageMatches('/\'read\' \'content\'/');
316
317
        $this->contentService->loadContentByContentInfo($contentInfo, ['eng-US'], 2);
318
    }
319
320
    /**
321
     * Test for the loadContentByVersionInfo() method.
@@ 326-338 (lines=13) @@
323
     * @see \eZ\Publish\API\Repository\ContentService::loadContentByVersionInfo()
324
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByVersionInfo
325
     */
326
    public function testLoadContentByVersionInfoThrowsUnauthorizedException()
327
    {
328
        $contentInfo = $this->getContentInfoForAnonymousUser();
329
330
        $versionInfo = $this->contentService->loadVersionInfo($contentInfo);
331
332
        $this->setRestrictedEditorUser();
333
334
        $this->expectException(UnauthorizedException::class);
335
        $this->expectExceptionMessageMatches('/\'read\' \'content\'/');
336
337
        $this->contentService->loadContentByVersionInfo($versionInfo);
338
    }
339
340
    /**
341
     * Test for the loadContentByVersionInfo() method.
@@ 346-358 (lines=13) @@
343
     * @see \eZ\Publish\API\Repository\ContentService::loadContentByVersionInfo($versionInfo, $languages)
344
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByVersionInfoWithSecondParameter
345
     */
346
    public function testLoadContentByVersionInfoThrowsUnauthorizedExceptionWithSecondParameter()
347
    {
348
        $contentInfo = $this->getContentInfoForAnonymousUser();
349
350
        $versionInfo = $this->contentService->loadVersionInfo($contentInfo);
351
352
        $this->setRestrictedEditorUser();
353
354
        $this->expectException(UnauthorizedException::class);
355
        $this->expectExceptionMessageMatches('/\'read\' \'content\'/');
356
357
        $this->contentService->loadContentByVersionInfo($versionInfo, ['eng-US']);
358
    }
359
360
    /**
361
     * Test for the loadContent() method.