* * 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:----gojQsvpglCtRFDhmTM0sVBiIoFM9JfGZUlHdoO0Cv8xqp5CRWGT3a10X2AniZK2QEIOgD6Ww86JLcrWL/q+XKcJRbUCyB4XlaZ7lSzOTCVOKb9NNWsKULRrbq2W9BuS9C0qC4S34EPrP1VdG/H7urcLXxJV1kX0SP845LO+7W00Sn9R0PsCX1jduVGKl4HvC3J9tm2GNUakjtELW93J1g9KODzM7YtBsmS9kyjsy5XgnbEV2HUmymXlS4wDanna/YzkfKPdG1GKOVXJs1eCUymRFpB6zJBFs/WyNRBEq0aEZTj7jAo1gIWt//d1xavy7s1L5v+IUlInmwdBBGbY2mVtmC+sV+UafIOJSwLBa6+2HvnwI7HgGVFfZZF7PPUbzFz63gh+5oni4SUvHjRsJYDfk1aYIGHz4GazyW2nHA/m7ySu+D7aByw0NdfmuzU3priR/9BYnlWt7igiRdk0DhK6S3E4ckQToOV5nTEDtPUS+lNfaCAU0DZEM6cTeiSD4eKatQqsoY7ezlrSQMW3FeJ46FqrcKeKz7cLWP1YBJw6wMUSlXhDmn70CYKPWNQ5P5IMZcPv0h6V2WXz9EDgALOWh0i+nvwrois+Kcjysot3ea2MuQ3VZsnPf9pfTVr/L3kNFU6Mi4Qs46JXWQAI7btv7j9RRCjugYubsgWNllAs=----ATTACHMENT:----ODI4MDc1NTMxMDEyMDI2MSAyODgyMDcwMTg5MTU5MzcyIDUxNDcyODg2OTQzNjc3MDQ=