1
0
mirror of synced 2024-12-13 14:56:01 +03:00

[DDC-2451] Fix entity listeners serialization

This commit is contained in:
Fabio B. Silva 2013-05-17 11:42:11 -03:00
parent eb1a162cbc
commit 4d6cef1ff6
2 changed files with 21 additions and 0 deletions

View File

@ -831,6 +831,10 @@ class ClassMetadataInfo implements ClassMetadata
$serialized[] = 'lifecycleCallbacks';
}
if ($this->entityListeners) {
$serialized[] = 'entityListeners';
}
if ($this->namedQueries) {
$serialized[] = 'namedQueries';
}

View File

@ -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