| @@ 148-201 (lines=54) @@ | ||
| 145 | /** |
|
| 146 | * @covers eZ\Publish\Core\Persistence\Cache\LocationHandler::loadLocationsByContent |
|
| 147 | */ |
|
| 148 | public function testLoadLocationsByContentHasCache() |
|
| 149 | { |
|
| 150 | $this->loggerMock->expects($this->never())->method($this->anything()); |
|
| 151 | ||
| 152 | $this->persistenceHandlerMock |
|
| 153 | ->expects($this->never()) |
|
| 154 | ->method($this->anything()); |
|
| 155 | ||
| 156 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 157 | $this->cacheMock |
|
| 158 | ->expects($this->at(0)) |
|
| 159 | ->method('getItem') |
|
| 160 | ->with('content', 'locations', 44) |
|
| 161 | ->will($this->returnValue($cacheItemMock)); |
|
| 162 | ||
| 163 | $cacheItemMock |
|
| 164 | ->expects($this->once()) |
|
| 165 | ->method('get') |
|
| 166 | ->will($this->returnValue(array(33))); |
|
| 167 | ||
| 168 | $cacheItemMock |
|
| 169 | ->expects($this->once()) |
|
| 170 | ->method('isMiss') |
|
| 171 | ->will($this->returnValue(false)); |
|
| 172 | ||
| 173 | $cacheItemMock |
|
| 174 | ->expects($this->never()) |
|
| 175 | ->method('set'); |
|
| 176 | ||
| 177 | // inline call to load() |
|
| 178 | $cacheItemMock2 = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 179 | $this->cacheMock |
|
| 180 | ->expects($this->at(1)) |
|
| 181 | ->method('getItem') |
|
| 182 | ->with('location', 33) |
|
| 183 | ->will($this->returnValue($cacheItemMock2)); |
|
| 184 | ||
| 185 | $cacheItemMock2 |
|
| 186 | ->expects($this->once()) |
|
| 187 | ->method('get') |
|
| 188 | ->will($this->returnValue(new Location(array('id' => 33)))); |
|
| 189 | ||
| 190 | $cacheItemMock2 |
|
| 191 | ->expects($this->once()) |
|
| 192 | ->method('isMiss') |
|
| 193 | ->will($this->returnValue(false)); |
|
| 194 | ||
| 195 | $cacheItemMock2 |
|
| 196 | ->expects($this->never()) |
|
| 197 | ->method('set'); |
|
| 198 | ||
| 199 | $handler = $this->persistenceCacheHandler->locationHandler(); |
|
| 200 | $handler->loadLocationsByContent(44); |
|
| 201 | } |
|
| 202 | ||
| 203 | /** |
|
| 204 | * @covers eZ\Publish\Core\Persistence\Cache\LocationHandler::loadParentLocationsForDraftContent |
|
| @@ 250-303 (lines=54) @@ | ||
| 247 | /** |
|
| 248 | * @covers eZ\Publish\Core\Persistence\Cache\LocationHandler::loadParentLocationsForDraftContent |
|
| 249 | */ |
|
| 250 | public function testLoadParentLocationsForDraftContentHasCache() |
|
| 251 | { |
|
| 252 | $this->loggerMock->expects($this->never())->method($this->anything()); |
|
| 253 | ||
| 254 | $this->persistenceHandlerMock |
|
| 255 | ->expects($this->never()) |
|
| 256 | ->method($this->anything()); |
|
| 257 | ||
| 258 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 259 | $this->cacheMock |
|
| 260 | ->expects($this->at(0)) |
|
| 261 | ->method('getItem') |
|
| 262 | ->with('content', 'locations', '44', 'parentLocationsForDraftContent') |
|
| 263 | ->will($this->returnValue($cacheItemMock)); |
|
| 264 | ||
| 265 | $cacheItemMock |
|
| 266 | ->expects($this->once()) |
|
| 267 | ->method('get') |
|
| 268 | ->will($this->returnValue(array(33))); |
|
| 269 | ||
| 270 | $cacheItemMock |
|
| 271 | ->expects($this->once()) |
|
| 272 | ->method('isMiss') |
|
| 273 | ->will($this->returnValue(false)); |
|
| 274 | ||
| 275 | $cacheItemMock |
|
| 276 | ->expects($this->never()) |
|
| 277 | ->method('set'); |
|
| 278 | ||
| 279 | // inline call to load() |
|
| 280 | $cacheItemMock2 = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 281 | $this->cacheMock |
|
| 282 | ->expects($this->at(1)) |
|
| 283 | ->method('getItem') |
|
| 284 | ->with('location', 33) |
|
| 285 | ->will($this->returnValue($cacheItemMock2)); |
|
| 286 | ||
| 287 | $cacheItemMock2 |
|
| 288 | ->expects($this->once()) |
|
| 289 | ->method('get') |
|
| 290 | ->will($this->returnValue(new Location(array('id' => 33)))); |
|
| 291 | ||
| 292 | $cacheItemMock2 |
|
| 293 | ->expects($this->once()) |
|
| 294 | ->method('isMiss') |
|
| 295 | ->will($this->returnValue(false)); |
|
| 296 | ||
| 297 | $cacheItemMock2 |
|
| 298 | ->expects($this->never()) |
|
| 299 | ->method('set'); |
|
| 300 | ||
| 301 | $handler = $this->persistenceCacheHandler->locationHandler(); |
|
| 302 | $handler->loadParentLocationsForDraftContent(44); |
|
| 303 | } |
|
| 304 | ||
| 305 | /** |
|
| 306 | * @covers eZ\Publish\Core\Persistence\Cache\LocationHandler::loadLocationsByContent |
|
| @@ 352-405 (lines=54) @@ | ||
| 349 | /** |
|
| 350 | * @covers eZ\Publish\Core\Persistence\Cache\LocationHandler::loadLocationsByContent |
|
| 351 | */ |
|
| 352 | public function testLoadLocationsByContentWithRootHasCache() |
|
| 353 | { |
|
| 354 | $this->loggerMock->expects($this->never())->method($this->anything()); |
|
| 355 | ||
| 356 | $this->persistenceHandlerMock |
|
| 357 | ->expects($this->never()) |
|
| 358 | ->method($this->anything()); |
|
| 359 | ||
| 360 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 361 | $this->cacheMock |
|
| 362 | ->expects($this->at(0)) |
|
| 363 | ->method('getItem') |
|
| 364 | ->with('content', 'locations', '44', 'root', '2') |
|
| 365 | ->will($this->returnValue($cacheItemMock)); |
|
| 366 | ||
| 367 | $cacheItemMock |
|
| 368 | ->expects($this->once()) |
|
| 369 | ->method('get') |
|
| 370 | ->will($this->returnValue(array(33))); |
|
| 371 | ||
| 372 | $cacheItemMock |
|
| 373 | ->expects($this->once()) |
|
| 374 | ->method('isMiss') |
|
| 375 | ->will($this->returnValue(false)); |
|
| 376 | ||
| 377 | $cacheItemMock |
|
| 378 | ->expects($this->never()) |
|
| 379 | ->method('set'); |
|
| 380 | ||
| 381 | // inline call to load() |
|
| 382 | $cacheItemMock2 = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 383 | $this->cacheMock |
|
| 384 | ->expects($this->at(1)) |
|
| 385 | ->method('getItem') |
|
| 386 | ->with('location', 33) |
|
| 387 | ->will($this->returnValue($cacheItemMock2)); |
|
| 388 | ||
| 389 | $cacheItemMock2 |
|
| 390 | ->expects($this->once()) |
|
| 391 | ->method('get') |
|
| 392 | ->will($this->returnValue(new Location(array('id' => 33)))); |
|
| 393 | ||
| 394 | $cacheItemMock2 |
|
| 395 | ->expects($this->once()) |
|
| 396 | ->method('isMiss') |
|
| 397 | ->will($this->returnValue(false)); |
|
| 398 | ||
| 399 | $cacheItemMock2 |
|
| 400 | ->expects($this->never()) |
|
| 401 | ->method('set'); |
|
| 402 | ||
| 403 | $handler = $this->persistenceCacheHandler->locationHandler(); |
|
| 404 | $handler->loadLocationsByContent(44, 2); |
|
| 405 | } |
|
| 406 | ||
| 407 | /** |
|
| 408 | * @covers eZ\Publish\Core\Persistence\Cache\LocationHandler::loadByRemoteId |
|
| @@ 711-763 (lines=53) @@ | ||
| 708 | /** |
|
| 709 | * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::lookup |
|
| 710 | */ |
|
| 711 | public function testLookupHasCache() |
|
| 712 | { |
|
| 713 | $this->loggerMock->expects($this->never())->method('logCall'); |
|
| 714 | ||
| 715 | $this->persistenceHandlerMock |
|
| 716 | ->expects($this->never()) |
|
| 717 | ->method($this->anything()); |
|
| 718 | ||
| 719 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 720 | $this->cacheMock |
|
| 721 | ->expects($this->at(0)) |
|
| 722 | ->method('getItem') |
|
| 723 | ->with('urlAlias', 'url', '/url') |
|
| 724 | ->will($this->returnValue($cacheItemMock)); |
|
| 725 | ||
| 726 | $cacheItemMock |
|
| 727 | ->expects($this->once()) |
|
| 728 | ->method('get') |
|
| 729 | ->will($this->returnValue(55)); |
|
| 730 | ||
| 731 | $cacheItemMock |
|
| 732 | ->expects($this->once()) |
|
| 733 | ->method('isMiss') |
|
| 734 | ->will($this->returnValue(false)); |
|
| 735 | ||
| 736 | $cacheItemMock |
|
| 737 | ->expects($this->never()) |
|
| 738 | ->method('set'); |
|
| 739 | ||
| 740 | $cacheItemMock2 = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 741 | $this->cacheMock |
|
| 742 | ->expects($this->at(1)) |
|
| 743 | ->method('getItem') |
|
| 744 | ->with('urlAlias', 55) |
|
| 745 | ->will($this->returnValue($cacheItemMock2)); |
|
| 746 | ||
| 747 | $cacheItemMock2 |
|
| 748 | ->expects($this->once()) |
|
| 749 | ->method('get') |
|
| 750 | ->will($this->returnValue(new UrlAlias(array('id' => 55)))); |
|
| 751 | ||
| 752 | $cacheItemMock2 |
|
| 753 | ->expects($this->once()) |
|
| 754 | ->method('isMiss') |
|
| 755 | ->will($this->returnValue(false)); |
|
| 756 | ||
| 757 | $cacheItemMock2 |
|
| 758 | ->expects($this->never()) |
|
| 759 | ->method('set'); |
|
| 760 | ||
| 761 | $handler = $this->persistenceCacheHandler->urlAliasHandler(); |
|
| 762 | $handler->lookup('/url'); |
|
| 763 | } |
|
| 764 | ||
| 765 | /** |
|
| 766 | * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::loadUrlAlias |
|