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

testCreateGroup() public method

public testCreateGroup ( )
    public function testCreateGroup()
    {
        $inputStruct = new SPIInputStruct(array('identifier' => 'test_state_group', 'name' => 'Test State Group'));
        $expectedGroup = new SPIObjectStateGroup(array('id' => 1, 'identifier' => 'test_state_group', 'name' => 'Test State Group'));
        $this->loggerMock->expects($this->once())->method('logCall');
        $innerHandler = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\ObjectState\\Handler');
        $this->persistenceHandlerMock->expects($this->once())->method('objectStateHandler')->will($this->returnValue($innerHandler));
        $innerHandler->expects($this->once())->method('createGroup')->with($inputStruct)->will($this->returnValue($expectedGroup));
        $this->cacheMock->expects($this->once())->method('clear')->with('objectstategroup', 'all')->will($this->returnValue(null));
        $cacheItemMock = $this->getMock('Stash\\Interfaces\\ItemInterface');
        $this->cacheMock->expects($this->once())->method('getItem')->with('objectstategroup', 1)->will($this->returnValue($cacheItemMock));
        $cacheItemMock->expects($this->once())->method('set')->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\ObjectState\\Group'))->will($this->returnValue($cacheItemMock));
        $cacheItemMock->expects($this->once())->method('save')->with();
        $handler = $this->persistenceCacheHandler->objectStateHandler();
        $group = $handler->createGroup($inputStruct);
        $this->assertEquals($group, $expectedGroup);
    }