Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[DDC-93] Rename ReflectionProxy to ReflectionEmbeddedProperty, Add DQ…

…L test with Object and Array Hydration.
  • Loading branch information...
commit 9613f1d8cb40c552ea5e57ad12b3adf0a654d167 1 parent 879ab6e
@beberlei beberlei authored
View
2  lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
@@ -895,7 +895,7 @@ public function wakeupReflection($reflService)
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']]
View
4 lib/Doctrine/ORM/Mapping/ReflectionProxy.php → ...RM/Mapping/ReflectionEmbeddedProperty.php
@@ -25,8 +25,10 @@
*
* 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;
View
48 tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php
@@ -11,10 +11,13 @@ public function setUp()
{
parent::setUp();
- $this->_schemaTool->createSchema(array(
- $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC93Person'),
- $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC93Address'),
- ));
+ 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 @@ public function testCRUD()
$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']);
+ }
+ }
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.