diff --git a/lib/Doctrine/ORM/AbstractQuery.php b/lib/Doctrine/ORM/AbstractQuery.php index d57e6335a..5ff47c15a 100644 --- a/lib/Doctrine/ORM/AbstractQuery.php +++ b/lib/Doctrine/ORM/AbstractQuery.php @@ -316,7 +316,7 @@ abstract class AbstractQuery $this->_queryCacheProfile = $this->_queryCacheProfile ? $this->_queryCacheProfile->setLifetime($lifetime) - : new QueryCacheProfile($lifetime); + : new QueryCacheProfile($lifetime, null, $this->_em->getConfiguration()->getResultCacheImpl()); return $this; } @@ -615,7 +615,7 @@ abstract class AbstractQuery { $this->_queryCacheProfile = $this->_queryCacheProfile ? $this->_queryCacheProfile->setCacheKey($id) - : new QueryCacheProfile(0, $id); + : new QueryCacheProfile(0, $id, $this->_em->getConfiguration()->getResultCacheImpl()); return $this; } diff --git a/tests/Doctrine/Tests/ORM/Query/QueryTest.php b/tests/Doctrine/Tests/ORM/Query/QueryTest.php index b1d2bee23..4e142e149 100644 --- a/tests/Doctrine/Tests/ORM/Query/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Query/QueryTest.php @@ -2,7 +2,7 @@ namespace Doctrine\Tests\ORM\Query; -require_once __DIR__ . '/../../TestInit.php'; +use Doctrine\Common\Cache\ArrayCache; class QueryTest extends \Doctrine\Tests\OrmTestCase { @@ -90,4 +90,15 @@ class QueryTest extends \Doctrine\Tests\OrmTestCase $this->assertEquals('baz', $q->getHint('bar')); $this->assertEquals(array('foo' => 'bar', 'bar' => 'baz'), $q->getHints()); } -} \ No newline at end of file + + /** + * @group DDC-1588 + */ + public function testQueryDefaultResultCache() + { + $this->_em->getConfiguration()->setResultCacheImpl(new ArrayCache()); + $q = $this->_em->createQuery("select a from Doctrine\Tests\Models\CMS\CmsArticle a"); + $q->useResultCache(true); + $this->assertSame($this->_em->getConfiguration()->getResultCacheImpl(), $q->getQueryCacheProfile()->getResultCacheDriver()); + } +}