public function testInitializationRestoresDefaultPublicLazyLoadedFieldValues() { // setting noop persister $this->proxyLoader->expects($this->once())->method('load')->will($this->returnValue($this->lazyObject)); $this->lazyObject->__setInitializer($this->getSuggestedInitializerImplementation()); $this->assertSame('publicPersistentFieldValue', $this->lazyObject->publicPersistentField, 'Persistent field is restored to default value'); $this->assertSame('publicAssociationValue', $this->lazyObject->publicAssociation, 'Association is restored to default value'); }
/** * Sets a value in the current proxy object without triggering lazy loading through `__set` * * @link https://bugs.php.net/bug.php?id=63463 * * @param string $property * @param mixed $value */ public function setProxyValue($property, $value) { $reflectionProperty = new \ReflectionProperty($this->lazyObject, $property); $initializer = $this->lazyObject->__getInitializer(); // disabling initializer since setting `publicPersistentField` triggers `__set`/`__get` $this->lazyObject->__setInitializer(null); $reflectionProperty->setValue($this->lazyObject, $value); $this->lazyObject->__setInitializer($initializer); }