1
0
mirror of synced 2025-02-03 05:49:25 +03:00

add Unit Test for isEmpty change in LazyCriteriaCollection

This commit is contained in:
Oliver Tischlinger 2015-09-24 11:39:14 +02:00
parent 3e26330c53
commit 03523c67d5

View File

@ -103,4 +103,28 @@ class LazyCriteriaCollectionTest extends PHPUnit_Framework_TestCase
$this->assertEquals(array($foo), $this->lazyCriteriaCollection->matching($criteria)->toArray()); $this->assertEquals(array($foo), $this->lazyCriteriaCollection->matching($criteria)->toArray());
} }
public function testIsEmptyUsesCountWhenNotInitialized()
{
$this->persister->expects($this->once())->method('count')->with($this->criteria)->will($this->returnValue(0));
$this->assertTrue($this->lazyCriteriaCollection->isEmpty());
}
public function testIsEmptyUsesWrappedCollectionWhenInitialized()
{
$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->assertFalse($this->lazyCriteriaCollection->isEmpty());
}
} }