Move failing unit test into ticket-specific case
This commit is contained in:
parent
c4465abaa0
commit
6f8a80be79
@ -9,7 +9,6 @@ use Doctrine\ORM\ORMInvalidArgumentException;
|
|||||||
use Doctrine\ORM\PersistentCollection;
|
use Doctrine\ORM\PersistentCollection;
|
||||||
use Doctrine\ORM\Proxy\Proxy;
|
use Doctrine\ORM\Proxy\Proxy;
|
||||||
use Doctrine\ORM\Query;
|
use Doctrine\ORM\Query;
|
||||||
use Doctrine\Tests\Models\CMS\CmsEmail;
|
|
||||||
use Doctrine\ORM\UnitOfWork;
|
use Doctrine\ORM\UnitOfWork;
|
||||||
use Doctrine\Tests\Models\CMS\CmsAddress;
|
use Doctrine\Tests\Models\CMS\CmsAddress;
|
||||||
use Doctrine\Tests\Models\CMS\CmsArticle;
|
use Doctrine\Tests\Models\CMS\CmsArticle;
|
||||||
@ -802,50 +801,6 @@ class BasicFunctionalTest extends OrmFunctionalTestCase
|
|||||||
$this->_em->flush();
|
$this->_em->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @group DDC-2922
|
|
||||||
*/
|
|
||||||
public function testNewAssociatedEntityWorksWithJustOnePath()
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* First we persist and flush an e-mail with no user. This seems
|
|
||||||
* Save an un-owned email with no user. This seems to
|
|
||||||
* matter for reproducing the bug
|
|
||||||
*/
|
|
||||||
$mail = new CmsEmail();
|
|
||||||
$mail->email = "nobody@example.com";
|
|
||||||
$mail->user = null;
|
|
||||||
|
|
||||||
$this->_em->persist($mail);
|
|
||||||
$this->_em->flush();
|
|
||||||
|
|
||||||
$user = new CmsUser();
|
|
||||||
$user->username = "beberlei";
|
|
||||||
$user->name = "Benjamin E.";
|
|
||||||
$user->status = 'active';
|
|
||||||
|
|
||||||
$mail->user = $user;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Note that we have NOT directly persisted the CmsUser, and CmsAddress
|
|
||||||
* does NOT have cascade-persist.
|
|
||||||
*
|
|
||||||
* However, CmsEmail *does* have a cascade-persist, which ought to
|
|
||||||
* allow us to save the CmsUser anyway through that connection.
|
|
||||||
*/
|
|
||||||
$address = new CmsAddress();
|
|
||||||
$address->city = "Bonn";
|
|
||||||
$address->zip = "12354";
|
|
||||||
$address->country = "Germany";
|
|
||||||
$address->street = "somestreet";
|
|
||||||
$address->user = $user;
|
|
||||||
|
|
||||||
$this->_em->persist($address);
|
|
||||||
$this->_em->flush();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testOneToOneOrphanRemoval()
|
public function testOneToOneOrphanRemoval()
|
||||||
{
|
{
|
||||||
$user = new CmsUser();
|
$user = new CmsUser();
|
||||||
|
72
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2922Test.php
Normal file
72
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2922Test.php
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
||||||
|
|
||||||
|
|
||||||
|
use Doctrine\ORM\ORMInvalidArgumentException;
|
||||||
|
use Doctrine\Tests\Models\CMS\CmsAddress;
|
||||||
|
use Doctrine\Tests\Models\CMS\CmsEmail;
|
||||||
|
use Doctrine\Tests\Models\CMS\CmsUser;
|
||||||
|
|
||||||
|
class DDC2922Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
$this->useModelSet('cms');
|
||||||
|
parent::setUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group DDC-2922
|
||||||
|
*/
|
||||||
|
public function testNewAssociatedEntityWorksWithJustOnePath()
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* First we persist and flush an e-mail with no user. This seems
|
||||||
|
* Save an un-owned email with no user. This seems to
|
||||||
|
* matter for reproducing the bug
|
||||||
|
*/
|
||||||
|
$mail = new CmsEmail();
|
||||||
|
$mail->email = "nobody@example.com";
|
||||||
|
$mail->user = null;
|
||||||
|
|
||||||
|
$this->_em->persist($mail);
|
||||||
|
$this->_em->flush();
|
||||||
|
|
||||||
|
$user = new CmsUser();
|
||||||
|
$user->username = "beberlei";
|
||||||
|
$user->name = "Benjamin E.";
|
||||||
|
$user->status = 'active';
|
||||||
|
|
||||||
|
$mail->user = $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Note that we have NOT directly persisted the CmsUser, and CmsAddress
|
||||||
|
* does NOT have cascade-persist.
|
||||||
|
*
|
||||||
|
* However, CmsEmail *does* have a cascade-persist, which ought to
|
||||||
|
* allow us to save the CmsUser anyway through that connection.
|
||||||
|
*/
|
||||||
|
$address = new CmsAddress();
|
||||||
|
$address->city = "Bonn";
|
||||||
|
$address->zip = "12354";
|
||||||
|
$address->country = "Germany";
|
||||||
|
$address->street = "somestreet";
|
||||||
|
$address->user = $user;
|
||||||
|
|
||||||
|
$this->_em->persist($address);
|
||||||
|
try{
|
||||||
|
$this->_em->flush();
|
||||||
|
}catch(ORMInvalidArgumentException $e){
|
||||||
|
if(strpos($e->getMessage(),'not configured to cascade persist operations') !== FALSE) {
|
||||||
|
$this->fail($e);
|
||||||
|
}
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user