eZ\Publish\Core\Persistence\Cache\Tests\ContentTypeHandlerTest::testLoadByIdentifierHasCache PHP Method

testLoadByIdentifierHasCache() public method

    public function testLoadByIdentifierHasCache()
    {
        $this->loggerMock->expects($this->never())->method($this->anything());
        $cacheItemMock = $this->getMock('Stash\\Interfaces\\ItemInterface');
        $this->cacheMock->expects($this->at(0))->method('getItem')->with('contentType', 'identifier', 'forum')->will($this->returnValue($cacheItemMock));
        $cacheItemMock->expects($this->once())->method('get')->will($this->returnValue(55));
        $cacheItemMock->expects($this->once())->method('isMiss')->will($this->returnValue(false));
        $this->persistenceHandlerMock->expects($this->never())->method('contentTypeHandler');
        $cacheItemMock->expects($this->never())->method('set');
        // the code reuses load():
        $cacheItemMock2 = $this->getMock('Stash\\Interfaces\\ItemInterface');
        $this->cacheMock->expects($this->at(1))->method('getItem')->with('contentType', 55)->will($this->returnValue($cacheItemMock2));
        $cacheItemMock2->expects($this->once())->method('isMiss')->will($this->returnValue(false));
        $cacheItemMock2->expects($this->once())->method('get')->will($this->returnValue(new SPIType(array('id' => 55, 'name' => 'Forum', 'identifier' => 'forum'))));
        $cacheItemMock2->expects($this->never())->method('set');
        $handler = $this->persistenceCacheHandler->contentTypeHandler();
        $handler->loadByIdentifier('forum');
    }