diff --git a/composer.json b/composer.json index 5e9944929..83dc4bc2b 100644 --- a/composer.json +++ b/composer.json @@ -19,6 +19,7 @@ "doctrine/dbal": ">=2.5-dev,<2.6-dev", "doctrine/instantiator": "~1.0.1", "doctrine/common": ">=2.5-dev,<2.6-dev", + "doctrine/cache": "~1.4", "symfony/console": "~2.5" }, "require-dev": { diff --git a/docs/en/reference/second-level-cache.rst b/docs/en/reference/second-level-cache.rst index d88e83fc6..5408ca97c 100644 --- a/docs/en/reference/second-level-cache.rst +++ b/docs/en/reference/second-level-cache.rst @@ -185,7 +185,7 @@ To enable the second-level-cache, you should provide a cache factory cache = $cache; $this->regionsConfig = $cacheConfig; @@ -178,7 +180,13 @@ class DefaultCacheFactory implements CacheFactory */ public function buildCollectionHydrator(EntityManagerInterface $em, array $mapping) { - return new DefaultCollectionHydrator($em); + /* @var $targetPersister \Doctrine\ORM\Cache\Persister\CachedPersister */ + $targetPersister = $em->getUnitOfWork()->getEntityPersister($mapping['targetEntity']); + + return new DefaultCollectionHydrator( + $em, + $targetPersister->getCacheRegion() + ); } /** @@ -200,9 +208,16 @@ class DefaultCacheFactory implements CacheFactory $cacheAdapter = clone $this->cache; - $cacheAdapter->setNamespace($cache['region']); + if ($cacheAdapter instanceof CacheProvider) { + $cacheAdapter->setNamespace($cache['region']); + } - $region = new DefaultRegion($cache['region'], $cacheAdapter, $this->regionsConfig->getLifetime($cache['region'])); + $name = $cache['region']; + $lifetime = $this->regionsConfig->getLifetime($cache['region']); + + $region = ($cacheAdapter instanceof MultiGetCache) + ? new DefaultMultiGetRegion($name, $cacheAdapter, $lifetime) + : new DefaultRegion($name, $cacheAdapter, $lifetime); if ($cache['usage'] === ClassMetadata::CACHE_USAGE_READ_WRITE) { diff --git a/lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php b/lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php index cedd891da..5ca1e59df 100644 --- a/lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php +++ b/lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php @@ -65,9 +65,8 @@ class DefaultCollectionHydrator implements CollectionHydrator $data = array(); foreach ($collection as $index => $entity) { - $data[$index] = $this->uow->getEntityIdentifier($entity); + $data[$index] = new EntityCacheKey($metadata->name, $this->uow->getEntityIdentifier($entity)); } - return new CollectionCacheEntry($data); } @@ -77,19 +76,20 @@ class DefaultCollectionHydrator implements CollectionHydrator public function loadCacheEntry(ClassMetadata $metadata, CollectionCacheKey $key, CollectionCacheEntry $entry, PersistentCollection $collection) { $assoc = $metadata->associationMappings[$key->association]; + /* @var $targetPersister \Doctrine\ORM\Cache\Persister\CachedPersister */ $targetPersister = $this->uow->getEntityPersister($assoc['targetEntity']); $targetRegion = $targetPersister->getCacheRegion(); $list = array(); - foreach ($entry->identifiers as $index => $identifier) { + $entityEntries = $targetRegion->getMultiple($entry); - $entityEntry = $targetRegion->get(new EntityCacheKey($assoc['targetEntity'], $identifier)); + if ($entityEntries === null) { + return null; + } - if ($entityEntry === null) { - return null; - } - - $list[$index] = $this->uow->createEntity($entityEntry->class, $entityEntry->resolveAssociationEntries($this->em), self::$hints); + /* @var $entityEntries \Doctrine\ORM\Cache\EntityCacheEntry[] */ + foreach ($entityEntries as $index => $entityEntry) { + $list[$index] = $this->uow->createEntity($entityEntry->class, $entityEntry->data, self::$hints); } array_walk($list, function($entity, $index) use ($collection) { diff --git a/lib/Doctrine/ORM/Cache/MultiGetRegion.php b/lib/Doctrine/ORM/Cache/MultiGetRegion.php new file mode 100644 index 000000000..6de9c888d --- /dev/null +++ b/lib/Doctrine/ORM/Cache/MultiGetRegion.php @@ -0,0 +1,42 @@ +. + */ + +namespace Doctrine\ORM\Cache; + +/** + * Defines a region that supports multi-get reading. + * + * With one method call we can get multipe items. + * + * @since 2.5 + * @author Asmir Mustafic + */ +interface MultiGetRegion +{ + /** + * Get all items from the cache indentifed by $keys. + * It returns NULL if some elements can not be found. + * + * @param CollectionCacheEntry $collection The collection of the items to be retrieved. + * + * @return CacheEntry[]|null The cached entries or NULL if one or more entries can not be found + */ + public function getMultiple(CollectionCacheEntry $collection); +} diff --git a/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php b/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php index 33d437253..f62156763 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php @@ -167,8 +167,7 @@ abstract class AbstractCollectionPersister implements CachedCollectionPersister $targetHydrator = $targetPersister->getEntityHydrator(); $entry = $this->hydrator->buildCacheEntry($this->targetEntity, $key, $elements); - foreach ($entry->identifiers as $index => $identifier) { - $entityKey = new EntityCacheKey($this->targetEntity->rootEntityName, $identifier); + foreach ($entry->identifiers as $index => $entityKey) { if ($targetRegion->contains($entityKey)) { continue; diff --git a/lib/Doctrine/ORM/Cache/Region.php b/lib/Doctrine/ORM/Cache/Region.php index 894fd2f9b..3bffbbce7 100644 --- a/lib/Doctrine/ORM/Cache/Region.php +++ b/lib/Doctrine/ORM/Cache/Region.php @@ -26,7 +26,7 @@ namespace Doctrine\ORM\Cache; * @since 2.5 * @author Fabio B. Silva */ -interface Region +interface Region extends MultiGetRegion { /** * Retrieve the name of this region. diff --git a/lib/Doctrine/ORM/Cache/Region/DefaultMultiGetRegion.php b/lib/Doctrine/ORM/Cache/Region/DefaultMultiGetRegion.php new file mode 100644 index 000000000..39bf9c9e8 --- /dev/null +++ b/lib/Doctrine/ORM/Cache/Region/DefaultMultiGetRegion.php @@ -0,0 +1,75 @@ +. + */ + +namespace Doctrine\ORM\Cache\Region; + +use Doctrine\Common\Cache\MultiGetCache; +use Doctrine\ORM\Cache\Region; +use Doctrine\ORM\Cache\CollectionCacheEntry; + +/** + * A cache region that enables the retrieval of multiple elements with one call + * + * @since 2.5 + * @author Asmir Mustafic + */ +class DefaultMultiGetRegion extends DefaultRegion +{ + /** + * Note that the multiple type is due to doctrine/cache not integrating the MultiGetCache interface + * in its signature due to BC in 1.x + * + * @var MultiGetCache|\Doctrine\Common\Cache\Cache + */ + protected $cache; + + /** + * {@inheritDoc} + * + * @param MultiGetCache $cache + */ + public function __construct($name, MultiGetCache $cache, $lifetime = 0) + { + /* @var $cache \Doctrine\Common\Cache\Cache */ + parent::__construct($name, $cache, $lifetime); + } + + /** + * {@inheritdoc} + */ + public function getMultiple(CollectionCacheEntry $collection) + { + $keysToRetrieve = array(); + foreach ($collection->identifiers as $index => $key) { + $keysToRetrieve[$index] = $this->name . '_' . $key->hash; + } + + $items = $this->cache->fetchMultiple($keysToRetrieve); + if (count($items) !== count($keysToRetrieve)) { + return null; + } + + $returnableItems = array(); + foreach ($keysToRetrieve as $index => $key) { + $returnableItems[$index] = $items[$key]; + } + return $returnableItems; + } +} diff --git a/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php b/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php index a1362989f..f4525ee11 100644 --- a/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php +++ b/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php @@ -20,11 +20,13 @@ namespace Doctrine\ORM\Cache\Region; +use Doctrine\Common\Cache\Cache as CacheAdapter; +use Doctrine\Common\Cache\ClearableCache; +use Doctrine\ORM\Cache\CacheEntry; +use Doctrine\ORM\Cache\CacheKey; +use Doctrine\ORM\Cache\CollectionCacheEntry; use Doctrine\ORM\Cache\Lock; use Doctrine\ORM\Cache\Region; -use Doctrine\ORM\Cache\CacheKey; -use Doctrine\ORM\Cache\CacheEntry; -use Doctrine\Common\Cache\CacheProvider; /** * The simplest cache region compatible with all doctrine-cache drivers. @@ -35,7 +37,7 @@ use Doctrine\Common\Cache\CacheProvider; class DefaultRegion implements Region { /** - * @var \Doctrine\Common\Cache\CacheProvider + * @var CacheAdapter */ protected $cache; @@ -50,11 +52,11 @@ class DefaultRegion implements Region protected $lifetime = 0; /** - * @param string $name - * @param \Doctrine\Common\Cache\CacheProvider $cache - * @param integer $lifetime + * @param string $name + * @param CacheAdapter $cache + * @param integer $lifetime */ - public function __construct($name, CacheProvider $cache, $lifetime = 0) + public function __construct($name, CacheAdapter $cache, $lifetime = 0) { $this->cache = $cache; $this->name = (string) $name; @@ -93,6 +95,37 @@ class DefaultRegion implements Region return $this->cache->fetch($this->name . '_' . $key->hash) ?: null; } + /** + * {@inheritdoc} + */ + public function getMultiple(CollectionCacheEntry $collection) + { + $keysToRetrieve = array(); + + foreach ($collection->identifiers as $index => $key) { + $keysToRetrieve[$index] = $this->name . '_' . $key->hash; + } + + $items = array_filter( + array_map([$this->cache, 'fetch'], $keysToRetrieve), + function ($retrieved) { + return false !== $retrieved; + } + ); + + if (count($items) !== count($keysToRetrieve)) { + return null; + } + + $returnableItems = array(); + + foreach ($keysToRetrieve as $index => $key) { + $returnableItems[$index] = $items[$key]; + } + + return $returnableItems; + } + /** * {@inheritdoc} */ @@ -114,6 +147,13 @@ class DefaultRegion implements Region */ public function evictAll() { + if (! $this->cache instanceof ClearableCache) { + throw new \BadMethodCallException(sprintf( + 'Clearing all cache entries is not supported by the supplied cache adapter of type %s', + get_class($this->cache) + )); + } + return $this->cache->deleteAll(); } } diff --git a/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php b/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php index 083329c55..69167bc90 100644 --- a/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php +++ b/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php @@ -20,6 +20,7 @@ namespace Doctrine\ORM\Cache\Region; +use Doctrine\ORM\Cache\CollectionCacheEntry; use Doctrine\ORM\Cache\Lock; use Doctrine\ORM\Cache\Region; use Doctrine\ORM\Cache\CacheKey; @@ -172,6 +173,18 @@ class FileLockRegion implements ConcurrentRegion return $this->region->get($key); } + /** + * {@inheritdoc} + */ + public function getMultiple(CollectionCacheEntry $collection) + { + if (array_filter(array_map([$this, 'isLocked'], $collection->identifiers))) { + return null; + } + + return $this->region->getMultiple($collection); + } + /** * {inheritdoc} */ diff --git a/tests/Doctrine/Tests/Mocks/CacheRegionMock.php b/tests/Doctrine/Tests/Mocks/CacheRegionMock.php index 05366379e..519e72494 100644 --- a/tests/Doctrine/Tests/Mocks/CacheRegionMock.php +++ b/tests/Doctrine/Tests/Mocks/CacheRegionMock.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\Mocks; use Doctrine\ORM\Cache\CacheEntry; use Doctrine\ORM\Cache\CacheKey; +use Doctrine\ORM\Cache\CollectionCacheEntry; use Doctrine\ORM\Cache\Lock; use Doctrine\ORM\Cache\Region; @@ -94,6 +95,16 @@ class CacheRegionMock implements Region return $this->getReturn(__FUNCTION__, null); } + /** + * {@inheritdoc} + */ + public function getMultiple(CollectionCacheEntry $collection) + { + $this->calls[__FUNCTION__][] = array('collection' => $collection); + + return $this->getReturn(__FUNCTION__, null); + } + /** * {@inheritdoc} */ diff --git a/tests/Doctrine/Tests/Mocks/ConcurrentRegionMock.php b/tests/Doctrine/Tests/Mocks/ConcurrentRegionMock.php index fc488b4b2..82685b7d7 100644 --- a/tests/Doctrine/Tests/Mocks/ConcurrentRegionMock.php +++ b/tests/Doctrine/Tests/Mocks/ConcurrentRegionMock.php @@ -3,6 +3,7 @@ namespace Doctrine\Tests\Mocks; +use Doctrine\ORM\Cache\CollectionCacheEntry; use Doctrine\ORM\Cache\ConcurrentRegion; use Doctrine\ORM\Cache\LockException; use Doctrine\ORM\Cache\CacheEntry; @@ -131,6 +132,18 @@ class ConcurrentRegionMock implements ConcurrentRegion return $this->region->get($key); } + /** + * {@inheritdoc} + */ + public function getMultiple(CollectionCacheEntry $collection) + { + $this->calls[__FUNCTION__][] = array('collection' => $collection); + + $this->throwException(__FUNCTION__); + + return $this->region->getMultiple($collection); + } + /** * {@inheritdoc} */ diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php index c6dc3b501..cd41726d5 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php @@ -64,7 +64,6 @@ class DefaultCacheFactoryTest extends OrmTestCase ->with($this->equalTo($metadata->cache)) ->will($this->returnValue($region)); - $cachedPersister = $this->factory->buildCachedEntityPersister($em, $persister, $metadata); $this->assertInstanceOf('Doctrine\ORM\Cache\Persister\Entity\CachedEntityPersister', $cachedPersister); @@ -281,4 +280,37 @@ class DefaultCacheFactoryTest extends OrmTestCase $this->assertSame('foo', $fooRegion->getCache()->getNamespace()); $this->assertSame('bar', $barRegion->getCache()->getNamespace()); } + + public function testBuildsDefaultCacheRegionFromGenericCacheRegion() + { + /* @var $cache \Doctrine\Common\Cache\Cache */ + $cache = $this->getMock('Doctrine\Common\Cache\Cache'); + + $factory = new DefaultCacheFactory($this->regionsConfig, $cache); + + $this->assertInstanceOf( + 'Doctrine\ORM\Cache\Region\DefaultRegion', + $factory->getRegion(array( + 'region' => 'bar', + 'usage' => ClassMetadata::CACHE_USAGE_READ_ONLY, + )) + ); + } + + public function testBuildsMultiGetCacheRegionFromGenericCacheRegion() + { + /* @var $cache \Doctrine\Common\Cache\CacheProvider */ + $cache = $this->getMockForAbstractClass('Doctrine\Common\Cache\CacheProvider'); + + $factory = new DefaultCacheFactory($this->regionsConfig, $cache); + + $this->assertInstanceOf( + 'Doctrine\ORM\Cache\Region\DefaultMultiGetRegion', + $factory->getRegion(array( + 'region' => 'bar', + 'usage' => ClassMetadata::CACHE_USAGE_READ_ONLY, + )) + ); + } + } diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultCollectionHydratorTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultCollectionHydratorTest.php index 74082d8a7..ed0456e39 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultCollectionHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultCollectionHydratorTest.php @@ -29,7 +29,8 @@ class DefaultCollectionHydratorTest extends OrmFunctionalTestCase $this->enableSecondLevelCache(); parent::setUp(); - $this->structure = new DefaultCollectionHydrator($this->_em); + $targetPersister = $this->_em->getUnitOfWork()->getEntityPersister(City::CLASSNAME); + $this->structure = new DefaultCollectionHydrator($this->_em, $targetPersister); } public function testImplementsCollectionEntryStructure() @@ -41,8 +42,8 @@ class DefaultCollectionHydratorTest extends OrmFunctionalTestCase { $targetRegion = $this->_em->getCache()->getEntityCacheRegion(City::CLASSNAME); $entry = new CollectionCacheEntry(array( - array('id'=>31), - array('id'=>32), + new EntityCacheKey(City::CLASSNAME, array('id'=>31)), + new EntityCacheKey(City::CLASSNAME, array('id'=>32)), )); $targetRegion->put(new EntityCacheKey(City::CLASSNAME, array('id'=>31)), new EntityCacheEntry(City::CLASSNAME, array('id'=>31, 'name'=>'Foo'))); diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php index f449cfe6d..94cc99e35 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php @@ -60,4 +60,16 @@ class DefaultRegionTest extends AbstractRegionTest $this->assertSame('foo', $cache->getNamespace()); } + + public function testEvictAllWithGenericCacheThrowsUnsupportedException() + { + /* @var $cache \Doctrine\Common\Cache\Cache */ + $cache = $this->getMock('Doctrine\Common\Cache\Cache'); + + $region = new DefaultRegion('foo', $cache); + + $this->setExpectedException('BadMethodCallException'); + + $region->evictAll(); + } } \ No newline at end of file diff --git a/tests/Doctrine/Tests/ORM/Cache/MultiGetRegionTest.php b/tests/Doctrine/Tests/ORM/Cache/MultiGetRegionTest.php new file mode 100644 index 000000000..4c3258a12 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Cache/MultiGetRegionTest.php @@ -0,0 +1,41 @@ + + */ +class MultiGetRegionTest extends AbstractRegionTest +{ + protected function createRegion() + { + return new DefaultMultiGetRegion('default.region.test', $this->cache); + } + + public function testGetMulti() + { + $key1 = new CacheKeyMock('key.1'); + $value1 = new CacheEntryMock(array('id'=>1, 'name' => 'bar')); + + $key2 = new CacheKeyMock('key.2'); + $value2 = new CacheEntryMock(array('id'=>2, 'name' => 'bar')); + + $this->assertFalse($this->region->contains($key1)); + $this->assertFalse($this->region->contains($key2)); + + $this->region->put($key1, $value1); + $this->region->put($key2, $value2); + + $actual = $this->region->getMultiple(new CollectionCacheEntry(array($key1, $key2))); + + $this->assertEquals($value1, $actual[0]); + $this->assertEquals($value2, $actual[1]); + } +} diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/AbstractCollectionPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/AbstractCollectionPersisterTest.php index c3db83a44..17e7c4d7e 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/AbstractCollectionPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/AbstractCollectionPersisterTest.php @@ -38,6 +38,7 @@ abstract class AbstractCollectionPersisterTest extends OrmTestCase 'getName', 'contains', 'get', + 'getMultiple', 'put', 'evict', 'evictAll' @@ -56,6 +57,7 @@ abstract class AbstractCollectionPersisterTest extends OrmTestCase 'removeElement', 'removeKey', 'get', + 'getMultiple', 'loadCriteria' ); @@ -65,7 +67,7 @@ abstract class AbstractCollectionPersisterTest extends OrmTestCase * @param \Doctrine\ORM\Cache\Region $region * @param array $mapping * - * @return Doctrine\ORM\Cache\Persister\Collection\AbstractCollectionPersister + * @return \Doctrine\ORM\Cache\Persister\Collection\AbstractCollectionPersister */ abstract protected function createPersister(EntityManager $em, CollectionPersister $persister, Region $region, array $mapping); @@ -77,7 +79,10 @@ abstract class AbstractCollectionPersisterTest extends OrmTestCase $this->em = $this->_getTestEntityManager(); $this->region = $this->createRegion(); - $this->collectionPersister = $this->getMock('Doctrine\ORM\Persisters\Collection\CollectionPersister', $this->collectionPersisterMockMethods); + $this->collectionPersister = $this->getMock( + 'Doctrine\ORM\Persisters\Collection\CollectionPersister', + $this->collectionPersisterMockMethods + ); } /** diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php index 0bb6f58ed..529da203f 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php @@ -19,6 +19,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister 'getName', 'contains', 'get', + 'getMultiple', 'put', 'evict', 'evictAll', diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/AbstractEntityPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/AbstractEntityPersisterTest.php index 116339c87..662a9dfe6 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/AbstractEntityPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/AbstractEntityPersisterTest.php @@ -41,6 +41,7 @@ abstract class AbstractEntityPersisterTest extends OrmTestCase 'getName', 'contains', 'get', + 'getMultiple', 'put', 'evict', 'evictAll' @@ -85,7 +86,7 @@ abstract class AbstractEntityPersisterTest extends OrmTestCase * @param \Doctrine\ORM\Cache\Region $region * @param \Doctrine\ORM\Mapping\ClassMetadata $metadata * - * @return Doctrine\ORM\Cache\Persister\Entity\AbstractEntityPersister + * @return \Doctrine\ORM\Cache\Persister\Entity\AbstractEntityPersister */ abstract protected function createPersister(EntityManager $em, EntityPersister $persister, Region $region, ClassMetadata $metadata); @@ -97,7 +98,10 @@ abstract class AbstractEntityPersisterTest extends OrmTestCase $this->em = $this->_getTestEntityManager(); $this->region = $this->createRegion(); - $this->entityPersister = $this->getMock('Doctrine\ORM\Persisters\Entity\EntityPersister', $this->entityPersisterMockMethods); + $this->entityPersister = $this->getMock( + 'Doctrine\ORM\Persisters\Entity\EntityPersister', + $this->entityPersisterMockMethods + ); } /** @@ -109,7 +113,7 @@ abstract class AbstractEntityPersisterTest extends OrmTestCase } /** - * @return Doctrine\ORM\Cache\Persister\AbstractEntityPersister + * @return \Doctrine\ORM\Cache\Persister\AbstractEntityPersister */ protected function createPersisterDefault() { diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php index 1f598a903..054bf951d 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php @@ -20,6 +20,7 @@ class ReadWriteCachedEntityPersisterTest extends AbstractEntityPersisterTest 'getName', 'contains', 'get', + 'getMultiple', 'put', 'evict', 'evictAll', diff --git a/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php b/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php index 3bede3f15..2807ccfd7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php @@ -39,6 +39,10 @@ class ExtraLazyCollectionTest extends \Doctrine\Tests\OrmFunctionalTestCase $class->associationMappings['phonenumbers']['fetch'] = ClassMetadataInfo::FETCH_EXTRA_LAZY; $class->associationMappings['phonenumbers']['indexBy'] = 'phonenumber'; + unset($class->associationMappings['phonenumbers']['cache']); + unset($class->associationMappings['articles']['cache']); + unset($class->associationMappings['users']['cache']); + $class = $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsGroup'); $class->associationMappings['users']['fetch'] = ClassMetadataInfo::FETCH_EXTRA_LAZY; $class->associationMappings['users']['indexBy'] = 'username';