Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

php static driver

  • Loading branch information...
commit 415c2a95f2bb57ad370c99e11ce224d48c47327a 1 parent f0b0437
Fabio B. Silva authored fabio.silva committed
40 tests/Doctrine/Tests/Models/Company/CompanyContract.php
View
@@ -129,4 +129,44 @@ public function removeEngineer(CompanyEmployee $engineer)
}
abstract public function calculatePrice();
+
+ static public function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)
+ {
+ $metadata->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');
+ }
}
9 tests/Doctrine/Tests/Models/Company/CompanyFixContract.php
View
@@ -27,4 +27,13 @@ public function setFixPrice($fixPrice)
{
$this->fixPrice = $fixPrice;
}
+
+ static public function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)
+ {
+ $metadata->mapField(array(
+ 'type' => 'integer',
+ 'name' => 'fixPrice',
+ 'fieldName' => 'fixPrice',
+ ));
+ }
}
15 tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php
View
@@ -107,4 +107,19 @@ public function removeManager(CompanyManager $manager)
{
$this->managers->removeElement($manager);
}
+
+ static public function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)
+ {
+ $metadata->mapField(array(
+ 'type' => 'integer',
+ 'name' => 'hoursWorked',
+ 'fieldName' => 'hoursWorked',
+ ));
+
+ $metadata->mapField(array(
+ 'type' => 'integer',
+ 'name' => 'pricePerHour',
+ 'fieldName' => 'pricePerHour',
+ ));
+ }
}
23 tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php
View
@@ -28,4 +28,27 @@ public function setMaxPrice($maxPrice)
{
$this->maxPrice = $maxPrice;
}
+
+ static public function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)
+ {
+ $metadata->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');
+ }
}
8 tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php
View
@@ -758,9 +758,7 @@ public function testAttributeOverridesMapping()
*/
public function testEntityListeners()
{
- if ( ! ($this instanceof AnnotationDriverTest)
- && ! ($this instanceof XmlMappingDriverTest)
- && ! ($this instanceof YamlMappingDriverTest)) {
+ if ($this instanceof PHPMappingDriverTest) {
$this->markTestIncomplete();
}
@@ -818,9 +816,7 @@ public function testEntityListeners()
*/
public function testCallEntityListeners()
{
- if ( ! ($this instanceof AnnotationDriverTest)
- && ! ($this instanceof XmlMappingDriverTest)
- && ! ($this instanceof YamlMappingDriverTest)) {
+ if ($this instanceof PHPMappingDriverTest) {
$this->markTestIncomplete();
}
Please sign in to comment.
Something went wrong with that request. Please try again.