[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
5 changed files with 19 additions and 2 deletions
|
@ -189,6 +189,18 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase
|
||||||
|
|
||||||
return $class;
|
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"})
|
* @OneToOne(targetEntity="Address", cascade={"remove"})
|
||||||
|
* @JoinColumn(onDelete="CASCADE", onUpdate="CASCADE")
|
||||||
*/
|
*/
|
||||||
public $address;
|
public $address;
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,8 @@ $metadata->mapOneToOne(array(
|
||||||
array(
|
array(
|
||||||
'name' => 'address_id',
|
'name' => 'address_id',
|
||||||
'referencedColumnName' => 'id',
|
'referencedColumnName' => 'id',
|
||||||
|
'onDelete' => 'CASCADE',
|
||||||
|
'onUpdate' => 'CASCADE'
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'orphanRemoval' => false,
|
'orphanRemoval' => false,
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
<one-to-one field="address" target-entity="Address">
|
<one-to-one field="address" target-entity="Address">
|
||||||
<cascade><cascade-remove /></cascade>
|
<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-one>
|
||||||
|
|
||||||
<one-to-many field="phonenumbers" target-entity="Phonenumber" mapped-by="user">
|
<one-to-many field="phonenumbers" target-entity="Phonenumber" mapped-by="user">
|
||||||
|
|
|
@ -22,6 +22,8 @@ Doctrine\Tests\ORM\Mapping\User:
|
||||||
joinColumn:
|
joinColumn:
|
||||||
name: address_id
|
name: address_id
|
||||||
referencedColumnName: id
|
referencedColumnName: id
|
||||||
|
onDelete: CASCADE
|
||||||
|
onUpdate: CASCADE
|
||||||
cascade: [ remove ]
|
cascade: [ remove ]
|
||||||
oneToMany:
|
oneToMany:
|
||||||
phonenumbers:
|
phonenumbers:
|
||||||
|
|
|
@ -45,4 +45,4 @@ class User
|
||||||
$address->setUser($this);
|
$address->setUser($this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue