From 4b3ecfe67468085a8c30df3dc85444eff64bed9c Mon Sep 17 00:00:00 2001 From: Stefano Rodriguez Date: Fri, 7 Sep 2012 10:42:40 +0200 Subject: [PATCH] Added a failing test case on PersistentCollection::matching() when collection is not initialized and there are NEW entities in the collection --- .../OneToManyBidirectionalAssociationTest.php | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php index cea80fd6bc..0efe76fdf7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php @@ -173,6 +173,30 @@ public function testMatching() $this->assertInstanceOf('Doctrine\Common\Collections\Collection', $results); $this->assertEquals(2, count($results)); } + + public function testMatchingBis() + { + $this->_createFixture(); + + $product = $this->_em->find('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $this->product->getId()); + $features = $product->getFeatures(); + + $thirdFeature = new ECommerceFeature(); + $thirdFeature->setDescription('Third feature'); + $product->addFeature($thirdFeature); + + $results = $features->matching(new Criteria( + Criteria::expr()->eq('description', 'Third feature') + )); + + $this->assertInstanceOf('Doctrine\Common\Collections\Collection', $results); + $this->assertEquals(1, count($results)); + + $results = $features->matching(new Criteria()); + + $this->assertInstanceOf('Doctrine\Common\Collections\Collection', $results); + $this->assertEquals(3, count($results)); + } private function _createFixture() {