| @@ 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 |
|
| @@ 765-817 (lines=53) @@ | ||
| 762 | /** |
|
| 763 | * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::lookup |
|
| 764 | */ |
|
| 765 | public function testLookupHasCache() |
|
| 766 | { |
|
| 767 | $this->loggerMock->expects($this->never())->method('logCall'); |
|
| 768 | ||
| 769 | $this->persistenceHandlerMock |
|
| 770 | ->expects($this->never()) |
|
| 771 | ->method($this->anything()); |
|
| 772 | ||
| 773 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 774 | $this->cacheMock |
|
| 775 | ->expects($this->at(0)) |
|
| 776 | ->method('getItem') |
|
| 777 | ->with('urlAlias', 'url', '/url') |
|
| 778 | ->will($this->returnValue($cacheItemMock)); |
|
| 779 | ||
| 780 | $cacheItemMock |
|
| 781 | ->expects($this->once()) |
|
| 782 | ->method('get') |
|
| 783 | ->will($this->returnValue(55)); |
|
| 784 | ||
| 785 | $cacheItemMock |
|
| 786 | ->expects($this->once()) |
|
| 787 | ->method('isMiss') |
|
| 788 | ->will($this->returnValue(false)); |
|
| 789 | ||
| 790 | $cacheItemMock |
|
| 791 | ->expects($this->never()) |
|
| 792 | ->method('set'); |
|
| 793 | ||
| 794 | $cacheItemMock2 = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 795 | $this->cacheMock |
|
| 796 | ->expects($this->at(1)) |
|
| 797 | ->method('getItem') |
|
| 798 | ->with('urlAlias', 55) |
|
| 799 | ->will($this->returnValue($cacheItemMock2)); |
|
| 800 | ||
| 801 | $cacheItemMock2 |
|
| 802 | ->expects($this->once()) |
|
| 803 | ->method('get') |
|
| 804 | ->will($this->returnValue(new UrlAlias(array('id' => 55)))); |
|
| 805 | ||
| 806 | $cacheItemMock2 |
|
| 807 | ->expects($this->once()) |
|
| 808 | ->method('isMiss') |
|
| 809 | ->will($this->returnValue(false)); |
|
| 810 | ||
| 811 | $cacheItemMock2 |
|
| 812 | ->expects($this->never()) |
|
| 813 | ->method('set'); |
|
| 814 | ||
| 815 | $handler = $this->persistenceCacheHandler->urlAliasHandler(); |
|
| 816 | $handler->lookup('/url'); |
|
| 817 | } |
|
| 818 | ||
| 819 | /** |
|
| 820 | * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::loadUrlAlias |
|