From c46b63f6b4ae294794f129566bc273da502ed127 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 17 May 2014 18:51:01 +0200 Subject: [PATCH] Verifying that count on the lazy criteria collection is cached --- .../Tests/ORM/LazyCriteriaCollectionTest.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php b/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php index 59fd543f6..93cdc01d5 100644 --- a/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php @@ -34,8 +34,17 @@ class LazyCriteriaCollectionTest extends PHPUnit_Framework_TestCase */ protected function setUp() { - $this->persister = $this->getMock('Doctrine\ORM\Persisters\EntityPersister'); - $this->criteria = new Criteria(); - $this->$lazyCriteriaCollection = new LazyCriteriaCollection($this->persister, $this->criteria); + $this->persister = $this->getMock('Doctrine\ORM\Persisters\EntityPersister'); + $this->criteria = new Criteria(); + $this->lazyCriteriaCollection = new LazyCriteriaCollection($this->persister, $this->criteria); + } + + public function testCountIsCached() + { + $this->persister->expects($this->once())->method('count')->with($this->criteria)->will($this->returnValue(10)); + + $this->assertSame(10, $this->lazyCriteriaCollection->count()); + $this->assertSame(10, $this->lazyCriteriaCollection->count()); + $this->assertSame(10, $this->lazyCriteriaCollection->count()); } }