[2.0] Adding test to ensure onDelete and onUpdate are read properly from all mapping drivers
This commit is contained in:
parent
9b5968957d
commit
1d60c65daf
@ -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;
|
||||
|
||||
|
@ -45,6 +45,8 @@ $metadata->mapOneToOne(array(
|
||||
array(
|
||||
'name' => 'address_id',
|
||||
'referencedColumnName' => 'id',
|
||||
'onDelete' => 'CASCADE',
|
||||
'onUpdate' => 'CASCADE'
|
||||
),
|
||||
),
|
||||
'orphanRemoval' => false,
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
<one-to-one field="address" target-entity="Address">
|
||||
<cascade><cascade-remove /></cascade>
|
||||
<join-column name="address_id" referenced-column-name="id"/>
|
||||
<join-column name="address_id" referenced-column-name="id" on-delete="CASCADE" on-update="CASCADE"/>
|
||||
</one-to-one>
|
||||
|
||||
<one-to-many field="phonenumbers" target-entity="Phonenumber" mapped-by="user">
|
||||
|
@ -22,6 +22,8 @@ Doctrine\Tests\ORM\Mapping\User:
|
||||
joinColumn:
|
||||
name: address_id
|
||||
referencedColumnName: id
|
||||
onDelete: CASCADE
|
||||
onUpdate: CASCADE
|
||||
cascade: [ remove ]
|
||||
oneToMany:
|
||||
phonenumbers:
|
||||
|
@ -45,4 +45,4 @@ class User
|
||||
$address->setUser($this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user