public function ProxyMagicMethodsTest::testInheritedMagicGet in Plug 7
File
- lib/
doctrine/ common/ tests/ Doctrine/ Tests/ Common/ Proxy/ ProxyMagicMethodsTest.php, line 68
Class
- ProxyMagicMethodsTest
- Test for behavior of proxies with inherited magic methods
Namespace
Doctrine\Tests\Common\ProxyCode
public function testInheritedMagicGet() {
$proxyClassName = $this
->generateProxyClass(__NAMESPACE__ . '\\MagicGetClass');
$proxy = new $proxyClassName(function (Proxy $proxy, $method, $params) use (&$counter) {
if (!in_array($params[0], array(
'publicField',
'test',
'notDefined',
))) {
throw new \InvalidArgumentException('Unexpected access to field "' . $params[0] . '"');
}
$initializer = $proxy
->__getInitializer();
$proxy
->__setInitializer(null);
$proxy->publicField = 'modifiedPublicField';
$counter += 1;
$proxy
->__setInitializer($initializer);
});
$this
->assertSame('id', $proxy->id);
$this
->assertSame('modifiedPublicField', $proxy->publicField);
$this
->assertSame('test', $proxy->test);
$this
->assertSame('not defined', $proxy->notDefined);
$this
->assertSame(3, $counter);
}