Merge branch 'DDC-1399'
This commit is contained in:
commit
3b819b52ca
@ -468,7 +468,7 @@ final class PersistentCollection implements Collection
|
|||||||
if (!$this->initialized && $this->association['fetch'] == Mapping\ClassMetadataInfo::FETCH_EXTRA_LAZY) {
|
if (!$this->initialized && $this->association['fetch'] == Mapping\ClassMetadataInfo::FETCH_EXTRA_LAZY) {
|
||||||
return $this->em->getUnitOfWork()
|
return $this->em->getUnitOfWork()
|
||||||
->getCollectionPersister($this->association)
|
->getCollectionPersister($this->association)
|
||||||
->count($this) + $this->coll->count();
|
->count($this) + ($this->isDirty ? $this->coll->count() : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->initialize();
|
$this->initialize();
|
||||||
|
@ -304,6 +304,28 @@ class ExtraLazyCollectionTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
|||||||
$this->assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized.");
|
$this->assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group DDC-1399
|
||||||
|
*/
|
||||||
|
public function testCountAfterAddThenFlush()
|
||||||
|
{
|
||||||
|
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId);
|
||||||
|
|
||||||
|
$newGroup = new \Doctrine\Tests\Models\CMS\CmsGroup();
|
||||||
|
$newGroup->name = "Test4";
|
||||||
|
|
||||||
|
$user->addGroup($newGroup);
|
||||||
|
$this->_em->persist($newGroup);
|
||||||
|
|
||||||
|
$this->assertFalse($user->groups->isInitialized());
|
||||||
|
$this->assertEquals(4, count($user->groups));
|
||||||
|
$this->assertFalse($user->groups->isInitialized());
|
||||||
|
|
||||||
|
$this->_em->flush();
|
||||||
|
|
||||||
|
$this->assertEquals(4, count($user->groups));
|
||||||
|
}
|
||||||
|
|
||||||
private function loadFixture()
|
private function loadFixture()
|
||||||
{
|
{
|
||||||
$user1 = new \Doctrine\Tests\Models\CMS\CmsUser();
|
$user1 = new \Doctrine\Tests\Models\CMS\CmsUser();
|
||||||
|
Loading…
Reference in New Issue
Block a user