Skip to content

Commit

Permalink
Implementing tests to cover #115 and #175 in lazy loading value holde…
Browse files Browse the repository at this point in the history
…r (failing)
  • Loading branch information
Ocramius committed Oct 1, 2014
1 parent 3ad6a64 commit 667718d
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use ProxyManager\Proxy\VirtualProxyInterface;
use ProxyManager\ProxyGenerator\LazyLoadingValueHolderGenerator;
use ProxyManagerTestAsset\BaseClass;
use ProxyManagerTestAsset\ClassWithCounterConstructor;
use ProxyManagerTestAsset\ClassWithPublicArrayProperty;
use ProxyManagerTestAsset\ClassWithPublicProperties;
use ReflectionClass;
Expand Down Expand Up @@ -237,6 +238,32 @@ public function testWillAllowMultipleProxyInitialization()
$this->assertSame('3', $proxy->publicProperty);
}

/**
* @group 115
* @group 175
*/
public function testWillBehaveLikeObjectWithNormalConstructor()
{
$instance = new ClassWithCounterConstructor(10);

$this->assertSame(10, $instance->amount, 'Verifying that test asset works as expected');
$this->assertSame(10, $instance->getAmount(), 'Verifying that test asset works as expected');
$instance->__construct(3);
$this->assertSame(13, $instance->amount, 'Verifying that test asset works as expected');
$this->assertSame(13, $instance->getAmount(), 'Verifying that test asset works as expected');

$proxyName = $this->generateProxy(get_class($instance));

/* @var $proxy ClassWithCounterConstructor */
$proxy = new $proxyName(15);

$this->assertSame(15, $proxy->amount, 'Verifying that the proxy constructor works as expected');
$this->assertSame(15, $proxy->getAmount(), 'Verifying that the proxy constructor works as expected');
$proxy->__construct(5);
$this->assertSame(20, $proxy->amount, 'Verifying that the proxy constructor works as expected');
$this->assertSame(20, $proxy->getAmount(), 'Verifying that the proxy constructor works as expected');
}

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

0 comments on commit 667718d

Please sign in to comment.