From 378db759e0bf2fcbcfe93b139641ae17da444799 Mon Sep 17 00:00:00 2001 From: Pierre du Plessis Date: Tue, 6 Oct 2015 23:49:38 +0200 Subject: [PATCH] Added more tests for PropertyAccess --- .../PropertyAccess/Tests/PropertyAccessorTest.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php index fb4e3c34ee..ce4438550e 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\PropertyAccess\Tests; +use Symfony\Component\PropertyAccess\Exception\NoSuchIndexException; use Symfony\Component\PropertyAccess\PropertyAccessor; use Symfony\Component\PropertyAccess\Tests\Fixtures\TestClass; use Symfony\Component\PropertyAccess\Tests\Fixtures\TestClassMagicCall; @@ -139,6 +140,20 @@ class PropertyAccessorTest extends \PHPUnit_Framework_TestCase $this->assertSame(array('Bernhard'), $object->firstName); } + public function testGetValueNotModifyObjectException() + { + $propertyAccessor = new PropertyAccessor(false, true); + $object = new \stdClass(); + $object->firstName = array('Bernhard'); + + try { + $propertyAccessor->getValue($object, 'firstName[1]'); + } catch (NoSuchIndexException $e) { + } + + $this->assertSame(array('Bernhard'), $object->firstName); + } + /** * @expectedException \Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException */