From 667718d17f5f39b2890b77472ba1ba10d1b3084f Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Wed, 1 Oct 2014 21:56:03 +0200 Subject: [PATCH] Implementing tests to cover #115 and #175 in lazy loading value holder (failing) --- .../LazyLoadingValueHolderFunctionalTest.php | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/ProxyManagerTest/Functional/LazyLoadingValueHolderFunctionalTest.php b/tests/ProxyManagerTest/Functional/LazyLoadingValueHolderFunctionalTest.php index 66b585a37..0403d1019 100644 --- a/tests/ProxyManagerTest/Functional/LazyLoadingValueHolderFunctionalTest.php +++ b/tests/ProxyManagerTest/Functional/LazyLoadingValueHolderFunctionalTest.php @@ -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; @@ -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 *