public function testSerializeUnserialize()
{
$cm = new ClassMetadata("Doctrine\\Tests\\ODM\\CouchDB\\Mapping\\Person");
$cm->initializeReflection(new RuntimeReflectionService());
$cm->indexed = true;
$this->assertEquals("Doctrine\\Tests\\ODM\\CouchDB\\Mapping\\Person", $cm->name);
// property based comparison
$unserialized = unserialize(serialize($cm));
$unserialized->wakeupReflection(new RuntimeReflectionService());
$this->assertEquals($cm, $unserialized);
$cm->mapField(array('fieldName' => 'id', 'id' => true));
$cm->mapField(array('fieldName' => 'username', 'type' => 'string', 'indexed' => true));
$cm->mapField(array('fieldName' => 'created', 'type' => 'datetime'));
$cm->mapField(array('fieldName' => 'version', 'jsonName' => '_rev', 'isVersionField' => true));
$cm->mapManyToOne(array('fieldName' => 'address', 'targetDocument' => 'Doctrine\\Tests\\ODM\\CouchDB\\Mapping\\Address'));
$cm->mapAttachments("attachments");
// @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);
}