Code Duplication    Length = 39-39 lines in 3 locations

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

@@ 156-194 (lines=39) @@
153
    /**
154
     * @covers eZ\Publish\Core\Persistence\Cache\UserHandler::delete
155
     */
156
    public function testDelete()
157
    {
158
        $this->loggerMock->expects($this->once())->method('logCall');
159
160
        $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\User\\Handler');
161
        $this->persistenceHandlerMock
162
            ->expects($this->once())
163
            ->method('userHandler')
164
            ->will($this->returnValue($innerHandlerMock));
165
166
        $innerHandlerMock
167
            ->expects($this->once())
168
            ->method('delete')
169
            ->with(14)
170
            ->will(
171
                $this->returnValue(true)
172
            );
173
174
        $this->cacheMock
175
            ->expects($this->at(0))
176
            ->method('clear')
177
            ->with('content', 14)
178
            ->will($this->returnValue(true));
179
180
        $this->cacheMock
181
            ->expects($this->at(1))
182
            ->method('clear')
183
            ->with('user', 'role', 'assignments', 'byGroup', 14)
184
            ->will($this->returnValue(true));
185
186
        $this->cacheMock
187
            ->expects($this->at(2))
188
            ->method('clear')
189
            ->with('user', 'role', 'assignments', 'byGroup', 'inherited', 14)
190
            ->will($this->returnValue(true));
191
192
        $handler = $this->persistenceCacheHandler->userHandler();
193
        $handler->delete(14);
194
    }
195
196
    /**
197
     * @covers eZ\Publish\Core\Persistence\Cache\UserHandler::loadRole
@@ 945-983 (lines=39) @@
942
    /**
943
     * @covers eZ\Publish\Core\Persistence\Cache\UserHandler::assignRole
944
     */
945
    public function testAssignRole()
946
    {
947
        $this->loggerMock->expects($this->once())->method('logCall');
948
949
        $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\User\\Handler');
950
        $this->persistenceHandlerMock
951
            ->expects($this->once())
952
            ->method('userHandler')
953
            ->will($this->returnValue($innerHandlerMock));
954
955
        $innerHandlerMock
956
            ->expects($this->once())
957
            ->method('assignRole')
958
            ->with(33, 22)
959
            ->will(
960
                $this->returnValue(true)
961
            );
962
963
        $this->cacheMock
964
            ->expects($this->at(0))
965
            ->method('clear')
966
            ->with('user', 'role', 22)
967
            ->will($this->returnValue(true));
968
969
        $this->cacheMock
970
            ->expects($this->at(1))
971
            ->method('clear')
972
            ->with('user', 'role', 'assignments', 'byGroup', 33)
973
            ->will($this->returnValue(true));
974
975
        $this->cacheMock
976
            ->expects($this->at(2))
977
            ->method('clear')
978
            ->with('user', 'role', 'assignments', 'byGroup', 'inherited')
979
            ->will($this->returnValue(true));
980
981
        $handler = $this->persistenceCacheHandler->userHandler();
982
        $handler->assignRole(33, 22);
983
    }
984
985
    /**
986
     * @covers eZ\Publish\Core\Persistence\Cache\UserHandler::unassignRole
@@ 988-1026 (lines=39) @@
985
    /**
986
     * @covers eZ\Publish\Core\Persistence\Cache\UserHandler::unassignRole
987
     */
988
    public function testUnassignRole()
989
    {
990
        $this->loggerMock->expects($this->once())->method('logCall');
991
992
        $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\User\\Handler');
993
        $this->persistenceHandlerMock
994
            ->expects($this->once())
995
            ->method('userHandler')
996
            ->will($this->returnValue($innerHandlerMock));
997
998
        $innerHandlerMock
999
            ->expects($this->once())
1000
            ->method('unassignRole')
1001
            ->with(33, 22)
1002
            ->will(
1003
                $this->returnValue(true)
1004
            );
1005
1006
        $this->cacheMock
1007
            ->expects($this->at(0))
1008
            ->method('clear')
1009
            ->with('user', 'role', 22)
1010
            ->will($this->returnValue(true));
1011
1012
        $this->cacheMock
1013
            ->expects($this->at(1))
1014
            ->method('clear')
1015
            ->with('user', 'role', 'assignments', 'byGroup', 33)
1016
            ->will($this->returnValue(true));
1017
1018
        $this->cacheMock
1019
            ->expects($this->at(2))
1020
            ->method('clear')
1021
            ->with('user', 'role', 'assignments', 'byGroup', 'inherited')
1022
            ->will($this->returnValue(true));
1023
1024
        $handler = $this->persistenceCacheHandler->userHandler();
1025
        $handler->unassignRole(33, 22);
1026
    }
1027
}
1028