| @@ 486-561 (lines=76) @@ | ||
| 483 | /** |
|
| 484 | * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::listURLAliasesForLocation |
|
| 485 | */ |
|
| 486 | public function testListURLAliasesForLocationHasCache() |
|
| 487 | { |
|
| 488 | $this->loggerMock->expects($this->never())->method('logCall'); |
|
| 489 | ||
| 490 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 491 | $this->cacheMock |
|
| 492 | ->expects($this->at(0)) |
|
| 493 | ->method('getItem') |
|
| 494 | ->with('urlAlias', 'location', 44) |
|
| 495 | ->will($this->returnValue($cacheItemMock)); |
|
| 496 | ||
| 497 | $cacheItemMock |
|
| 498 | ->expects($this->once()) |
|
| 499 | ->method('get') |
|
| 500 | ->will($this->returnValue(array(55, 58, 91))); |
|
| 501 | ||
| 502 | $cacheItemMock |
|
| 503 | ->expects($this->once()) |
|
| 504 | ->method('isMiss') |
|
| 505 | ->will($this->returnValue(false)); |
|
| 506 | ||
| 507 | $this->persistenceHandlerMock |
|
| 508 | ->expects($this->never()) |
|
| 509 | ->method($this->anything()); |
|
| 510 | ||
| 511 | $cacheItemMock |
|
| 512 | ->expects($this->never()) |
|
| 513 | ->method('set'); |
|
| 514 | ||
| 515 | // inline calls to loadUrlAlias() using the cache |
|
| 516 | $cacheItemMock2 = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 517 | $this->cacheMock |
|
| 518 | ->expects($this->at(1)) |
|
| 519 | ->method('getItem') |
|
| 520 | ->with('urlAlias', 55) |
|
| 521 | ->will($this->returnValue($cacheItemMock2)); |
|
| 522 | ||
| 523 | $cacheItemMock2 |
|
| 524 | ->expects($this->at(0)) |
|
| 525 | ->method('get') |
|
| 526 | ->will($this->returnValue(new UrlAlias(array('id' => 55)))); |
|
| 527 | ||
| 528 | $this->cacheMock |
|
| 529 | ->expects($this->at(2)) |
|
| 530 | ->method('getItem') |
|
| 531 | ->with('urlAlias', 58) |
|
| 532 | ->will($this->returnValue($cacheItemMock2)); |
|
| 533 | ||
| 534 | $cacheItemMock2 |
|
| 535 | ->expects($this->at(1)) |
|
| 536 | ->method('get') |
|
| 537 | ->will($this->returnValue(new UrlAlias(array('id' => 58)))); |
|
| 538 | ||
| 539 | $this->cacheMock |
|
| 540 | ->expects($this->at(3)) |
|
| 541 | ->method('getItem') |
|
| 542 | ->with('urlAlias', 91) |
|
| 543 | ->will($this->returnValue($cacheItemMock2)); |
|
| 544 | ||
| 545 | $cacheItemMock2 |
|
| 546 | ->expects($this->at(2)) |
|
| 547 | ->method('get') |
|
| 548 | ->will($this->returnValue(new UrlAlias(array('id' => 91)))); |
|
| 549 | ||
| 550 | $cacheItemMock2 |
|
| 551 | ->expects($this->exactly(3)) |
|
| 552 | ->method('isMiss') |
|
| 553 | ->will($this->returnValue(false)); |
|
| 554 | ||
| 555 | $cacheItemMock2 |
|
| 556 | ->expects($this->never()) |
|
| 557 | ->method('set'); |
|
| 558 | ||
| 559 | $handler = $this->persistenceCacheHandler->urlAliasHandler(); |
|
| 560 | $handler->listURLAliasesForLocation(44, false); |
|
| 561 | } |
|
| 562 | ||
| 563 | /** |
|
| 564 | * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::listURLAliasesForLocation |
|
| @@ 566-641 (lines=76) @@ | ||
| 563 | /** |
|
| 564 | * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::listURLAliasesForLocation |
|
| 565 | */ |
|
| 566 | public function testListURLAliasesForLocationCustomHasCache() |
|
| 567 | { |
|
| 568 | $this->loggerMock->expects($this->never())->method('logCall'); |
|
| 569 | ||
| 570 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 571 | $this->cacheMock |
|
| 572 | ->expects($this->at(0)) |
|
| 573 | ->method('getItem') |
|
| 574 | ->with('urlAlias', 'location', '44', 'custom') |
|
| 575 | ->will($this->returnValue($cacheItemMock)); |
|
| 576 | ||
| 577 | $cacheItemMock |
|
| 578 | ->expects($this->once()) |
|
| 579 | ->method('get') |
|
| 580 | ->will($this->returnValue(array(55, 58, 91))); |
|
| 581 | ||
| 582 | $cacheItemMock |
|
| 583 | ->expects($this->once()) |
|
| 584 | ->method('isMiss') |
|
| 585 | ->will($this->returnValue(false)); |
|
| 586 | ||
| 587 | $this->persistenceHandlerMock |
|
| 588 | ->expects($this->never()) |
|
| 589 | ->method($this->anything()); |
|
| 590 | ||
| 591 | $cacheItemMock |
|
| 592 | ->expects($this->never()) |
|
| 593 | ->method('set'); |
|
| 594 | ||
| 595 | // inline calls to loadUrlAlias() using the cache |
|
| 596 | $cacheItemMock2 = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 597 | $this->cacheMock |
|
| 598 | ->expects($this->at(1)) |
|
| 599 | ->method('getItem') |
|
| 600 | ->with('urlAlias', 55) |
|
| 601 | ->will($this->returnValue($cacheItemMock2)); |
|
| 602 | ||
| 603 | $cacheItemMock2 |
|
| 604 | ->expects($this->at(0)) |
|
| 605 | ->method('get') |
|
| 606 | ->will($this->returnValue(new UrlAlias(array('id' => 55)))); |
|
| 607 | ||
| 608 | $this->cacheMock |
|
| 609 | ->expects($this->at(2)) |
|
| 610 | ->method('getItem') |
|
| 611 | ->with('urlAlias', 58) |
|
| 612 | ->will($this->returnValue($cacheItemMock2)); |
|
| 613 | ||
| 614 | $cacheItemMock2 |
|
| 615 | ->expects($this->at(1)) |
|
| 616 | ->method('get') |
|
| 617 | ->will($this->returnValue(new UrlAlias(array('id' => 58)))); |
|
| 618 | ||
| 619 | $this->cacheMock |
|
| 620 | ->expects($this->at(3)) |
|
| 621 | ->method('getItem') |
|
| 622 | ->with('urlAlias', 91) |
|
| 623 | ->will($this->returnValue($cacheItemMock2)); |
|
| 624 | ||
| 625 | $cacheItemMock2 |
|
| 626 | ->expects($this->at(2)) |
|
| 627 | ->method('get') |
|
| 628 | ->will($this->returnValue(new UrlAlias(array('id' => 91)))); |
|
| 629 | ||
| 630 | $cacheItemMock2 |
|
| 631 | ->expects($this->exactly(3)) |
|
| 632 | ->method('isMiss') |
|
| 633 | ->will($this->returnValue(false)); |
|
| 634 | ||
| 635 | $cacheItemMock2 |
|
| 636 | ->expects($this->never()) |
|
| 637 | ->method('set'); |
|
| 638 | ||
| 639 | $handler = $this->persistenceCacheHandler->urlAliasHandler(); |
|
| 640 | $handler->listURLAliasesForLocation(44, true); |
|
| 641 | } |
|
| 642 | ||
| 643 | /** |
|
| 644 | * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::removeURLAliases |
|