8000 Added test cases for issue #8930 · thunderer/symfony@f93fe99 · GitHub
[go: up one dir, main page]

Skip to content

Commit f93fe99

Browse files
committed
Added test cases for issue symfony#8930
1 parent 6764f91 commit f93fe99

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed

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

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -70,32 +70,29 @@ public function testGetValueThrowsExceptionIfIndexNotationExpected()
7070
$this->getPropertyAccessor()->getValue($array, 'firstName');
7171
}
7272

73-
public function testGetValueReadsZeroIndex()
74-
{
75-
$array = array('Bernhard');
76-
77-
$this->assertEquals('Bernhard', $this->getPropertyAccessor()->getValue($array, '[0]'));
78-
}
79-
80-
public function testGetValueReadsIndexWithSpecialChars()
73+
/**
74+
* @dataProvider provideValueReads
75+
*/
76+
public function testGetValueReads($propertyPath, $expectedValue, $testedData)
8177
{
82-
$array = array('%!@$§.' => 'Bernhard');
83-
84-
$this->assertEquals('Bernhard', $this->getPropertyAccessor()->getValue($array, '[%!@$§.]'));
78+
$this->assertEquals($expectedValue, $this->getPropertyAccessor()->getValue($testedData, $propertyPath));
8579
}
8680

87-
public function testGetValueReadsNestedIndexWithSpecialChars()
81+
public function provideValueReads()
8882
{
89-
$array = array('root' => array('%!@$§.' => 'Bernhard'));
83+
return array(
84+
array('%!@$§', 'Bernhard', (object) array('%!@$§' => 'Bernhard')),
85+
array('[0]', 'Bernhard', array('Bernhard')),
86+
array('[%!@$§.]', 'Bernhard', array('%!@$§.' => 'Bernhard')),
9087

91-
$this->assertEquals('Bernhard', $this->getPropertyAccessor()->getValue($array, '[root][%!@$§.]'));
92-
}
93-
94-
public function testGetValueReadsArrayWithCustomPropertyPath()
95-
{
96-
$array = array('child' => array('index' => array('firstName' => 'Bernhard')));
88+
array('[root][%!@$§.]', 'Bernhard', array('root' => array('%!@$§.' => 'Bernhard'))),
89+
array('[child][index][firstName]', 'Bernhard', array('child' => array('index' => array('firstName' => 'Bernhard')))),
9790

98-
$this->assertEquals('Bernhard', $this->getPropertyAccessor()->getValue($array, '[child][index][firstName]'));
91+
// additional tests for #8930
92+
array('[@name]', 'Thunderer', array('@name' => 'Thunderer')),
93+
array('@name', 'Thunderer', (object) array('@name' => 'Thunderer')),
94+
array('_name', 'Thunderer', (object) array('_name' => 'Thunderer')),
95+
);
9996
}
10097

10198
public function testGetValueReadsArrayWithMissingIndexForCustomPropertyPath()

0 commit comments

Comments
 (0)
0