Code Duplication    Length = 38-38 lines in 2 locations

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

@@ 349-386 (lines=38) @@
346
    /**
347
     * @covers eZ\Publish\Core\Persistence\Cache\UserHandler::loadRoleAssignmentsByGroupId
348
     */
349
    public function testLoadRoleAssignmentsByGroupIdHasCache()
350
    {
351
        $this->loggerMock->expects($this->never())->method('logCall');
352
353
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
354
        $this->cacheMock
355
            ->expects($this->once())
356
            ->method('getItem')
357
            ->with('user', 'role', 'assignments', 'byGroup', 42)
358
            ->will($this->returnValue($cacheItemMock));
359
360
        $cacheItemMock
361
            ->expects($this->once())
362
            ->method('get')
363
            ->will(
364
                $this->returnValue(array(new RoleAssignment(array('roleId' => 33))))
365
            );
366
367
        $cacheItemMock
368
            ->expects($this->once())
369
            ->method('isMiss')
370
            ->will($this->returnValue(false));
371
372
        $this->persistenceHandlerMock
373
            ->expects($this->never())
374
            ->method($this->anything());
375
376
        $cacheItemMock
377
            ->expects($this->never())
378
            ->method('set');
379
380
        $handler = $this->persistenceCacheHandler->userHandler();
381
        $roleAssignments = $handler->loadRoleAssignmentsByGroupId(42);
382
383
        $this->assertEquals(1, count($roleAssignments));
384
        $this->assertInstanceOf('\\eZ\\Publish\\SPI\\Persistence\\User\\RoleAssignment', $roleAssignments[0]);
385
        $this->assertEquals(33, $roleAssignments[0]->roleId);
386
    }
387
388
    /**
389
     * @covers eZ\Publish\Core\Persistence\Cache\UserHandler::loadRoleAssignmentsByGroupId
@@ 448-485 (lines=38) @@
445
    /**
446
     * @covers eZ\Publish\Core\Persistence\Cache\UserHandler::loadRoleAssignmentsByGroupId
447
     */
448
    public function testLoadRoleAssignmentsByGroupIdInheritedHasCache()
449
    {
450
        $this->loggerMock->expects($this->never())->method('logCall');
451
452
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
453
        $this->cacheMock
454
            ->expects($this->once())
455
            ->method('getItem')
456
            ->with('user', 'role', 'assignments', 'byGroup', 'inherited', '42')
457
            ->will($this->returnValue($cacheItemMock));
458
459
        $cacheItemMock
460
            ->expects($this->once())
461
            ->method('get')
462
            ->will(
463
                $this->returnValue(array(new RoleAssignment(array('roleId' => 33))))
464
            );
465
466
        $cacheItemMock
467
            ->expects($this->once())
468
            ->method('isMiss')
469
            ->will($this->returnValue(false));
470
471
        $this->persistenceHandlerMock
472
            ->expects($this->never())
473
            ->method($this->anything());
474
475
        $cacheItemMock
476
            ->expects($this->never())
477
            ->method('set');
478
479
        $handler = $this->persistenceCacheHandler->userHandler();
480
        $roleAssignments = $handler->loadRoleAssignmentsByGroupId(42, true);
481
482
        $this->assertEquals(1, count($roleAssignments));
483
        $this->assertInstanceOf('\\eZ\\Publish\\SPI\\Persistence\\User\\RoleAssignment', $roleAssignments[0]);
484
        $this->assertEquals(33, $roleAssignments[0]->roleId);
485
    }
486
487
    /**
488
     * @covers eZ\Publish\Core\Persistence\Cache\UserHandler::createRole