eZ\Publish\Core\Persistence\Cache\Tests\ObjectStateHandlerTest::testGetContentStateCached PHP Method

testGetContentStateCached() public method

    public function testGetContentStateCached()
    {
        $expectedState = new SPIObjectState(array('id' => 1, 'identifier' => 'test_state', 'name' => 'Test State', 'groupId' => 1));
        $cacheItemMock = $this->getMock('Stash\\Interfaces\\ItemInterface');
        $this->cacheMock->expects($this->at(0))->method('getItem')->with('objectstate', 'byContent', 10, 1)->will($this->returnValue($cacheItemMock));
        $cacheItemMock->expects($this->once())->method('get')->will($this->returnValue(1));
        $cacheItemMock->expects($this->once())->method('isMiss')->will($this->returnValue(false));
        // load()
        $this->cacheMock->expects($this->at(1))->method('getItem')->with('objectstate', $expectedState->id)->will($this->returnCallback(function ($cachekey, $i) use($expectedState) {
            $cacheItemMock = $this->getMock('Stash\\Interfaces\\ItemInterface');
            $cacheItemMock->expects($this->once())->method('get')->will($this->returnValue($expectedState));
            return $cacheItemMock;
        }));
        $handler = $this->persistenceCacheHandler->objectStateHandler();
        $state = $handler->getContentState(10, 1);
        $this->assertEquals($state, $expectedState);
    }