Added more tests for PropertyAccess

This commit is contained in:
Pierre du Plessis 2015-10-06 23:49:38 +02:00
parent 380e2ba103
commit 378db759e0
1 changed files with 15 additions and 0 deletions

View File

@ -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
*/