Fix tests by forcing collection initialization
This commit is contained in:
parent
172df22281
commit
92a2b01c77
@ -394,14 +394,14 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
public function testFindOneByOrderBy()
|
||||
{
|
||||
$this->loadFixture();
|
||||
|
||||
|
||||
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
|
||||
$userAsc = $repos->findOneBy(array(), array("username" => "ASC"));
|
||||
$userDesc = $repos->findOneBy(array(), array("username" => "DESC"));
|
||||
|
||||
|
||||
$this->assertNotSame($userAsc, $userDesc);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @group DDC-817
|
||||
*/
|
||||
@ -613,7 +613,7 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
|
||||
/**
|
||||
* @group DDC-1376
|
||||
*
|
||||
*
|
||||
* @expectedException Doctrine\ORM\ORMException
|
||||
* @expectedExceptionMessage You cannot search for the association field 'Doctrine\Tests\Models\CMS\CmsUser#address', because it is the inverse side of an association.
|
||||
*/
|
||||
@ -913,9 +913,12 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$this->setExpectedException('Doctrine\ORM\ORMException', 'Unrecognized field: ');
|
||||
|
||||
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
|
||||
$repository->matching(new Criteria(
|
||||
$result = $repository->matching(new Criteria(
|
||||
Criteria::expr()->eq('username = ?; DELETE FROM cms_users; SELECT 1 WHERE 1', 'beberlei')
|
||||
));
|
||||
|
||||
// Because repository returns a lazy collection, we call toArray to force initialization
|
||||
$result->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -28,6 +28,9 @@ class SecondLevelCacheCriteriaTest extends SecondLevelCacheAbstractTest
|
||||
Criteria::expr()->eq('name', $name)
|
||||
));
|
||||
|
||||
// Because matching returns lazy collection, we force initialization
|
||||
$result1->toArray();
|
||||
|
||||
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
|
||||
$this->assertEquals($this->countries[0]->getId(), $result1[0]->getId());
|
||||
$this->assertEquals($this->countries[0]->getName(), $result1[0]->getName());
|
||||
@ -64,6 +67,9 @@ class SecondLevelCacheCriteriaTest extends SecondLevelCacheAbstractTest
|
||||
Criteria::expr()->eq('name', $this->countries[0]->getName())
|
||||
));
|
||||
|
||||
// Because matching returns lazy collection, we force initialization
|
||||
$result1->toArray();
|
||||
|
||||
$this->assertCount(1, $result1);
|
||||
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
|
||||
$this->assertEquals($this->countries[0]->getId(), $result1[0]->getId());
|
||||
@ -75,6 +81,9 @@ class SecondLevelCacheCriteriaTest extends SecondLevelCacheAbstractTest
|
||||
Criteria::expr()->eq('name', $this->countries[0]->getName())
|
||||
));
|
||||
|
||||
// Because matching returns lazy collection, we force initialization
|
||||
$result2->toArray();
|
||||
|
||||
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
|
||||
$this->assertCount(1, $result2);
|
||||
|
||||
@ -87,6 +96,9 @@ class SecondLevelCacheCriteriaTest extends SecondLevelCacheAbstractTest
|
||||
Criteria::expr()->eq('name', $this->countries[1]->getName())
|
||||
));
|
||||
|
||||
// Because matching returns lazy collection, we force initialization
|
||||
$result3->toArray();
|
||||
|
||||
$this->assertEquals($queryCount + 2, $this->getCurrentQueryCount());
|
||||
$this->assertCount(1, $result3);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user