[DDC-2451] Fix entity listeners serialization
This commit is contained in:
parent
eb1a162cbc
commit
4d6cef1ff6
@ -831,6 +831,10 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
$serialized[] = 'lifecycleCallbacks';
|
||||
}
|
||||
|
||||
if ($this->entityListeners) {
|
||||
$serialized[] = 'entityListeners';
|
||||
}
|
||||
|
||||
if ($this->namedQueries) {
|
||||
$serialized[] = 'namedQueries';
|
||||
}
|
||||
|
@ -714,6 +714,23 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
||||
$this->assertEquals(1, count($cm->getNamedNativeQueries()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @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($unserialize->entityListeners, $metadata->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
|
||||
|
Loading…
Reference in New Issue
Block a user