Skip to content

Commit

Permalink
Merge pull request #176 from Ocramius/hotfix/#16-proxy-multiple-initi…
Browse files Browse the repository at this point in the history
…alization-init

Adding test case to solidify logic as of discussion in #16 - proxies should be lazy-loadable multiple times
  • Loading branch information
Ocramius committed Sep 28, 2014
2 parents c5ded65 + c3c996d commit 0ac0eb3
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,29 @@ public function testWillModifyByRefRetrievedPublicProperties()
$this->assertSame('foo', $proxy->property0);
}

/**
* @group 16
*
* Verifies that initialization of a value holder proxy may happen multiple times
*/
public function testWillAllowMultipleProxyInitialization()
{
$proxyClass = $this->generateProxy('ProxyManagerTestAsset\\BaseClass');
$counter = 0;
$initializer = function (& $wrappedInstance) use (& $counter) {
$wrappedInstance = new BaseClass();

$wrappedInstance->publicProperty = (string) ($counter += 1);
};

/* @var $proxy BaseClass */
$proxy = new $proxyClass($initializer);

$this->assertSame('1', $proxy->publicProperty);
$this->assertSame('2', $proxy->publicProperty);
$this->assertSame('3', $proxy->publicProperty);
}

/**
* Generates a proxy for the given class name, and retrieves its class name
*
Expand Down

0 comments on commit 0ac0eb3

Please sign in to comment.