Merge branch 'DDC-839'
This commit is contained in:
commit
6006979fc6
@ -335,6 +335,7 @@ class ObjectHydrator extends AbstractHydrator
|
|||||||
}
|
}
|
||||||
} else if ( ! $reflField->getValue($parentObject)) {
|
} else if ( ! $reflField->getValue($parentObject)) {
|
||||||
$coll = new PersistentCollection($this->_em, $this->_ce[$entityName], new ArrayCollection);
|
$coll = new PersistentCollection($this->_em, $this->_ce[$entityName], new ArrayCollection);
|
||||||
|
$coll->setOwner($parentObject, $relation);
|
||||||
$reflField->setValue($parentObject, $coll);
|
$reflField->setValue($parentObject, $coll);
|
||||||
$this->_uow->setOriginalEntityProperty($oid, $relationField, $coll);
|
$this->_uow->setOriginalEntityProperty($oid, $relationField, $coll);
|
||||||
}
|
}
|
||||||
|
@ -247,6 +247,34 @@ class ManyToManyBasicAssociationTest extends \Doctrine\Tests\OrmFunctionalTestCa
|
|||||||
$this->assertEquals(0, count($newUser->getGroups()));
|
$this->assertEquals(0, count($newUser->getGroups()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group DDC-839
|
||||||
|
*/
|
||||||
|
public function testWorkWithDqlHydratedEmptyCollection()
|
||||||
|
{
|
||||||
|
$user = $this->addCmsUserGblancoWithGroups(0);
|
||||||
|
$group = new CmsGroup();
|
||||||
|
$group->name = "Developers0";
|
||||||
|
$this->_em->persist($group);
|
||||||
|
|
||||||
|
$this->_em->flush();
|
||||||
|
$this->_em->clear();
|
||||||
|
|
||||||
|
$newUser = $this->_em->createQuery('SELECT u, g FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.groups g WHERE u.id = ?1')
|
||||||
|
->setParameter(1, $user->getId())
|
||||||
|
->getSingleResult();
|
||||||
|
$this->assertEquals(0, count($newUser->groups));
|
||||||
|
$this->assertType('array', $newUser->groups->getMapping());
|
||||||
|
|
||||||
|
$newUser->addGroup($group);
|
||||||
|
|
||||||
|
$this->_em->flush();
|
||||||
|
$this->_em->clear();
|
||||||
|
|
||||||
|
$newUser = $this->_em->find(get_class($user), $user->getId());
|
||||||
|
$this->assertEquals(1, count($newUser->groups));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $groupCount
|
* @param int $groupCount
|
||||||
* @return CmsUser
|
* @return CmsUser
|
||||||
|
Loading…
Reference in New Issue
Block a user