@@ -71,8 +71,8 @@ public function testDropCollection()
71
71
72
72
public function testListCollections ()
73
73
{
74
- $ writeResult = $ this ->manager -> executeInsert ($ this ->getNamespace (), array ( ' x ' => 1 ));
75
- $ this ->assertEquals ( 1 , $ writeResult -> getInsertedCount () );
74
+ $ commandResult = $ this ->database -> createCollection ($ this ->getCollectionName ( ));
75
+ $ this ->assertCommandSucceeded ( $ commandResult );
76
76
77
77
$ collections = $ this ->database ->listCollections ();
78
78
$ this ->assertInstanceOf ('MongoDB\Model\CollectionInfoIterator ' , $ collections );
@@ -82,6 +82,24 @@ public function testListCollections()
82
82
}
83
83
}
84
84
85
+ public function testListCollectionsWithFilter ()
86
+ {
87
+ $ commandResult = $ this ->database ->createCollection ($ this ->getCollectionName ());
88
+ $ this ->assertCommandSucceeded ($ commandResult );
89
+
90
+ $ collectionName = $ this ->getCollectionName ();
91
+ $ options = array ('filter ' => array ('name ' => $ collectionName ));
92
+
93
+ $ collections = $ this ->database ->listCollections ($ options );
94
+ $ this ->assertInstanceOf ('MongoDB\Model\CollectionInfoIterator ' , $ collections );
95
+ $ this ->assertCount (1 , $ collections );
96
+
97
+ foreach ($ collections as $ collection ) {
98
+ $ this ->assertInstanceOf ('MongoDB\Model\CollectionInfo ' , $ collection );
99
+ $ this ->assertEquals ($ collectionName , $ collection ->getName ());
100
+ }
101
+ }
102
+
85
103
/**
86
104
* Asserts that a collection with the given name exists in the database.
87
105
*
0 commit comments