Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
Added more tests for PropertyAccess
  • Loading branch information
pierredup committed Oct 6, 2015
commit 378db759e0bf2fcbcfe93b139641ae17da444799
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\PropertyAccess\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