8000 Added tests for #8930 by thunderer · Pull Request #9764 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Added tests for #8930 #9764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added tests for #8930
  • Loading branch information
thunderer committed Dec 14, 2013
commit 07ad25b97eabb53eae62f9b7bb68a9c13e2e59f7
44 changes: 17 additions & 27 deletions src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

array('[@name]', 'Thunderer', array('@name' => 'Thunderer')),
array('@name', 'Thunderer', (object) array('@name' => 'Thunderer')),
array('_name', 'Thunderer', (object) array('_name' => 'Thunderer')),
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix indentation

}

public function testGetValueReadsArrayWithMissingIndexForCustomPropertyPath()
Expand All @@ -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();
Expand Down
0