Verifying that the persister is used only once when matching on a lazy criteria collection
This commit is contained in:
parent
d2174a893a
commit
c68ed4c204
@ -5,6 +5,7 @@ namespace Doctrine\Tests\ORM;
|
||||
use Doctrine\Common\Collections\Criteria;
|
||||
use Doctrine\ORM\LazyCriteriaCollection;
|
||||
use Doctrine\Tests\Mocks\ConnectionMock;
|
||||
use stdClass;
|
||||
use PHPUnit_Framework_TestCase;
|
||||
|
||||
/**
|
||||
@ -73,4 +74,33 @@ class LazyCriteriaCollectionTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
$this->assertSame(3, $this->lazyCriteriaCollection->count());
|
||||
}
|
||||
|
||||
public function testMatchingUsesThePersisterOnlyOnce()
|
||||
{
|
||||
$foo = new stdClass();
|
||||
$bar = new stdClass();
|
||||
$baz = new stdClass();
|
||||
|
||||
$foo->val = 'foo';
|
||||
$bar->val = 'bar';
|
||||
$baz->val = 'baz';
|
||||
|
||||
$this
|
||||
->persister
|
||||
->expects($this->once())
|
||||
->method('loadCriteria')
|
||||
->with($this->criteria)
|
||||
->will($this->returnValue(array($foo, $bar, $baz)));
|
||||
|
||||
$criteria = new Criteria();
|
||||
|
||||
$criteria->andWhere($criteria->expr()->eq('val', 'foo'));
|
||||
|
||||
$filtered = $this->lazyCriteriaCollection->matching($criteria);
|
||||
|
||||
$this->assertInstanceOf('Doctrine\Common\Collections\Collection', $filtered);
|
||||
$this->assertEquals(array($foo), $filtered->toArray());
|
||||
|
||||
$this->assertEquals(array($foo), $this->lazyCriteriaCollection->matching($criteria)->toArray());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user