| @@ 79-121 (lines=43) @@ | ||
| 76 | /** |
|
| 77 | * @covers eZ\Publish\Core\Persistence\Cache\ObjectStateHandler::loadGroup |
|
| 78 | */ |
|
| 79 | public function testLoadGroup() |
|
| 80 | { |
|
| 81 | $expectedGroup = new SPIObjectStateGroup( |
|
| 82 | array( |
|
| 83 | 'id' => 1, |
|
| 84 | 'identifier' => 'test_state_group', |
|
| 85 | 'name' => 'Test State Group', |
|
| 86 | ) |
|
| 87 | ); |
|
| 88 | ||
| 89 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 90 | $this->cacheMock |
|
| 91 | ->expects($this->once()) |
|
| 92 | ->method('getItem') |
|
| 93 | ->with('objectstategroup', 1) |
|
| 94 | ->will($this->returnValue($cacheItemMock)); |
|
| 95 | $cacheItemMock |
|
| 96 | ->expects($this->once()) |
|
| 97 | ->method('get') |
|
| 98 | ->will($this->returnValue(null)); |
|
| 99 | $cacheItemMock |
|
| 100 | ->expects($this->once()) |
|
| 101 | ->method('isMiss') |
|
| 102 | ->will($this->returnValue(true)); |
|
| 103 | ||
| 104 | $this->loggerMock->expects($this->once())->method('logCall'); |
|
| 105 | ||
| 106 | $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\ObjectState\\Handler'); |
|
| 107 | $this->persistenceHandlerMock |
|
| 108 | ->expects($this->once()) |
|
| 109 | ->method('objectStateHandler') |
|
| 110 | ->will($this->returnValue($innerHandlerMock)); |
|
| 111 | ||
| 112 | $innerHandlerMock |
|
| 113 | ->expects($this->once()) |
|
| 114 | ->method('loadGroup') |
|
| 115 | ->with(1) |
|
| 116 | ->will($this->returnValue($expectedGroup)); |
|
| 117 | ||
| 118 | $handler = $this->persistenceCacheHandler->objectStateHandler(); |
|
| 119 | $group = $handler->loadGroup(1); |
|
| 120 | $this->assertEquals($group, $expectedGroup); |
|
| 121 | } |
|
| 122 | ||
| 123 | /** |
|
| 124 | * @covers eZ\Publish\Core\Persistence\Cache\ObjectStateHandler::loadGroup |
|
| @@ 619-662 (lines=44) @@ | ||
| 616 | /** |
|
| 617 | * @covers \eZ\Publish\SPI\Persistence\Content\ObjectState\Handler::load |
|
| 618 | */ |
|
| 619 | public function testLoad() |
|
| 620 | { |
|
| 621 | $expectedState = new SPIObjectState( |
|
| 622 | array( |
|
| 623 | 'id' => 1, |
|
| 624 | 'identifier' => 'test_state', |
|
| 625 | 'name' => 'Test State', |
|
| 626 | 'groupId' => 1, |
|
| 627 | ) |
|
| 628 | ); |
|
| 629 | ||
| 630 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 631 | $this->cacheMock |
|
| 632 | ->expects($this->once()) |
|
| 633 | ->method('getItem') |
|
| 634 | ->with('objectstate', 1) |
|
| 635 | ->will($this->returnValue($cacheItemMock)); |
|
| 636 | $cacheItemMock |
|
| 637 | ->expects($this->once()) |
|
| 638 | ->method('get') |
|
| 639 | ->will($this->returnValue(null)); |
|
| 640 | $cacheItemMock |
|
| 641 | ->expects($this->once()) |
|
| 642 | ->method('isMiss') |
|
| 643 | ->will($this->returnValue(true)); |
|
| 644 | ||
| 645 | $this->loggerMock->expects($this->once())->method('logCall'); |
|
| 646 | ||
| 647 | $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\ObjectState\\Handler'); |
|
| 648 | $this->persistenceHandlerMock |
|
| 649 | ->expects($this->once()) |
|
| 650 | ->method('objectStateHandler') |
|
| 651 | ->will($this->returnValue($innerHandlerMock)); |
|
| 652 | ||
| 653 | $innerHandlerMock |
|
| 654 | ->expects($this->once()) |
|
| 655 | ->method('load') |
|
| 656 | ->with(1) |
|
| 657 | ->will($this->returnValue($expectedState)); |
|
| 658 | ||
| 659 | $handler = $this->persistenceCacheHandler->objectStateHandler(); |
|
| 660 | $state = $handler->load(1); |
|
| 661 | $this->assertEquals($state, $expectedState); |
|
| 662 | } |
|
| 663 | ||
| 664 | /** |
|
| 665 | * @covers \eZ\Publish\SPI\Persistence\Content\ObjectState\Handler::load |
|