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

rename subscribers to listeners

This commit is contained in:
Fabio B. Silva 2012-08-11 23:48:09 -03:00 committed by fabio.silva
parent 46474bf457
commit a265511368
13 changed files with 122 additions and 122 deletions

View File

@ -7,7 +7,7 @@ namespace Doctrine\Tests\Models\Company;
* @Table(name="company_contracts") * @Table(name="company_contracts")
* @InheritanceType("SINGLE_TABLE") * @InheritanceType("SINGLE_TABLE")
* @DiscriminatorColumn(name="discr", type="string") * @DiscriminatorColumn(name="discr", type="string")
* @EntityListeners({"ContractSubscriber"}) * @EntityListeners({"CompanyContractListener"})
* @DiscriminatorMap({ * @DiscriminatorMap({
* "fix" = "CompanyFixContract", * "fix" = "CompanyFixContract",
* "flexible" = "CompanyFlexContract", * "flexible" = "CompanyFlexContract",
@ -157,16 +157,16 @@ abstract class CompanyContract
"flexultra" => "CompanyFlexUltraContract" "flexultra" => "CompanyFlexUltraContract"
)); ));
$metadata->addEntityListener(\Doctrine\ORM\Events::postPersist, 'ContractSubscriber', 'postPersistHandler'); $metadata->addEntityListener(\Doctrine\ORM\Events::postPersist, 'CompanyContractListener', 'postPersistHandler');
$metadata->addEntityListener(\Doctrine\ORM\Events::prePersist, 'ContractSubscriber', 'prePersistHandler'); $metadata->addEntityListener(\Doctrine\ORM\Events::prePersist, 'CompanyContractListener', 'prePersistHandler');
$metadata->addEntityListener(\Doctrine\ORM\Events::postUpdate, 'ContractSubscriber', 'postUpdateHandler'); $metadata->addEntityListener(\Doctrine\ORM\Events::postUpdate, 'CompanyContractListener', 'postUpdateHandler');
$metadata->addEntityListener(\Doctrine\ORM\Events::preUpdate, 'ContractSubscriber', 'preUpdateHandler'); $metadata->addEntityListener(\Doctrine\ORM\Events::preUpdate, 'CompanyContractListener', 'preUpdateHandler');
$metadata->addEntityListener(\Doctrine\ORM\Events::postRemove, 'ContractSubscriber', 'postRemoveHandler'); $metadata->addEntityListener(\Doctrine\ORM\Events::postRemove, 'CompanyContractListener', 'postRemoveHandler');
$metadata->addEntityListener(\Doctrine\ORM\Events::preRemove, 'ContractSubscriber', 'preRemoveHandler'); $metadata->addEntityListener(\Doctrine\ORM\Events::preRemove, 'CompanyContractListener', 'preRemoveHandler');
$metadata->addEntityListener(\Doctrine\ORM\Events::preFlush, 'ContractSubscriber', 'preFlushHandler'); $metadata->addEntityListener(\Doctrine\ORM\Events::preFlush, 'CompanyContractListener', 'preFlushHandler');
$metadata->addEntityListener(\Doctrine\ORM\Events::postLoad, 'ContractSubscriber', 'postLoadHandler'); $metadata->addEntityListener(\Doctrine\ORM\Events::postLoad, 'CompanyContractListener', 'postLoadHandler');
} }
} }

View File

@ -2,7 +2,7 @@
namespace Doctrine\Tests\Models\Company; namespace Doctrine\Tests\Models\Company;
class ContractSubscriber class CompanyContractListener
{ {
static public $postPersistCalls; static public $postPersistCalls;
static public $prePersistCalls; static public $prePersistCalls;

View File

@ -4,7 +4,7 @@ namespace Doctrine\Tests\Models\Company;
/** /**
* @Entity * @Entity
* @EntityListeners({"ContractSubscriber","FlexUltraContractSubscriber"}) * @EntityListeners({"CompanyContractListener","CompanyFlexUltraContractListener"})
*/ */
class CompanyFlexUltraContract extends CompanyFlexContract class CompanyFlexUltraContract extends CompanyFlexContract
{ {
@ -36,19 +36,19 @@ class CompanyFlexUltraContract extends CompanyFlexContract
'name' => 'maxPrice', 'name' => 'maxPrice',
'fieldName' => 'maxPrice', 'fieldName' => 'maxPrice',
)); ));
$metadata->addEntityListener(\Doctrine\ORM\Events::postPersist, 'ContractSubscriber', 'postPersistHandler'); $metadata->addEntityListener(\Doctrine\ORM\Events::postPersist, 'CompanyContractListener', 'postPersistHandler');
$metadata->addEntityListener(\Doctrine\ORM\Events::prePersist, 'ContractSubscriber', 'prePersistHandler'); $metadata->addEntityListener(\Doctrine\ORM\Events::prePersist, 'CompanyContractListener', 'prePersistHandler');
$metadata->addEntityListener(\Doctrine\ORM\Events::postUpdate, 'ContractSubscriber', 'postUpdateHandler'); $metadata->addEntityListener(\Doctrine\ORM\Events::postUpdate, 'CompanyContractListener', 'postUpdateHandler');
$metadata->addEntityListener(\Doctrine\ORM\Events::preUpdate, 'ContractSubscriber', 'preUpdateHandler'); $metadata->addEntityListener(\Doctrine\ORM\Events::preUpdate, 'CompanyContractListener', 'preUpdateHandler');
$metadata->addEntityListener(\Doctrine\ORM\Events::postRemove, 'ContractSubscriber', 'postRemoveHandler'); $metadata->addEntityListener(\Doctrine\ORM\Events::postRemove, 'CompanyContractListener', 'postRemoveHandler');
$metadata->addEntityListener(\Doctrine\ORM\Events::preRemove, 'ContractSubscriber', 'preRemoveHandler'); $metadata->addEntityListener(\Doctrine\ORM\Events::preRemove, 'CompanyContractListener', 'preRemoveHandler');
$metadata->addEntityListener(\Doctrine\ORM\Events::preFlush, 'ContractSubscriber', 'preFlushHandler'); $metadata->addEntityListener(\Doctrine\ORM\Events::preFlush, 'CompanyContractListener', 'preFlushHandler');
$metadata->addEntityListener(\Doctrine\ORM\Events::postLoad, 'ContractSubscriber', 'postLoadHandler'); $metadata->addEntityListener(\Doctrine\ORM\Events::postLoad, 'CompanyContractListener', 'postLoadHandler');
$metadata->addEntityListener(\Doctrine\ORM\Events::prePersist, 'FlexUltraContractSubscriber', 'prePersistHandler1'); $metadata->addEntityListener(\Doctrine\ORM\Events::prePersist, 'CompanyFlexUltraContractListener', 'prePersistHandler1');
$metadata->addEntityListener(\Doctrine\ORM\Events::prePersist, 'FlexUltraContractSubscriber', 'prePersistHandler2'); $metadata->addEntityListener(\Doctrine\ORM\Events::prePersist, 'CompanyFlexUltraContractListener', 'prePersistHandler2');
} }
} }

View File

@ -4,7 +4,7 @@ namespace Doctrine\Tests\Models\Company;
use Doctrine\ORM\Event\LifecycleEventArgs; use Doctrine\ORM\Event\LifecycleEventArgs;
class FlexUltraContractSubscriber class CompanyFlexUltraContractListener
{ {
static public $prePersistCalls; static public $prePersistCalls;
static public $instances; static public $instances;

View File

@ -3,7 +3,7 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\Tests\Models\Company\CompanyFixContract; use Doctrine\Tests\Models\Company\CompanyFixContract;
use Doctrine\Tests\Models\Company\ContractSubscriber; use Doctrine\Tests\Models\Company\CompanyContractListener;
require_once __DIR__ . '/../../TestInit.php'; require_once __DIR__ . '/../../TestInit.php';
@ -24,24 +24,24 @@ class EntityListenersTest extends \Doctrine\Tests\OrmFunctionalTestCase
$fix = new CompanyFixContract(); $fix = new CompanyFixContract();
$fix->setFixPrice(2000); $fix->setFixPrice(2000);
ContractSubscriber::$preFlushCalls = array(); CompanyContractListener::$preFlushCalls = array();
$this->_em->persist($fix); $this->_em->persist($fix);
$this->_em->flush(); $this->_em->flush();
$this->assertCount(1,ContractSubscriber::$instances); $this->assertCount(1,CompanyContractListener::$instances);
$this->assertCount(1,ContractSubscriber::$preFlushCalls); $this->assertCount(1,CompanyContractListener::$preFlushCalls);
$this->assertSame($fix, ContractSubscriber::$preFlushCalls[0][0]); $this->assertSame($fix, CompanyContractListener::$preFlushCalls[0][0]);
$this->assertInstanceOf( $this->assertInstanceOf(
'Doctrine\Tests\Models\Company\CompanyFixContract', 'Doctrine\Tests\Models\Company\CompanyFixContract',
ContractSubscriber::$preFlushCalls[0][0] CompanyContractListener::$preFlushCalls[0][0]
); );
$this->assertInstanceOf( $this->assertInstanceOf(
'Doctrine\ORM\Event\PreFlushEventArgs', 'Doctrine\ORM\Event\PreFlushEventArgs',
ContractSubscriber::$preFlushCalls[0][1] CompanyContractListener::$preFlushCalls[0][1]
); );
} }
@ -54,24 +54,24 @@ class EntityListenersTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
ContractSubscriber::$postLoadCalls = array(); CompanyContractListener::$postLoadCalls = array();
$dql = "SELECT f FROM Doctrine\Tests\Models\Company\CompanyFixContract f WHERE f.id = ?1"; $dql = "SELECT f FROM Doctrine\Tests\Models\Company\CompanyFixContract f WHERE f.id = ?1";
$fix = $this->_em->createQuery($dql)->setParameter(1, $fix->getId())->getSingleResult(); $fix = $this->_em->createQuery($dql)->setParameter(1, $fix->getId())->getSingleResult();
$this->assertCount(1,ContractSubscriber::$instances); $this->assertCount(1,CompanyContractListener::$instances);
$this->assertCount(1,ContractSubscriber::$postLoadCalls); $this->assertCount(1,CompanyContractListener::$postLoadCalls);
$this->assertSame($fix, ContractSubscriber::$postLoadCalls[0][0]); $this->assertSame($fix, CompanyContractListener::$postLoadCalls[0][0]);
$this->assertInstanceOf( $this->assertInstanceOf(
'Doctrine\Tests\Models\Company\CompanyFixContract', 'Doctrine\Tests\Models\Company\CompanyFixContract',
ContractSubscriber::$postLoadCalls[0][0] CompanyContractListener::$postLoadCalls[0][0]
); );
$this->assertInstanceOf( $this->assertInstanceOf(
'Doctrine\ORM\Event\LifecycleEventArgs', 'Doctrine\ORM\Event\LifecycleEventArgs',
ContractSubscriber::$postLoadCalls[0][1] CompanyContractListener::$postLoadCalls[0][1]
); );
} }
@ -80,24 +80,24 @@ class EntityListenersTest extends \Doctrine\Tests\OrmFunctionalTestCase
$fix = new CompanyFixContract(); $fix = new CompanyFixContract();
$fix->setFixPrice(2000); $fix->setFixPrice(2000);
ContractSubscriber::$prePersistCalls = array(); CompanyContractListener::$prePersistCalls = array();
$this->_em->persist($fix); $this->_em->persist($fix);
$this->_em->flush(); $this->_em->flush();
$this->assertCount(1,ContractSubscriber::$instances); $this->assertCount(1,CompanyContractListener::$instances);
$this->assertCount(1,ContractSubscriber::$prePersistCalls); $this->assertCount(1,CompanyContractListener::$prePersistCalls);
$this->assertSame($fix, ContractSubscriber::$prePersistCalls[0][0]); $this->assertSame($fix, CompanyContractListener::$prePersistCalls[0][0]);
$this->assertInstanceOf( $this->assertInstanceOf(
'Doctrine\Tests\Models\Company\CompanyFixContract', 'Doctrine\Tests\Models\Company\CompanyFixContract',
ContractSubscriber::$prePersistCalls[0][0] CompanyContractListener::$prePersistCalls[0][0]
); );
$this->assertInstanceOf( $this->assertInstanceOf(
'Doctrine\ORM\Event\LifecycleEventArgs', 'Doctrine\ORM\Event\LifecycleEventArgs',
ContractSubscriber::$prePersistCalls[0][1] CompanyContractListener::$prePersistCalls[0][1]
); );
} }
@ -106,24 +106,24 @@ class EntityListenersTest extends \Doctrine\Tests\OrmFunctionalTestCase
$fix = new CompanyFixContract(); $fix = new CompanyFixContract();
$fix->setFixPrice(2000); $fix->setFixPrice(2000);
ContractSubscriber::$postPersistCalls = array(); CompanyContractListener::$postPersistCalls = array();
$this->_em->persist($fix); $this->_em->persist($fix);
$this->_em->flush(); $this->_em->flush();
$this->assertCount(1,ContractSubscriber::$instances); $this->assertCount(1,CompanyContractListener::$instances);
$this->assertCount(1,ContractSubscriber::$postPersistCalls); $this->assertCount(1,CompanyContractListener::$postPersistCalls);
$this->assertSame($fix, ContractSubscriber::$postPersistCalls[0][0]); $this->assertSame($fix, CompanyContractListener::$postPersistCalls[0][0]);
$this->assertInstanceOf( $this->assertInstanceOf(
'Doctrine\Tests\Models\Company\CompanyFixContract', 'Doctrine\Tests\Models\Company\CompanyFixContract',
ContractSubscriber::$postPersistCalls[0][0] CompanyContractListener::$postPersistCalls[0][0]
); );
$this->assertInstanceOf( $this->assertInstanceOf(
'Doctrine\ORM\Event\LifecycleEventArgs', 'Doctrine\ORM\Event\LifecycleEventArgs',
ContractSubscriber::$postPersistCalls[0][1] CompanyContractListener::$postPersistCalls[0][1]
); );
} }
@ -135,26 +135,26 @@ class EntityListenersTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->persist($fix); $this->_em->persist($fix);
$this->_em->flush(); $this->_em->flush();
ContractSubscriber::$preUpdateCalls = array(); CompanyContractListener::$preUpdateCalls = array();
$fix->setFixPrice(2000); $fix->setFixPrice(2000);
$this->_em->persist($fix); $this->_em->persist($fix);
$this->_em->flush(); $this->_em->flush();
$this->assertCount(1,ContractSubscriber::$instances); $this->assertCount(1,CompanyContractListener::$instances);
$this->assertCount(1,ContractSubscriber::$preUpdateCalls); $this->assertCount(1,CompanyContractListener::$preUpdateCalls);
$this->assertSame($fix, ContractSubscriber::$preUpdateCalls[0][0]); $this->assertSame($fix, CompanyContractListener::$preUpdateCalls[0][0]);
$this->assertInstanceOf( $this->assertInstanceOf(
'Doctrine\Tests\Models\Company\CompanyFixContract', 'Doctrine\Tests\Models\Company\CompanyFixContract',
ContractSubscriber::$preUpdateCalls[0][0] CompanyContractListener::$preUpdateCalls[0][0]
); );
$this->assertInstanceOf( $this->assertInstanceOf(
'Doctrine\ORM\Event\PreUpdateEventArgs', 'Doctrine\ORM\Event\PreUpdateEventArgs',
ContractSubscriber::$preUpdateCalls[0][1] CompanyContractListener::$preUpdateCalls[0][1]
); );
} }
@ -166,26 +166,26 @@ class EntityListenersTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->persist($fix); $this->_em->persist($fix);
$this->_em->flush(); $this->_em->flush();
ContractSubscriber::$postUpdateCalls = array(); CompanyContractListener::$postUpdateCalls = array();
$fix->setFixPrice(2000); $fix->setFixPrice(2000);
$this->_em->persist($fix); $this->_em->persist($fix);
$this->_em->flush(); $this->_em->flush();
$this->assertCount(1,ContractSubscriber::$instances); $this->assertCount(1,CompanyContractListener::$instances);
$this->assertCount(1,ContractSubscriber::$postUpdateCalls); $this->assertCount(1,CompanyContractListener::$postUpdateCalls);
$this->assertSame($fix, ContractSubscriber::$postUpdateCalls[0][0]); $this->assertSame($fix, CompanyContractListener::$postUpdateCalls[0][0]);
$this->assertInstanceOf( $this->assertInstanceOf(
'Doctrine\Tests\Models\Company\CompanyFixContract', 'Doctrine\Tests\Models\Company\CompanyFixContract',
ContractSubscriber::$postUpdateCalls[0][0] CompanyContractListener::$postUpdateCalls[0][0]
); );
$this->assertInstanceOf( $this->assertInstanceOf(
'Doctrine\ORM\Event\LifecycleEventArgs', 'Doctrine\ORM\Event\LifecycleEventArgs',
ContractSubscriber::$postUpdateCalls[0][1] CompanyContractListener::$postUpdateCalls[0][1]
); );
} }
@ -197,24 +197,24 @@ class EntityListenersTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->persist($fix); $this->_em->persist($fix);
$this->_em->flush(); $this->_em->flush();
ContractSubscriber::$preRemoveCalls = array(); CompanyContractListener::$preRemoveCalls = array();
$this->_em->remove($fix); $this->_em->remove($fix);
$this->_em->flush(); $this->_em->flush();
$this->assertCount(1,ContractSubscriber::$instances); $this->assertCount(1,CompanyContractListener::$instances);
$this->assertCount(1,ContractSubscriber::$preRemoveCalls); $this->assertCount(1,CompanyContractListener::$preRemoveCalls);
$this->assertSame($fix, ContractSubscriber::$preRemoveCalls[0][0]); $this->assertSame($fix, CompanyContractListener::$preRemoveCalls[0][0]);
$this->assertInstanceOf( $this->assertInstanceOf(
'Doctrine\Tests\Models\Company\CompanyFixContract', 'Doctrine\Tests\Models\Company\CompanyFixContract',
ContractSubscriber::$preRemoveCalls[0][0] CompanyContractListener::$preRemoveCalls[0][0]
); );
$this->assertInstanceOf( $this->assertInstanceOf(
'Doctrine\ORM\Event\LifecycleEventArgs', 'Doctrine\ORM\Event\LifecycleEventArgs',
ContractSubscriber::$preRemoveCalls[0][1] CompanyContractListener::$preRemoveCalls[0][1]
); );
} }
@ -226,24 +226,24 @@ class EntityListenersTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->persist($fix); $this->_em->persist($fix);
$this->_em->flush(); $this->_em->flush();
ContractSubscriber::$postRemoveCalls = array(); CompanyContractListener::$postRemoveCalls = array();
$this->_em->remove($fix); $this->_em->remove($fix);
$this->_em->flush(); $this->_em->flush();
$this->assertCount(1,ContractSubscriber::$instances); $this->assertCount(1,CompanyContractListener::$instances);
$this->assertCount(1,ContractSubscriber::$postRemoveCalls); $this->assertCount(1,CompanyContractListener::$postRemoveCalls);
$this->assertSame($fix, ContractSubscriber::$postRemoveCalls[0][0]); $this->assertSame($fix, CompanyContractListener::$postRemoveCalls[0][0]);
$this->assertInstanceOf( $this->assertInstanceOf(
'Doctrine\Tests\Models\Company\CompanyFixContract', 'Doctrine\Tests\Models\Company\CompanyFixContract',
ContractSubscriber::$postRemoveCalls[0][0] CompanyContractListener::$postRemoveCalls[0][0]
); );
$this->assertInstanceOf( $this->assertInstanceOf(
'Doctrine\ORM\Event\LifecycleEventArgs', 'Doctrine\ORM\Event\LifecycleEventArgs',
ContractSubscriber::$postRemoveCalls[0][1] CompanyContractListener::$postRemoveCalls[0][1]
); );
} }
} }

View File

@ -6,8 +6,8 @@ use Doctrine\ORM\Events;
use Doctrine\ORM\Event\LifecycleEventArgs; use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\Tests\Models\Company\CompanyFixContract; use Doctrine\Tests\Models\Company\CompanyFixContract;
use Doctrine\Tests\Models\Company\CompanyFlexContract; use Doctrine\Tests\Models\Company\CompanyFlexContract;
use Doctrine\Tests\Models\Company\ContractSubscriber; use Doctrine\Tests\Models\Company\CompanyContractListener;
use Doctrine\Tests\Models\Company\FlexUltraContractSubscriber; use Doctrine\Tests\Models\Company\CompanyFlexUltraContractListener;
use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Mapping\ClassMetadataInfo; use Doctrine\ORM\Mapping\ClassMetadataInfo;
@ -774,8 +774,8 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase
$postPersist = $superClass->entityListeners[Events::postPersist][0]; $postPersist = $superClass->entityListeners[Events::postPersist][0];
$prePersist = $superClass->entityListeners[Events::prePersist][0]; $prePersist = $superClass->entityListeners[Events::prePersist][0];
$this->assertEquals('Doctrine\Tests\Models\Company\ContractSubscriber', $postPersist['class']); $this->assertEquals('Doctrine\Tests\Models\Company\CompanyContractListener', $postPersist['class']);
$this->assertEquals('Doctrine\Tests\Models\Company\ContractSubscriber', $prePersist['class']); $this->assertEquals('Doctrine\Tests\Models\Company\CompanyContractListener', $prePersist['class']);
$this->assertEquals('postPersistHandler', $postPersist['method']); $this->assertEquals('postPersistHandler', $postPersist['method']);
$this->assertEquals('prePersistHandler', $prePersist['method']); $this->assertEquals('prePersistHandler', $prePersist['method']);
@ -793,17 +793,17 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase
$postPersist = $ultraClass->entityListeners[Events::postPersist][0]; $postPersist = $ultraClass->entityListeners[Events::postPersist][0];
$prePersist = $ultraClass->entityListeners[Events::prePersist][0]; $prePersist = $ultraClass->entityListeners[Events::prePersist][0];
$this->assertEquals('Doctrine\Tests\Models\Company\ContractSubscriber', $postPersist['class']); $this->assertEquals('Doctrine\Tests\Models\Company\CompanyContractListener', $postPersist['class']);
$this->assertEquals('Doctrine\Tests\Models\Company\ContractSubscriber', $prePersist['class']); $this->assertEquals('Doctrine\Tests\Models\Company\CompanyContractListener', $prePersist['class']);
$this->assertEquals('postPersistHandler', $postPersist['method']); $this->assertEquals('postPersistHandler', $postPersist['method']);
$this->assertEquals('prePersistHandler', $prePersist['method']); $this->assertEquals('prePersistHandler', $prePersist['method']);
$prePersist = $ultraClass->entityListeners[Events::prePersist][1]; $prePersist = $ultraClass->entityListeners[Events::prePersist][1];
$this->assertEquals('Doctrine\Tests\Models\Company\FlexUltraContractSubscriber', $prePersist['class']); $this->assertEquals('Doctrine\Tests\Models\Company\CompanyFlexUltraContractListener', $prePersist['class']);
$this->assertEquals('prePersistHandler1', $prePersist['method']); $this->assertEquals('prePersistHandler1', $prePersist['method']);
$prePersist = $ultraClass->entityListeners[Events::prePersist][2]; $prePersist = $ultraClass->entityListeners[Events::prePersist][2];
$this->assertEquals('Doctrine\Tests\Models\Company\FlexUltraContractSubscriber', $prePersist['class']); $this->assertEquals('Doctrine\Tests\Models\Company\CompanyFlexUltraContractListener', $prePersist['class']);
$this->assertEquals('prePersistHandler2', $prePersist['method']); $this->assertEquals('prePersistHandler2', $prePersist['method']);
} }
@ -818,9 +818,9 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase
$fixClass = $factory->getMetadataFor('Doctrine\Tests\Models\Company\CompanyFlexContract'); $fixClass = $factory->getMetadataFor('Doctrine\Tests\Models\Company\CompanyFlexContract');
$ultraClass = $factory->getMetadataFor('Doctrine\Tests\Models\Company\CompanyFlexUltraContract'); $ultraClass = $factory->getMetadataFor('Doctrine\Tests\Models\Company\CompanyFlexUltraContract');
ContractSubscriber::$prePersistCalls = array(); CompanyContractListener::$prePersistCalls = array();
ContractSubscriber::$postPersistCalls = array(); CompanyContractListener::$postPersistCalls = array();
FlexUltraContractSubscriber::$prePersistCalls = array(); CompanyFlexUltraContractListener::$prePersistCalls = array();
$fix = new CompanyFixContract(); $fix = new CompanyFixContract();
$fixArg = new LifecycleEventArgs($fix, $em); $fixArg = new LifecycleEventArgs($fix, $em);
@ -835,26 +835,26 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase
$flexClass->dispatchEntityListeners(Events::prePersist, $flex, $flexArg); $flexClass->dispatchEntityListeners(Events::prePersist, $flex, $flexArg);
$ultraClass->dispatchEntityListeners(Events::prePersist, $ultra, $ultraArg); $ultraClass->dispatchEntityListeners(Events::prePersist, $ultra, $ultraArg);
$this->assertCount(3, ContractSubscriber::$prePersistCalls); $this->assertCount(3, CompanyContractListener::$prePersistCalls);
$this->assertCount(2, FlexUltraContractSubscriber::$prePersistCalls); $this->assertCount(2, CompanyFlexUltraContractListener::$prePersistCalls);
$this->assertSame($fix, ContractSubscriber::$prePersistCalls[0][0]); $this->assertSame($fix, CompanyContractListener::$prePersistCalls[0][0]);
$this->assertSame($fixArg, ContractSubscriber::$prePersistCalls[0][1]); $this->assertSame($fixArg, CompanyContractListener::$prePersistCalls[0][1]);
$this->assertSame($flex, ContractSubscriber::$prePersistCalls[1][0]); $this->assertSame($flex, CompanyContractListener::$prePersistCalls[1][0]);
$this->assertSame($flexArg, ContractSubscriber::$prePersistCalls[1][1]); $this->assertSame($flexArg, CompanyContractListener::$prePersistCalls[1][1]);
$this->assertSame($ultra, ContractSubscriber::$prePersistCalls[2][0]); $this->assertSame($ultra, CompanyContractListener::$prePersistCalls[2][0]);
$this->assertSame($ultraArg, ContractSubscriber::$prePersistCalls[2][1]); $this->assertSame($ultraArg, CompanyContractListener::$prePersistCalls[2][1]);
$this->assertSame($ultra, FlexUltraContractSubscriber::$prePersistCalls[0][0]); $this->assertSame($ultra, CompanyFlexUltraContractListener::$prePersistCalls[0][0]);
$this->assertSame($ultraArg, FlexUltraContractSubscriber::$prePersistCalls[0][1]); $this->assertSame($ultraArg, CompanyFlexUltraContractListener::$prePersistCalls[0][1]);
$this->assertSame($ultra, FlexUltraContractSubscriber::$prePersistCalls[1][0]); $this->assertSame($ultra, CompanyFlexUltraContractListener::$prePersistCalls[1][0]);
$this->assertSame($ultraArg, FlexUltraContractSubscriber::$prePersistCalls[1][1]); $this->assertSame($ultraArg, CompanyFlexUltraContractListener::$prePersistCalls[1][1]);
$this->assertCount(1, ContractSubscriber::$instances); $this->assertCount(1, CompanyContractListener::$instances);
$this->assertEmpty(ContractSubscriber::$postPersistCalls); $this->assertEmpty(CompanyContractListener::$postPersistCalls);
} }
/** /**

View File

@ -1016,14 +1016,14 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
* @group DDC-1955 * @group DDC-1955
* *
* @expectedException Doctrine\ORM\Mapping\MappingException * @expectedException Doctrine\ORM\Mapping\MappingException
* @expectedExceptionMessage Entity Listener "\Doctrine\Tests\Models\Company\ContractSubscriber" declared on "Doctrine\Tests\Models\CMS\CmsUser" has no method "invalidMethod". * @expectedExceptionMessage Entity Listener "\Doctrine\Tests\Models\Company\CompanyContractListener" declared on "Doctrine\Tests\Models\CMS\CmsUser" has no method "invalidMethod".
*/ */
public function testInvalidEntityListenerMethodException() public function testInvalidEntityListenerMethodException()
{ {
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
$cm->addEntityListener(Events::postLoad, '\Doctrine\Tests\Models\Company\ContractSubscriber', 'invalidMethod'); $cm->addEntityListener(Events::postLoad, '\Doctrine\Tests\Models\Company\CompanyContractListener', 'invalidMethod');
} }
} }

View File

@ -27,14 +27,14 @@ $metadata->setDiscriminatorMap(array(
"flexultra" => "CompanyFlexUltraContract" "flexultra" => "CompanyFlexUltraContract"
)); ));
$metadata->addEntityListener(\Doctrine\ORM\Events::postPersist, 'ContractSubscriber', 'postPersistHandler'); $metadata->addEntityListener(\Doctrine\ORM\Events::postPersist, 'CompanyContractListener', 'postPersistHandler');
$metadata->addEntityListener(\Doctrine\ORM\Events::prePersist, 'ContractSubscriber', 'prePersistHandler'); $metadata->addEntityListener(\Doctrine\ORM\Events::prePersist, 'CompanyContractListener', 'prePersistHandler');
$metadata->addEntityListener(\Doctrine\ORM\Events::postUpdate, 'ContractSubscriber', 'postUpdateHandler'); $metadata->addEntityListener(\Doctrine\ORM\Events::postUpdate, 'CompanyContractListener', 'postUpdateHandler');
$metadata->addEntityListener(\Doctrine\ORM\Events::preUpdate, 'ContractSubscriber', 'preUpdateHandler'); $metadata->addEntityListener(\Doctrine\ORM\Events::preUpdate, 'CompanyContractListener', 'preUpdateHandler');
$metadata->addEntityListener(\Doctrine\ORM\Events::postRemove, 'ContractSubscriber', 'postRemoveHandler'); $metadata->addEntityListener(\Doctrine\ORM\Events::postRemove, 'CompanyContractListener', 'postRemoveHandler');
$metadata->addEntityListener(\Doctrine\ORM\Events::preRemove, 'ContractSubscriber', 'preRemoveHandler'); $metadata->addEntityListener(\Doctrine\ORM\Events::preRemove, 'CompanyContractListener', 'preRemoveHandler');
$metadata->addEntityListener(\Doctrine\ORM\Events::preFlush, 'ContractSubscriber', 'preFlushHandler'); $metadata->addEntityListener(\Doctrine\ORM\Events::preFlush, 'CompanyContractListener', 'preFlushHandler');
$metadata->addEntityListener(\Doctrine\ORM\Events::postLoad, 'ContractSubscriber', 'postLoadHandler'); $metadata->addEntityListener(\Doctrine\ORM\Events::postLoad, 'CompanyContractListener', 'postLoadHandler');

View File

@ -5,17 +5,17 @@ $metadata->mapField(array(
'name' => 'maxPrice', 'name' => 'maxPrice',
'fieldName' => 'maxPrice', 'fieldName' => 'maxPrice',
)); ));
$metadata->addEntityListener(\Doctrine\ORM\Events::postPersist, 'ContractSubscriber', 'postPersistHandler'); $metadata->addEntityListener(\Doctrine\ORM\Events::postPersist, 'CompanyContractListener', 'postPersistHandler');
$metadata->addEntityListener(\Doctrine\ORM\Events::prePersist, 'ContractSubscriber', 'prePersistHandler'); $metadata->addEntityListener(\Doctrine\ORM\Events::prePersist, 'CompanyContractListener', 'prePersistHandler');
$metadata->addEntityListener(\Doctrine\ORM\Events::postUpdate, 'ContractSubscriber', 'postUpdateHandler'); $metadata->addEntityListener(\Doctrine\ORM\Events::postUpdate, 'CompanyContractListener', 'postUpdateHandler');
$metadata->addEntityListener(\Doctrine\ORM\Events::preUpdate, 'ContractSubscriber', 'preUpdateHandler'); $metadata->addEntityListener(\Doctrine\ORM\Events::preUpdate, 'CompanyContractListener', 'preUpdateHandler');
$metadata->addEntityListener(\Doctrine\ORM\Events::postRemove, 'ContractSubscriber', 'postRemoveHandler'); $metadata->addEntityListener(\Doctrine\ORM\Events::postRemove, 'CompanyContractListener', 'postRemoveHandler');
$metadata->addEntityListener(\Doctrine\ORM\Events::preRemove, 'ContractSubscriber', 'preRemoveHandler'); $metadata->addEntityListener(\Doctrine\ORM\Events::preRemove, 'CompanyContractListener', 'preRemoveHandler');
$metadata->addEntityListener(\Doctrine\ORM\Events::preFlush, 'ContractSubscriber', 'preFlushHandler'); $metadata->addEntityListener(\Doctrine\ORM\Events::preFlush, 'CompanyContractListener', 'preFlushHandler');
$metadata->addEntityListener(\Doctrine\ORM\Events::postLoad, 'ContractSubscriber', 'postLoadHandler'); $metadata->addEntityListener(\Doctrine\ORM\Events::postLoad, 'CompanyContractListener', 'postLoadHandler');
$metadata->addEntityListener(\Doctrine\ORM\Events::prePersist, 'FlexUltraContractSubscriber', 'prePersistHandler1'); $metadata->addEntityListener(\Doctrine\ORM\Events::prePersist, 'CompanyFlexUltraContractListener', 'prePersistHandler1');
$metadata->addEntityListener(\Doctrine\ORM\Events::prePersist, 'FlexUltraContractSubscriber', 'prePersistHandler2'); $metadata->addEntityListener(\Doctrine\ORM\Events::prePersist, 'CompanyFlexUltraContractListener', 'prePersistHandler2');

View File

@ -14,7 +14,7 @@
</discriminator-map> </discriminator-map>
<entity-listeners> <entity-listeners>
<entity-listener class="ContractSubscriber"> <entity-listener class="CompanyContractListener">
<pre-flush method="preFlushHandler"/> <pre-flush method="preFlushHandler"/>
<post-load method="postLoadHandler"/> <post-load method="postLoadHandler"/>

View File

@ -8,7 +8,7 @@
<entity name="Doctrine\Tests\Models\Company\CompanyFlexUltraContract"> <entity name="Doctrine\Tests\Models\Company\CompanyFlexUltraContract">
<entity-listeners> <entity-listeners>
<entity-listener class="ContractSubscriber"> <entity-listener class="CompanyContractListener">
<pre-flush method="preFlushHandler"/> <pre-flush method="preFlushHandler"/>
<post-load method="postLoadHandler"/> <post-load method="postLoadHandler"/>
<pre-persist method="prePersistHandler"/> <pre-persist method="prePersistHandler"/>
@ -19,7 +19,7 @@
<post-remove method="postRemoveHandler"/> <post-remove method="postRemoveHandler"/>
</entity-listener> </entity-listener>
<entity-listener class="FlexUltraContractSubscriber"> <entity-listener class="CompanyFlexUltraContractListener">
<pre-persist method="prePersistHandler1"/> <pre-persist method="prePersistHandler1"/>
<pre-persist method="prePersistHandler2"/> <pre-persist method="prePersistHandler2"/>
</entity-listener> </entity-listener>

View File

@ -9,7 +9,7 @@ Doctrine\Tests\Models\Company\CompanyContract:
entityListeners: entityListeners:
listener[0]: listener[0]:
class : ContractSubscriber class : CompanyContractListener
preFlush: [preFlushHandler] preFlush: [preFlushHandler]
postLoad: [postLoadHandler] postLoad: [postLoadHandler]

View File

@ -3,7 +3,7 @@ Doctrine\Tests\Models\Company\CompanyFlexUltraContract:
entityListeners: entityListeners:
listener[0]: listener[0]:
class : ContractSubscriber class : CompanyContractListener
preFlush: [preFlushHandler] preFlush: [preFlushHandler]
postLoad: [postLoadHandler] postLoad: [postLoadHandler]
@ -18,7 +18,7 @@ Doctrine\Tests\Models\Company\CompanyFlexUltraContract:
preRemove: [preRemoveHandler] preRemove: [preRemoveHandler]
listener[1]: listener[1]:
class : FlexUltraContractSubscriber class : CompanyFlexUltraContractListener
prePersist: [prePersistHandler1, prePersistHandler2] prePersist: [prePersistHandler1, prePersistHandler2]