1
0
mirror of synced 2025-02-10 17:29:27 +03:00

Add another test to demonstrate the bug doesn't appear if everything is flushed at once.

This commit is contained in:
Darien Hager 2015-09-29 16:59:08 -07:00 committed by Marco Pivetta
parent 6f8a80be79
commit 997000352a
No known key found for this signature in database
GPG Key ID: 4167D3337FD9D629

View File

@ -19,29 +19,64 @@ class DDC2922Test extends \Doctrine\Tests\OrmFunctionalTestCase
} }
/** /**
* Unlike next test, this one demonstrates that the problem does
* not necessarily reproduce if all the pieces are being flushed together.
*
* @group DDC-2922 * @group DDC-2922
*/ */
public function testNewAssociatedEntityWorksWithJustOnePath() public function testNewAssociatedEntityWorksWithJustOnePathIfAllPartsNew()
{ {
/**
* 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 = new CmsUser();
$user->username = "beberlei"; $user->username = "beberlei";
$user->name = "Benjamin E."; $user->name = "Benjamin E.";
$user->status = 'active'; $user->status = 'active';
$mail->user = $user; $email = new CmsEmail();
$email->email = "nobody@example.com";
$email->user = $user;
$address = new CmsAddress();
$address->city = "Bonn";
$address->zip = "12354";
$address->country = "Germany";
$address->street = "somestreet";
$address->user = $user;
$this->_em->persist($email);
$this->_em->persist($address);
$this->_em->flush();
}
/**
* This test exhibits the bug describe in the ticket, where an object that
* ought to be reachable causes errors.
*
* @group DDC-2922
*/
public function testNewAssociatedEntityWorksWithJustOnePath()
{
/**
* First we persist and flush an e-mail with no user. Having the
* "cascading path" involve a non-new object seems to be important to
* reproducing the bug.
*/
$email = new CmsEmail();
$email->email = "nobody@example.com";
$email->user = null;
$this->_em->persist($email);
$this->_em->flush(); // Flush before introducing CmsUser
$user = new CmsUser();
$user->username = "beberlei";
$user->name = "Benjamin E.";
$user->status = 'active';
$email->user = $user;
/** /**
* Note that we have NOT directly persisted the CmsUser, and CmsAddress * Note that we have NOT directly persisted the CmsUser, and CmsAddress
@ -66,7 +101,5 @@ class DDC2922Test extends \Doctrine\Tests\OrmFunctionalTestCase
} }
throw $e; throw $e;
} }
} }
} }