Code Duplication    Length = 38-38 lines in 2 locations

eZ/Publish/Core/Persistence/Cache/Tests/UserHandlerTest.php 2 locations

@@ 360-397 (lines=38) @@
357
    /**
358
     * @covers \eZ\Publish\Core\Persistence\Cache\UserHandler::loadRoleAssignmentsByGroupId
359
     */
360
    public function testLoadRoleAssignmentsByGroupIdHasCache()
361
    {
362
        $this->loggerMock->expects($this->never())->method('logCall');
363
364
        $cacheItemMock = $this->getCacheItemMock();
365
        $this->cacheMock
366
            ->expects($this->once())
367
            ->method('getItem')
368
            ->with('user', 'role', 'assignments', 'byGroup', 42)
369
            ->will($this->returnValue($cacheItemMock));
370
371
        $cacheItemMock
372
            ->expects($this->once())
373
            ->method('get')
374
            ->will(
375
                $this->returnValue(array(new RoleAssignment(array('roleId' => 33))))
376
            );
377
378
        $cacheItemMock
379
            ->expects($this->once())
380
            ->method('isMiss')
381
            ->will($this->returnValue(false));
382
383
        $this->persistenceHandlerMock
384
            ->expects($this->never())
385
            ->method($this->anything());
386
387
        $cacheItemMock
388
            ->expects($this->never())
389
            ->method('set');
390
391
        $handler = $this->persistenceCacheHandler->userHandler();
392
        $roleAssignments = $handler->loadRoleAssignmentsByGroupId(42);
393
394
        $this->assertEquals(1, count($roleAssignments));
395
        $this->assertInstanceOf(RoleAssignment::class, $roleAssignments[0]);
396
        $this->assertEquals(33, $roleAssignments[0]->roleId);
397
    }
398
399
    /**
400
     * @covers \eZ\Publish\Core\Persistence\Cache\UserHandler::loadRoleAssignmentsByGroupId
@@ 459-496 (lines=38) @@
456
    /**
457
     * @covers \eZ\Publish\Core\Persistence\Cache\UserHandler::loadRoleAssignmentsByGroupId
458
     */
459
    public function testLoadRoleAssignmentsByGroupIdInheritedHasCache()
460
    {
461
        $this->loggerMock->expects($this->never())->method('logCall');
462
463
        $cacheItemMock = $this->getCacheItemMock();
464
        $this->cacheMock
465
            ->expects($this->once())
466
            ->method('getItem')
467
            ->with('user', 'role', 'assignments', 'byGroup', 'inherited', '42')
468
            ->will($this->returnValue($cacheItemMock));
469
470
        $cacheItemMock
471
            ->expects($this->once())
472
            ->method('get')
473
            ->will(
474
                $this->returnValue(array(new RoleAssignment(array('roleId' => 33))))
475
            );
476
477
        $cacheItemMock
478
            ->expects($this->once())
479
            ->method('isMiss')
480
            ->will($this->returnValue(false));
481
482
        $this->persistenceHandlerMock
483
            ->expects($this->never())
484
            ->method($this->anything());
485
486
        $cacheItemMock
487
            ->expects($this->never())
488
            ->method('set');
489
490
        $handler = $this->persistenceCacheHandler->userHandler();
491
        $roleAssignments = $handler->loadRoleAssignmentsByGroupId(42, true);
492
493
        $this->assertEquals(1, count($roleAssignments));
494
        $this->assertInstanceOf(RoleAssignment::class, $roleAssignments[0]);
495
        $this->assertEquals(33, $roleAssignments[0]->roleId);
496
    }
497
498
    /**
499
     * @covers \eZ\Publish\Core\Persistence\Cache\UserHandler::createRole