File tree Expand file tree Collapse file tree 3 files changed +98
-0
lines changed Expand file tree Collapse file tree 3 files changed +98
-0
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ PHPC-430: Query constructor arguments are modified
3
+ --SKIPIF--
4
+ <?php require __DIR__ . "/../utils/basic-skipif.inc " ?>
5
+ --FILE--
6
+ <?php
7
+ require_once __DIR__ . "/../utils/basic.inc " ;
8
+
9
+ $ filter = [];
10
+ $ options = ['sort ' => ['x ' => 1 ]];
11
+ $ query = new MongoDB \Driver \Query ($ filter , $ options );
12
+
13
+ var_dump ($ filter );
14
+ var_dump ($ options );
15
+
16
+ ?>
17
+ ===DONE===
18
+ <?php exit (0 ); ?>
19
+ --EXPECT--
20
+ array(0) {
21
+ }
22
+ array(1) {
23
+ ["sort"]=>
24
+ array(1) {
25
+ ["x"]=>
26
+ int(1)
27
+ }
28
+ }
29
+ ===DONE===
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ PHPC-430: Query constructor arguments are modified
3
+ --SKIPIF--
4
+ <?php require __DIR__ . "/../utils/basic-skipif.inc " ?>
5
+ --FILE--
6
+ <?php
7
+ require_once __DIR__ . "/../utils/basic.inc " ;
8
+
9
+ $ options = ['sort ' => ['x ' => 1 ]];
10
+
11
+ $ optionsCopy = $ options ;
12
+ $ optionsCopy ['cursorFlags ' ] = 0 ;
13
+
14
+ $ query = new MongoDB \Driver \Query ([], $ options );
15
+
16
+ var_dump ($ options );
17
+ var_dump ($ optionsCopy );
18
+
19
+ ?>
20
+ ===DONE===
21
+ <?php exit (0 ); ?>
22
+ --EXPECT--
23
+ array(1) {
24
+ ["sort"]=>
25
+ array(1) {
26
+ ["x"]=>
27
+ int(1)
28
+ }
29
+ }
30
+ array(2) {
31
+ ["sort"]=>
32
+ array(1) {
33
+ ["x"]=>
34
+ int(1)
35
+ }
36
+ ["cursorFlags"]=>
37
+ int(0)
38
+ }
39
+ ===DONE===
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ PHPC-430: Query constructor arguments are modified
3
+ --SKIPIF--
4
+ <?php require __DIR__ . "/../utils/basic-skipif.inc " ?>
5
+ --FILE--
6
+ <?php
7
+ require_once __DIR__ . "/../utils/basic.inc " ;
8
+
9
+ function buildQuery ($ filter , $ options )
10
+ {
11
+ $ options ["cursorFlags " ] = 0 ;
12
+ return new MongoDB \Driver \Query ($ filter , $ options );
13
+ }
14
+
15
+ $ filter = [];
16
+ $ options = ['sort ' => []];
17
+ $ query = buildQuery ($ filter , $ options );
18
+
19
+ var_dump ($ options );
20
+
21
+ ?>
22
+ ===DONE===
23
+ <?php exit (0 ); ?>
24
+ --EXPECT--
25
+ array(1) {
26
+ ["sort"]=>
27
+ array(0) {
28
+ }
29
+ }
30
+ ===DONE===
You can’t perform that action at this time.
0 commit comments