| @@ 385-460 (lines=76) @@ | ||
| 382 | /** |
|
| 383 | * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::listURLAliasesForLocation |
|
| 384 | */ |
|
| 385 | public function testListURLAliasesForLocationHasCache() |
|
| 386 | { |
|
| 387 | $this->loggerMock->expects($this->never())->method('logCall'); |
|
| 388 | ||
| 389 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 390 | $this->cacheMock |
|
| 391 | ->expects($this->at(0)) |
|
| 392 | ->method('getItem') |
|
| 393 | ->with('urlAlias', 'location', 44) |
|
| 394 | ->will($this->returnValue($cacheItemMock)); |
|
| 395 | ||
| 396 | $cacheItemMock |
|
| 397 | ->expects($this->once()) |
|
| 398 | ->method('get') |
|
| 399 | ->will($this->returnValue(array(55, 58, 91))); |
|
| 400 | ||
| 401 | $cacheItemMock |
|
| 402 | ->expects($this->once()) |
|
| 403 | ->method('isMiss') |
|
| 404 | ->will($this->returnValue(false)); |
|
| 405 | ||
| 406 | $this->persistenceHandlerMock |
|
| 407 | ->expects($this->never()) |
|
| 408 | ->method($this->anything()); |
|
| 409 | ||
| 410 | $cacheItemMock |
|
| 411 | ->expects($this->never()) |
|
| 412 | ->method('set'); |
|
| 413 | ||
| 414 | // inline calls to loadUrlAlias() using the cache |
|
| 415 | $cacheItemMock2 = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 416 | $this->cacheMock |
|
| 417 | ->expects($this->at(1)) |
|
| 418 | ->method('getItem') |
|
| 419 | ->with('urlAlias', 55) |
|
| 420 | ->will($this->returnValue($cacheItemMock2)); |
|
| 421 | ||
| 422 | $cacheItemMock2 |
|
| 423 | ->expects($this->at(0)) |
|
| 424 | ->method('get') |
|
| 425 | ->will($this->returnValue(new UrlAlias(array('id' => 55)))); |
|
| 426 | ||
| 427 | $this->cacheMock |
|
| 428 | ->expects($this->at(2)) |
|
| 429 | ->method('getItem') |
|
| 430 | ->with('urlAlias', 58) |
|
| 431 | ->will($this->returnValue($cacheItemMock2)); |
|
| 432 | ||
| 433 | $cacheItemMock2 |
|
| 434 | ->expects($this->at(1)) |
|
| 435 | ->method('get') |
|
| 436 | ->will($this->returnValue(new UrlAlias(array('id' => 58)))); |
|
| 437 | ||
| 438 | $this->cacheMock |
|
| 439 | ->expects($this->at(3)) |
|
| 440 | ->method('getItem') |
|
| 441 | ->with('urlAlias', 91) |
|
| 442 | ->will($this->returnValue($cacheItemMock2)); |
|
| 443 | ||
| 444 | $cacheItemMock2 |
|
| 445 | ->expects($this->at(2)) |
|
| 446 | ->method('get') |
|
| 447 | ->will($this->returnValue(new UrlAlias(array('id' => 91)))); |
|
| 448 | ||
| 449 | $cacheItemMock2 |
|
| 450 | ->expects($this->exactly(3)) |
|
| 451 | ->method('isMiss') |
|
| 452 | ->will($this->returnValue(false)); |
|
| 453 | ||
| 454 | $cacheItemMock2 |
|
| 455 | ->expects($this->never()) |
|
| 456 | ->method('set'); |
|
| 457 | ||
| 458 | $handler = $this->persistenceCacheHandler->urlAliasHandler(); |
|
| 459 | $handler->listURLAliasesForLocation(44, false); |
|
| 460 | } |
|
| 461 | ||
| 462 | /** |
|
| 463 | * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::listURLAliasesForLocation |
|
| @@ 465-540 (lines=76) @@ | ||
| 462 | /** |
|
| 463 | * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::listURLAliasesForLocation |
|
| 464 | */ |
|
| 465 | public function testListURLAliasesForLocationCustomHasCache() |
|
| 466 | { |
|
| 467 | $this->loggerMock->expects($this->never())->method('logCall'); |
|
| 468 | ||
| 469 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 470 | $this->cacheMock |
|
| 471 | ->expects($this->at(0)) |
|
| 472 | ->method('getItem') |
|
| 473 | ->with('urlAlias', 'location', '44', 'custom') |
|
| 474 | ->will($this->returnValue($cacheItemMock)); |
|
| 475 | ||
| 476 | $cacheItemMock |
|
| 477 | ->expects($this->once()) |
|
| 478 | ->method('get') |
|
| 479 | ->will($this->returnValue(array(55, 58, 91))); |
|
| 480 | ||
| 481 | $cacheItemMock |
|
| 482 | ->expects($this->once()) |
|
| 483 | ->method('isMiss') |
|
| 484 | ->will($this->returnValue(false)); |
|
| 485 | ||
| 486 | $this->persistenceHandlerMock |
|
| 487 | ->expects($this->never()) |
|
| 488 | ->method($this->anything()); |
|
| 489 | ||
| 490 | $cacheItemMock |
|
| 491 | ->expects($this->never()) |
|
| 492 | ->method('set'); |
|
| 493 | ||
| 494 | // inline calls to loadUrlAlias() using the cache |
|
| 495 | $cacheItemMock2 = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 496 | $this->cacheMock |
|
| 497 | ->expects($this->at(1)) |
|
| 498 | ->method('getItem') |
|
| 499 | ->with('urlAlias', 55) |
|
| 500 | ->will($this->returnValue($cacheItemMock2)); |
|
| 501 | ||
| 502 | $cacheItemMock2 |
|
| 503 | ->expects($this->at(0)) |
|
| 504 | ->method('get') |
|
| 505 | ->will($this->returnValue(new UrlAlias(array('id' => 55)))); |
|
| 506 | ||
| 507 | $this->cacheMock |
|
| 508 | ->expects($this->at(2)) |
|
| 509 | ->method('getItem') |
|
| 510 | ->with('urlAlias', 58) |
|
| 511 | ->will($this->returnValue($cacheItemMock2)); |
|
| 512 | ||
| 513 | $cacheItemMock2 |
|
| 514 | ->expects($this->at(1)) |
|
| 515 | ->method('get') |
|
| 516 | ->will($this->returnValue(new UrlAlias(array('id' => 58)))); |
|
| 517 | ||
| 518 | $this->cacheMock |
|
| 519 | ->expects($this->at(3)) |
|
| 520 | ->method('getItem') |
|
| 521 | ->with('urlAlias', 91) |
|
| 522 | ->will($this->returnValue($cacheItemMock2)); |
|
| 523 | ||
| 524 | $cacheItemMock2 |
|
| 525 | ->expects($this->at(2)) |
|
| 526 | ->method('get') |
|
| 527 | ->will($this->returnValue(new UrlAlias(array('id' => 91)))); |
|
| 528 | ||
| 529 | $cacheItemMock2 |
|
| 530 | ->expects($this->exactly(3)) |
|
| 531 | ->method('isMiss') |
|
| 532 | ->will($this->returnValue(false)); |
|
| 533 | ||
| 534 | $cacheItemMock2 |
|
| 535 | ->expects($this->never()) |
|
| 536 | ->method('set'); |
|
| 537 | ||
| 538 | $handler = $this->persistenceCacheHandler->urlAliasHandler(); |
|
| 539 | $handler->listURLAliasesForLocation(44, true); |
|
| 540 | } |
|
| 541 | ||
| 542 | /** |
|
| 543 | * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::removeURLAliases |
|