[DDC-93] Rename ReflectionProxy to ReflectionEmbeddedProperty, Add DQL test with Object and Array Hydration.
This commit is contained in:
parent
879ab6e52b
commit
9613f1d8cb
@ -895,7 +895,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
|
||||
foreach ($this->fieldMappings as $field => $mapping) {
|
||||
if (isset($mapping['declaredField'])) {
|
||||
$this->reflFields[$field] = new ReflectionProxy(
|
||||
$this->reflFields[$field] = new ReflectionEmbeddedProperty(
|
||||
$reflService->getAccessibleProperty($this->name, $mapping['declaredField']),
|
||||
$reflService->getAccessibleProperty($this->embeddedClasses[$mapping['declaredField']], $mapping['originalField']),
|
||||
$this->embeddedClasses[$mapping['declaredField']]
|
||||
|
@ -25,8 +25,10 @@ namespace Doctrine\ORM\Mapping;
|
||||
*
|
||||
* This way value objects "just work" without UnitOfWork, Persisters or Hydrators
|
||||
* needing any changes.
|
||||
*
|
||||
* TODO: Move this class into Common\Reflection
|
||||
*/
|
||||
class ReflectionProxy
|
||||
class ReflectionEmbeddedProperty
|
||||
{
|
||||
private $parentProperty;
|
||||
private $childProperty;
|
@ -11,10 +11,13 @@ class ValueObjectsTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
try {
|
||||
$this->_schemaTool->createSchema(array(
|
||||
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC93Person'),
|
||||
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC93Address'),
|
||||
));
|
||||
} catch(\Exception $e) {
|
||||
}
|
||||
}
|
||||
|
||||
public function testCRUD()
|
||||
@ -61,6 +64,43 @@ class ValueObjectsTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
|
||||
$this->assertNull($this->_em->find(DDC93Person::CLASSNAME, $personId));
|
||||
}
|
||||
|
||||
public function testLoadDql()
|
||||
{
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
$person = new DDC93Person();
|
||||
$person->name = "Donkey Kong$i";
|
||||
$person->address = new DDC93Address();
|
||||
$person->address->street = "Tree";
|
||||
$person->address->zip = "12345";
|
||||
$person->address->city = "funkytown";
|
||||
|
||||
$this->_em->persist($person);
|
||||
}
|
||||
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
|
||||
$dql = "SELECT p FROM " . __NAMESPACE__ . "\DDC93Person p";
|
||||
$persons = $this->_em->createQuery($dql)->getResult();
|
||||
|
||||
$this->assertCount(3, $persons);
|
||||
foreach ($persons as $person) {
|
||||
$this->assertInstanceOf(DDC93Address::CLASSNAME, $person->address);
|
||||
$this->assertEquals('Tree', $person->address->street);
|
||||
$this->assertEquals('12345', $person->address->zip);
|
||||
$this->assertEquals('funkytown', $person->address->city);
|
||||
}
|
||||
|
||||
$dql = "SELECT p FROM " . __NAMESPACE__ . "\DDC93Person p";
|
||||
$persons = $this->_em->createQuery($dql)->getArrayResult();
|
||||
|
||||
foreach ($persons as $person) {
|
||||
$this->assertEquals('Tree', $person['address.street']);
|
||||
$this->assertEquals('12345', $person['address.zip']);
|
||||
$this->assertEquals('funkytown', $person['address.city']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user