added tests on empty values
This commit is contained in:
parent
aac523d155
commit
6d40859228
@ -294,10 +294,14 @@ abstract class AbstractHydrator
|
|||||||
$dqlAlias = $cacheKeyInfo['dqlAlias'];
|
$dqlAlias = $cacheKeyInfo['dqlAlias'];
|
||||||
$type = $cacheKeyInfo['type'];
|
$type = $cacheKeyInfo['type'];
|
||||||
|
|
||||||
|
var_dump($dqlAlias);
|
||||||
|
var_dump($cacheKeyInfo);
|
||||||
|
echo "\n\n\n";
|
||||||
|
|
||||||
// in an inheritance hierarchy the same field could be defined several times.
|
// in an inheritance hierarchy the same field could be defined several times.
|
||||||
// We overwrite this value so long we don't have a non-null value, that value we keep.
|
// We overwrite this value so long we don't have a non-null value, that value we keep.
|
||||||
// Per definition it cannot be that a field is defined several times and has several values.
|
// Per definition it cannot be that a field is defined several times and has several values.
|
||||||
if (isset($rowData['data'][$dqlAlias][$fieldName])) {
|
if (!empty($rowData['data'][$dqlAlias][$fieldName])) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,4 +53,49 @@ class DDC6303Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testEmptyValuesInJoinedInheritance()
|
||||||
|
{
|
||||||
|
$contractStringEmptyData = '';
|
||||||
|
$contractStringZeroData = 0;
|
||||||
|
|
||||||
|
$contractArrayEmptyData = [];
|
||||||
|
|
||||||
|
$contractStringEmpty = new DDC6303ContractA();
|
||||||
|
$contractStringEmpty->originalData = $contractStringEmptyData;
|
||||||
|
|
||||||
|
$contractStringZero = new DDC6303ContractA();
|
||||||
|
$contractStringZero->originalData = $contractStringZeroData;
|
||||||
|
|
||||||
|
$contractArrayEmpty = new DDC6303ContractB();
|
||||||
|
$contractArrayEmpty->originalData = $contractArrayEmptyData;
|
||||||
|
|
||||||
|
$this->_em->persist($contractStringZero);
|
||||||
|
$this->_em->persist($contractStringEmpty);
|
||||||
|
$this->_em->persist($contractArrayEmpty);
|
||||||
|
|
||||||
|
$this->_em->flush();
|
||||||
|
|
||||||
|
// clear entity manager so that $repository->find actually fetches them and uses the hydrator
|
||||||
|
// instead of just returning the existing managed entities
|
||||||
|
$this->_em->clear();
|
||||||
|
|
||||||
|
$repository = $this->_em->getRepository(DDC6303Contract::class);
|
||||||
|
$dataMap = [
|
||||||
|
$contractStringZero->id => $contractStringZeroData,
|
||||||
|
$contractStringEmpty->id => $contractStringEmptyData,
|
||||||
|
$contractArrayEmpty->id => $contractArrayEmptyData,
|
||||||
|
];
|
||||||
|
|
||||||
|
$contracts = $repository->createQueryBuilder('p')
|
||||||
|
->where('p.id IN(:ids)')
|
||||||
|
->setParameter('ids', array_keys($dataMap))
|
||||||
|
->getQuery()->getResult();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
foreach( $contracts as $contract ){
|
||||||
|
static::assertEquals($contract->originalData, $dataMap[$contract->id], 'contract ' . get_class($contract) . ' not equals to original');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user