From c571f6f6a9b5f42df783bb217d303dddfd4714b0 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Wed, 14 Jan 2015 14:36:01 +0100 Subject: [PATCH] Correctly dealing with emulated cascades in `ExtraLazyCollectionTest` --- .../Functional/ExtraLazyCollectionTest.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php b/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php index e724517e8..4a762ae66 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php @@ -523,8 +523,16 @@ class ExtraLazyCollectionTest extends \Doctrine\Tests\OrmFunctionalTestCase $otherClass->childClasses->removeElement($childClass); $this->assertFalse($otherClass->childClasses->isInitialized(), 'Collection is not initialized.'); + + $expectedQueryCount = $queryCount + 1; + + if (! $this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) { + // the ORM emulates cascades in a JTI if the underlying platform does not support them + $expectedQueryCount = $queryCount + 2; + }; + $this->assertEquals( - $queryCount + 2, + $expectedQueryCount, $this->getCurrentQueryCount(), 'One removal per table in the JTI has been executed' ); @@ -585,8 +593,15 @@ class ExtraLazyCollectionTest extends \Doctrine\Tests\OrmFunctionalTestCase $otherClass->childClasses->removeElement($childClass); + $expectedQueryCount = $queryCount + 1; + + if (! $this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) { + // the ORM emulates cascades in a JTI if the underlying platform does not support them + $expectedQueryCount = $queryCount + 2; + }; + $this->assertEquals( - $queryCount + 2, + $expectedQueryCount, $this->getCurrentQueryCount(), 'Removing a persisted entity should cause two queries to be executed.' );