public function ProxyLogicTest::testNotInitializedProxyUnserialization in Plug 7
File
- lib/
doctrine/ common/ tests/ Doctrine/ Tests/ Common/ Proxy/ ProxyLogicTest.php, line 379
Class
- ProxyLogicTest
- Test the generated proxies behavior. These tests make assumptions about the structure of LazyLoadableObject
Namespace
Doctrine\Tests\Common\ProxyCode
public function testNotInitializedProxyUnserialization() {
$this
->configureInitializerMock();
$serialized = serialize($this->lazyObject);
/* @var $unserialized LazyLoadableObject|Proxy */
$unserialized = unserialize($serialized);
$reflClass = $this->lazyLoadableObjectMetadata
->getReflectionClass();
$this
->assertFalse($unserialized
->__isInitialized(), 'serialization didn\'t cause intialization');
// Checking identifiers
$this
->assertSame('publicIdentifierFieldValue', $unserialized->publicIdentifierField, 'identifiers are kept');
$protectedIdentifierField = $reflClass
->getProperty('protectedIdentifierField');
$protectedIdentifierField
->setAccessible(true);
$this
->assertSame('protectedIdentifierFieldValue', $protectedIdentifierField
->getValue($unserialized), 'identifiers are kept');
// Checking transient fields
$this
->assertSame('publicTransientFieldValue', $unserialized->publicTransientField, 'transient fields are kept');
$protectedTransientField = $reflClass
->getProperty('protectedTransientField');
$protectedTransientField
->setAccessible(true);
$this
->assertSame('protectedTransientFieldValue', $protectedTransientField
->getValue($unserialized), 'transient fields are kept');
// Checking persistent fields
$this
->assertSame('publicPersistentFieldValue', $unserialized->publicPersistentField, 'persistent fields are kept');
$protectedPersistentField = $reflClass
->getProperty('protectedPersistentField');
$protectedPersistentField
->setAccessible(true);
$this
->assertSame('protectedPersistentFieldValue', $protectedPersistentField
->getValue($unserialized), 'persistent fields are kept');
// Checking associations
$this
->assertSame('publicAssociationValue', $unserialized->publicAssociation, 'associations are kept');
$protectedAssociationField = $reflClass
->getProperty('protectedAssociation');
$protectedAssociationField
->setAccessible(true);
$this
->assertSame('protectedAssociationValue', $protectedAssociationField
->getValue($unserialized), 'associations are kept');
}