From a3208f8d086d37fc9c6f2de8b10a8b4bc9c1a929 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Mon, 21 Aug 2017 19:47:16 +0200 Subject: [PATCH] #1521 DDC-2922 removed unrelated model usage from test - using minimal models only --- .../ORM/Functional/Ticket/DDC2922Test.php | 107 +----------------- 1 file changed, 4 insertions(+), 103 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2922Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2922Test.php index 6598be42e..b1aa6c0da 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2922Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2922Test.php @@ -4,17 +4,13 @@ declare(strict_types=1); namespace Doctrine\Tests\ORM\Functional\Ticket; use Doctrine\ORM\Mapping\ClassMetadata; -use Doctrine\ORM\ORMInvalidArgumentException; use Doctrine\ORM\Tools\ToolsException; -use Doctrine\Tests\Models\CMS\CmsAddress; -use Doctrine\Tests\Models\CMS\CmsEmail; -use Doctrine\Tests\Models\CMS\CmsUser; +use Doctrine\Tests\OrmFunctionalTestCase; -class DDC2922Test extends \Doctrine\Tests\OrmFunctionalTestCase +class DDC2922Test extends OrmFunctionalTestCase { - protected function setUp() + protected function setUp() : void { - $this->useModelSet('cms'); parent::setUp(); try { @@ -28,103 +24,8 @@ class DDC2922Test extends \Doctrine\Tests\OrmFunctionalTestCase DDC2922EntityWithNonCascadingAssociation::class, ] )); - } catch (ToolsException $ignored) {} - } - - /** - * Unlike next test, this one demonstrates that the problem does - * not necessarily reproduce if all the pieces are being flushed together. - * - * @group DDC-2922 - */ - public function testNewAssociatedEntityWorksWithJustOnePathIfAllPartsNew() - { - - $user = new CmsUser(); - $user->username = "beberlei"; - $user->name = "Benjamin E."; - $user->status = 'active'; - - $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(); - - // Verify the flush succeeded - $this->assertEquals($email, $this->_em->find(get_class($email),$email->id)); - $this->assertEquals($address, $this->_em->find(get_class($address),$address->id)); - $this->assertEquals($user, $this->_em->find(get_class($user),$user->id)); - - } - - /** - * 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() - { - self::markTestSkipped(); - /** - * 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 - * 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; + } catch (ToolsException $ignored) { } - - // Verify the flushes succeeded - $this->assertEquals($email, $this->_em->find(get_class($email),$email->id)); - $this->assertEquals($address, $this->_em->find(get_class($address),$address->id)); - $this->assertEquals($user, $this->_em->find(get_class($user),$user->id)); - } /**