From 07ad25b97eabb53eae62f9b7bb68a9c13e2e59f7 Mon Sep 17 00:00:00 2001 From: Tomasz Kowalczyk Date: Sat, 14 Dec 2013 13:56:13 +0100 Subject: [PATCH 1/2] Added tests for #8930 --- .../Tests/PropertyAccessorTest.php | 44 +++++++------------ 1 file changed, 17 insertions(+), 27 deletions(-) diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php index e22ca097be56d..e30534b6e5636 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php @@ -45,32 +45,29 @@ public function testGetValueThrowsExceptionIfIndexNotationExpected() $this->propertyAccessor->getValue($array, 'firstName'); } - public function testGetValueReadsZeroIndex() - { - $array = array('Bernhard'); - - $this->assertEquals('Bernhard', $this->propertyAccessor->getValue($array, '[0]')); - } - - public function testGetValueReadsIndexWithSpecialChars() + /** + * @dataProvider provideValueReads + */ + public function testGetValueReads($propertyPath, $expectedValue, $testedData) { - $array = array('%!@$§.' => 'Bernhard'); - - $this->assertEquals('Bernhard', $this->propertyAccessor->getValue($array, '[%!@$§.]')); + $this->assertEquals($expectedValue, $this->propertyAccessor->getValue($testedData, $propertyPath)); } - public function testGetValueReadsNestedIndexWithSpecialChars() + public function provideValueReads() { - $array = array('root' => array('%!@$§.' => 'Bernhard')); + return array( + array('%!@$§', 'Bernhard', (object) array('%!@$§' => 'Bernhard')), + array('[0]', 'Bernhard', array('Bernhard')), + array('[%!@$§.]', 'Bernhard', array('%!@$§.' => 'Bernhard')), - $this->assertEquals('Bernhard', $this->propertyAccessor->getValue($array, '[root][%!@$§.]')); - } - - public function testGetValueReadsArrayWithCustomPropertyPath() - { - $array = array('child' => array('index' => array('firstName' => 'Bernhard'))); + array('[root][%!@$§.]', 'Bernhard', array('root' => array('%!@$§.' => 'Bernhard'))), + array('[child][index][firstName]', 'Bernhard', array('child' => array('index' => array('firstName' => 'Bernhard')))), - $this->assertEquals('Bernhard', $this->propertyAccessor->getValue($array, '[child][index][firstName]')); + // additional tests for #8930 + array('[@name]', 'Thunderer', array('@name' => 'Thunderer')), + array('@name', 'Thunderer', (object) array('@name' => 'Thunderer')), + array('_name', 'Thunderer', (object) array('_name' => 'Thunderer')), + ); } public function testGetValueReadsArrayWithMissingIndexForCustomPropertyPath() @@ -97,13 +94,6 @@ public function testGetValueIgnoresSingular() $this->assertEquals('Many', $this->propertyAccessor->getValue($object, 'children|child')); } - public function testGetValueReadsPropertyWithSpecialCharsExceptDot() - { - $array = (object) array('%!@$§' => 'Bernhard'); - - $this->assertEquals('Bernhard', $this->propertyAccessor->getValue($array, '%!@$§')); - } - public function testGetValueReadsPropertyWithCustomPropertyPath() { $object = new Author(); From 246756432a1e8ee00cf95cfbc2462d22d16c19c9 Mon Sep 17 00:00:00 2001 From: Tomasz Kowalczyk Date: Sat, 14 Dec 2013 14:54:14 +0100 Subject: [PATCH 2/2] CS fixes --- .../Component/PropertyAccess/Tests/PropertyAccessorTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php index e30534b6e5636..42918aadc469b 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php @@ -63,11 +63,10 @@ public function provideValueReads() array('[root][%!@$§.]', 'Bernhard', array('root' => array('%!@$§.' => 'Bernhard'))), array('[child][index][firstName]', 'Bernhard', array('child' => array('index' => array('firstName' => 'Bernhard')))), - // additional tests for #8930 array('[@name]', 'Thunderer', array('@name' => 'Thunderer')), array('@name', 'Thunderer', (object) array('@name' => 'Thunderer')), array('_name', 'Thunderer', (object) array('_name' => 'Thunderer')), - ); + ); } public function testGetValueReadsArrayWithMissingIndexForCustomPropertyPath() pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy