Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'DDC-1189'

  • Loading branch information...
commit 6f8ac212737025d1964bc4774e02abe514c479f5 2 parents 7810f5f + 82f0c24
@beberlei beberlei authored
View
1  lib/Doctrine/ORM/PersistentCollection.php
@@ -572,6 +572,7 @@ public function clear()
}
}
$this->coll->clear();
+ $this->initialized = true; // direct call, {@link initialize()} is too expensive
if ($this->association['isOwningSide']) {
$this->changed();
$this->em->getUnitOfWork()->scheduleCollectionDeletion($this);
View
30 tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php
@@ -827,36 +827,6 @@ public function testOneToOneOrphanRemoval()
$this->assertEquals(0, $this->_em->getConnection()->fetchColumn("select count(*) from cms_addresses where id=".$addressId.""));
}
- public function testClearingCollectionDoesNotInitialize()
- {
- $user = new CmsUser();
- $user->username = "beberlei";
- $user->name = "Benjamin E.";
- $user->status = 'active';
-
- $grp = new CmsGroup();
- $grp->setName("The Dudes");
-
- $grp->addUser($user);
- $user->addGroup($grp);
-
- $this->_em->persist($user);
- $this->_em->persist($grp);
- $this->_em->flush();
- $this->_em->clear();
-
- $this->assertEquals(1, $this->_em->getConnection()->fetchColumn("select count(*) from cms_users_groups"));
-
- $user2 = $this->_em->find(get_class($user), $user->id);
- $this->assertFalse($user2->groups->isInitialized());
- $user2->groups->clear();
- $this->assertFalse($user2->groups->isInitialized());
- $this->_em->flush();
- $this->assertFalse($user2->groups->isInitialized());
-
- $this->assertEquals(0, $this->_em->getConnection()->fetchColumn("select count(*) from cms_users_groups"));
- }
-
public function testGetPartialReferenceToUpdateObjectWithoutLoadingIt()
{
//$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
View
20 tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php
@@ -357,4 +357,24 @@ public function testInitializePersistentCollection()
$this->_em->getUnitOfWork()->initializeObject($user->groups);
$this->assertTrue($user->groups->isInitialized(), "Collection should be initialized after calling UnitOfWork::initializeObject()");
}
+
+ /**
+ * @group DDC-1189
+ * @group DDC-956
+ */
+ public function testClearBeforeLazyLoad()
+ {
+ $user = $this->addCmsUserGblancoWithGroups(4);
+
+ $this->_em->clear();
+
+ $user = $this->_em->find(get_class($user), $user->id);
+ $user->groups->clear();
+ $this->assertEquals(0, count($user->groups));
+
+ $this->_em->flush();
+
+ $user = $this->_em->find(get_class($user), $user->id);
+ $this->assertEquals(0, count($user->groups));
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.