|
@@ -3,9 +3,11 @@
|
|
|
namespace Symfony\Tests\Component\Form;
|
|
|
|
|
|
require_once __DIR__ . '/Fixtures/Author.php';
|
|
|
+require_once __DIR__ . '/Fixtures/Magician.php';
|
|
|
|
|
|
use Symfony\Component\Form\PropertyPath;
|
|
|
use Symfony\Tests\Component\Form\Fixtures\Author;
|
|
|
+use Symfony\Tests\Component\Form\Fixtures\Magician;
|
|
|
|
|
|
class PropertyPathTest extends \PHPUnit_Framework_TestCase
|
|
|
{
|
|
@@ -135,6 +137,16 @@ class PropertyPathTest extends \PHPUnit_Framework_TestCase
|
|
|
$this->assertSame(false, $path->getValue($object));
|
|
|
}
|
|
|
|
|
|
+ public function testGetValueReadsMagicGet()
|
|
|
+ {
|
|
|
+ $path = new PropertyPath('magicProperty');
|
|
|
+
|
|
|
+ $object = new Magician();
|
|
|
+ $object->__set('magicProperty', 'foobar');
|
|
|
+
|
|
|
+ $this->assertSame('foobar', $path->getValue($object));
|
|
|
+ }
|
|
|
+
|
|
|
public function testGetValueThrowsExceptionIfIsserIsNotPublic()
|
|
|
{
|
|
|
$path = new PropertyPath('privateIsser');
|
|
@@ -205,6 +217,16 @@ class PropertyPathTest extends \PHPUnit_Framework_TestCase
|
|
|
$this->assertEquals('Bernhard', $object['firstName']);
|
|
|
}
|
|
|
|
|
|
+ public function testSetValueUpdateMagicSet()
|
|
|
+ {
|
|
|
+ $object = new Magician();
|
|
|
+
|
|
|
+ $path = new PropertyPath('magicProperty');
|
|
|
+ $path->setValue($object, 'foobar');
|
|
|
+
|
|
|
+ $this->assertEquals('foobar', $object->__get('magicProperty'));
|
|
|
+ }
|
|
|
+
|
|
|
public function testSetValueThrowsExceptionIfArrayAccessExpected()
|
|
|
{
|
|
|
$path = new PropertyPath('[firstName]');
|