| @@ 143-188 (lines=46) @@ | ||
| 140 | /** |
|
| 141 | * @covers eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::loadGroup |
|
| 142 | */ |
|
| 143 | public function testLoadGroupIsMiss() |
|
| 144 | { |
|
| 145 | $this->loggerMock->expects($this->once())->method('logCall'); |
|
| 146 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 147 | $this->cacheMock |
|
| 148 | ->expects($this->once()) |
|
| 149 | ->method('getItem') |
|
| 150 | ->with('contentTypeGroup', 55) |
|
| 151 | ->will($this->returnValue($cacheItemMock)); |
|
| 152 | ||
| 153 | $cacheItemMock |
|
| 154 | ->expects($this->once()) |
|
| 155 | ->method('get') |
|
| 156 | ->will($this->returnValue(null)); |
|
| 157 | ||
| 158 | $cacheItemMock |
|
| 159 | ->expects($this->once()) |
|
| 160 | ->method('isMiss') |
|
| 161 | ->will($this->returnValue(true)); |
|
| 162 | ||
| 163 | $innerHandler = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Type\\Handler'); |
|
| 164 | $this->persistenceHandlerMock |
|
| 165 | ->expects($this->once()) |
|
| 166 | ->method('contentTypeHandler') |
|
| 167 | ->will($this->returnValue($innerHandler)); |
|
| 168 | ||
| 169 | $innerHandler |
|
| 170 | ->expects($this->once()) |
|
| 171 | ->method('loadGroup') |
|
| 172 | ->with(55) |
|
| 173 | ->will($this->returnValue(new SPITypeGroup())); |
|
| 174 | ||
| 175 | $cacheItemMock |
|
| 176 | ->expects($this->once()) |
|
| 177 | ->method('set') |
|
| 178 | ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\Type\\Group')) |
|
| 179 | ->will($this->returnValue($cacheItemMock)); |
|
| 180 | ||
| 181 | $cacheItemMock |
|
| 182 | ->expects($this->once()) |
|
| 183 | ->method('save') |
|
| 184 | ->with(); |
|
| 185 | ||
| 186 | $handler = $this->persistenceCacheHandler->contentTypeHandler(); |
|
| 187 | $handler->loadGroup(55); |
|
| 188 | } |
|
| 189 | ||
| 190 | /** |
|
| 191 | * @covers eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::loadGroup |
|
| @@ 23-68 (lines=46) @@ | ||
| 20 | /** |
|
| 21 | * @covers eZ\Publish\Core\Persistence\Cache\LocationHandler::load |
|
| 22 | */ |
|
| 23 | public function testLoadCacheIsMiss() |
|
| 24 | { |
|
| 25 | $this->loggerMock->expects($this->once())->method('logCall'); |
|
| 26 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 27 | $this->cacheMock |
|
| 28 | ->expects($this->once()) |
|
| 29 | ->method('getItem') |
|
| 30 | ->with('location', 33) |
|
| 31 | ->will($this->returnValue($cacheItemMock)); |
|
| 32 | ||
| 33 | $cacheItemMock |
|
| 34 | ->expects($this->once()) |
|
| 35 | ->method('get') |
|
| 36 | ->will($this->returnValue(null)); |
|
| 37 | ||
| 38 | $cacheItemMock |
|
| 39 | ->expects($this->once()) |
|
| 40 | ->method('isMiss') |
|
| 41 | ->will($this->returnValue(true)); |
|
| 42 | ||
| 43 | $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Location\\Handler'); |
|
| 44 | $this->persistenceHandlerMock |
|
| 45 | ->expects($this->once()) |
|
| 46 | ->method('locationHandler') |
|
| 47 | ->will($this->returnValue($innerHandlerMock)); |
|
| 48 | ||
| 49 | $innerHandlerMock |
|
| 50 | ->expects($this->once()) |
|
| 51 | ->method('load') |
|
| 52 | ->with(33) |
|
| 53 | ->will($this->returnValue(new Location(array('id' => 33)))); |
|
| 54 | ||
| 55 | $cacheItemMock |
|
| 56 | ->expects($this->once()) |
|
| 57 | ->method('set') |
|
| 58 | ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\Location')) |
|
| 59 | ->will($this->returnValue($cacheItemMock)); |
|
| 60 | ||
| 61 | $cacheItemMock |
|
| 62 | ->expects($this->once()) |
|
| 63 | ->method('save') |
|
| 64 | ->with(); |
|
| 65 | ||
| 66 | $handler = $this->persistenceCacheHandler->locationHandler(); |
|
| 67 | $handler->load(33); |
|
| 68 | } |
|
| 69 | ||
| 70 | /** |
|
| 71 | * @covers eZ\Publish\Core\Persistence\Cache\LocationHandler::load |
|
| @@ 197-245 (lines=49) @@ | ||
| 194 | /** |
|
| 195 | * @covers eZ\Publish\Core\Persistence\Cache\UserHandler::loadRole |
|
| 196 | */ |
|
| 197 | public function testLoadRoleIsMiss() |
|
| 198 | { |
|
| 199 | $this->loggerMock->expects($this->once())->method('logCall'); |
|
| 200 | ||
| 201 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 202 | $this->cacheMock |
|
| 203 | ->expects($this->once()) |
|
| 204 | ->method('getItem') |
|
| 205 | ->with('user', 'role', 33) |
|
| 206 | ->will($this->returnValue($cacheItemMock)); |
|
| 207 | ||
| 208 | $cacheItemMock |
|
| 209 | ->expects($this->once()) |
|
| 210 | ->method('get') |
|
| 211 | ->will($this->returnValue(null)); |
|
| 212 | ||
| 213 | $cacheItemMock |
|
| 214 | ->expects($this->once()) |
|
| 215 | ->method('isMiss') |
|
| 216 | ->will($this->returnValue(true)); |
|
| 217 | ||
| 218 | $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\User\\Handler'); |
|
| 219 | $this->persistenceHandlerMock |
|
| 220 | ->expects($this->once()) |
|
| 221 | ->method('userHandler') |
|
| 222 | ->will($this->returnValue($innerHandlerMock)); |
|
| 223 | ||
| 224 | $innerHandlerMock |
|
| 225 | ->expects($this->once()) |
|
| 226 | ->method('loadRole') |
|
| 227 | ->with(33) |
|
| 228 | ->will( |
|
| 229 | $this->returnValue(new Role()) |
|
| 230 | ); |
|
| 231 | ||
| 232 | $cacheItemMock |
|
| 233 | ->expects($this->once()) |
|
| 234 | ->method('set') |
|
| 235 | ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\User\\Role')) |
|
| 236 | ->will($this->returnValue($cacheItemMock)); |
|
| 237 | ||
| 238 | $cacheItemMock |
|
| 239 | ->expects($this->once()) |
|
| 240 | ->method('save') |
|
| 241 | ->with(); |
|
| 242 | ||
| 243 | $handler = $this->persistenceCacheHandler->userHandler(); |
|
| 244 | $handler->loadRole(33); |
|
| 245 | } |
|
| 246 | ||
| 247 | /** |
|
| 248 | * @covers eZ\Publish\Core\Persistence\Cache\UserHandler::loadRole |
|
| @@ 965-1011 (lines=47) @@ | ||
| 962 | /** |
|
| 963 | * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::loadUrlAlias |
|
| 964 | */ |
|
| 965 | public function testLoadUrlAliasIsMiss() |
|
| 966 | { |
|
| 967 | $this->loggerMock->expects($this->once())->method('logCall'); |
|
| 968 | ||
| 969 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 970 | $this->cacheMock |
|
| 971 | ->expects($this->once()) |
|
| 972 | ->method('getItem') |
|
| 973 | ->with('urlAlias', 55) |
|
| 974 | ->will($this->returnValue($cacheItemMock)); |
|
| 975 | ||
| 976 | $cacheItemMock |
|
| 977 | ->expects($this->once()) |
|
| 978 | ->method('get') |
|
| 979 | ->will($this->returnValue(null)); |
|
| 980 | ||
| 981 | $cacheItemMock |
|
| 982 | ->expects($this->once()) |
|
| 983 | ->method('isMiss') |
|
| 984 | ->will($this->returnValue(true)); |
|
| 985 | ||
| 986 | $innerHandler = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\UrlAlias\\Handler'); |
|
| 987 | $this->persistenceHandlerMock |
|
| 988 | ->expects($this->once()) |
|
| 989 | ->method('urlAliasHandler') |
|
| 990 | ->will($this->returnValue($innerHandler)); |
|
| 991 | ||
| 992 | $innerHandler |
|
| 993 | ->expects($this->once()) |
|
| 994 | ->method('loadUrlAlias') |
|
| 995 | ->with(55) |
|
| 996 | ->will($this->returnValue(new UrlAlias(array('id' => 55)))); |
|
| 997 | ||
| 998 | $cacheItemMock |
|
| 999 | ->expects($this->once()) |
|
| 1000 | ->method('set') |
|
| 1001 | ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\UrlAlias')) |
|
| 1002 | ->will($this->returnValue($cacheItemMock)); |
|
| 1003 | ||
| 1004 | $cacheItemMock |
|
| 1005 | ->expects($this->once()) |
|
| 1006 | ->method('save') |
|
| 1007 | ->with(); |
|
| 1008 | ||
| 1009 | $handler = $this->persistenceCacheHandler->urlAliasHandler(); |
|
| 1010 | $handler->loadUrlAlias(55); |
|
| 1011 | } |
|
| 1012 | ||
| 1013 | /** |
|
| 1014 | * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::loadUrlAlias |
|