| @@ 339-393 (lines=55) @@ | ||
| 336 | /** |
|
| 337 | * @covers \eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::listURLAliasesForLocation |
|
| 338 | */ |
|
| 339 | public function testListURLAliasesForLocationIsMiss() |
|
| 340 | { |
|
| 341 | $this->loggerMock->expects($this->once())->method('logCall'); |
|
| 342 | ||
| 343 | $cacheItemMock = $this->getCacheItemMock(); |
|
| 344 | $this->cacheMock |
|
| 345 | ->expects($this->once()) |
|
| 346 | ->method('getItem') |
|
| 347 | ->with('urlAlias', 'location', 44) |
|
| 348 | ->will($this->returnValue($cacheItemMock)); |
|
| 349 | ||
| 350 | $cacheItemMock |
|
| 351 | ->expects($this->once()) |
|
| 352 | ->method('get') |
|
| 353 | ->will($this->returnValue(null)); |
|
| 354 | ||
| 355 | $cacheItemMock |
|
| 356 | ->expects($this->once()) |
|
| 357 | ->method('isMiss') |
|
| 358 | ->will($this->returnValue(true)); |
|
| 359 | ||
| 360 | $innerHandler = $this->getSPIUrlAliasHandlerMock(); |
|
| 361 | $this->persistenceHandlerMock |
|
| 362 | ->expects($this->once()) |
|
| 363 | ->method('urlAliasHandler') |
|
| 364 | ->will($this->returnValue($innerHandler)); |
|
| 365 | ||
| 366 | $innerHandler |
|
| 367 | ->expects($this->once()) |
|
| 368 | ->method('listURLAliasesForLocation') |
|
| 369 | ->with(44, false) |
|
| 370 | ->will( |
|
| 371 | $this->returnValue( |
|
| 372 | [ |
|
| 373 | new UrlAlias(['id' => 55]), |
|
| 374 | new UrlAlias(['id' => 58]), |
|
| 375 | new UrlAlias(['id' => 91]), |
|
| 376 | ] |
|
| 377 | ) |
|
| 378 | ); |
|
| 379 | ||
| 380 | $cacheItemMock |
|
| 381 | ->expects($this->once()) |
|
| 382 | ->method('set') |
|
| 383 | ->with([55, 58, 91]) |
|
| 384 | ->will($this->returnValue($cacheItemMock)); |
|
| 385 | ||
| 386 | $cacheItemMock |
|
| 387 | ->expects($this->once()) |
|
| 388 | ->method('save') |
|
| 389 | ->with(); |
|
| 390 | ||
| 391 | $handler = $this->persistenceCacheHandler->urlAliasHandler(); |
|
| 392 | $handler->listURLAliasesForLocation(44, false); |
|
| 393 | } |
|
| 394 | ||
| 395 | /** |
|
| 396 | * @covers \eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::listURLAliasesForLocation |
|
| @@ 398-452 (lines=55) @@ | ||
| 395 | /** |
|
| 396 | * @covers \eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::listURLAliasesForLocation |
|
| 397 | */ |
|
| 398 | public function testListURLAliasesForLocationCustomIsMiss() |
|
| 399 | { |
|
| 400 | $this->loggerMock->expects($this->once())->method('logCall'); |
|
| 401 | ||
| 402 | $cacheItemMock = $this->getCacheItemMock(); |
|
| 403 | $this->cacheMock |
|
| 404 | ->expects($this->once()) |
|
| 405 | ->method('getItem') |
|
| 406 | ->with('urlAlias', 'location', '44', 'custom') |
|
| 407 | ->will($this->returnValue($cacheItemMock)); |
|
| 408 | ||
| 409 | $cacheItemMock |
|
| 410 | ->expects($this->once()) |
|
| 411 | ->method('get') |
|
| 412 | ->will($this->returnValue(null)); |
|
| 413 | ||
| 414 | $cacheItemMock |
|
| 415 | ->expects($this->once()) |
|
| 416 | ->method('isMiss') |
|
| 417 | ->will($this->returnValue(true)); |
|
| 418 | ||
| 419 | $innerHandler = $this->getSPIUrlAliasHandlerMock(); |
|
| 420 | $this->persistenceHandlerMock |
|
| 421 | ->expects($this->once()) |
|
| 422 | ->method('urlAliasHandler') |
|
| 423 | ->will($this->returnValue($innerHandler)); |
|
| 424 | ||
| 425 | $innerHandler |
|
| 426 | ->expects($this->once()) |
|
| 427 | ->method('listURLAliasesForLocation') |
|
| 428 | ->with(44, true) |
|
| 429 | ->will( |
|
| 430 | $this->returnValue( |
|
| 431 | [ |
|
| 432 | new UrlAlias(['id' => 55]), |
|
| 433 | new UrlAlias(['id' => 58]), |
|
| 434 | new UrlAlias(['id' => 91]), |
|
| 435 | ] |
|
| 436 | ) |
|
| 437 | ); |
|
| 438 | ||
| 439 | $cacheItemMock |
|
| 440 | ->expects($this->once()) |
|
| 441 | ->method('set') |
|
| 442 | ->with([55, 58, 91]) |
|
| 443 | ->will($this->returnValue($cacheItemMock)); |
|
| 444 | ||
| 445 | $cacheItemMock |
|
| 446 | ->expects($this->once()) |
|
| 447 | ->method('save') |
|
| 448 | ->with(); |
|
| 449 | ||
| 450 | $handler = $this->persistenceCacheHandler->urlAliasHandler(); |
|
| 451 | $handler->listURLAliasesForLocation(44, true); |
|
| 452 | } |
|
| 453 | ||
| 454 | /** |
|
| 455 | * @covers \eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::listURLAliasesForLocation |
|