Restores some state that can not be serialized/unserialized.
public wakeupReflection ( $reflService ) |
public function getClassMetadata($class) { $metadata = new \Doctrine\ODM\CouchDB\Mapping\ClassMetadata($class); $metadata->initializeReflection(new RuntimeReflectionService()); $metadata->wakeupReflection(new RuntimeReflectionService()); return $metadata; }
public function setUp() { $this->type = 'Doctrine\\Tests\\ODM\\CouchDB\\UoWUser'; $this->dm = \Doctrine\ODM\CouchDB\DocumentManager::create(array('dbname' => 'test')); $this->uow = new UnitOfWork($this->dm); $metadata = new \Doctrine\ODM\CouchDB\Mapping\ClassMetadata($this->type); $metadata->mapField(array('fieldName' => 'id', 'id' => true)); $metadata->mapField(array('fieldName' => 'username', 'type' => 'string')); $metadata->idGenerator = \Doctrine\ODM\CouchDB\Mapping\ClassMetadata::IDGENERATOR_ASSIGNED; $metadata->initializeReflection(new RuntimeReflectionService()); $metadata->wakeupReflection(new RuntimeReflectionService()); $cmf = $this->dm->getClassMetadataFactory(); $cmf->setMetadataFor($this->type, $metadata); }
/** * @depends testClassName */ public function testSerializeUnserializeSerializableObject() { $cm = new ClassMetadata("Doctrine\\Tests\\ODM\\CouchDB\\Mapping\\SerializableObject"); $cm->initializeReflection(new RuntimeReflectionService()); $cm->mapField(array('fieldName' => 'property', 'type' => 'integer')); // @TODO This is the only way the $reflFields property is initialized // as far as I understand the ClassMetadata code. This seems wrong to // call here, but otherwise the comparison fails. The $reflFields are // accesssed all over the code though – I guess there are some bugs // hidden here. $cm->wakeupReflection(new RuntimeReflectionService()); // property based comparison $unserialized = unserialize(serialize($cm)); $unserialized->wakeupReflection(new RuntimeReflectionService()); $this->assertEquals($cm, $unserialized); }