Merge branch 'DDC-1666'
This commit is contained in:
commit
6ee9e2284a
@ -1487,6 +1487,10 @@ class ClassMetadataInfo implements ClassMetadata
|
|||||||
$mapping['orphanRemoval'] = isset($mapping['orphanRemoval']) ? (bool) $mapping['orphanRemoval'] : false;
|
$mapping['orphanRemoval'] = isset($mapping['orphanRemoval']) ? (bool) $mapping['orphanRemoval'] : false;
|
||||||
$mapping['isCascadeRemove'] = $mapping['orphanRemoval'] ? true : $mapping['isCascadeRemove'];
|
$mapping['isCascadeRemove'] = $mapping['orphanRemoval'] ? true : $mapping['isCascadeRemove'];
|
||||||
|
|
||||||
|
if ($mapping['orphanRemoval']) {
|
||||||
|
unset($mapping['unique']);
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($mapping['id']) && $mapping['id'] === true && !$mapping['isOwningSide']) {
|
if (isset($mapping['id']) && $mapping['id'] === true && !$mapping['isOwningSide']) {
|
||||||
throw MappingException::illegalInverseIdentifierAssociation($this->name, $mapping['fieldName']);
|
throw MappingException::illegalInverseIdentifierAssociation($this->name, $mapping['fieldName']);
|
||||||
}
|
}
|
||||||
|
40
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1666Test.php
Normal file
40
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1666Test.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
||||||
|
|
||||||
|
use Doctrine\Tests\Models\CMS\CmsUser;
|
||||||
|
use Doctrine\Tests\Models\CMS\CmsEmail;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group DDC-1666
|
||||||
|
*/
|
||||||
|
class DDC1666Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||||
|
{
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
$this->useModelSet('cms');
|
||||||
|
parent::setUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGivenOrphanRemovalOneToOne_WhenReplacing_ThenNoUniqueConstraintError()
|
||||||
|
{
|
||||||
|
$user = new CmsUser();
|
||||||
|
$user->name = "Benjamin";
|
||||||
|
$user->username = "beberlei";
|
||||||
|
$user->status = "something";
|
||||||
|
$user->setEmail($email = new CmsEmail());
|
||||||
|
$email->setEmail("kontakt@beberlei.de");
|
||||||
|
|
||||||
|
$this->_em->persist($user);
|
||||||
|
$this->_em->flush();
|
||||||
|
|
||||||
|
$this->assertTrue($this->_em->contains($email));
|
||||||
|
|
||||||
|
$user->setEmail($newEmail = new CmsEmail());
|
||||||
|
$newEmail->setEmail("benjamin.eberlei@googlemail.com");
|
||||||
|
|
||||||
|
$this->_em->flush();
|
||||||
|
|
||||||
|
$this->assertFalse($this->_em->contains($email));
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user