Code Duplication    Length = 38-50 lines in 3 locations

eZ/Publish/Core/Repository/Tests/Service/Mock/PermissionTest.php 3 locations

@@ 238-287 (lines=50) @@
235
    /**
236
     * @return array
237
     */
238
    public function providerForTestHasAccessReturnsPermissionSets()
239
    {
240
        return [
241
            [
242
                [
243
                    31 => $this->createRole(
244
                        [
245
                            ['test-module', 'test-function', 'test-limitation'],
246
                        ],
247
                        31
248
                    ),
249
                ],
250
                [
251
                    new RoleAssignment(
252
                        [
253
                            'roleId' => 31,
254
                        ]
255
                    ),
256
                ],
257
            ],
258
            [
259
                [
260
                    31 => $this->createRole(
261
                        [
262
                            ['test-module', 'test-function', 'test-limitation'],
263
                        ],
264
                        31
265
                    ),
266
                    32 => $this->createRole(
267
                        [
268
                            ['test-module', 'test-function', 'test-limitation2'],
269
                        ],
270
                        32
271
                    ),
272
                ],
273
                [
274
                    new RoleAssignment(
275
                        [
276
                            'roleId' => 31,
277
                        ]
278
                    ),
279
                    new RoleAssignment(
280
                        [
281
                            'roleId' => 32,
282
                        ]
283
                    ),
284
                ],
285
            ],
286
        ];
287
    }
288
289
    /**
290
     * Test for the hasAccess() method.
@@ 352-401 (lines=50) @@
349
    /**
350
     * @return array
351
     */
352
    public function providerForTestHasAccessReturnsException()
353
    {
354
        return [
355
            [
356
                [
357
                    31 => $this->createRole(
358
                        [
359
                            ['test-module', 'test-function', 'notfound'],
360
                        ],
361
                        31
362
                    ),
363
                ],
364
                [
365
                    new RoleAssignment(
366
                        [
367
                            'roleId' => 31,
368
                        ]
369
                    ),
370
                ],
371
            ],
372
            [
373
                [
374
                    31 => $this->createRole(
375
                        [
376
                            ['test-module', 'test-function', 'test-limitation'],
377
                        ],
378
                        31
379
                    ),
380
                    32 => $this->createRole(
381
                        [
382
                            ['test-module', 'test-function', 'notfound'],
383
                        ],
384
                        32
385
                    ),
386
                ],
387
                [
388
                    new RoleAssignment(
389
                        [
390
                            'roleId' => 31,
391
                        ]
392
                    ),
393
                    new RoleAssignment(
394
                        [
395
                            'roleId' => 32,
396
                        ]
397
                    ),
398
                ],
399
            ],
400
        ];
401
    }
402
403
    /**
404
     * Test for the hasAccess() method.
@@ 463-500 (lines=38) @@
460
        $permissionResolverMock->hasAccess('test-module', 'test-function');
461
    }
462
463
    public function providerForTestHasAccessReturnsPermissionSetsWithRoleLimitation()
464
    {
465
        return [
466
            [
467
                [
468
                    32 => $this->createRole(
469
                        [
470
                            ['test-module', 'test-function', 'test-limitation'],
471
                        ],
472
                        32
473
                    ),
474
                ],
475
                [
476
                    new RoleAssignment(
477
                        [
478
                            'roleId' => 32,
479
                            'limitationIdentifier' => 'test-role-limitation',
480
                            'values' => ['test-role-limitation-value'],
481
                        ]
482
                    ),
483
                ],
484
            ],
485
            [
486
                [
487
                    33 => $this->createRole([['*', '*', '*']], 33),
488
                ],
489
                [
490
                    new RoleAssignment(
491
                        [
492
                            'roleId' => 33,
493
                            'limitationIdentifier' => 'test-role-limitation',
494
                            'values' => ['test-role-limitation-value'],
495
                        ]
496
                    ),
497
                ],
498
            ],
499
        ];
500
    }
501
502
    /**
503
     * Test for the hasAccess() method.