8000 [PropertyAccess] Test access to dynamic properties · symfony/symfony@916f9e0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 916f9e0

Browse files
committed
[PropertyAccess] Test access to dynamic properties
1 parent 352dfb9 commit 916f9e0

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,4 +375,32 @@ public function testTicket5755()
375375

376376
$this->assertEquals('foobar', $object->getProperty());
377377
}
378+
379+
/**
380+
* @dataProvider getValidPropertyPaths
381+
*/
382+
public function testSetValue($objectOrArray, $path)
383+
{
384+
$this->propertyAccessor->setValue($objectOrArray, $path, 'Updated');
385+
386+
$this->assertSame('Updated', $this->propertyAccessor->getValue($objectOrArray, $path));
387+
}
388+
389+
public function getValidPropertyPaths()
390+
{
391+
return array(
392+
array(array('Bernhard', 'Schussek'), '[0]', 'Bernhard'),
393+
array(array('Bernhard', 'Schussek'), '[1]', 'Schussek'),
394+
array(array('firstName' => 'Bernhard'), '[firstName]', 'Bernhard'),
395+
array(array('index' => array('firstName' => 'Bernhard')), '[index][firstName]', 'Bernhard'),
396+
array((object) array('firstName' => 'Bernhard'), 'firstName', 'Bernhard'),
397+
array((object) array('property' => array('firstName' => 'Bernhard')), 'property[firstName]', 'Bernhard'),
398+
array(array('index' => (object) array('firstName' => 'Bernhard')), '[index].firstName', 'Bernhard'),
399+
array((object) array('property' => (object) array('firstName' => 'Bernhard')), 'property.firstName', 'Bernhard'),
400+
401+
// Missing indices
402+
array(array('index' => array()), '[index][firstName]', null),
403+
array(array('root' => array('index' => array())), '[root][index][firstName]', null),
404+
);
405+
}
378406
}

0 commit comments

Comments
 (0)
0