#5854 - Fix SLC queries with multiple nested DQL aliases
This commit is contained in:
parent
c834ccf3fa
commit
163dac4a91
@ -233,6 +233,7 @@ class DefaultQueryCache implements QueryCache
|
|||||||
|
|
||||||
$data = array();
|
$data = array();
|
||||||
$entityName = reset($rsm->aliasMap);
|
$entityName = reset($rsm->aliasMap);
|
||||||
|
$rootAlias = key($rsm->aliasMap);
|
||||||
$hasRelation = ( ! empty($rsm->relationMap));
|
$hasRelation = ( ! empty($rsm->relationMap));
|
||||||
$persister = $this->uow->getEntityPersister($entityName);
|
$persister = $this->uow->getEntityPersister($entityName);
|
||||||
|
|
||||||
@ -244,10 +245,11 @@ class DefaultQueryCache implements QueryCache
|
|||||||
|
|
||||||
foreach ($result as $index => $entity) {
|
foreach ($result as $index => $entity) {
|
||||||
$identifier = $this->uow->getEntityIdentifier($entity);
|
$identifier = $this->uow->getEntityIdentifier($entity);
|
||||||
|
$entityKey = new EntityCacheKey($entityName, $identifier);
|
||||||
$data[$index]['identifier'] = $identifier;
|
$data[$index]['identifier'] = $identifier;
|
||||||
$data[$index]['associations'] = array();
|
$data[$index]['associations'] = array();
|
||||||
|
|
||||||
if (($key->cacheMode & Cache::MODE_REFRESH) || ! $region->contains($entityKey = new EntityCacheKey($entityName, $identifier))) {
|
if (($key->cacheMode & Cache::MODE_REFRESH) || ! $region->contains($entityKey)) {
|
||||||
// Cancel put result if entity put fail
|
// Cancel put result if entity put fail
|
||||||
if ( ! $persister->storeEntityCache($entity, $entityKey)) {
|
if ( ! $persister->storeEntityCache($entity, $entityKey)) {
|
||||||
return false;
|
return false;
|
||||||
@ -260,45 +262,81 @@ class DefaultQueryCache implements QueryCache
|
|||||||
|
|
||||||
// @TODO - move to cache hydration components
|
// @TODO - move to cache hydration components
|
||||||
foreach ($rsm->relationMap as $alias => $name) {
|
foreach ($rsm->relationMap as $alias => $name) {
|
||||||
$metadata = $this->em->getClassMetadata($rsm->aliasMap[$rsm->parentAliasMap[$alias]]);
|
$parentAlias = $rsm->parentAliasMap[$alias];
|
||||||
$className = $metadata->getName();
|
$parentClass = $rsm->aliasMap[$parentAlias];
|
||||||
|
$metadata = $this->em->getClassMetadata($parentClass);
|
||||||
if (! $entity instanceof $className) {
|
|
||||||
// this alias is not the root alias, therefore we skip it. $entity is always the root of the selection here
|
|
||||||
// @TODO should actually cache all aliases
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$assoc = $metadata->associationMappings[$name];
|
$assoc = $metadata->associationMappings[$name];
|
||||||
|
$assocValue = $this->getAssociationValue($rsm, $alias, $entity);
|
||||||
|
|
||||||
if (($assocValue = $metadata->getFieldValue($entity, $name)) === null || $assocValue instanceof Proxy) {
|
if ($assocValue === null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$assocPersister = $this->uow->getEntityPersister($assoc['targetEntity']);
|
// root entity association
|
||||||
$assocRegion = $assocPersister->getCacheRegion();
|
if ($rootAlias === $parentAlias) {
|
||||||
$assocMetadata = $assocPersister->getClassMetadata();
|
// Cancel put result if association put fail
|
||||||
|
if ( ($assocInfo = $this->storeAssociationCache($key, $assoc, $assocValue)) === null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Handle *-to-one associations
|
$data[$index]['associations'][$name] = $assocInfo;
|
||||||
if ($assoc['type'] & ClassMetadata::TO_ONE) {
|
|
||||||
|
|
||||||
$assocIdentifier = $this->uow->getEntityIdentifier($assocValue);
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (($key->cacheMode & Cache::MODE_REFRESH) || ! $assocRegion->contains($entityKey = new EntityCacheKey($assocMetadata->rootEntityName, $assocIdentifier))) {
|
// store single nested association
|
||||||
|
if ( ! is_array($assocValue)) {
|
||||||
|
// Cancel put result if association put fail
|
||||||
|
if ($this->storeAssociationCache($key, $assoc, $assocValue) === null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Cancel put result if association entity put fail
|
continue;
|
||||||
if ( ! $assocPersister->storeEntityCache($assocValue, $entityKey)) {
|
}
|
||||||
|
|
||||||
|
// store array of nested association
|
||||||
|
foreach ($assocValue as $aVal) {
|
||||||
|
// Cancel put result if association put fail
|
||||||
|
if ($this->storeAssociationCache($key, $assoc, $aVal) === null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$data[$index]['associations'][$name] = array(
|
return $this->region->put($key, new QueryCacheEntry($data));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Doctrine\ORM\Cache\QueryCacheKey $key
|
||||||
|
* @param array $assoc
|
||||||
|
* @param mixed $assocValue
|
||||||
|
*
|
||||||
|
* @return array|null
|
||||||
|
*/
|
||||||
|
private function storeAssociationCache(QueryCacheKey $key, array $assoc, $assocValue)
|
||||||
|
{
|
||||||
|
$assocPersister = $this->uow->getEntityPersister($assoc['targetEntity']);
|
||||||
|
$assocMetadata = $assocPersister->getClassMetadata();
|
||||||
|
$assocRegion = $assocPersister->getCacheRegion();
|
||||||
|
|
||||||
|
// Handle *-to-one associations
|
||||||
|
if ($assoc['type'] & ClassMetadata::TO_ONE) {
|
||||||
|
$assocIdentifier = $this->uow->getEntityIdentifier($assocValue);
|
||||||
|
$entityKey = new EntityCacheKey($assocMetadata->rootEntityName, $assocIdentifier);
|
||||||
|
|
||||||
|
if ( ! $assocValue instanceof Proxy && ($key->cacheMode & Cache::MODE_REFRESH) || ! $assocRegion->contains($entityKey)) {
|
||||||
|
// Entity put fail
|
||||||
|
if ( ! $assocPersister->storeEntityCache($assocValue, $entityKey)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return array(
|
||||||
'targetEntity' => $assocMetadata->rootEntityName,
|
'targetEntity' => $assocMetadata->rootEntityName,
|
||||||
'identifier' => $assocIdentifier,
|
'identifier' => $assocIdentifier,
|
||||||
'type' => $assoc['type']
|
'type' => $assoc['type']
|
||||||
);
|
);
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle *-to-many associations
|
// Handle *-to-many associations
|
||||||
@ -306,27 +344,86 @@ class DefaultQueryCache implements QueryCache
|
|||||||
|
|
||||||
foreach ($assocValue as $assocItemIndex => $assocItem) {
|
foreach ($assocValue as $assocItemIndex => $assocItem) {
|
||||||
$assocIdentifier = $this->uow->getEntityIdentifier($assocItem);
|
$assocIdentifier = $this->uow->getEntityIdentifier($assocItem);
|
||||||
|
$entityKey = new EntityCacheKey($assocMetadata->rootEntityName, $assocIdentifier);
|
||||||
|
|
||||||
if (($key->cacheMode & Cache::MODE_REFRESH) || ! $assocRegion->contains($entityKey = new EntityCacheKey($assocMetadata->rootEntityName, $assocIdentifier))) {
|
if (($key->cacheMode & Cache::MODE_REFRESH) || ! $assocRegion->contains($entityKey)) {
|
||||||
|
// Entity put fail
|
||||||
// Cancel put result if entity put fail
|
|
||||||
if ( ! $assocPersister->storeEntityCache($assocItem, $entityKey)) {
|
if ( ! $assocPersister->storeEntityCache($assocItem, $entityKey)) {
|
||||||
return false;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$list[$assocItemIndex] = $assocIdentifier;
|
$list[$assocItemIndex] = $assocIdentifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data[$index]['associations'][$name] = array(
|
return array(
|
||||||
'targetEntity' => $assocMetadata->rootEntityName,
|
'targetEntity' => $assocMetadata->rootEntityName,
|
||||||
'type' => $assoc['type'],
|
'type' => $assoc['type'],
|
||||||
'list' => $list,
|
'list' => $list,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Doctrine\ORM\Query\ResultSetMapping $rsm
|
||||||
|
* @param string $assocAlias
|
||||||
|
* @param object $entity
|
||||||
|
*
|
||||||
|
* @return array|object
|
||||||
|
*/
|
||||||
|
private function getAssociationValue(ResultSetMapping $rsm, $assocAlias, $entity)
|
||||||
|
{
|
||||||
|
$path = array();
|
||||||
|
$alias = $assocAlias;
|
||||||
|
|
||||||
|
while (isset($rsm->parentAliasMap[$alias])) {
|
||||||
|
$parent = $rsm->parentAliasMap[$alias];
|
||||||
|
$field = $rsm->relationMap[$alias];
|
||||||
|
$class = $rsm->aliasMap[$parent];
|
||||||
|
|
||||||
|
array_unshift($path, array(
|
||||||
|
'field' => $field,
|
||||||
|
'class' => $class
|
||||||
|
));
|
||||||
|
|
||||||
|
$alias = $parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->region->put($key, new QueryCacheEntry($data));
|
return $this->getAssociationPathValue($entity, $path);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $value
|
||||||
|
* @param array $path
|
||||||
|
*
|
||||||
|
* @return array|object|null
|
||||||
|
*/
|
||||||
|
private function getAssociationPathValue($value, array $path)
|
||||||
|
{
|
||||||
|
$mapping = array_shift($path);
|
||||||
|
$metadata = $this->em->getClassMetadata($mapping['class']);
|
||||||
|
$assoc = $metadata->associationMappings[$mapping['field']];
|
||||||
|
$value = $metadata->getFieldValue($value, $mapping['field']);
|
||||||
|
|
||||||
|
if ($value === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($path)) {
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle *-to-one associations
|
||||||
|
if ($assoc['type'] & ClassMetadata::TO_ONE) {
|
||||||
|
return $this->getAssociationPathValue($value, $path);
|
||||||
|
}
|
||||||
|
|
||||||
|
$values = array();
|
||||||
|
|
||||||
|
foreach ($value as $item) {
|
||||||
|
$values[] = $this->getAssociationPathValue($item, $path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $values;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12,6 +12,7 @@ use Doctrine\ORM\Query\ResultSetMappingBuilder;
|
|||||||
use Doctrine\Tests\Models\Cache\Country;
|
use Doctrine\Tests\Models\Cache\Country;
|
||||||
use Doctrine\Tests\Models\Cache\City;
|
use Doctrine\Tests\Models\Cache\City;
|
||||||
use Doctrine\Tests\Models\Cache\State;
|
use Doctrine\Tests\Models\Cache\State;
|
||||||
|
use Doctrine\Tests\Models\Cache\Restaurant;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\Tests\Models\Generic\BooleanModel;
|
use Doctrine\Tests\Models\Generic\BooleanModel;
|
||||||
use Doctrine\ORM\Cache\EntityCacheEntry;
|
use Doctrine\ORM\Cache\EntityCacheEntry;
|
||||||
@ -176,13 +177,13 @@ class DefaultQueryCacheTest extends OrmTestCase
|
|||||||
$countryClass->setFieldValue($country, 'id', $i*3);
|
$countryClass->setFieldValue($country, 'id', $i*3);
|
||||||
|
|
||||||
$uow->registerManaged($country, array('id' => $country->getId()), array('name' => $country->getName()));
|
$uow->registerManaged($country, array('id' => $country->getId()), array('name' => $country->getName()));
|
||||||
$uow->registerManaged($state, array('id' => $state->getId()), array('name' => $city->getName(), 'country' => $country));
|
$uow->registerManaged($state, array('id' => $state->getId()), array('name' => $state->getName(), 'country' => $country));
|
||||||
$uow->registerManaged($city, array('id' => $city->getId()), array('name' => $city->getName(), 'state' => $state));
|
$uow->registerManaged($city, array('id' => $city->getId()), array('name' => $city->getName(), 'state' => $state));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->assertTrue($this->queryCache->put($key, $rsm, $result));
|
$this->assertTrue($this->queryCache->put($key, $rsm, $result));
|
||||||
$this->assertArrayHasKey('put', $this->region->calls);
|
$this->assertArrayHasKey('put', $this->region->calls);
|
||||||
$this->assertCount(9, $this->region->calls['put']);
|
$this->assertCount(13, $this->region->calls['put']);
|
||||||
|
|
||||||
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][0]['key']);
|
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][0]['key']);
|
||||||
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][1]['key']);
|
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][1]['key']);
|
||||||
@ -192,7 +193,11 @@ class DefaultQueryCacheTest extends OrmTestCase
|
|||||||
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][5]['key']);
|
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][5]['key']);
|
||||||
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][6]['key']);
|
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][6]['key']);
|
||||||
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][7]['key']);
|
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][7]['key']);
|
||||||
$this->assertInstanceOf('Doctrine\ORM\Cache\QueryCacheKey', $this->region->calls['put'][8]['key']);
|
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][8]['key']);
|
||||||
|
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][9]['key']);
|
||||||
|
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][10]['key']);
|
||||||
|
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][11]['key']);
|
||||||
|
$this->assertInstanceOf('Doctrine\ORM\Cache\QueryCacheKey', $this->region->calls['put'][12]['key']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPutToOneAssociationNullQueryResult()
|
public function testPutToOneAssociationNullQueryResult()
|
||||||
@ -482,6 +487,50 @@ class DefaultQueryCacheTest extends OrmTestCase
|
|||||||
$this->assertNull($this->queryCache->get($key, $rsm));
|
$this->assertNull($this->queryCache->get($key, $rsm));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGetAssociationValue()
|
||||||
|
{
|
||||||
|
$reflection = new \ReflectionMethod($this->queryCache, 'getAssociationValue');
|
||||||
|
$rsm = new ResultSetMappingBuilder($this->em);
|
||||||
|
$key = new QueryCacheKey('query.key1', 0);
|
||||||
|
|
||||||
|
$reflection->setAccessible(true);
|
||||||
|
|
||||||
|
$germany = new Country("Germany");
|
||||||
|
$bavaria = new State("Bavaria", $germany);
|
||||||
|
$wurzburg = new City("Würzburg", $bavaria);
|
||||||
|
$munich = new City("Munich", $bavaria);
|
||||||
|
|
||||||
|
$bavaria->addCity($munich);
|
||||||
|
$bavaria->addCity($wurzburg);
|
||||||
|
|
||||||
|
$munich->addAttraction(new Restaurant('Reinstoff', $munich));
|
||||||
|
$munich->addAttraction(new Restaurant('Schneider Weisse', $munich));
|
||||||
|
$wurzburg->addAttraction(new Restaurant('Fischers Fritz', $wurzburg));
|
||||||
|
|
||||||
|
$rsm->addRootEntityFromClassMetadata(State::CLASSNAME, 's');
|
||||||
|
$rsm->addJoinedEntityFromClassMetadata(City::CLASSNAME, 'c', 's', 'cities', array(
|
||||||
|
'id' => 'c_id',
|
||||||
|
'name' => 'c_name'
|
||||||
|
));
|
||||||
|
$rsm->addJoinedEntityFromClassMetadata(Restaurant::CLASSNAME, 'a', 'c', 'attractions', array(
|
||||||
|
'id' => 'a_id',
|
||||||
|
'name' => 'a_name'
|
||||||
|
));
|
||||||
|
|
||||||
|
$cities = $reflection->invoke($this->queryCache, $rsm, 'c', $bavaria);
|
||||||
|
$attractions = $reflection->invoke($this->queryCache, $rsm, 'a', $bavaria);
|
||||||
|
|
||||||
|
$this->assertCount(2, $cities);
|
||||||
|
$this->assertCount(2, $attractions);
|
||||||
|
|
||||||
|
$this->assertInstanceOf('Doctrine\Common\Collections\Collection', $cities);
|
||||||
|
$this->assertInstanceOf('Doctrine\Common\Collections\Collection', $attractions[0]);
|
||||||
|
$this->assertInstanceOf('Doctrine\Common\Collections\Collection', $attractions[1]);
|
||||||
|
|
||||||
|
$this->assertCount(2, $attractions[0]);
|
||||||
|
$this->assertCount(1, $attractions[1]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException Doctrine\ORM\Cache\CacheException
|
* @expectedException Doctrine\ORM\Cache\CacheException
|
||||||
* @expectedExceptionMessage Second level cache does not support scalar results.
|
* @expectedExceptionMessage Second level cache does not support scalar results.
|
||||||
|
@ -3,10 +3,11 @@
|
|||||||
namespace Doctrine\Tests\ORM\Functional;
|
namespace Doctrine\Tests\ORM\Functional;
|
||||||
|
|
||||||
use Doctrine\ORM\AbstractQuery;
|
use Doctrine\ORM\AbstractQuery;
|
||||||
use Doctrine\Tests\Models\Cache\Country;
|
|
||||||
use Doctrine\ORM\Query\ResultSetMapping;
|
use Doctrine\ORM\Query\ResultSetMapping;
|
||||||
use Doctrine\Tests\Models\Cache\State;
|
|
||||||
use Doctrine\Tests\Models\Cache\City;
|
use Doctrine\Tests\Models\Cache\City;
|
||||||
|
use Doctrine\Tests\Models\Cache\State;
|
||||||
|
use Doctrine\Tests\Models\Cache\Country;
|
||||||
|
use Doctrine\Tests\Models\Cache\Attraction;
|
||||||
use Doctrine\ORM\Cache\QueryCacheKey;
|
use Doctrine\ORM\Cache\QueryCacheKey;
|
||||||
use Doctrine\ORM\Cache\EntityCacheKey;
|
use Doctrine\ORM\Cache\EntityCacheKey;
|
||||||
use Doctrine\ORM\Cache\EntityCacheEntry;
|
use Doctrine\ORM\Cache\EntityCacheEntry;
|
||||||
@ -283,6 +284,89 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
|
|||||||
$this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName()));
|
$this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group 5854
|
||||||
|
*/
|
||||||
|
public function testMultipleNestedDQLAliases()
|
||||||
|
{
|
||||||
|
$this->loadFixturesCountries();
|
||||||
|
$this->loadFixturesStates();
|
||||||
|
$this->loadFixturesCities();
|
||||||
|
$this->loadFixturesAttractions();
|
||||||
|
|
||||||
|
$queryRegionName = $this->getDefaultQueryRegionName();
|
||||||
|
$cityRegionName = $this->getEntityRegion(City::CLASSNAME);
|
||||||
|
$stateRegionName = $this->getEntityRegion(State::CLASSNAME);
|
||||||
|
$attractionRegionName = $this->getEntityRegion(Attraction::CLASSNAME);
|
||||||
|
|
||||||
|
$this->secondLevelCacheLogger->clearStats();
|
||||||
|
$this->evictRegions();
|
||||||
|
$this->_em->clear();
|
||||||
|
|
||||||
|
$queryCount = $this->getCurrentQueryCount();
|
||||||
|
$dql = 'SELECT s, c, a FROM Doctrine\Tests\Models\Cache\State s JOIN s.cities c JOIN c.attractions a';
|
||||||
|
$result1 = $this->_em->createQuery($dql)
|
||||||
|
->setCacheable(true)
|
||||||
|
->getResult();
|
||||||
|
|
||||||
|
$this->assertCount(2, $result1);
|
||||||
|
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
|
||||||
|
|
||||||
|
$this->assertTrue($this->cache->containsEntity(State::CLASSNAME, $this->states[0]->getId()));
|
||||||
|
$this->assertTrue($this->cache->containsEntity(State::CLASSNAME, $this->states[1]->getId()));
|
||||||
|
|
||||||
|
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[0]->getId()));
|
||||||
|
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[1]->getId()));
|
||||||
|
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[2]->getId()));
|
||||||
|
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[3]->getId()));
|
||||||
|
|
||||||
|
$this->assertTrue($this->cache->containsEntity(Attraction::CLASSNAME, $this->attractions[0]->getId()));
|
||||||
|
$this->assertTrue($this->cache->containsEntity(Attraction::CLASSNAME, $this->attractions[1]->getId()));
|
||||||
|
$this->assertTrue($this->cache->containsEntity(Attraction::CLASSNAME, $this->attractions[2]->getId()));
|
||||||
|
$this->assertTrue($this->cache->containsEntity(Attraction::CLASSNAME, $this->attractions[3]->getId()));
|
||||||
|
|
||||||
|
$this->assertInstanceOf(State::CLASSNAME, $result1[0]);
|
||||||
|
$this->assertInstanceOf(State::CLASSNAME, $result1[1]);
|
||||||
|
|
||||||
|
$this->assertCount(2, $result1[0]->getCities());
|
||||||
|
$this->assertCount(2, $result1[1]->getCities());
|
||||||
|
|
||||||
|
$this->assertInstanceOf(City::CLASSNAME, $result1[0]->getCities()->get(0));
|
||||||
|
$this->assertInstanceOf(City::CLASSNAME, $result1[0]->getCities()->get(1));
|
||||||
|
$this->assertInstanceOf(City::CLASSNAME, $result1[1]->getCities()->get(0));
|
||||||
|
$this->assertInstanceOf(City::CLASSNAME, $result1[1]->getCities()->get(1));
|
||||||
|
|
||||||
|
$this->assertCount(2, $result1[0]->getCities()->get(0)->getAttractions());
|
||||||
|
$this->assertCount(2, $result1[0]->getCities()->get(1)->getAttractions());
|
||||||
|
$this->assertCount(2, $result1[1]->getCities()->get(0)->getAttractions());
|
||||||
|
$this->assertCount(1, $result1[1]->getCities()->get(1)->getAttractions());
|
||||||
|
|
||||||
|
$this->_em->clear();
|
||||||
|
|
||||||
|
$result2 = $this->_em->createQuery($dql)
|
||||||
|
->setCacheable(true)
|
||||||
|
->getResult();
|
||||||
|
|
||||||
|
$this->assertCount(2, $result2);
|
||||||
|
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
|
||||||
|
|
||||||
|
$this->assertInstanceOf(State::CLASSNAME, $result2[0]);
|
||||||
|
$this->assertInstanceOf(State::CLASSNAME, $result2[1]);
|
||||||
|
|
||||||
|
$this->assertCount(2, $result2[0]->getCities());
|
||||||
|
$this->assertCount(2, $result2[1]->getCities());
|
||||||
|
|
||||||
|
$this->assertInstanceOf(City::CLASSNAME, $result2[0]->getCities()->get(0));
|
||||||
|
$this->assertInstanceOf(City::CLASSNAME, $result2[0]->getCities()->get(1));
|
||||||
|
$this->assertInstanceOf(City::CLASSNAME, $result2[1]->getCities()->get(0));
|
||||||
|
$this->assertInstanceOf(City::CLASSNAME, $result2[1]->getCities()->get(1));
|
||||||
|
|
||||||
|
$this->assertCount(2, $result2[0]->getCities()->get(0)->getAttractions());
|
||||||
|
$this->assertCount(2, $result2[0]->getCities()->get(1)->getAttractions());
|
||||||
|
$this->assertCount(2, $result2[1]->getCities()->get(0)->getAttractions());
|
||||||
|
$this->assertCount(1, $result2[1]->getCities()->get(1)->getAttractions());
|
||||||
|
}
|
||||||
|
|
||||||
public function testBasicQueryParams()
|
public function testBasicQueryParams()
|
||||||
{
|
{
|
||||||
$this->evictRegions();
|
$this->evictRegions();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user