[DDC-2451] Fix entity listeners serialization
This commit is contained in:
parent
eb1a162cbc
commit
4d6cef1ff6
2 changed files with 21 additions and 0 deletions
|
@ -831,6 +831,10 @@ class ClassMetadataInfo implements ClassMetadata
|
||||||
$serialized[] = 'lifecycleCallbacks';
|
$serialized[] = 'lifecycleCallbacks';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->entityListeners) {
|
||||||
|
$serialized[] = 'entityListeners';
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->namedQueries) {
|
if ($this->namedQueries) {
|
||||||
$serialized[] = 'namedQueries';
|
$serialized[] = 'namedQueries';
|
||||||
}
|
}
|
||||||
|
|
|
@ -714,6 +714,23 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
||||||
$this->assertEquals(1, count($cm->getNamedNativeQueries()));
|
$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
|
* @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
|
* @expectedExceptionMessage Query named "userById" in "Doctrine\Tests\Models\CMS\CmsUser" was already declared, but it must be declared only once
|
||||||
|
|
Loading…
Add table
Reference in a new issue