From ecf028490fe3fe2aab333df4f775f29e3e4c5277 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 5 Dec 2014 12:56:34 +0100 Subject: [PATCH] Test to verify that `Doctrine\ORM\Mapping\ReflectionEmbeddedProperty` is able to interact with internal PHP classes --- .../ReflectionEmbeddedPropertyTest.php | 100 ++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 tests/Doctrine/Tests/ORM/Mapping/ReflectionEmbeddedPropertyTest.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/ReflectionEmbeddedPropertyTest.php b/tests/Doctrine/Tests/ORM/Mapping/ReflectionEmbeddedPropertyTest.php new file mode 100644 index 000000000..84a614ddb --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Mapping/ReflectionEmbeddedPropertyTest.php @@ -0,0 +1,100 @@ +getDeclaringClass()->getName() + ); + + $instantiator = new Instantiator(); + + $object = $instantiator->instantiate($parentProperty->getDeclaringClass()->getName()); + + $embeddedPropertyReflection->setValue($object, 'newValue'); + + $this->assertSame('newValue', $embeddedPropertyReflection->getValue($object)); + + $embeddedPropertyReflection->setValue($object, 'changedValue'); + + $this->assertSame('changedValue', $embeddedPropertyReflection->getValue($object)); + } + + /** + * Data provider + * + * @return ReflectionProperty[][] + */ + public function getTestedReflectionProperties() + { + return array( + array( + $this->getReflectionProperty( + 'Doctrine\\Tests\\Models\\Reflection\\ArrayObjectExtendingClass', + 'publicProperty' + ), + $this->getReflectionProperty( + 'Doctrine\\Tests\\Models\\Reflection\\ArrayObjectExtendingClass', + 'privateProperty' + ), + ), + array( + $this->getReflectionProperty( + 'Doctrine\\Tests\\Models\\Reflection\\ArrayObjectExtendingClass', + 'publicProperty' + ), + $this->getReflectionProperty( + 'Doctrine\\Tests\\Models\\Reflection\\ArrayObjectExtendingClass', + 'protectedProperty' + ), + ), + array( + $this->getReflectionProperty( + 'Doctrine\\Tests\\Models\\Reflection\\ArrayObjectExtendingClass', + 'publicProperty' + ), + $this->getReflectionProperty( + 'Doctrine\\Tests\\Models\\Reflection\\ArrayObjectExtendingClass', + 'publicProperty' + ), + ), + ); + } + + /** + * @param string $className + * @param string $propertyName + * + * @return ReflectionProperty + */ + private function getReflectionProperty($className, $propertyName) + { + $reflectionProperty = new ReflectionProperty($className, $propertyName); + + $reflectionProperty->setAccessible(true); + + return $reflectionProperty; + } +}