@@ -45,32 +45,29 @@ public function testGetValueThrowsExceptionIfIndexNotationExpected()
45
45
$ this ->propertyAccessor ->getValue ($ array , 'firstName ' );
46
46
}
47
47
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 )
56
52
{
57
- $ array = array ('%!@$§. ' => 'Bernhard ' );
58
-
59
- $ this ->assertEquals ('Bernhard ' , $ this ->propertyAccessor ->getValue ($ array , '[%!@$§.] ' ));
53
+ $ this ->assertEquals ($ expectedValue , $ this ->propertyAccessor ->getValue ($ testedData , $ propertyPath ));
60
54
}
61
55
62
- public function testGetValueReadsNestedIndexWithSpecialChars ()
56
+ public function provideValueReads ()
63
57
{
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 ' )),
65
62
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 ' )))),
72
65
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
+ );
74
71
}
75
72
76
73
public function testGetValueReadsArrayWithMissingIndexForCustomPropertyPath ()
@@ -97,13 +94,6 @@ public function testGetValueIgnoresSingular()
97
94
$ this ->assertEquals ('Many ' , $ this ->propertyAccessor ->getValue ($ object , 'children|child ' ));
98
95
}
99
96
100
- public function testGetValueReadsPropertyWithSpecialCharsExceptDot ()
101
- {
102
- $ array = (object ) array ('%!@$§ ' => 'Bernhard ' );
103
-
104
- $ this ->assertEquals ('Bernhard ' , $ this ->propertyAccessor ->getValue ($ array , '%!@$§ ' ));
105
- }
106
-
107
97
public function testGetValueReadsPropertyWithCustomPropertyPath ()
108
98
{
109
99
$ object = new Author ();
0 commit comments