8000 Added tests for #8930 · thunderer/symfony@07ad25b · GitHub
[go: up one dir, main page]

Skip to content

Commit 07ad25b

Browse files
committed
Added tests for symfony#8930
1 parent cbce472 commit 07ad25b

File tree

1 file changed

+17
-27
lines changed

1 file changed

+17
-27
lines changed

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

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -45,32 +45,29 @@ public function testGetValueThrowsExceptionIfIndexNotationExpected()
4545
$this->propertyAccessor->getValue($array, 'firstName');
4646
}
4747

48-
public function testGetValueReadsZeroIndex()
49-
{
50-
$array = array('Bernhard');
51-
52-
$this->assertEquals('Bernhard', $this->propertyAccessor->getValue($array, '[0]'));
53-
}
54-
55-
public function testGetValueReadsIndexWithSpecialChars()
48+
/**
49+
* @dataProvider provideValueReads
50+
*/
51+
public function testGetValueReads($propertyPath, $expectedValue, $testedData)
5652
{
57-
$array = array('%!@$§.' => 'Bernhard');
58-
59-
$this->assertEquals('Bernhard', $this->propertyAccessor->getValue($array, '[%!@$§.]'));
53+
$this->assertEquals($expectedValue, $this->propertyAccessor->getValue($testedData, $propertyPath));
6054
}
6155

62-
public function testGetValueReadsNestedIndexWithSpecialChars()
56+
public function provideValueReads()
6357
{
64-
$array = array('root' => array('%!@$§.' => 'Bernhard'));
58+
return array(
59+
array('%!@$§', 'Bernhard', (object) array('%!@$§' => 'Bernhard')),
60+
array('[0]', 'Bernhard', array('Bernhard')),
61+
array('[%!@$§.]', 'Bernhard', array('%!@$§.' => 'Bernhard')),
6562

66-
$this->assertEquals('Bernhard', $this->propertyAccessor->getValue($array, '[root][%!@$§.]'));
67-
}
68-
69-
public function testGetValueReadsArrayWithCustomPropertyPath()
70-
{
71-
$array = array('child' => array('index' => array('firstName' => 'Bernhard')));
63+
array('[root][%!@$§.]', 'Bernhard', array('root' => array('%!@$§.' => 'Bernhard'))),
64+
array('[child][index][firstName]', 'Bernhard', array('child' => array('index' => array('firstName' => 'Bernhard')))),
7265

73-
$this->assertEquals('Bernhard', $this->propertyAccessor->getValue($array, '[child][index][firstName]'));
66+
// additional tests for #8930
67+
array('[@name]', 'Thunderer', array('@name' => 'Thunderer')),
68+
array('@name', 'Thunderer', (object) array('@name' => 'Thunderer')),
69+
array('_name', 'Thunderer', (object) array('_name' => 'Thunderer')),
70+
);
7471
}
7572

7673
public function testGetValueReadsArrayWithMissingIndexForCustomPropertyPath()
@@ -97,13 +94,6 @@ public function testGetValueIgnoresSingular()
9794
$this->assertEquals('Many', $this->propertyAccessor->getValue($object, 'children|child'));
9895
}
9996

100-
public function testGetValueReadsPropertyWithSpecialCharsExceptDot()
101-
{
102-
$array = (object) array('%!@$§' => 'Bernhard');
103-
104-
$this->assertEquals('Bernhard', $this->propertyAccessor->getValue($array, '%!@$§'));
105-
}
106-
10797
public function testGetValueReadsPropertyWithCustomPropertyPath()
10898
{
10999
$object = new Author();

0 commit comments

Comments
 (0)
0