From bd667b82d9160a97964ddc175261e593745c9960 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Tue, 20 Jan 2015 15:24:48 +0100 Subject: [PATCH] DDC-2704 - carefully checking defined classes in `getAllReflectionProperties` --- .../Tests/ORM/Mapping/ClassMetadataTest.php | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php index 36b92f81d..4a7882862 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php @@ -7,6 +7,8 @@ use Doctrine\Common\Persistence\Mapping\StaticReflectionService; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Events; use Doctrine\ORM\Mapping\DefaultNamingStrategy; +use Doctrine\Tests\Models\DirectoryTree\AbstractContentItem; +use Doctrine\Tests\Models\DirectoryTree\File; require_once __DIR__ . '/../../Models/Global/GlobalNamespaceModel.php'; @@ -1152,6 +1154,41 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase $classMetadata->getAllReflectionProperties(); } + + /** + * @group DDC-2704 + */ + public function testGetAllReflectionPropertiesRetrievesCollidingPrivateProperties() + { + $classMetadata = new ClassMetadata(File::CLASSNAME); + + $classMetadata->initializeReflection(new RuntimeReflectionService()); + + $properties = $classMetadata->getAllReflectionProperties(); + + $this->assertInternalType('array', $properties); + $this->assertCount(5, $properties); + + $propertyNames = array_map( + function (\ReflectionProperty $property) { + return $property->getDeclaringClass()->getName() . '::' . $property->getName(); + }, + $properties + ); + + sort($propertyNames); + + $this->assertEquals( + [ + 'Doctrine\Tests\Models\DirectoryTree\AbstractContentItem::id', + 'Doctrine\Tests\Models\DirectoryTree\AbstractContentItem::name', + 'Doctrine\Tests\Models\DirectoryTree\AbstractContentItem::nodeIsLoaded', + 'Doctrine\Tests\Models\DirectoryTree\AbstractContentItem::parentDirectory', + 'Doctrine\Tests\Models\DirectoryTree\File::extension', + ], + $propertyNames + ); + } } /**