From 1d60c65dafdfc4b69a582da42839a639103d71ea Mon Sep 17 00:00:00 2001 From: jwage Date: Wed, 17 Mar 2010 14:20:18 +0000 Subject: [PATCH] [2.0] Adding test to ensure onDelete and onUpdate are read properly from all mapping drivers --- .../Tests/ORM/Mapping/AbstractMappingDriverTest.php | 13 +++++++++++++ .../Mapping/php/Doctrine.Tests.ORM.Mapping.User.php | 2 ++ .../xml/Doctrine.Tests.ORM.Mapping.User.dcm.xml | 2 +- .../yaml/Doctrine.Tests.ORM.Mapping.User.dcm.yml | 2 ++ tools/sandbox/Entities/User.php | 2 +- 5 files changed, 19 insertions(+), 2 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php index dd3e03483..53518613c 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php @@ -189,6 +189,18 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase return $class; } + + /** + * @depends testColumnDefinition + * @param ClassMetadata $class + */ + public function testJoinColumnOnDeleteAndOnUpdate($class) + { + $this->assertEquals('CASCADE', $class->associationMappings['address']->joinColumns[0]['onDelete']); + $this->assertEquals('CASCADE', $class->associationMappings['address']->joinColumns[0]['onUpdate']); + + return $class; + } } /** @@ -213,6 +225,7 @@ class User /** * @OneToOne(targetEntity="Address", cascade={"remove"}) + * @JoinColumn(onDelete="CASCADE", onUpdate="CASCADE") */ public $address; diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.User.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.User.php index 9623e991f..7bd7fcaf4 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.User.php +++ b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.User.php @@ -45,6 +45,8 @@ $metadata->mapOneToOne(array( array( 'name' => 'address_id', 'referencedColumnName' => 'id', + 'onDelete' => 'CASCADE', + 'onUpdate' => 'CASCADE' ), ), 'orphanRemoval' => false, diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.User.dcm.xml b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.User.dcm.xml index ecfafdc20..776185a28 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.User.dcm.xml +++ b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.User.dcm.xml @@ -22,7 +22,7 @@ - + diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.User.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.User.dcm.yml index 79ba6f7e3..5e239da3f 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.User.dcm.yml +++ b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.User.dcm.yml @@ -22,6 +22,8 @@ Doctrine\Tests\ORM\Mapping\User: joinColumn: name: address_id referencedColumnName: id + onDelete: CASCADE + onUpdate: CASCADE cascade: [ remove ] oneToMany: phonenumbers: diff --git a/tools/sandbox/Entities/User.php b/tools/sandbox/Entities/User.php index 19ae4d553..9f6af35e1 100644 --- a/tools/sandbox/Entities/User.php +++ b/tools/sandbox/Entities/User.php @@ -45,4 +45,4 @@ class User $address->setUser($this); } } -} +} \ No newline at end of file