Skip to content

Commit e1c4fe5

Browse files
committed
PHPC-1890: Constant for ReadConcern snapshot level
1 parent ad20ac5 commit e1c4fe5

8 files changed

+36
-0
lines changed

src/MongoDB/ReadConcern.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ void php_phongo_readconcern_init_ce(INIT_FUNC_ARGS) /* {{{ */
370370
zend_declare_class_constant_stringl(php_phongo_readconcern_ce, ZEND_STRL("MAJORITY"), ZEND_STRL(MONGOC_READ_CONCERN_LEVEL_MAJORITY));
371371
zend_declare_class_constant_stringl(php_phongo_readconcern_ce, ZEND_STRL("LINEARIZABLE"), ZEND_STRL(MONGOC_READ_CONCERN_LEVEL_LINEARIZABLE));
372372
zend_declare_class_constant_stringl(php_phongo_readconcern_ce, ZEND_STRL("AVAILABLE"), ZEND_STRL(MONGOC_READ_CONCERN_LEVEL_AVAILABLE));
373+
zend_declare_class_constant_stringl(php_phongo_readconcern_ce, ZEND_STRL("SNAPSHOT"), ZEND_STRL(MONGOC_READ_CONCERN_LEVEL_SNAPSHOT));
373374
} /* }}} */
374375

375376
/*

tests/readConcern/readconcern-bsonserialize-001.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ $tests = [
1111
new MongoDB\Driver\ReadConcern(MongoDB\Driver\ReadConcern::LOCAL),
1212
new MongoDB\Driver\ReadConcern(MongoDB\Driver\ReadConcern::MAJORITY),
1313
new MongoDB\Driver\ReadConcern(MongoDB\Driver\ReadConcern::AVAILABLE),
14+
new MongoDB\Driver\ReadConcern(MongoDB\Driver\ReadConcern::SNAPSHOT),
1415
];
1516

1617
foreach ($tests as $test) {
@@ -26,4 +27,5 @@ foreach ($tests as $test) {
2627
{ "level" : "local" }
2728
{ "level" : "majority" }
2829
{ "level" : "available" }
30+
{ "level" : "snapshot" }
2931
===DONE===

tests/readConcern/readconcern-bsonserialize-002.phpt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ $tests = [
1111
new MongoDB\Driver\ReadConcern(MongoDB\Driver\ReadConcern::LOCAL),
1212
new MongoDB\Driver\ReadConcern(MongoDB\Driver\ReadConcern::MAJORITY),
1313
new MongoDB\Driver\ReadConcern(MongoDB\Driver\ReadConcern::AVAILABLE),
14+
new MongoDB\Driver\ReadConcern(MongoDB\Driver\ReadConcern::SNAPSHOT),
1415
];
1516

1617
foreach ($tests as $test) {
@@ -39,4 +40,8 @@ object(stdClass)#%d (%d) {
3940
["level"]=>
4041
string(9) "available"
4142
}
43+
object(stdClass)#%d (%d) {
44+
["level"]=>
45+
string(8) "snapshot"
46+
}
4247
===DONE===

tests/readConcern/readconcern-constants.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ var_dump(MongoDB\Driver\ReadConcern::LINEARIZABLE);
77
var_dump(MongoDB\Driver\ReadConcern::LOCAL);
88
var_dump(MongoDB\Driver\ReadConcern::MAJORITY);
99
var_dump(MongoDB\Driver\ReadConcern::AVAILABLE);
10+
var_dump(MongoDB\Driver\ReadConcern::SNAPSHOT);
1011

1112
?>
1213
===DONE===
@@ -16,4 +17,5 @@ string(12) "linearizable"
1617
string(5) "local"
1718
string(8) "majority"
1819
string(9) "available"
20+
string(8) "snapshot"
1921
===DONE===

tests/readConcern/readconcern-debug-001.phpt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ $tests = [
1111
new MongoDB\Driver\ReadConcern(MongoDB\Driver\ReadConcern::LOCAL),
1212
new MongoDB\Driver\ReadConcern(MongoDB\Driver\ReadConcern::MAJORITY),
1313
new MongoDB\Driver\ReadConcern(MongoDB\Driver\ReadConcern::AVAILABLE),
14+
new MongoDB\Driver\ReadConcern(MongoDB\Driver\ReadConcern::SNAPSHOT),
1415
];
1516

1617
foreach ($tests as $test) {
@@ -39,4 +40,8 @@ object(MongoDB\Driver\ReadConcern)#%d (%d) {
3940
["level"]=>
4041
string(9) "available"
4142
}
43+
object(MongoDB\Driver\ReadConcern)#%d (%d) {
44+
["level"]=>
45+
string(8) "snapshot"
46+
}
4247
===DONE===

tests/readConcern/readconcern-serialization-001.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ $tests = [
1111
new MongoDB\Driver\ReadConcern(MongoDB\Driver\ReadConcern::LOCAL),
1212
new MongoDB\Driver\ReadConcern(MongoDB\Driver\ReadConcern::MAJORITY),
1313
new MongoDB\Driver\ReadConcern(MongoDB\Driver\ReadConcern::AVAILABLE),
14+
new MongoDB\Driver\ReadConcern(MongoDB\Driver\ReadConcern::SNAPSHOT),
1415
];
1516

1617
foreach ($tests as $test) {
@@ -76,4 +77,15 @@ object(MongoDB\Driver\ReadConcern)#%d (%d) {
7677
string(9) "available"
7778
}
7879

80+
object(MongoDB\Driver\ReadConcern)#%d (%d) {
81+
["level"]=>
82+
string(8) "snapshot"
83+
}
84+
bool(true)
85+
C:26:"MongoDB\Driver\ReadConcern":33:{a:1:{s:5:"level";s:8:"snapshot";}}
86+
object(MongoDB\Driver\ReadConcern)#%d (%d) {
87+
["level"]=>
88+
string(8) "snapshot"
89+
}
90+
7991
===DONE===

tests/readConcern/readconcern-set_state-001.phpt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ $tests = [
88
MongoDB\Driver\ReadConcern::LINEARIZABLE,
99
MongoDB\Driver\ReadConcern::LOCAL,
1010
MongoDB\Driver\ReadConcern::MAJORITY,
11+
MongoDB\Driver\ReadConcern::SNAPSHOT,
1112
];
1213

1314
foreach ($tests as $level) {
@@ -42,6 +43,10 @@ MongoDB\Driver\ReadConcern::__set_state(array(
4243
%w'level' => 'majority',
4344
))
4445

46+
MongoDB\Driver\ReadConcern::__set_state(array(
47+
%w'level' => 'snapshot',
48+
))
49+
4550
MongoDB\Driver\ReadConcern::__set_state(array(
4651
))
4752

tests/readConcern/readconcern-var_export-001.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ $tests = [
1111
new MongoDB\Driver\ReadConcern(MongoDB\Driver\ReadConcern::LOCAL),
1212
new MongoDB\Driver\ReadConcern(MongoDB\Driver\ReadConcern::MAJORITY),
1313
new MongoDB\Driver\ReadConcern(MongoDB\Driver\ReadConcern::AVAILABLE),
14+
new MongoDB\Driver\ReadConcern(MongoDB\Driver\ReadConcern::SNAPSHOT),
1415
];
1516

1617
foreach ($tests as $test) {
@@ -35,4 +36,7 @@ MongoDB\Driver\ReadConcern::__set_state(array(
3536
MongoDB\Driver\ReadConcern::__set_state(array(
3637
'level' => 'available',
3738
))
39+
MongoDB\Driver\ReadConcern::__set_state(array(
40+
'level' => 'snapshot',
41+
))
3842
===DONE===

0 commit comments

Comments
 (0)