| @@ 140-164 (lines=25) @@ | ||
| 137 | * @covers \eZ\Publish\Core\Persistence\Cache\ObjectStateHandler::loadGroup |
|
| 138 | * @depends testLoadGroup |
|
| 139 | */ |
|
| 140 | public function testLoadGroupHasCache() |
|
| 141 | { |
|
| 142 | $expectedGroup = new SPIObjectStateGroup( |
|
| 143 | array( |
|
| 144 | 'id' => 1, |
|
| 145 | 'identifier' => 'test_state_group', |
|
| 146 | 'name' => 'Test State Group', |
|
| 147 | ) |
|
| 148 | ); |
|
| 149 | ||
| 150 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 151 | $this->cacheMock |
|
| 152 | ->expects($this->once()) |
|
| 153 | ->method('getItem') |
|
| 154 | ->with('objectstategroup', 1) |
|
| 155 | ->will($this->returnValue($cacheItemMock)); |
|
| 156 | $cacheItemMock |
|
| 157 | ->expects($this->once()) |
|
| 158 | ->method('get') |
|
| 159 | ->will($this->returnValue($expectedGroup)); |
|
| 160 | ||
| 161 | $handler = $this->persistenceCacheHandler->objectStateHandler(); |
|
| 162 | $group = $handler->loadGroup(1); |
|
| 163 | $this->assertEquals($group, $expectedGroup); |
|
| 164 | } |
|
| 165 | ||
| 166 | /** |
|
| 167 | * @covers \eZ\Publish\SPI\Persistence\Content\ObjectState\Handler::loadGroupByIdentifier |
|
| @@ 675-700 (lines=26) @@ | ||
| 672 | * @covers \eZ\Publish\SPI\Persistence\Content\ObjectState\Handler::load |
|
| 673 | * @depends testLoad |
|
| 674 | */ |
|
| 675 | public function testLoadCached() |
|
| 676 | { |
|
| 677 | $expectedState = new SPIObjectState( |
|
| 678 | array( |
|
| 679 | 'id' => 1, |
|
| 680 | 'identifier' => 'test_state', |
|
| 681 | 'name' => 'Test State', |
|
| 682 | 'groupId' => 1, |
|
| 683 | ) |
|
| 684 | ); |
|
| 685 | ||
| 686 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 687 | $this->cacheMock |
|
| 688 | ->expects($this->once()) |
|
| 689 | ->method('getItem') |
|
| 690 | ->with('objectstate', 1) |
|
| 691 | ->will($this->returnValue($cacheItemMock)); |
|
| 692 | $cacheItemMock |
|
| 693 | ->expects($this->once()) |
|
| 694 | ->method('get') |
|
| 695 | ->will($this->returnValue($expectedState)); |
|
| 696 | ||
| 697 | $handler = $this->persistenceCacheHandler->objectStateHandler(); |
|
| 698 | $state = $handler->load(1); |
|
| 699 | $this->assertEquals($state, $expectedState); |
|
| 700 | } |
|
| 701 | ||
| 702 | /** |
|
| 703 | * @covers \eZ\Publish\SPI\Persistence\Content\ObjectState\Handler::loadByIdentifier |
|