| @@ 446-521 (lines=76) @@ | ||
| 443 | /** |
|
| 444 | * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::listURLAliasesForLocation |
|
| 445 | */ |
|
| 446 | public function testListURLAliasesForLocationHasCache() |
|
| 447 | { |
|
| 448 | $this->loggerMock->expects($this->never())->method('logCall'); |
|
| 449 | ||
| 450 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 451 | $this->cacheMock |
|
| 452 | ->expects($this->at(0)) |
|
| 453 | ->method('getItem') |
|
| 454 | ->with('urlAlias', 'location', 44) |
|
| 455 | ->will($this->returnValue($cacheItemMock)); |
|
| 456 | ||
| 457 | $cacheItemMock |
|
| 458 | ->expects($this->once()) |
|
| 459 | ->method('get') |
|
| 460 | ->will($this->returnValue(array(55, 58, 91))); |
|
| 461 | ||
| 462 | $cacheItemMock |
|
| 463 | ->expects($this->once()) |
|
| 464 | ->method('isMiss') |
|
| 465 | ->will($this->returnValue(false)); |
|
| 466 | ||
| 467 | $this->persistenceHandlerMock |
|
| 468 | ->expects($this->never()) |
|
| 469 | ->method($this->anything()); |
|
| 470 | ||
| 471 | $cacheItemMock |
|
| 472 | ->expects($this->never()) |
|
| 473 | ->method('set'); |
|
| 474 | ||
| 475 | // inline calls to loadUrlAlias() using the cache |
|
| 476 | $cacheItemMock2 = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 477 | $this->cacheMock |
|
| 478 | ->expects($this->at(1)) |
|
| 479 | ->method('getItem') |
|
| 480 | ->with('urlAlias', 55) |
|
| 481 | ->will($this->returnValue($cacheItemMock2)); |
|
| 482 | ||
| 483 | $cacheItemMock2 |
|
| 484 | ->expects($this->at(0)) |
|
| 485 | ->method('get') |
|
| 486 | ->will($this->returnValue(new UrlAlias(array('id' => 55)))); |
|
| 487 | ||
| 488 | $this->cacheMock |
|
| 489 | ->expects($this->at(2)) |
|
| 490 | ->method('getItem') |
|
| 491 | ->with('urlAlias', 58) |
|
| 492 | ->will($this->returnValue($cacheItemMock2)); |
|
| 493 | ||
| 494 | $cacheItemMock2 |
|
| 495 | ->expects($this->at(1)) |
|
| 496 | ->method('get') |
|
| 497 | ->will($this->returnValue(new UrlAlias(array('id' => 58)))); |
|
| 498 | ||
| 499 | $this->cacheMock |
|
| 500 | ->expects($this->at(3)) |
|
| 501 | ->method('getItem') |
|
| 502 | ->with('urlAlias', 91) |
|
| 503 | ->will($this->returnValue($cacheItemMock2)); |
|
| 504 | ||
| 505 | $cacheItemMock2 |
|
| 506 | ->expects($this->at(2)) |
|
| 507 | ->method('get') |
|
| 508 | ->will($this->returnValue(new UrlAlias(array('id' => 91)))); |
|
| 509 | ||
| 510 | $cacheItemMock2 |
|
| 511 | ->expects($this->exactly(3)) |
|
| 512 | ->method('isMiss') |
|
| 513 | ->will($this->returnValue(false)); |
|
| 514 | ||
| 515 | $cacheItemMock2 |
|
| 516 | ->expects($this->never()) |
|
| 517 | ->method('set'); |
|
| 518 | ||
| 519 | $handler = $this->persistenceCacheHandler->urlAliasHandler(); |
|
| 520 | $handler->listURLAliasesForLocation(44, false); |
|
| 521 | } |
|
| 522 | ||
| 523 | /** |
|
| 524 | * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::listURLAliasesForLocation |
|
| @@ 526-601 (lines=76) @@ | ||
| 523 | /** |
|
| 524 | * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::listURLAliasesForLocation |
|
| 525 | */ |
|
| 526 | public function testListURLAliasesForLocationCustomHasCache() |
|
| 527 | { |
|
| 528 | $this->loggerMock->expects($this->never())->method('logCall'); |
|
| 529 | ||
| 530 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 531 | $this->cacheMock |
|
| 532 | ->expects($this->at(0)) |
|
| 533 | ->method('getItem') |
|
| 534 | ->with('urlAlias', 'location', '44', 'custom') |
|
| 535 | ->will($this->returnValue($cacheItemMock)); |
|
| 536 | ||
| 537 | $cacheItemMock |
|
| 538 | ->expects($this->once()) |
|
| 539 | ->method('get') |
|
| 540 | ->will($this->returnValue(array(55, 58, 91))); |
|
| 541 | ||
| 542 | $cacheItemMock |
|
| 543 | ->expects($this->once()) |
|
| 544 | ->method('isMiss') |
|
| 545 | ->will($this->returnValue(false)); |
|
| 546 | ||
| 547 | $this->persistenceHandlerMock |
|
| 548 | ->expects($this->never()) |
|
| 549 | ->method($this->anything()); |
|
| 550 | ||
| 551 | $cacheItemMock |
|
| 552 | ->expects($this->never()) |
|
| 553 | ->method('set'); |
|
| 554 | ||
| 555 | // inline calls to loadUrlAlias() using the cache |
|
| 556 | $cacheItemMock2 = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 557 | $this->cacheMock |
|
| 558 | ->expects($this->at(1)) |
|
| 559 | ->method('getItem') |
|
| 560 | ->with('urlAlias', 55) |
|
| 561 | ->will($this->returnValue($cacheItemMock2)); |
|
| 562 | ||
| 563 | $cacheItemMock2 |
|
| 564 | ->expects($this->at(0)) |
|
| 565 | ->method('get') |
|
| 566 | ->will($this->returnValue(new UrlAlias(array('id' => 55)))); |
|
| 567 | ||
| 568 | $this->cacheMock |
|
| 569 | ->expects($this->at(2)) |
|
| 570 | ->method('getItem') |
|
| 571 | ->with('urlAlias', 58) |
|
| 572 | ->will($this->returnValue($cacheItemMock2)); |
|
| 573 | ||
| 574 | $cacheItemMock2 |
|
| 575 | ->expects($this->at(1)) |
|
| 576 | ->method('get') |
|
| 577 | ->will($this->returnValue(new UrlAlias(array('id' => 58)))); |
|
| 578 | ||
| 579 | $this->cacheMock |
|
| 580 | ->expects($this->at(3)) |
|
| 581 | ->method('getItem') |
|
| 582 | ->with('urlAlias', 91) |
|
| 583 | ->will($this->returnValue($cacheItemMock2)); |
|
| 584 | ||
| 585 | $cacheItemMock2 |
|
| 586 | ->expects($this->at(2)) |
|
| 587 | ->method('get') |
|
| 588 | ->will($this->returnValue(new UrlAlias(array('id' => 91)))); |
|
| 589 | ||
| 590 | $cacheItemMock2 |
|
| 591 | ->expects($this->exactly(3)) |
|
| 592 | ->method('isMiss') |
|
| 593 | ->will($this->returnValue(false)); |
|
| 594 | ||
| 595 | $cacheItemMock2 |
|
| 596 | ->expects($this->never()) |
|
| 597 | ->method('set'); |
|
| 598 | ||
| 599 | $handler = $this->persistenceCacheHandler->urlAliasHandler(); |
|
| 600 | $handler->listURLAliasesForLocation(44, true); |
|
| 601 | } |
|
| 602 | ||
| 603 | /** |
|
| 604 | * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::removeURLAliases |
|