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());
 }
 public function testInvokeExists()
 {
     $entity = new Country("Foo");
     $persister = $this->createPersisterDefault();
     $this->entityPersister->expects($this->once())->method('exists')->with($this->equalTo($entity), $this->equalTo(null));
     $this->assertNull($persister->exists($entity));
 }