8000 Added more tests for PropertyAccess by pierredup · Pull Request #16155 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Added more tests for PropertyAccess #16155

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

Merged
merged 1 commit into from
Oct 7, 2015
Merged
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Component\PropertyAccess\Tests;

use Symfony\Component\PropertyAccess\Exception\NoSuchIndexException;
use Symfony\Component\PropertyAccess\PropertyAccessor;
use Symfony\Component\PropertyAccess\Tests\Fixtures\TestClass;
use Symfony\Component\Proper 8000 tyAccess\Tests\Fixtures\TestClassMagicCall;
Expand Down Expand Up @@ -139,6 +140,20 @@ public function testGetValueNotModifyObject()
$this->assertSame(array('Bernhard'), $object->firstName);
}

public function testGetValueNotModifyObjectException()
{
$propertyAccessor = new PropertyAccessor(false, true);
$object = new \stdClass();
$object->firstName = array('Bernhard');

try {
$propertyAccessor->getValue($object, 'firstName[1]');
Copy link
Contributor

Choose a reason for hiding this comment

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

this is missing a fail() after wards. Otherwise the test also passed if the exception is not thrown which would be wrong.

} catch (NoSuchIndexException $e) {
}

$this->assertSame(array('Bernhard'), $object->firstName);
Copy link
Contributor

Choose a reason for hiding this comment

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

this makes no sense as its not executed currently

Copy link
Contributor

Choose a reason for hiding this comment

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

you need to catch the exception if you want to test what the tests says

}

/**
* @expectedException \Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException
*/
Expand Down
0