| @@ 272-320 (lines=49) @@ | ||
| 269 | /** |
|
| 270 | * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::listURLAliasesForLocation |
|
| 271 | */ |
|
| 272 | public function testListURLAliasesForLocationIsMiss() |
|
| 273 | { |
|
| 274 | $this->loggerMock->expects($this->once())->method('logCall'); |
|
| 275 | ||
| 276 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 277 | $this->cacheMock |
|
| 278 | ->expects($this->once()) |
|
| 279 | ->method('getItem') |
|
| 280 | ->with('urlAlias', 'location', 44) |
|
| 281 | ->will($this->returnValue($cacheItemMock)); |
|
| 282 | ||
| 283 | $cacheItemMock |
|
| 284 | ->expects($this->once()) |
|
| 285 | ->method('get') |
|
| 286 | ->will($this->returnValue(null)); |
|
| 287 | ||
| 288 | $cacheItemMock |
|
| 289 | ->expects($this->once()) |
|
| 290 | ->method('isMiss') |
|
| 291 | ->will($this->returnValue(true)); |
|
| 292 | ||
| 293 | $innerHandler = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\UrlAlias\\Handler'); |
|
| 294 | $this->persistenceHandlerMock |
|
| 295 | ->expects($this->once()) |
|
| 296 | ->method('urlAliasHandler') |
|
| 297 | ->will($this->returnValue($innerHandler)); |
|
| 298 | ||
| 299 | $innerHandler |
|
| 300 | ->expects($this->once()) |
|
| 301 | ->method('listURLAliasesForLocation') |
|
| 302 | ->with(44, false) |
|
| 303 | ->will( |
|
| 304 | $this->returnValue( |
|
| 305 | array( |
|
| 306 | new UrlAlias(array('id' => 55)), |
|
| 307 | new UrlAlias(array('id' => 58)), |
|
| 308 | new UrlAlias(array('id' => 91)), |
|
| 309 | ) |
|
| 310 | ) |
|
| 311 | ); |
|
| 312 | ||
| 313 | $cacheItemMock |
|
| 314 | ->expects($this->once()) |
|
| 315 | ->method('set') |
|
| 316 | ->with(array(55, 58, 91)); |
|
| 317 | ||
| 318 | $handler = $this->persistenceCacheHandler->urlAliasHandler(); |
|
| 319 | $handler->listURLAliasesForLocation(44, false); |
|
| 320 | } |
|
| 321 | ||
| 322 | /** |
|
| 323 | * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::listURLAliasesForLocation |
|
| @@ 325-373 (lines=49) @@ | ||
| 322 | /** |
|
| 323 | * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::listURLAliasesForLocation |
|
| 324 | */ |
|
| 325 | public function testListURLAliasesForLocationCustomIsMiss() |
|
| 326 | { |
|
| 327 | $this->loggerMock->expects($this->once())->method('logCall'); |
|
| 328 | ||
| 329 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 330 | $this->cacheMock |
|
| 331 | ->expects($this->once()) |
|
| 332 | ->method('getItem') |
|
| 333 | ->with('urlAlias', 'location', '44', 'custom') |
|
| 334 | ->will($this->returnValue($cacheItemMock)); |
|
| 335 | ||
| 336 | $cacheItemMock |
|
| 337 | ->expects($this->once()) |
|
| 338 | ->method('get') |
|
| 339 | ->will($this->returnValue(null)); |
|
| 340 | ||
| 341 | $cacheItemMock |
|
| 342 | ->expects($this->once()) |
|
| 343 | ->method('isMiss') |
|
| 344 | ->will($this->returnValue(true)); |
|
| 345 | ||
| 346 | $innerHandler = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\UrlAlias\\Handler'); |
|
| 347 | $this->persistenceHandlerMock |
|
| 348 | ->expects($this->once()) |
|
| 349 | ->method('urlAliasHandler') |
|
| 350 | ->will($this->returnValue($innerHandler)); |
|
| 351 | ||
| 352 | $innerHandler |
|
| 353 | ->expects($this->once()) |
|
| 354 | ->method('listURLAliasesForLocation') |
|
| 355 | ->with(44, true) |
|
| 356 | ->will( |
|
| 357 | $this->returnValue( |
|
| 358 | array( |
|
| 359 | new UrlAlias(array('id' => 55)), |
|
| 360 | new UrlAlias(array('id' => 58)), |
|
| 361 | new UrlAlias(array('id' => 91)), |
|
| 362 | ) |
|
| 363 | ) |
|
| 364 | ); |
|
| 365 | ||
| 366 | $cacheItemMock |
|
| 367 | ->expects($this->once()) |
|
| 368 | ->method('set') |
|
| 369 | ->with(array(55, 58, 91)); |
|
| 370 | ||
| 371 | $handler = $this->persistenceCacheHandler->urlAliasHandler(); |
|
| 372 | $handler->listURLAliasesForLocation(44, true); |
|
| 373 | } |
|
| 374 | ||
| 375 | /** |
|
| 376 | * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::listURLAliasesForLocation |
|