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