1
0
mirror of synced 2025-01-18 06:21:40 +03:00

Update Common and fix cache tests with different assumptions about keys.

This commit is contained in:
Benjamin Eberlei 2012-05-26 19:29:51 +02:00
parent a5b90fd3c6
commit 0868ec1c19
5 changed files with 18 additions and 18 deletions

View File

@ -21,6 +21,7 @@ namespace Doctrine\ORM;
use Doctrine\DBAL\LockMode,
Doctrine\ORM\Query\Parser,
Doctrine\ORM\Query\ParserResult,
Doctrine\ORM\Query\QueryException;
/**
@ -216,7 +217,7 @@ final class Query extends AbstractQuery
$hash = $this->_getQueryCacheId();
$cached = $this->_expireQueryCache ? false : $queryCache->fetch($hash);
if ($cached !== false) {
if ($cached instanceof ParserResult) {
// Cache hit.
$this->_parserResult = $cached;

@ -1 +1 @@
Subproject commit cc04744bcf5a4743c46fae0487ac7a093a722856
Subproject commit 4ac23ae8737fe7b95a7dd0f1346dbd48c7a503b0

View File

@ -44,12 +44,12 @@ class QueryCacheTest extends \Doctrine\Tests\OrmFunctionalTestCase
$query->setQueryCacheDriver($cache);
$query->getResult();
$this->assertEquals(1, $this->getCacheSize($cache));
$this->assertEquals(2, $this->getCacheSize($cache));
$query->setHint('foo', 'bar');
$query->getResult();
$this->assertEquals(2, $this->getCacheSize($cache));
$this->assertEquals(3, $this->getCacheSize($cache));
return $query;
}
@ -104,18 +104,16 @@ class QueryCacheTest extends \Doctrine\Tests\OrmFunctionalTestCase
$query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux');
$cache = $this->getMock('Doctrine\Common\Cache\ArrayCache', array('doFetch', 'doSave', 'doGetStats'));
$cache->expects($this->at(0))
->method('doFetch')
->with($this->isType('string'))
->will($this->returnValue(false));
$cache->expects($this->at(1))
->method('doSave')
->with($this->isType('string'), $this->isInstanceOf('Doctrine\ORM\Query\ParserResult'), $this->equalTo(null));
$cache = new \Doctrine\Common\Cache\ArrayCache();
$query->setQueryCacheDriver($cache);
$users = $query->getResult();
$data = $this->cacheDataReflection->getValue($cache);
$this->assertEquals(2, count($data));
$this->assertInstanceOf('Doctrine\ORM\Query\ParserResult', array_pop($data));
}
public function testQueryCache_HitDoesNotSaveParserResult()
@ -136,7 +134,8 @@ class QueryCacheTest extends \Doctrine\Tests\OrmFunctionalTestCase
$cache = $this->getMock('Doctrine\Common\Cache\CacheProvider',
array('doFetch', 'doContains', 'doSave', 'doDelete', 'doFlush', 'doGetStats'));
$cache->expects($this->once())
$cache->expects($this->at(0))->method('doFetch')->will($this->returnValue(1));
$cache->expects($this->at(1))
->method('doFetch')
->with($this->isType('string'))
->will($this->returnValue($parserResultMock));

View File

@ -143,7 +143,7 @@ class ResultCacheTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertEquals(0, $this->getCacheSize($cache));
$query->getResult();
$this->assertEquals(1, $this->getCacheSize($cache));
$this->assertEquals(2, $this->getCacheSize($cache));
return $query;
}

View File

@ -301,18 +301,18 @@ class SQLFilterTest extends \Doctrine\Tests\OrmFunctionalTestCase
$query->setQueryCacheDriver($cache);
$query->getResult();
$this->assertEquals(1, sizeof($cacheDataReflection->getValue($cache)));
$this->assertEquals(2, sizeof($cacheDataReflection->getValue($cache)));
$conf = $this->_em->getConfiguration();
$conf->addFilter("locale", "\Doctrine\Tests\ORM\Functional\MyLocaleFilter");
$this->_em->getFilters()->enable("locale");
$query->getResult();
$this->assertEquals(2, sizeof($cacheDataReflection->getValue($cache)));
$this->assertEquals(3, sizeof($cacheDataReflection->getValue($cache)));
// Another time doesn't add another cache entry
$query->getResult();
$this->assertEquals(2, sizeof($cacheDataReflection->getValue($cache)));
$this->assertEquals(3, sizeof($cacheDataReflection->getValue($cache)));
}
public function testQueryGeneration_DependsOnFilters()