logger = new CacheLoggerChain(); $this->mock = $this->getMock('Doctrine\ORM\Cache\Logging\CacheLogger'); } public function testGetAndSetLogger() { $this->assertEmpty($this->logger->getLoggers()); $this->assertNull($this->logger->getLogger('mock')); $this->logger->setLogger('mock', $this->mock); $this->assertSame($this->mock, $this->logger->getLogger('mock')); $this->assertEquals(array('mock' => $this->mock), $this->logger->getLoggers()); } public function testEntityCacheChain() { $name = 'my_entity_region'; $key = new EntityCacheKey(State::CLASSNAME, array('id' => 1)); $this->logger->setLogger('mock', $this->mock); $this->mock->expects($this->once()) ->method('entityCacheHit') ->with($this->equalTo($name), $this->equalTo($key)); $this->mock->expects($this->once()) ->method('entityCachePut') ->with($this->equalTo($name), $this->equalTo($key)); $this->mock->expects($this->once()) ->method('entityCacheMiss') ->with($this->equalTo($name), $this->equalTo($key)); $this->logger->entityCacheHit($name, $key); $this->logger->entityCachePut($name, $key); $this->logger->entityCacheMiss($name, $key); } public function testCollectionCacheChain() { $name = 'my_collection_region'; $key = new CollectionCacheKey(State::CLASSNAME, 'cities', array('id' => 1)); $this->logger->setLogger('mock', $this->mock); $this->mock->expects($this->once()) ->method('collectionCacheHit') ->with($this->equalTo($name), $this->equalTo($key)); $this->mock->expects($this->once()) ->method('collectionCachePut') ->with($this->equalTo($name), $this->equalTo($key)); $this->mock->expects($this->once()) ->method('collectionCacheMiss') ->with($this->equalTo($name), $this->equalTo($key)); $this->logger->collectionCacheHit($name, $key); $this->logger->collectionCachePut($name, $key); $this->logger->collectionCacheMiss($name, $key); } public function testQueryCacheChain() { $name = 'my_query_region'; $key = new QueryCacheKey('my_query_hash'); $this->logger->setLogger('mock', $this->mock); $this->mock->expects($this->once()) ->method('queryCacheHit') ->with($this->equalTo($name), $this->equalTo($key)); $this->mock->expects($this->once()) ->method('queryCachePut') ->with($this->equalTo($name), $this->equalTo($key)); $this->mock->expects($this->once()) ->method('queryCacheMiss') ->with($this->equalTo($name), $this->equalTo($key)); $this->logger->queryCacheHit($name, $key); $this->logger->queryCachePut($name, $key); $this->logger->queryCacheMiss($name, $key); } }