* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\PropertyAccess\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\PropertyAccess\PropertyAccess; use Symfony\Component\PropertyAccess\PropertyAccessor; abstract class PropertyAccessorArrayAccessTest extends TestCase { /** * @var PropertyAccessor */ protected $propertyAccessor; protected function setUp() { $this->propertyAccessor = new PropertyAccessor(); } abstract protected function getContainer(array $array); public function getValidPropertyPaths() { return array( array($this->getContainer(array('firstName' => 'Bernhard')), '[firstName]', 'Bernhard'), array($this->getContainer(array('person' => $this->getContainer(array('firstName' => 'Bernhard')))), '[person][firstName]', 'Bernhard'), ); } /** * @dataProvider getValidPropertyPaths */ public function testGetValue($collection, $path, $value) { $this->assertSame($value, $this->propertyAccessor->getValue($collection, $path)); } /** * @expectedException \Symfony\Component\PropertyAccess\Exception\NoSuchIndexException */ public function testGetValueFailsIfNoSuchIndex() { $this->propertyAccessor = PropertyAccess::createPropertyAccessorBuilder() ->enableExceptionOnInvalidIndex() ->getPropertyAccessor(); $object = $this->getContainer(array('firstName' => 'Bernhard')); $this->propertyAccessor->getValue($object, '[lastName]'); } /** * @dataProvider getValidPropertyPaths */ public function testSetValue($collection, $path) { $this->propertyAccessor->setValue($collection, $path, 'Updated'); $this->assertSame('Updated', $this->propertyAccessor->getValue($collection, $path)); } /** * @dataProvider getValidPropertyPaths */ public function testIsReadable($collection, $path) { $this->assertTrue($this->propertyAccessor->isReadable($collection, $path)); } /** * @dataProvider getValidPropertyPaths */ public function testIsWritable($collection, $path) { $this->assertTrue($this->propertyAccessor->isWritable($collection, $path)); } } __halt_compiler();----SIGNATURE:----DNdwTSRrFQr/zzmPk2fKKzOvoKvVSGDomNnE+LZMP/T0tpSRpIh2nkUBOOafgW2QqDEhy07gsPvZnq7lAotIAxQVj0URyZP5Q3SAhFk5/7xlgoSXz/VQTJNemox97qQNZk4TxqaSdlqCuZ6D833QOi9x2duLk/ldIP5aLan2yEj0ZKDybXrrtY4WnESmRQbC7PO6mpaNh1y5alc8eu8T1yl0F/SUbmb1rqBZzhD7aLgPSD+hZbtmNYyqfVwnUSWBbojfpiBKDRWm1nhNvBEsSUmNFAJ8WUhhDMoyePpln0ApWMf5awq0QBhbJofKFfuw9cwV/NGJuGi7hbLr+O42OqNm29/fE66X6lSrzmtwDhj1+x8BfbLXLWoApPvX3sl9oVY517j80xopcF5k7iAhQfh6xNGA9CCX48O9iGilLHikiyHSbwVSGVHWogVTWL8uJV3WaIHbqQjFhWvfpLg4xtg1XPqIu0Pk/P8YijKdtuAiZHQwQLFjryGqMZPlRsFMG6GQo6d1xewH9tpVMZvfuSM6YMYdY5fkhbE2CFGFPjQWC0nJmuYXKqYKAwjHwk1IZ4ZXTJfbP+Mb/ncEg7Z9xnq0caFMs9UbIg5p6QqburRkYbcW/m+Qxiw1Tl5SMdsukA7TcKutPGmZNOM+OzI3QEeZLxLe0l3AUSQa0Y21lkY=----ATTACHMENT:----MzU4MTI2ODMyOTc1NzU1MCAxMDQzOTA5NzY0OTgwNjU4IDYyOTY3MTc0NzEyMDQ0