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

testGetContentState() public method

public testGetContentState ( )
    public function testGetContentState()
    {
        $expectedState = new SPIObjectState(array('id' => 1, 'identifier' => 'test_state', 'name' => 'Test State', 'groupId' => 1, 'priority' => 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(null));
        $cacheItemMock->expects($this->once())->method('isMiss')->will($this->returnValue(true));
        $cacheItemMock->expects($this->once())->method('set')->with(1)->will($this->returnValue($cacheItemMock));
        $cacheItemMock->expects($this->once())->method('save')->with();
        $this->loggerMock->expects($this->once())->method('logCall');
        $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\ObjectState\\Handler');
        $this->persistenceHandlerMock->expects($this->once())->method('objectStateHandler')->will($this->returnValue($innerHandlerMock));
        $innerHandlerMock->expects($this->once())->method('getContentState')->with(10, 1)->will($this->returnValue($expectedState));
        $handler = $this->persistenceCacheHandler->objectStateHandler();
        $state = $handler->getContentState(10, 1, 2);
        $this->assertEquals($state, $expectedState);
    }