1
0
mirror of synced 2025-01-19 15:01:40 +03:00

Verifying that count is not called on the persister when the collection is initialized

This commit is contained in:
Marco Pivetta 2014-05-17 18:56:42 +02:00
parent 546bb53ef9
commit d2174a893a

View File

@ -56,4 +56,21 @@ class LazyCriteriaCollectionTest extends PHPUnit_Framework_TestCase
$this->assertSame(0, $this->lazyCriteriaCollection->count());
$this->assertSame(0, $this->lazyCriteriaCollection->count());
}
public function testCountUsesWrappedCollectionWhenInitialized()
{
$this
->persister
->expects($this->once())
->method('loadCriteria')
->with($this->criteria)
->will($this->returnValue(array('foo', 'bar', 'baz')));
// should never call the persister's count
$this->persister->expects($this->never())->method('count');
$this->assertSame(array('foo', 'bar', 'baz'), $this->lazyCriteriaCollection->toArray());
$this->assertSame(3, $this->lazyCriteriaCollection->count());
}
}