Permalink
Browse files

Merge pull request #670 from FabioBatSilva/DDC-2451

[DDC-2451] Fix entity listeners serialization
  • Loading branch information...
2 parents eb1a162 + 1d7c72c commit 65886fdfeaf38692be5196a59530f56fc3e6ab56 @beberlei beberlei committed May 17, 2013
@@ -831,6 +831,10 @@ public function __sleep()
$serialized[] = 'lifecycleCallbacks';
}
+ if ($this->entityListeners) {
+ $serialized[] = 'entityListeners';
+ }
+
if ($this->namedQueries) {
$serialized[] = 'namedQueries';
}
@@ -715,6 +715,23 @@ public function testRetrievalOfNamedNativeQueries()
}
/**
+ * @group DDC-2451
+ */
+ public function testSerializeEntityListeners()
+ {
+ $metadata = new ClassMetadata('Doctrine\Tests\Models\Company\CompanyContract');
+
+ $metadata->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
+ $metadata->addEntityListener(\Doctrine\ORM\Events::prePersist, 'CompanyContractListener', 'prePersistHandler');
+ $metadata->addEntityListener(\Doctrine\ORM\Events::postPersist, 'CompanyContractListener', 'postPersistHandler');
+
+ $serialize = serialize($metadata);
+ $unserialize = unserialize($serialize);
+
+ $this->assertEquals($metadata->entityListeners, $unserialize->entityListeners);
+ }
+
+ /**
* @expectedException \Doctrine\ORM\Mapping\MappingException
* @expectedExceptionMessage Query named "userById" in "Doctrine\Tests\Models\CMS\CmsUser" was already declared, but it must be declared only once
*/

0 comments on commit 65886fd

Please sign in to comment.