33namespace MongoDB \Tests ;
44
55use MongoDB \Client ;
6+ use MongoDB \Driver \ReadConcern ;
67use MongoDB \Driver \ReadPreference ;
78use MongoDB \Driver \WriteConcern ;
89
@@ -25,26 +26,32 @@ public function testToString()
2526 $ this ->assertSame ($ this ->getUri (), (string ) $ client );
2627 }
2728
28- public function testSelectCollectionInheritsReadPreferenceAndWriteConcern ()
29+ public function testSelectCollectionInheritsOptions ()
2930 {
30- $ clientOptions = [
31+ $ this ->markTestSkipped ('Depends on https://jira.mongodb.org/browse/PHPC-523 ' );
32+
33+ $ uriOptions = [
34+ 'readConcernLevel ' => ReadConcern::LOCAL ,
3135 'readPreference ' => 'secondaryPreferred ' ,
3236 'w ' => WriteConcern::MAJORITY ,
3337 ];
3438
35- $ client = new Client ($ this ->getUri (), $ clientOptions );
39+ $ client = new Client ($ this ->getUri (), $ uriOptions );
3640 $ collection = $ client ->selectCollection ($ this ->getDatabaseName (), $ this ->getCollectionName ());
3741 $ debug = $ collection ->__debugInfo ();
3842
43+ $ this ->assertInstanceOf ('MongoDB\Driver\ReadConcern ' , $ debug ['readConcern ' ]);
44+ $ this ->assertSame (ReadConcern::LOCAL , $ debug ['readConcern ' ]->getLevel ());
3945 $ this ->assertInstanceOf ('MongoDB\Driver\ReadPreference ' , $ debug ['readPreference ' ]);
4046 $ this ->assertSame (ReadPreference::RP_SECONDARY_PREFERRED , $ debug ['readPreference ' ]->getMode ());
4147 $ this ->assertInstanceOf ('MongoDB\Driver\WriteConcern ' , $ debug ['writeConcern ' ]);
4248 $ this ->assertSame (WriteConcern::MAJORITY , $ debug ['writeConcern ' ]->getW ());
4349 }
4450
45- public function testSelectCollectionPassesReadPreferenceAndWriteConcern ()
51+ public function testSelectCollectionPassesOptions ()
4652 {
4753 $ collectionOptions = [
54+ 'readConcern ' => new ReadConcern (ReadConcern::LOCAL ),
4855 'readPreference ' => new ReadPreference (ReadPreference::RP_SECONDARY_PREFERRED ),
4956 'writeConcern ' => new WriteConcern (WriteConcern::MAJORITY ),
5057 ];
@@ -53,32 +60,40 @@ public function testSelectCollectionPassesReadPreferenceAndWriteConcern()
5360 $ collection = $ client ->selectCollection ($ this ->getDatabaseName (), $ this ->getCollectionName (), $ collectionOptions );
5461 $ debug = $ collection ->__debugInfo ();
5562
63+ $ this ->assertInstanceOf ('MongoDB\Driver\ReadConcern ' , $ debug ['readConcern ' ]);
64+ $ this ->assertSame (ReadConcern::LOCAL , $ debug ['readConcern ' ]->getLevel ());
5665 $ this ->assertInstanceOf ('MongoDB\Driver\ReadPreference ' , $ debug ['readPreference ' ]);
5766 $ this ->assertSame (ReadPreference::RP_SECONDARY_PREFERRED , $ debug ['readPreference ' ]->getMode ());
5867 $ this ->assertInstanceOf ('MongoDB\Driver\WriteConcern ' , $ debug ['writeConcern ' ]);
5968 $ this ->assertSame (WriteConcern::MAJORITY , $ debug ['writeConcern ' ]->getW ());
6069 }
6170
62- public function testSelectDatabaseInheritsReadPreferenceAndWriteConcern ()
71+ public function testSelectDatabaseInheritsOptions ()
6372 {
64- $ clientOptions = [
73+ $ this ->markTestSkipped ('Depends on https://jira.mongodb.org/browse/PHPC-523 ' );
74+
75+ $ uriOptions = [
76+ 'readConcernLevel ' => ReadConcern::LOCAL ,
6577 'readPreference ' => 'secondaryPreferred ' ,
6678 'w ' => WriteConcern::MAJORITY ,
6779 ];
6880
69- $ client = new Client ($ this ->getUri (), $ clientOptions );
81+ $ client = new Client ($ this ->getUri (), $ uriOptions );
7082 $ database = $ client ->selectDatabase ($ this ->getDatabaseName ());
7183 $ debug = $ database ->__debugInfo ();
7284
85+ $ this ->assertInstanceOf ('MongoDB\Driver\ReadConcern ' , $ debug ['readConcern ' ]);
86+ $ this ->assertSame (ReadConcern::LOCAL , $ debug ['readConcern ' ]->getLevel ());
7387 $ this ->assertInstanceOf ('MongoDB\Driver\ReadPreference ' , $ debug ['readPreference ' ]);
7488 $ this ->assertSame (ReadPreference::RP_SECONDARY_PREFERRED , $ debug ['readPreference ' ]->getMode ());
7589 $ this ->assertInstanceOf ('MongoDB\Driver\WriteConcern ' , $ debug ['writeConcern ' ]);
7690 $ this ->assertSame (WriteConcern::MAJORITY , $ debug ['writeConcern ' ]->getW ());
7791 }
7892
79- public function testSelectDatabasePassesReadPreferenceAndWriteConcern ()
93+ public function testSelectDatabasePassesOptions ()
8094 {
8195 $ databaseOptions = [
96+ 'readConcern ' => new ReadConcern (ReadConcern::LOCAL ),
8297 'readPreference ' => new ReadPreference (ReadPreference::RP_SECONDARY_PREFERRED ),
8398 'writeConcern ' => new WriteConcern (WriteConcern::MAJORITY ),
8499 ];
@@ -87,6 +102,8 @@ public function testSelectDatabasePassesReadPreferenceAndWriteConcern()
87102 $ database = $ client ->selectDatabase ($ this ->getDatabaseName (), $ databaseOptions );
88103 $ debug = $ database ->__debugInfo ();
89104
105+ $ this ->assertInstanceOf ('MongoDB\Driver\ReadConcern ' , $ debug ['readConcern ' ]);
106+ $ this ->assertSame (ReadConcern::LOCAL , $ debug ['readConcern ' ]->getLevel ());
90107 $ this ->assertInstanceOf ('MongoDB\Driver\ReadPreference ' , $ debug ['readPreference ' ]);
91108 $ this ->assertSame (ReadPreference::RP_SECONDARY_PREFERRED , $ debug ['readPreference ' ]->getMode ());
92109 $ this ->assertInstanceOf ('MongoDB\Driver\WriteConcern ' , $ debug ['writeConcern ' ]);
0 commit comments