| @@ 142-166 (lines=25) @@ | ||
| 139 | * @covers eZ\Publish\Core\Persistence\Cache\ObjectStateHandler::loadGroup |
|
| 140 | * @depends testLoadGroup |
|
| 141 | */ |
|
| 142 | public function testLoadGroupHasCache() |
|
| 143 | { |
|
| 144 | $expectedGroup = new SPIObjectStateGroup( |
|
| 145 | array( |
|
| 146 | 'id' => 1, |
|
| 147 | 'identifier' => 'test_state_group', |
|
| 148 | 'name' => 'Test State Group', |
|
| 149 | ) |
|
| 150 | ); |
|
| 151 | ||
| 152 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 153 | $this->cacheMock |
|
| 154 | ->expects($this->once()) |
|
| 155 | ->method('getItem') |
|
| 156 | ->with('objectstategroup', 1) |
|
| 157 | ->will($this->returnValue($cacheItemMock)); |
|
| 158 | $cacheItemMock |
|
| 159 | ->expects($this->once()) |
|
| 160 | ->method('get') |
|
| 161 | ->will($this->returnValue($expectedGroup)); |
|
| 162 | ||
| 163 | $handler = $this->persistenceCacheHandler->objectStateHandler(); |
|
| 164 | $group = $handler->loadGroup(1); |
|
| 165 | $this->assertEquals($group, $expectedGroup); |
|
| 166 | } |
|
| 167 | ||
| 168 | /** |
|
| 169 | * @covers eZ\Publish\SPI\Persistence\Content\ObjectState\Handler::loadGroupByIdentifier |
|
| @@ 710-735 (lines=26) @@ | ||
| 707 | * @covers \eZ\Publish\SPI\Persistence\Content\ObjectState\Handler::load |
|
| 708 | * @depends testLoad |
|
| 709 | */ |
|
| 710 | public function testLoadCached() |
|
| 711 | { |
|
| 712 | $expectedState = new SPIObjectState( |
|
| 713 | array( |
|
| 714 | 'id' => 1, |
|
| 715 | 'identifier' => 'test_state', |
|
| 716 | 'name' => 'Test State', |
|
| 717 | 'groupId' => 1, |
|
| 718 | ) |
|
| 719 | ); |
|
| 720 | ||
| 721 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 722 | $this->cacheMock |
|
| 723 | ->expects($this->once()) |
|
| 724 | ->method('getItem') |
|
| 725 | ->with('objectstate', 1) |
|
| 726 | ->will($this->returnValue($cacheItemMock)); |
|
| 727 | $cacheItemMock |
|
| 728 | ->expects($this->once()) |
|
| 729 | ->method('get') |
|
| 730 | ->will($this->returnValue($expectedState)); |
|
| 731 | ||
| 732 | $handler = $this->persistenceCacheHandler->objectStateHandler(); |
|
| 733 | $state = $handler->load(1); |
|
| 734 | $this->assertEquals($state, $expectedState); |
|
| 735 | } |
|
| 736 | ||
| 737 | /** |
|
| 738 | * @covers \eZ\Publish\SPI\Persistence\Content\ObjectState\Handler::loadByIdentifier |
|