public function ProxyMagicMethodsTest::testInheritedMagicWakeup in Plug 7
File
- lib/
doctrine/ common/ tests/ Doctrine/ Tests/ Common/ Proxy/ ProxyMagicMethodsTest.php, line 165
Class
- ProxyMagicMethodsTest
- Test for behavior of proxies with inherited magic methods
Namespace
Doctrine\Tests\Common\ProxyCode
public function testInheritedMagicWakeup() {
$proxyClassName = $this
->generateProxyClass(__NAMESPACE__ . '\\MagicWakeupClass');
$proxy = new $proxyClassName();
$this
->assertSame('defaultValue', $proxy->wakeupValue);
$proxy->wakeupValue = 'changedValue';
$unserialized = unserialize(serialize($proxy));
$this
->assertSame('newWakeupValue', $unserialized->wakeupValue, '"__wakeup" was called');
$unserialized
->__setInitializer(function (Proxy $proxy) {
$proxy
->__setInitializer(null);
$proxy->publicField = 'newPublicFieldValue';
});
$this
->assertSame('newPublicFieldValue', $unserialized->publicField, 'Proxy can still be initialized');
}