Code Duplication    Length = 38-38 lines in 2 locations

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

@@ 337-374 (lines=38) @@
334
    /**
335
     * @covers eZ\Publish\Core\Persistence\Cache\UserHandler::loadRoleAssignmentsByGroupId
336
     */
337
    public function testLoadRoleAssignmentsByGroupIdHasCache()
338
    {
339
        $this->loggerMock->expects($this->never())->method('logCall');
340
341
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
342
        $this->cacheMock
343
            ->expects($this->once())
344
            ->method('getItem')
345
            ->with('user', 'role', 'assignments', 'byGroup', 42)
346
            ->will($this->returnValue($cacheItemMock));
347
348
        $cacheItemMock
349
            ->expects($this->once())
350
            ->method('get')
351
            ->will(
352
                $this->returnValue(array(new RoleAssignment(array('roleId' => 33))))
353
            );
354
355
        $cacheItemMock
356
            ->expects($this->once())
357
            ->method('isMiss')
358
            ->will($this->returnValue(false));
359
360
        $this->persistenceHandlerMock
361
            ->expects($this->never())
362
            ->method($this->anything());
363
364
        $cacheItemMock
365
            ->expects($this->never())
366
            ->method('set');
367
368
        $handler = $this->persistenceCacheHandler->userHandler();
369
        $roleAssignments = $handler->loadRoleAssignmentsByGroupId(42);
370
371
        $this->assertEquals(1, count($roleAssignments));
372
        $this->assertInstanceOf('\\eZ\\Publish\\SPI\\Persistence\\User\\RoleAssignment', $roleAssignments[0]);
373
        $this->assertEquals(33, $roleAssignments[0]->roleId);
374
    }
375
376
    /**
377
     * @covers eZ\Publish\Core\Persistence\Cache\UserHandler::loadRoleAssignmentsByGroupId
@@ 430-467 (lines=38) @@
427
    /**
428
     * @covers eZ\Publish\Core\Persistence\Cache\UserHandler::loadRoleAssignmentsByGroupId
429
     */
430
    public function testLoadRoleAssignmentsByGroupIdInheritedHasCache()
431
    {
432
        $this->loggerMock->expects($this->never())->method('logCall');
433
434
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
435
        $this->cacheMock
436
            ->expects($this->once())
437
            ->method('getItem')
438
            ->with('user', 'role', 'assignments', 'byGroup', 'inherited', '42')
439
            ->will($this->returnValue($cacheItemMock));
440
441
        $cacheItemMock
442
            ->expects($this->once())
443
            ->method('get')
444
            ->will(
445
                $this->returnValue(array(new RoleAssignment(array('roleId' => 33))))
446
            );
447
448
        $cacheItemMock
449
            ->expects($this->once())
450
            ->method('isMiss')
451
            ->will($this->returnValue(false));
452
453
        $this->persistenceHandlerMock
454
            ->expects($this->never())
455
            ->method($this->anything());
456
457
        $cacheItemMock
458
            ->expects($this->never())
459
            ->method('set');
460
461
        $handler = $this->persistenceCacheHandler->userHandler();
462
        $roleAssignments = $handler->loadRoleAssignmentsByGroupId(42, true);
463
464
        $this->assertEquals(1, count($roleAssignments));
465
        $this->assertInstanceOf('\\eZ\\Publish\\SPI\\Persistence\\User\\RoleAssignment', $roleAssignments[0]);
466
        $this->assertEquals(33, $roleAssignments[0]->roleId);
467
    }
468
469
    /**
470
     * @covers eZ\Publish\Core\Persistence\Cache\UserHandler::createRole