From 546bb53ef981d66881ec13970bd440ca074d0d71 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 17 May 2014 18:51:33 +0200 Subject: [PATCH] Verifying that count on the lazy criteria collection is cached even with `0` count --- tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php b/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php index 93cdc01d5..2d5209cf4 100644 --- a/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php @@ -47,4 +47,13 @@ class LazyCriteriaCollectionTest extends PHPUnit_Framework_TestCase $this->assertSame(10, $this->lazyCriteriaCollection->count()); $this->assertSame(10, $this->lazyCriteriaCollection->count()); } + + public function testCountIsCachedEvenWithZeroResult() + { + $this->persister->expects($this->once())->method('count')->with($this->criteria)->will($this->returnValue(0)); + + $this->assertSame(0, $this->lazyCriteriaCollection->count()); + $this->assertSame(0, $this->lazyCriteriaCollection->count()); + $this->assertSame(0, $this->lazyCriteriaCollection->count()); + } }