22
33namespace MongoDB \Tests \Collection ;
44
5- use MongoDB \Tests \FixtureGenerator ;
6-
75/**
86 * Functional tests for the Collection class.
97 */
@@ -18,34 +16,4 @@ public function testDrop()
1816 $ this ->assertCommandSucceeded ($ commandResult );
1917 $ this ->assertCollectionCount ($ this ->getNamespace (), 0 );
2018 }
21-
22- function testInsertAndRetrieve ()
23- {
24- $ generator = new FixtureGenerator ();
25-
26- for ($ i = 0 ; $ i < 10 ; $ i ++) {
27- $ user = $ generator ->createUser ();
28- $ result = $ this ->collection ->insertOne ($ user );
29- $ this ->assertInstanceOf ('MongoDB\InsertOneResult ' , $ result );
30- $ this ->assertInstanceOf ('BSON\ObjectId ' , $ result ->getInsertedId ());
31- $ this ->assertEquals (24 , strlen ($ result ->getInsertedId ()));
32-
33- $ user ["_id " ] = $ result ->getInsertedId ();
34- $ document = $ this ->collection ->findOne (array ("_id " => $ result ->getInsertedId ()));
35- $ this ->assertEquals ($ document , $ user , "The inserted and returned objects are the same " );
36- }
37-
38- $ this ->assertEquals (10 , $ i );
39-
40- $ query = array ("firstName " => "Ransom " );
41- $ count = $ this ->collection ->count ($ query );
42- $ this ->assertEquals (1 , $ count );
43- $ cursor = $ this ->collection ->find ($ query );
44- $ this ->assertInstanceOf ('MongoDB\Driver\Cursor ' , $ cursor );
45-
46- foreach ($ cursor as $ n => $ person ) {
47- $ this ->assertInternalType ("array " , $ person );
48- }
49- $ this ->assertEquals (0 , $ n );
50- }
5119}
0 commit comments