From 1b4eee6d0dd22d332a1776a7af8975e67938d639 Mon Sep 17 00:00:00 2001 From: Asmir Mustafic Date: Sat, 17 Jan 2015 11:52:39 +0100 Subject: [PATCH] Fixed strange test case with CmsUser and second-level cache --- lib/Doctrine/ORM/Cache/DefaultCacheFactory.php | 12 ++++++------ .../Tests/ORM/Functional/ExtraLazyCollectionTest.php | 4 ++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php b/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php index 04baf0de0..88a80a1a9 100644 --- a/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php +++ b/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php @@ -184,13 +184,13 @@ class DefaultCacheFactory implements CacheFactory if ($mapping['cache']) { $targetPersister = $em->getUnitOfWork()->getEntityPersister($mapping['targetEntity']); - if ($targetPersister instanceof CachedPersister) { + if (! ($targetPersister instanceof CachedPersister)) { + throw CacheException::nonCacheableEntity($mapping['targetEntity']); + } + $targetRegion = $targetPersister->getCacheRegion(); - $targetRegion = $targetPersister->getCacheRegion(); - - if ($targetRegion instanceof MultiGetRegion) { - return new MultiGetCollectionHydrator($em, $targetRegion); - } + if ($targetRegion instanceof MultiGetRegion) { + return new MultiGetCollectionHydrator($em, $targetRegion); } } 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';