| @@ 160-213 (lines=54) @@ | ||
| 157 | /** |
|
| 158 | * @covers eZ\Publish\Core\Persistence\Cache\LocationHandler::loadLocationsByContent |
|
| 159 | */ |
|
| 160 | public function testLoadLocationsByContentHasCache() |
|
| 161 | { |
|
| 162 | $this->loggerMock->expects($this->never())->method($this->anything()); |
|
| 163 | ||
| 164 | $this->persistenceHandlerMock |
|
| 165 | ->expects($this->never()) |
|
| 166 | ->method($this->anything()); |
|
| 167 | ||
| 168 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 169 | $this->cacheMock |
|
| 170 | ->expects($this->at(0)) |
|
| 171 | ->method('getItem') |
|
| 172 | ->with('content', 'locations', 44) |
|
| 173 | ->will($this->returnValue($cacheItemMock)); |
|
| 174 | ||
| 175 | $cacheItemMock |
|
| 176 | ->expects($this->once()) |
|
| 177 | ->method('get') |
|
| 178 | ->will($this->returnValue(array(33))); |
|
| 179 | ||
| 180 | $cacheItemMock |
|
| 181 | ->expects($this->once()) |
|
| 182 | ->method('isMiss') |
|
| 183 | ->will($this->returnValue(false)); |
|
| 184 | ||
| 185 | $cacheItemMock |
|
| 186 | ->expects($this->never()) |
|
| 187 | ->method('set'); |
|
| 188 | ||
| 189 | // inline call to load() |
|
| 190 | $cacheItemMock2 = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 191 | $this->cacheMock |
|
| 192 | ->expects($this->at(1)) |
|
| 193 | ->method('getItem') |
|
| 194 | ->with('location', 33) |
|
| 195 | ->will($this->returnValue($cacheItemMock2)); |
|
| 196 | ||
| 197 | $cacheItemMock2 |
|
| 198 | ->expects($this->once()) |
|
| 199 | ->method('get') |
|
| 200 | ->will($this->returnValue(new Location(array('id' => 33)))); |
|
| 201 | ||
| 202 | $cacheItemMock2 |
|
| 203 | ->expects($this->once()) |
|
| 204 | ->method('isMiss') |
|
| 205 | ->will($this->returnValue(false)); |
|
| 206 | ||
| 207 | $cacheItemMock2 |
|
| 208 | ->expects($this->never()) |
|
| 209 | ->method('set'); |
|
| 210 | ||
| 211 | $handler = $this->persistenceCacheHandler->locationHandler(); |
|
| 212 | $handler->loadLocationsByContent(44); |
|
| 213 | } |
|
| 214 | ||
| 215 | /** |
|
| 216 | * @covers eZ\Publish\Core\Persistence\Cache\LocationHandler::loadParentLocationsForDraftContent |
|
| @@ 268-321 (lines=54) @@ | ||
| 265 | /** |
|
| 266 | * @covers eZ\Publish\Core\Persistence\Cache\LocationHandler::loadParentLocationsForDraftContent |
|
| 267 | */ |
|
| 268 | public function testLoadParentLocationsForDraftContentHasCache() |
|
| 269 | { |
|
| 270 | $this->loggerMock->expects($this->never())->method($this->anything()); |
|
| 271 | ||
| 272 | $this->persistenceHandlerMock |
|
| 273 | ->expects($this->never()) |
|
| 274 | ->method($this->anything()); |
|
| 275 | ||
| 276 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 277 | $this->cacheMock |
|
| 278 | ->expects($this->at(0)) |
|
| 279 | ->method('getItem') |
|
| 280 | ->with('content', 'locations', '44', 'parentLocationsForDraftContent') |
|
| 281 | ->will($this->returnValue($cacheItemMock)); |
|
| 282 | ||
| 283 | $cacheItemMock |
|
| 284 | ->expects($this->once()) |
|
| 285 | ->method('get') |
|
| 286 | ->will($this->returnValue(array(33))); |
|
| 287 | ||
| 288 | $cacheItemMock |
|
| 289 | ->expects($this->once()) |
|
| 290 | ->method('isMiss') |
|
| 291 | ->will($this->returnValue(false)); |
|
| 292 | ||
| 293 | $cacheItemMock |
|
| 294 | ->expects($this->never()) |
|
| 295 | ->method('set'); |
|
| 296 | ||
| 297 | // inline call to load() |
|
| 298 | $cacheItemMock2 = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 299 | $this->cacheMock |
|
| 300 | ->expects($this->at(1)) |
|
| 301 | ->method('getItem') |
|
| 302 | ->with('location', 33) |
|
| 303 | ->will($this->returnValue($cacheItemMock2)); |
|
| 304 | ||
| 305 | $cacheItemMock2 |
|
| 306 | ->expects($this->once()) |
|
| 307 | ->method('get') |
|
| 308 | ->will($this->returnValue(new Location(array('id' => 33)))); |
|
| 309 | ||
| 310 | $cacheItemMock2 |
|
| 311 | ->expects($this->once()) |
|
| 312 | ->method('isMiss') |
|
| 313 | ->will($this->returnValue(false)); |
|
| 314 | ||
| 315 | $cacheItemMock2 |
|
| 316 | ->expects($this->never()) |
|
| 317 | ->method('set'); |
|
| 318 | ||
| 319 | $handler = $this->persistenceCacheHandler->locationHandler(); |
|
| 320 | $handler->loadParentLocationsForDraftContent(44); |
|
| 321 | } |
|
| 322 | ||
| 323 | /** |
|
| 324 | * @covers eZ\Publish\Core\Persistence\Cache\LocationHandler::loadLocationsByContent |
|
| @@ 376-429 (lines=54) @@ | ||
| 373 | /** |
|
| 374 | * @covers eZ\Publish\Core\Persistence\Cache\LocationHandler::loadLocationsByContent |
|
| 375 | */ |
|
| 376 | public function testLoadLocationsByContentWithRootHasCache() |
|
| 377 | { |
|
| 378 | $this->loggerMock->expects($this->never())->method($this->anything()); |
|
| 379 | ||
| 380 | $this->persistenceHandlerMock |
|
| 381 | ->expects($this->never()) |
|
| 382 | ->method($this->anything()); |
|
| 383 | ||
| 384 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 385 | $this->cacheMock |
|
| 386 | ->expects($this->at(0)) |
|
| 387 | ->method('getItem') |
|
| 388 | ->with('content', 'locations', '44', 'root', '2') |
|
| 389 | ->will($this->returnValue($cacheItemMock)); |
|
| 390 | ||
| 391 | $cacheItemMock |
|
| 392 | ->expects($this->once()) |
|
| 393 | ->method('get') |
|
| 394 | ->will($this->returnValue(array(33))); |
|
| 395 | ||
| 396 | $cacheItemMock |
|
| 397 | ->expects($this->once()) |
|
| 398 | ->method('isMiss') |
|
| 399 | ->will($this->returnValue(false)); |
|
| 400 | ||
| 401 | $cacheItemMock |
|
| 402 | ->expects($this->never()) |
|
| 403 | ->method('set'); |
|
| 404 | ||
| 405 | // inline call to load() |
|
| 406 | $cacheItemMock2 = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 407 | $this->cacheMock |
|
| 408 | ->expects($this->at(1)) |
|
| 409 | ->method('getItem') |
|
| 410 | ->with('location', 33) |
|
| 411 | ->will($this->returnValue($cacheItemMock2)); |
|
| 412 | ||
| 413 | $cacheItemMock2 |
|
| 414 | ->expects($this->once()) |
|
| 415 | ->method('get') |
|
| 416 | ->will($this->returnValue(new Location(array('id' => 33)))); |
|
| 417 | ||
| 418 | $cacheItemMock2 |
|
| 419 | ->expects($this->once()) |
|
| 420 | ->method('isMiss') |
|
| 421 | ->will($this->returnValue(false)); |
|
| 422 | ||
| 423 | $cacheItemMock2 |
|
| 424 | ->expects($this->never()) |
|
| 425 | ->method('set'); |
|
| 426 | ||
| 427 | $handler = $this->persistenceCacheHandler->locationHandler(); |
|
| 428 | $handler->loadLocationsByContent(44, 2); |
|
| 429 | } |
|
| 430 | ||
| 431 | /** |
|
| 432 | * @covers eZ\Publish\Core\Persistence\Cache\LocationHandler::loadByRemoteId |
|
| @@ 858-910 (lines=53) @@ | ||
| 855 | /** |
|
| 856 | * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::lookup |
|
| 857 | */ |
|
| 858 | public function testLookupHasCache() |
|
| 859 | { |
|
| 860 | $this->loggerMock->expects($this->never())->method('logCall'); |
|
| 861 | ||
| 862 | $this->persistenceHandlerMock |
|
| 863 | ->expects($this->never()) |
|
| 864 | ->method($this->anything()); |
|
| 865 | ||
| 866 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 867 | $this->cacheMock |
|
| 868 | ->expects($this->at(0)) |
|
| 869 | ->method('getItem') |
|
| 870 | ->with('urlAlias', 'url', '/url') |
|
| 871 | ->will($this->returnValue($cacheItemMock)); |
|
| 872 | ||
| 873 | $cacheItemMock |
|
| 874 | ->expects($this->once()) |
|
| 875 | ->method('get') |
|
| 876 | ->will($this->returnValue(55)); |
|
| 877 | ||
| 878 | $cacheItemMock |
|
| 879 | ->expects($this->once()) |
|
| 880 | ->method('isMiss') |
|
| 881 | ->will($this->returnValue(false)); |
|
| 882 | ||
| 883 | $cacheItemMock |
|
| 884 | ->expects($this->never()) |
|
| 885 | ->method('set'); |
|
| 886 | ||
| 887 | $cacheItemMock2 = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 888 | $this->cacheMock |
|
| 889 | ->expects($this->at(1)) |
|
| 890 | ->method('getItem') |
|
| 891 | ->with('urlAlias', 55) |
|
| 892 | ->will($this->returnValue($cacheItemMock2)); |
|
| 893 | ||
| 894 | $cacheItemMock2 |
|
| 895 | ->expects($this->once()) |
|
| 896 | ->method('get') |
|
| 897 | ->will($this->returnValue(new UrlAlias(array('id' => 55)))); |
|
| 898 | ||
| 899 | $cacheItemMock2 |
|
| 900 | ->expects($this->once()) |
|
| 901 | ->method('isMiss') |
|
| 902 | ->will($this->returnValue(false)); |
|
| 903 | ||
| 904 | $cacheItemMock2 |
|
| 905 | ->expects($this->never()) |
|
| 906 | ->method('set'); |
|
| 907 | ||
| 908 | $handler = $this->persistenceCacheHandler->urlAliasHandler(); |
|
| 909 | $handler->lookup('/url'); |
|
| 910 | } |
|
| 911 | ||
| 912 | /** |
|
| 913 | * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::lookup |
|