diff --git a/tests/Doctrine/Tests/Models/Company/ContractSubscriber.php b/tests/Doctrine/Tests/Models/Company/ContractSubscriber.php index 2a7d7c76a..afc30933e 100644 --- a/tests/Doctrine/Tests/Models/Company/ContractSubscriber.php +++ b/tests/Doctrine/Tests/Models/Company/ContractSubscriber.php @@ -5,7 +5,7 @@ namespace Doctrine\Tests\Models\Company; class ContractSubscriber { static public $prePersistCalls; - static public $postPersisCalls; + static public $postPersistCalls; static public $instances; public function __construct() @@ -18,7 +18,7 @@ class ContractSubscriber */ public function postPersistHandler(CompanyContract $contract) { - self::$postPersisCalls[] = func_get_args(); + self::$postPersistCalls[] = func_get_args(); } /** diff --git a/tests/Doctrine/Tests/Models/Company/FlexUltraContractSubscriber.php b/tests/Doctrine/Tests/Models/Company/FlexUltraContractSubscriber.php index fd64594ba..408bcad70 100644 --- a/tests/Doctrine/Tests/Models/Company/FlexUltraContractSubscriber.php +++ b/tests/Doctrine/Tests/Models/Company/FlexUltraContractSubscriber.php @@ -7,7 +7,6 @@ use Doctrine\ORM\Event\LifecycleEventArgs; class FlexUltraContractSubscriber { static public $prePersistCalls; - static public $postPersisCalls; static public $instances; public function __construct() @@ -18,16 +17,16 @@ class FlexUltraContractSubscriber /** * @PrePersist */ - public function postPersistHandler1(CompanyContract $contract, LifecycleEventArgs $args) + public function prePersistHandler1(CompanyContract $contract, LifecycleEventArgs $args) { - self::$postPersisCalls[] = func_get_args(); + self::$prePersistCalls[] = func_get_args(); } /** * @PrePersist */ - public function postPersistHandler2(CompanyContract $contract, LifecycleEventArgs $args) + public function prePersistHandler2(CompanyContract $contract, LifecycleEventArgs $args) { - self::$postPersisCalls[] = func_get_args(); + self::$prePersistCalls[] = func_get_args(); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/EntityListenersDispatcherTest.php b/tests/Doctrine/Tests/ORM/Functional/EntityListenersDispatcherTest.php index 8b13b5951..c45bd944c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/EntityListenersDispatcherTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/EntityListenersDispatcherTest.php @@ -18,26 +18,6 @@ class EntityListenersDispatcherTest extends \Doctrine\Tests\OrmFunctionalTestCas */ public function testEntityListeners() { - $flexClass = $this->_em->getClassMetadata('Doctrine\Tests\Models\Company\CompanyFixContract'); - $fixClass = $this->_em->getClassMetadata('Doctrine\Tests\Models\Company\CompanyFlexContract'); - - $this->assertNull(ContractSubscriber::$instances); - $this->assertNull(ContractSubscriber::$prePersistCalls); - $this->assertNull(ContractSubscriber::$postPersisCalls); - - $fix = new CompanyFixContract(); - $fixArg = new LifecycleEventArgs($fix, $this->_em); - - $flex = new CompanyFlexContract(); - $flexArg = new LifecycleEventArgs($fix, $this->_em); - - $fixClass->dispatchEntityListeners(Events::prePersist, $fix, $fixArg); - $flexClass->dispatchEntityListeners(Events::prePersist, $flex, $flexArg); - - $this->assertSame($fix, ContractSubscriber::$prePersistCalls[0][0]); - $this->assertSame($fixArg, ContractSubscriber::$prePersistCalls[0][1]); - - $this->assertCount(1, ContractSubscriber::$instances); - $this->assertNull(ContractSubscriber::$postPersisCalls); + $this->markTestIncomplete(); } } \ No newline at end of file diff --git a/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php index 365bc69d0..a509add48 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php @@ -7,6 +7,7 @@ use Doctrine\ORM\Event\LifecycleEventArgs; use Doctrine\Tests\Models\Company\CompanyFixContract; use Doctrine\Tests\Models\Company\CompanyFlexContract; use Doctrine\Tests\Models\Company\ContractSubscriber; +use Doctrine\Tests\Models\Company\FlexUltraContractSubscriber; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\ClassMetadataInfo; @@ -803,11 +804,11 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase $prePersist = $ultraClass->entityListeners[Events::prePersist][1]; $this->assertEquals('Doctrine\Tests\Models\Company\FlexUltraContractSubscriber', $prePersist['class']); - $this->assertEquals('postPersistHandler1', $prePersist['method']); + $this->assertEquals('prePersistHandler1', $prePersist['method']); $prePersist = $ultraClass->entityListeners[Events::prePersist][2]; $this->assertEquals('Doctrine\Tests\Models\Company\FlexUltraContractSubscriber', $prePersist['class']); - $this->assertEquals('postPersistHandler2', $prePersist['method']); + $this->assertEquals('prePersistHandler2', $prePersist['method']); } /** @@ -823,9 +824,11 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase $factory = $this->createClassMetadataFactory($em); $flexClass = $factory->getMetadataFor('Doctrine\Tests\Models\Company\CompanyFixContract'); $fixClass = $factory->getMetadataFor('Doctrine\Tests\Models\Company\CompanyFlexContract'); + $ultraClass = $factory->getMetadataFor('Doctrine\Tests\Models\Company\CompanyFlexUltraContract'); - ContractSubscriber::$prePersistCalls = null; - ContractSubscriber::$postPersisCalls = null; + ContractSubscriber::$prePersistCalls = null; + ContractSubscriber::$postPersistCalls = null; + FlexUltraContractSubscriber::$prePersistCalls = null; $fix = new CompanyFixContract(); $fixArg = new LifecycleEventArgs($fix, $em); @@ -833,14 +836,33 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase $flex = new CompanyFlexContract(); $flexArg = new LifecycleEventArgs($fix, $em); + $ultra = new CompanyFlexContract(); + $ultraArg = new LifecycleEventArgs($ultra, $em); + $fixClass->dispatchEntityListeners(Events::prePersist, $fix, $fixArg); $flexClass->dispatchEntityListeners(Events::prePersist, $flex, $flexArg); + $ultraClass->dispatchEntityListeners(Events::prePersist, $ultra, $ultraArg); + + $this->assertCount(3, ContractSubscriber::$prePersistCalls); + $this->assertCount(2, FlexUltraContractSubscriber::$prePersistCalls); $this->assertSame($fix, ContractSubscriber::$prePersistCalls[0][0]); $this->assertSame($fixArg, ContractSubscriber::$prePersistCalls[0][1]); + $this->assertSame($flex, ContractSubscriber::$prePersistCalls[1][0]); + $this->assertSame($flexArg, ContractSubscriber::$prePersistCalls[1][1]); + + $this->assertSame($ultra, ContractSubscriber::$prePersistCalls[2][0]); + $this->assertSame($ultraArg, ContractSubscriber::$prePersistCalls[2][1]); + + $this->assertSame($ultra, FlexUltraContractSubscriber::$prePersistCalls[0][0]); + $this->assertSame($ultraArg, FlexUltraContractSubscriber::$prePersistCalls[0][1]); + + $this->assertSame($ultra, FlexUltraContractSubscriber::$prePersistCalls[1][0]); + $this->assertSame($ultraArg, FlexUltraContractSubscriber::$prePersistCalls[1][1]); + $this->assertCount(1, ContractSubscriber::$instances); - $this->assertNull(ContractSubscriber::$postPersisCalls); + $this->assertNull(ContractSubscriber::$postPersistCalls); } }