From 7021f002f22bcfd16a6e67d16662c4501ea6f2ec Mon Sep 17 00:00:00 2001 From: "Fabio B. Silva" Date: Tue, 7 Aug 2012 21:36:47 -0300 Subject: [PATCH] php driver --- .../ORM/Mapping/AbstractMappingDriverTest.php | 8 ---- ...e.Tests.Models.Company.CompanyContract.php | 40 +++++++++++++++++++ ...ests.Models.Company.CompanyFixContract.php | 7 ++++ ...sts.Models.Company.CompanyFlexContract.php | 13 ++++++ ...odels.Company.CompanyFlexUltraContract.php | 21 ++++++++++ 5 files changed, 81 insertions(+), 8 deletions(-) create mode 100644 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyContract.php create mode 100644 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyFixContract.php create mode 100644 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyFlexContract.php create mode 100644 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyFlexUltraContract.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php index c5fc1fba7..ba9a0e0e9 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php @@ -758,10 +758,6 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase */ public function testEntityListeners() { - if ($this instanceof PHPMappingDriverTest) { - $this->markTestIncomplete(); - } - $em = $this->_getTestEntityManager(); $factory = $this->createClassMetadataFactory($em); $superClass = $factory->getMetadataFor('Doctrine\Tests\Models\Company\CompanyContract'); @@ -816,10 +812,6 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase */ public function testCallEntityListeners() { - if ($this instanceof PHPMappingDriverTest) { - $this->markTestIncomplete(); - } - $em = $this->_getTestEntityManager(); $factory = $this->createClassMetadataFactory($em); $flexClass = $factory->getMetadataFor('Doctrine\Tests\Models\Company\CompanyFixContract'); diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyContract.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyContract.php new file mode 100644 index 000000000..636b952c9 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyContract.php @@ -0,0 +1,40 @@ +setInheritanceType(\Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_JOINED); +$metadata->setTableName( 'company_contracts'); +$metadata->setDiscriminatorColumn(array( + 'name' => 'discr', + 'type' => 'string', +)); + +$metadata->mapField(array( + 'id' => true, + 'name' => 'id', + 'fieldName' => 'id', +)); + +$metadata->mapField(array( + 'type' => 'boolean', + 'name' => 'completed', + 'fieldName' => 'completed', +)); + +$metadata->setDiscriminatorMap(array( + "fix" => "CompanyFixContract", + "flexible" => "CompanyFlexContract", + "flexultra" => "CompanyFlexUltraContract" +)); + +$metadata->addEntityListener(\Doctrine\ORM\Events::postPersist, 'ContractSubscriber', 'postPersistHandler'); +$metadata->addEntityListener(\Doctrine\ORM\Events::prePersist, 'ContractSubscriber', 'prePersistHandler'); + +$metadata->addEntityListener(\Doctrine\ORM\Events::postUpdate, 'ContractSubscriber', 'postUpdateHandler'); +$metadata->addEntityListener(\Doctrine\ORM\Events::preUpdate, 'ContractSubscriber', 'preUpdateHandler'); + +$metadata->addEntityListener(\Doctrine\ORM\Events::postRemove, 'ContractSubscriber', 'postRemoveHandler'); +$metadata->addEntityListener(\Doctrine\ORM\Events::preRemove, 'ContractSubscriber', 'preRemoveHandler'); + +$metadata->addEntityListener(\Doctrine\ORM\Events::preFlush, 'ContractSubscriber', 'preFlushHandler'); +$metadata->addEntityListener(\Doctrine\ORM\Events::postLoad, 'ContractSubscriber', 'postLoadHandler'); \ No newline at end of file diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyFixContract.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyFixContract.php new file mode 100644 index 000000000..79b117729 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyFixContract.php @@ -0,0 +1,7 @@ +mapField(array( + 'type' => 'integer', + 'name' => 'fixPrice', + 'fieldName' => 'fixPrice', +)); \ No newline at end of file diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyFlexContract.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyFlexContract.php new file mode 100644 index 000000000..5f1542dde --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyFlexContract.php @@ -0,0 +1,13 @@ +mapField(array( + 'type' => 'integer', + 'name' => 'hoursWorked', + 'fieldName' => 'hoursWorked', +)); + +$metadata->mapField(array( + 'type' => 'integer', + 'name' => 'pricePerHour', + 'fieldName' => 'pricePerHour', +)); diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyFlexUltraContract.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyFlexUltraContract.php new file mode 100644 index 000000000..31e4b60c0 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyFlexUltraContract.php @@ -0,0 +1,21 @@ +mapField(array( + 'type' => 'integer', + 'name' => 'maxPrice', + 'fieldName' => 'maxPrice', +)); +$metadata->addEntityListener(\Doctrine\ORM\Events::postPersist, 'ContractSubscriber', 'postPersistHandler'); +$metadata->addEntityListener(\Doctrine\ORM\Events::prePersist, 'ContractSubscriber', 'prePersistHandler'); + +$metadata->addEntityListener(\Doctrine\ORM\Events::postUpdate, 'ContractSubscriber', 'postUpdateHandler'); +$metadata->addEntityListener(\Doctrine\ORM\Events::preUpdate, 'ContractSubscriber', 'preUpdateHandler'); + +$metadata->addEntityListener(\Doctrine\ORM\Events::postRemove, 'ContractSubscriber', 'postRemoveHandler'); +$metadata->addEntityListener(\Doctrine\ORM\Events::preRemove, 'ContractSubscriber', 'preRemoveHandler'); + +$metadata->addEntityListener(\Doctrine\ORM\Events::preFlush, 'ContractSubscriber', 'preFlushHandler'); +$metadata->addEntityListener(\Doctrine\ORM\Events::postLoad, 'ContractSubscriber', 'postLoadHandler'); + +$metadata->addEntityListener(\Doctrine\ORM\Events::prePersist, 'FlexUltraContractSubscriber', 'prePersistHandler1'); +$metadata->addEntityListener(\Doctrine\ORM\Events::prePersist, 'FlexUltraContractSubscriber', 'prePersistHandler2'); \ No newline at end of file