You are here

public function ProxyMagicMethodsTest::testInheritedMagicWakeup in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/ProxyMagicMethodsTest.php \Doctrine\Tests\Common\Proxy\ProxyMagicMethodsTest::testInheritedMagicWakeup()

File

vendor/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\Proxy

Code

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');
}