3
3
namespace MongoDB \Tests ;
4
4
5
5
use MongoDB \Client ;
6
+ use MongoDB \Driver \ReadConcern ;
6
7
use MongoDB \Driver \ReadPreference ;
7
8
use MongoDB \Driver \WriteConcern ;
8
9
@@ -25,26 +26,32 @@ public function testToString()
25
26
$ this ->assertSame ($ this ->getUri (), (string ) $ client );
26
27
}
27
28
28
- public function testSelectCollectionInheritsReadPreferenceAndWriteConcern ()
29
+ public function testSelectCollectionInheritsOptions ()
29
30
{
30
- $ clientOptions = [
31
+ $ this ->markTestSkipped ('Depends on https://jira.mongodb.org/browse/PHPC-523 ' );
32
+
33
+ $ uriOptions = [
34
+ 'readConcernLevel ' => ReadConcern::LOCAL ,
31
35
'readPreference ' => 'secondaryPreferred ' ,
32
36
'w ' => WriteConcern::MAJORITY ,
33
37
];
34
38
35
- $ client = new Client ($ this ->getUri (), $ clientOptions );
39
+ $ client = new Client ($ this ->getUri (), $ uriOptions );
36
40
$ collection = $ client ->selectCollection ($ this ->getDatabaseName (), $ this ->getCollectionName ());
37
41
$ debug = $ collection ->__debugInfo ();
38
42
43
+ $ this ->assertInstanceOf ('MongoDB\Driver\ReadConcern ' , $ debug ['readConcern ' ]);
44
+ $ this ->assertSame (ReadConcern::LOCAL , $ debug ['readConcern ' ]->getLevel ());
39
45
$ this ->assertInstanceOf ('MongoDB\Driver\ReadPreference ' , $ debug ['readPreference ' ]);
40
46
$ this ->assertSame (ReadPreference::RP_SECONDARY_PREFERRED , $ debug ['readPreference ' ]->getMode ());
41
47
$ this ->assertInstanceOf ('MongoDB\Driver\WriteConcern ' , $ debug ['writeConcern ' ]);
42
48
$ this ->assertSame (WriteConcern::MAJORITY , $ debug ['writeConcern ' ]->getW ());
43
49
}
44
50
45
- public function testSelectCollectionPassesReadPreferenceAndWriteConcern ()
51
+ public function testSelectCollectionPassesOptions ()
46
52
{
47
53
$ collectionOptions = [
54
+ 'readConcern ' => new ReadConcern (ReadConcern::LOCAL ),
48
55
'readPreference ' => new ReadPreference (ReadPreference::RP_SECONDARY_PREFERRED ),
49
56
'writeConcern ' => new WriteConcern (WriteConcern::MAJORITY ),
50
57
];
@@ -53,32 +60,40 @@ public function testSelectCollectionPassesReadPreferenceAndWriteConcern()
53
60
$ collection = $ client ->selectCollection ($ this ->getDatabaseName (), $ this ->getCollectionName (), $ collectionOptions );
54
61
$ debug = $ collection ->__debugInfo ();
55
62
63
+ $ this ->assertInstanceOf ('MongoDB\Driver\ReadConcern ' , $ debug ['readConcern ' ]);
64
+ $ this ->assertSame (ReadConcern::LOCAL , $ debug ['readConcern ' ]->getLevel ());
56
65
$ this ->assertInstanceOf ('MongoDB\Driver\ReadPreference ' , $ debug ['readPreference ' ]);
57
66
$ this ->assertSame (ReadPreference::RP_SECONDARY_PREFERRED , $ debug ['readPreference ' ]->getMode ());
58
67
$ this ->assertInstanceOf ('MongoDB\Driver\WriteConcern ' , $ debug ['writeConcern ' ]);
59
68
$ this ->assertSame (WriteConcern::MAJORITY , $ debug ['writeConcern ' ]->getW ());
60
69
}
61
70
62
- public function testSelectDatabaseInheritsReadPreferenceAndWriteConcern ()
71
+ public function testSelectDatabaseInheritsOptions ()
63
72
{
64
- $ clientOptions = [
73
+ $ this ->markTestSkipped ('Depends on https://jira.mongodb.org/browse/PHPC-523 ' );
74
+
75
+ $ uriOptions = [
76
+ 'readConcernLevel ' => ReadConcern::LOCAL ,
65
77
'readPreference ' => 'secondaryPreferred ' ,
66
78
'w ' => WriteConcern::MAJORITY ,
67
79
];
68
80
69
- $ client = new Client ($ this ->getUri (), $ clientOptions );
81
+ $ client = new Client ($ this ->getUri (), $ uriOptions );
70
82
$ database = $ client ->selectDatabase ($ this ->getDatabaseName ());
71
83
$ debug = $ database ->__debugInfo ();
72
84
85
+ $ this ->assertInstanceOf ('MongoDB\Driver\ReadConcern ' , $ debug ['readConcern ' ]);
86
+ $ this ->assertSame (ReadConcern::LOCAL , $ debug ['readConcern ' ]->getLevel ());
73
87
$ this ->assertInstanceOf ('MongoDB\Driver\ReadPreference ' , $ debug ['readPreference ' ]);
74
88
$ this ->assertSame (ReadPreference::RP_SECONDARY_PREFERRED , $ debug ['readPreference ' ]->getMode ());
75
89
$ this ->assertInstanceOf ('MongoDB\Driver\WriteConcern ' , $ debug ['writeConcern ' ]);
76
90
$ this ->assertSame (WriteConcern::MAJORITY , $ debug ['writeConcern ' ]->getW ());
77
91
}
78
92
79
- public function testSelectDatabasePassesReadPreferenceAndWriteConcern ()
93
+ public function testSelectDatabasePassesOptions ()
80
94
{
81
95
$ databaseOptions = [
96
+ 'readConcern ' => new ReadConcern (ReadConcern::LOCAL ),
82
97
'readPreference ' => new ReadPreference (ReadPreference::RP_SECONDARY_PREFERRED ),
83
98
'writeConcern ' => new WriteConcern (WriteConcern::MAJORITY ),
84
99
];
@@ -87,6 +102,8 @@ public function testSelectDatabasePassesReadPreferenceAndWriteConcern()
87
102
$ database = $ client ->selectDatabase ($ this ->getDatabaseName (), $ databaseOptions );
88
103
$ debug = $ database ->__debugInfo ();
89
104
105
+ $ this ->assertInstanceOf ('MongoDB\Driver\ReadConcern ' , $ debug ['readConcern ' ]);
106
+ $ this ->assertSame (ReadConcern::LOCAL , $ debug ['readConcern ' ]->getLevel ());
90
107
$ this ->assertInstanceOf ('MongoDB\Driver\ReadPreference ' , $ debug ['readPreference ' ]);
91
108
$ this ->assertSame (ReadPreference::RP_SECONDARY_PREFERRED , $ debug ['readPreference ' ]->getMode ());
92
109
$ this ->assertInstanceOf ('MongoDB\Driver\WriteConcern ' , $ debug ['writeConcern ' ]);
0 commit comments