| @@ 152-176 (lines=25) @@ | ||
| 149 | * @covers \eZ\Publish\Core\Persistence\Cache\ObjectStateHandler::loadGroup |
|
| 150 | * @depends testLoadGroup |
|
| 151 | */ |
|
| 152 | public function testLoadGroupHasCache() |
|
| 153 | { |
|
| 154 | $expectedGroup = new SPIObjectStateGroup( |
|
| 155 | array( |
|
| 156 | 'id' => 1, |
|
| 157 | 'identifier' => 'test_state_group', |
|
| 158 | 'name' => 'Test State Group', |
|
| 159 | ) |
|
| 160 | ); |
|
| 161 | ||
| 162 | $cacheItemMock = $this->getCacheItemMock(); |
|
| 163 | $this->cacheMock |
|
| 164 | ->expects($this->once()) |
|
| 165 | ->method('getItem') |
|
| 166 | ->with('objectstategroup', 1) |
|
| 167 | ->will($this->returnValue($cacheItemMock)); |
|
| 168 | $cacheItemMock |
|
| 169 | ->expects($this->once()) |
|
| 170 | ->method('get') |
|
| 171 | ->will($this->returnValue($expectedGroup)); |
|
| 172 | ||
| 173 | $handler = $this->persistenceCacheHandler->objectStateHandler(); |
|
| 174 | $group = $handler->loadGroup(1); |
|
| 175 | $this->assertEquals($group, $expectedGroup); |
|
| 176 | } |
|
| 177 | ||
| 178 | /** |
|
| 179 | * @covers \eZ\Publish\SPI\Persistence\Content\ObjectState\Handler::loadGroupByIdentifier |
|
| @@ 654-679 (lines=26) @@ | ||
| 651 | * @covers \eZ\Publish\SPI\Persistence\Content\ObjectState\Handler::load |
|
| 652 | * @depends testLoad |
|
| 653 | */ |
|
| 654 | public function testLoadCached() |
|
| 655 | { |
|
| 656 | $expectedState = new SPIObjectState( |
|
| 657 | array( |
|
| 658 | 'id' => 1, |
|
| 659 | 'identifier' => 'test_state', |
|
| 660 | 'name' => 'Test State', |
|
| 661 | 'groupId' => 1, |
|
| 662 | ) |
|
| 663 | ); |
|
| 664 | ||
| 665 | $cacheItemMock = $this->getCacheItemMock(); |
|
| 666 | $this->cacheMock |
|
| 667 | ->expects($this->once()) |
|
| 668 | ->method('getItem') |
|
| 669 | ->with('objectstate', 1) |
|
| 670 | ->will($this->returnValue($cacheItemMock)); |
|
| 671 | $cacheItemMock |
|
| 672 | ->expects($this->once()) |
|
| 673 | ->method('get') |
|
| 674 | ->will($this->returnValue($expectedState)); |
|
| 675 | ||
| 676 | $handler = $this->persistenceCacheHandler->objectStateHandler(); |
|
| 677 | $state = $handler->load(1); |
|
| 678 | $this->assertEquals($state, $expectedState); |
|
| 679 | } |
|
| 680 | ||
| 681 | /** |
|
| 682 | * @covers \eZ\Publish\SPI\Persistence\Content\ObjectState\Handler::loadByIdentifier |
|