summaryrefslogtreecommitdiffstats
path: root/526.patch
blob: 3e9b8694ae478d9e9e19636907c2723a3451cd5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
From 1cfffa55894eb8a95e1fd4a4e19f2f9cc442ca41 Mon Sep 17 00:00:00 2001
From: Jeremy Mikola <jmikola@gmail.com>
Date: Fri, 13 Jan 2017 14:30:36 -0500
Subject: [PATCH 1/7] Use exactly representable floating point numbers in tests

CDRIVER-1945 increased the precision when rendering floating point numbers in JavaScript. Using numbers that can be exactly represented in floating point will allow us to keep the expected output consistent with our input.
---
 tests/bson/bson-decode-001.phpt | 5 ++---
 tests/bson/bson-encode-001.phpt | 6 +++---
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/tests/bson/bson-decode-001.phpt b/tests/bson/bson-decode-001.phpt
index 2153dd9..64b2443 100644
--- a/tests/bson/bson-decode-001.phpt
+++ b/tests/bson/bson-decode-001.phpt
@@ -10,8 +10,7 @@ $tests = array(
     array((object)array("hello" => "world")),
     array(null),
     array(123),
-
-    array(4.23),
+    array(4.125),
     array(true),
     array(false),
     array("string"),
@@ -60,7 +59,7 @@ Test#2 { "0" : null }
 OK
 Test#3 { "0" : 123 }
 OK
-Test#4 { "0" : 4.23 }
+Test#4 { "0" : 4.125 }
 OK
 Test#5 { "0" : true }
 OK
diff --git a/tests/bson/bson-encode-001.phpt b/tests/bson/bson-encode-001.phpt
index 257e0de..f3d2649 100644
--- a/tests/bson/bson-encode-001.phpt
+++ b/tests/bson/bson-encode-001.phpt
@@ -15,7 +15,7 @@ $tests = array(
     array(array("0" => 1, "1" => 2, "2" => 3, "3" => 4, "4" => 5, "5" => 6, "6" => 7, "7" => 8, "8" => 9)),
     array(null),
     array(123),
-    array(4.23),
+    array(4.125),
     array(true),
     array(false),
     array("string"),
@@ -74,8 +74,8 @@ Test#7 { "0" : null }
      0 : 08 00 00 00 0a 30 00 00                          [.....0..]
 Test#8 { "0" : 123 }
      0 : 0c 00 00 00 10 30 00 7b 00 00 00 00              [.....0.{....]
-Test#9 { "0" : 4.23 }
-     0 : 10 00 00 00 01 30 00 ec 51 b8 1e 85 eb 10 40 00  [.....0..Q.....@.]
+Test#9 { "0" : 4.125 }
+     0 : 10 00 00 00 01 30 00 00 00 00 00 00 80 10 40 00  [.....0........@.]
 Test#10 { "0" : true }
      0 : 09 00 00 00 08 30 00 01 00                       [.....0...]
 Test#11 { "0" : false }

From 77be3df93d58d74ddf8d9e4f8c996798ac85af4a Mon Sep 17 00:00:00 2001
From: Jeremy Mikola <jmikola@gmail.com>
Date: Tue, 7 Feb 2017 16:28:41 -0500
Subject: [PATCH 2/7] Manager::executeQuery() without assignment test is
 obsolete

Testing query execution without return value assignment is already handled by tests/query/bug0705-001.phpt.
---
 .../manager-executequery-without-assignment.phpt   | 29 ----------------------
 1 file changed, 29 deletions(-)
 delete mode 100644 tests/manager/manager-executequery-without-assignment.phpt

diff --git a/tests/manager/manager-executequery-without-assignment.phpt b/tests/manager/manager-executequery-without-assignment.phpt
deleted file mode 100644
index cf1172b..0000000
--- a/tests/manager/manager-executequery-without-assignment.phpt
+++ /dev/null
@@ -1,29 +0,0 @@
---TEST--
-MongoDB\Driver\Manager: Executing Query without assignment still executes
---SKIPIF--
-<?php if (defined("HHVM_VERSION_ID")) exit("skip HHVM uses HHVM's logging functionality"); ?>
-<?php require __DIR__ . "/../utils/basic-skipif.inc"; CLEANUP(STANDALONE) ?>
---FILE--
-<?php
-require_once __DIR__ . "/../utils/basic.inc";
-
-$manager = new MongoDB\Driver\Manager(STANDALONE);
-
-$bulk = new MongoDB\Driver\BulkWrite();
-$bulk->insert(array('_id' => 1, 'x' => 1));
-$bulk->insert(array('_id' => 2, 'x' => 1));
-$manager->executeBulkWrite(NS, $bulk);
-
-ini_set("mongodb.debug", "stdout");
-$manager->executeQuery(NS, new MongoDB\Driver\Query(array("x" => 1)));
-ini_set("mongodb.debug", "off");
-
-?>
-===DONE===
-<?php exit(0); ?>
---EXPECTF--
-%a
-[%s]     cursor: TRACE   > ENTRY: mongoc_cursor_next():%d
-%a
-[%s]     cursor: TRACE   >  EXIT: mongoc_cursor_destroy():%d
-===DONE===

From e3c4439ae3b7520ba19e6c3f075bc8ff15ab0794 Mon Sep 17 00:00:00 2001
From: Jeremy Mikola <jmikola@gmail.com>
Date: Tue, 7 Feb 2017 16:30:04 -0500
Subject: [PATCH 3/7] Remove Manager::executeBulkWrite() insert error test

In libmongoc 1.6.0, insert documents are validated during BulkWrite::insert(). This is a fragile test that fails when v1.2 is compiled against libmongoc 1.6.0 as a system library.
---
 .../manager-executeBulkWrite_error-005.phpt        | 48 ----------------------
 1 file changed, 48 deletions(-)
 delete mode 100644 tests/manager/manager-executeBulkWrite_error-005.phpt

diff --git a/tests/manager/manager-executeBulkWrite_error-005.phpt b/tests/manager/manager-executeBulkWrite_error-005.phpt
deleted file mode 100644
index 81c965a..0000000
--- a/tests/manager/manager-executeBulkWrite_error-005.phpt
+++ /dev/null
@@ -1,48 +0,0 @@
---TEST--
-MongoDB\Driver\Manager::executeBulkWrite() insert write error
---SKIPIF--
-<?php require __DIR__ . "/../utils/basic-skipif.inc"; CLEANUP(STANDALONE) ?>
---FILE--
-<?php
-require_once __DIR__ . "/../utils/basic.inc";
-
-$manager = new MongoDB\Driver\Manager(STANDALONE);
-
-$bulk = new MongoDB\Driver\BulkWrite();
-$bulk->insert(['$foo' => 1]);
-
-try {
-    $manager->executeBulkWrite(NS, $bulk);
-} catch (MongoDB\Driver\Exception\BulkWriteException $e) {
-    printf("BulkWriteException: %s\n", $e->getMessage());
-
-    echo "\n===> WriteResult\n";
-    printWriteResult($e->getWriteResult());
-}
-
-?>
-===DONE===
-<?php exit(0); ?>
---EXPECTF--
-BulkWriteException: Document can't have $ prefixed field names: $foo
-
-===> WriteResult
-server: %s:%d
-insertedCount: 0
-matchedCount: 0
-modifiedCount: 0
-upsertedCount: 0
-deletedCount: 0
-object(MongoDB\Driver\WriteError)#%d (%d) {
-  ["message"]=>
-  string(48) "Document can't have $ prefixed field names: $foo"
-  ["code"]=>
-  int(2)
-  ["index"]=>
-  int(0)
-  ["info"]=>
-  NULL
-}
-writeError[0].message: Document can't have $ prefixed field names: $foo
-writeError[0].code: 2
-===DONE===

From 8edd0c903416f7ff4b6a3d478720ee7cd8f935b5 Mon Sep 17 00:00:00 2001
From: Jeremy Mikola <jmikola@gmail.com>
Date: Tue, 7 Feb 2017 16:31:54 -0500
Subject: [PATCH 4/7] Do not assert error message in fromJSON() error test

libbson 1.6.0 switched JSON parsers, which means this test fails when compiled against libbson 1.6.0 as a system library. Removing the error message assertion keeps the test portable.
---
 tests/bson/bson-fromJSON_error-001.phpt | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/tests/bson/bson-fromJSON_error-001.phpt b/tests/bson/bson-fromJSON_error-001.phpt
index a86ca7a..a0f91a0 100644
--- a/tests/bson/bson-fromJSON_error-001.phpt
+++ b/tests/bson/bson-fromJSON_error-001.phpt
@@ -5,17 +5,13 @@ MongoDB\BSON\fromJSON(): invalid JSON
 
 require_once __DIR__ . '/../utils/tools.php';
 
-echo throws(function() {
+throws(function() {
     fromJSON('foo');
-}, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n";
+}, 'MongoDB\Driver\Exception\UnexpectedValueException');
 
 ?>
 ===DONE===
 <?php exit(0); ?>
 --EXPECT--
 OK: Got MongoDB\Driver\Exception\UnexpectedValueException
-lexical error: invalid string in json text.
-                                       foo
-                     (right here) ------^
-
 ===DONE===

From 04bd60be6334a083ba47d874cb262b8d453e9277 Mon Sep 17 00:00:00 2001
From: Jeremy Mikola <jmikola@gmail.com>
Date: Tue, 7 Feb 2017 16:34:10 -0500
Subject: [PATCH 5/7] Make JavaScript::jsonSerialize() tests portable for
 libbson 1.5 and 1.6

---
 tests/bson/bson-javascript-jsonserialize-003.phpt | 6 +++---
 tests/bson/bson-javascript-jsonserialize-004.phpt | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/tests/bson/bson-javascript-jsonserialize-003.phpt b/tests/bson/bson-javascript-jsonserialize-003.phpt
index 0478bb4..c551483 100644
--- a/tests/bson/bson-javascript-jsonserialize-003.phpt
+++ b/tests/bson/bson-javascript-jsonserialize-003.phpt
@@ -20,9 +20,9 @@ var_dump(toPHP(fromJSON($json)));
 {"foo":{"$code":"function foo(bar) { return bar; }"}}
 object(stdClass)#%d (%d) {
   ["foo"]=>
-  object(stdClass)#%d (%d) {
-    ["$code"]=>
+  object(%r(stdClass|MongoDB\\BSON\\Javascript)%r)#%d (%d) {
+    ["%r(\$?)%rcode"]=>
     string(33) "function foo(bar) { return bar; }"
-  }
+  %A}
 }
 ===DONE===
diff --git a/tests/bson/bson-javascript-jsonserialize-004.phpt b/tests/bson/bson-javascript-jsonserialize-004.phpt
index a3daaa5..f134edb 100644
--- a/tests/bson/bson-javascript-jsonserialize-004.phpt
+++ b/tests/bson/bson-javascript-jsonserialize-004.phpt
@@ -20,10 +20,10 @@ var_dump(toPHP(fromJSON($json)));
 {"foo":{"$code":"function foo(bar) { return bar; }","$scope":{"foo":42}}}
 object(stdClass)#%d (%d) {
   ["foo"]=>
-  object(stdClass)#%d (%d) {
-    ["$code"]=>
+  object(%r(stdClass|MongoDB\\BSON\\Javascript)%r)#%d (%d) {
+    ["%r(\$?)%rcode"]=>
     string(33) "function foo(bar) { return bar; }"
-    ["$scope"]=>
+    ["%r(\$?)%rscope"]=>
     object(stdClass)#%d (%d) {
       ["foo"]=>
       int(42)

From 6ed6a34f5bbc15e427886411982bbff97b04ba82 Mon Sep 17 00:00:00 2001
From: Jeremy Mikola <jmikola@gmail.com>
Date: Tue, 7 Feb 2017 16:37:12 -0500
Subject: [PATCH 6/7] Only assert mongodb.debug INI in phpinfo() tests

The current phpinfo() tests were fragile and not compatible when build against libbson/libmongoc system libraries, which might also have different SSL options.
---
 tests/functional/phpinfo-1.phpt | 20 +-------------------
 tests/functional/phpinfo-2.phpt | 20 +-------------------
 2 files changed, 2 insertions(+), 38 deletions(-)

diff --git a/tests/functional/phpinfo-1.phpt b/tests/functional/phpinfo-1.phpt
index 045c540..c752cd9 100644
--- a/tests/functional/phpinfo-1.phpt
+++ b/tests/functional/phpinfo-1.phpt
@@ -1,11 +1,9 @@
 --TEST--
-phpinfo()
+phpinfo() reports mongodb.debug (no value)
 --SKIPIF--
 <?php if (defined("HHVM_VERSION_ID")) exit("skip HHVM does not do phpinfo() this way"); ?>
-<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
 --FILE--
 <?php
-require_once __DIR__ . "/../utils/basic.inc";
 
 phpinfo();
 
@@ -14,22 +12,6 @@ phpinfo();
 <?php exit(0); ?>
 --EXPECTF--
 %a
-mongodb
-
-MongoDB support => enabled
-MongoDB extension version => 1.%d.%d%S
-MongoDB extension stability => %s
-libbson bundled version => 1.%d.%d%S
-libmongoc bundled version => 1.%d.%d%S
-libmongoc SSL => enabled
-libmongoc SSL library => %s
-libmongoc crypto => enabled
-libmongoc crypto library => %s
-libmongoc crypto system profile => %s
-libmongoc SASL => enabled
-
-Directive => Local Value => Master Value
 mongodb.debug => no value => no value
-
 %a
 ===DONE===
diff --git a/tests/functional/phpinfo-2.phpt b/tests/functional/phpinfo-2.phpt
index 91b3236..7549077 100644
--- a/tests/functional/phpinfo-2.phpt
+++ b/tests/functional/phpinfo-2.phpt
@@ -1,13 +1,11 @@
 --TEST--
-phpinfo()
+phpinfo() reports mongodb.debug (default and overridden)
 --INI--
 mongodb.debug=stderr
 --SKIPIF--
 <?php if (defined("HHVM_VERSION_ID")) exit("skip HHVM does not do phpinfo() this way"); ?>
-<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
 --FILE--
 <?php
-require_once __DIR__ . "/../utils/basic.inc";
 
 ini_set("mongodb.debug", "stdout");
 phpinfo();
@@ -17,22 +15,6 @@ phpinfo();
 <?php exit(0); ?>
 --EXPECTF--
 %a
-mongodb
-
-MongoDB support => enabled
-MongoDB extension version => 1.%d.%d%S
-MongoDB extension stability => %s
-libbson bundled version => 1.%d.%d%S
-libmongoc bundled version => 1.%d.%d%S
-libmongoc SSL => enabled
-libmongoc SSL library => %s
-libmongoc crypto => enabled
-libmongoc crypto library => %s
-libmongoc crypto system profile => %s
-libmongoc SASL => enabled
-
-Directive => Local Value => Master Value
 mongodb.debug => stdout => stderr
-
 %a
 ===DONE===

From 44ac5c48891f017a654b2cf13513d82a284dd914 Mon Sep 17 00:00:00 2001
From: Jeremy Mikola <jmikola@gmail.com>
Date: Tue, 7 Feb 2017 16:39:10 -0500
Subject: [PATCH 7/7] Manager debug ouput tests should not depend on libmongoc
 tracing

These tests were fragile and could fail when using libmongoc as a system library where tracing may not be enabled.
---
 tests/manager/manager-debug-001.phpt | 27 ++++++++-------------------
 tests/manager/manager-debug-002.phpt | 13 +++----------
 2 files changed, 11 insertions(+), 29 deletions(-)

diff --git a/tests/manager/manager-debug-001.phpt b/tests/manager/manager-debug-001.phpt
index dc34bb6..68a4ece 100644
--- a/tests/manager/manager-debug-001.phpt
+++ b/tests/manager/manager-debug-001.phpt
@@ -2,38 +2,27 @@
 MongoDB\Driver\Manager: Writing debug log files
 --SKIPIF--
 <?php if (defined("HHVM_VERSION_ID")) exit("skip HHVM uses HHVM's logging functionality"); ?>
-<?php require __DIR__ . "/../utils/basic-skipif.inc"; CLEANUP(STANDALONE) ?>
 --FILE--
 <?php
-require_once __DIR__ . "/../utils/basic.inc";
 
 $name = tempnam(sys_get_temp_dir(), "PHONGO");
 unlink($name);
 mkdir($name);
+
 ini_set('mongodb.debug', $name);
-$manager = new MongoDB\Driver\Manager(STANDALONE);
-$bulk = new MongoDB\Driver\BulkWrite();
-$bulk->insert(array('_id' => 1, 'x' => 1));
-$result = $manager->executeBulkWrite(NS, $bulk);
+$manager = new MongoDB\Driver\Manager;
 ini_set('mongodb.debug', 'off');
-foreach(glob($name."/*") as $file);
-$content = file($file);
-unlink($file);
-rmdir($name);
 
-echo $content[0], $content[1];
-foreach($content as $line) {
-    if (strpos($line, "mongoc_bulk_operation_execute")) {
-        echo $line;
-    }
+foreach (glob($name."/*") as $file) {
+    echo file_get_contents($file);
+    unlink($file);
 }
+rmdir($name);
 
 ?>
 ===DONE===
 <?php exit(0); ?>
 --EXPECTF--
-[%s]     PHONGO: DEBUG   > Connection string: '%s'
+%A[%s]     PHONGO: DEBUG   > Connection string: '%s'
 [%s]     PHONGO: DEBUG   > Creating Manager, phongo-1.%d.%d%S[%s] - mongoc-1.%s(%s), libbson-1.%s(%s), php-%s
-[%s]     mongoc: TRACE   > ENTRY: mongoc_bulk_operation_execute():%d
-[%s]     mongoc: TRACE   >  EXIT: mongoc_bulk_operation_execute():%d
-===DONE===
+%A===DONE===%A
diff --git a/tests/manager/manager-debug-002.phpt b/tests/manager/manager-debug-002.phpt
index f68f736..e98aa27 100644
--- a/tests/manager/manager-debug-002.phpt
+++ b/tests/manager/manager-debug-002.phpt
@@ -2,24 +2,17 @@
 MongoDB\Driver\Manager: mongodb.debug=stderr
 --SKIPIF--
 <?php if (defined("HHVM_VERSION_ID")) exit("skip HHVM uses HHVM's logging functionality"); ?>
-<?php require __DIR__ . "/../utils/basic-skipif.inc"; CLEANUP(STANDALONE) ?>
 --INI--
 mongodb.debug=stderr
 --FILE--
 <?php
-require_once __DIR__ . "/../utils/basic.inc";
 
-$manager = new MongoDB\Driver\Manager(STANDALONE);
-$bulk = new MongoDB\Driver\BulkWrite();
-$bulk->insert(array('_id' => 1, 'x' => 1));
-$result = $manager->executeBulkWrite(NS, $bulk);
+$manager = new MongoDB\Driver\Manager;
 
 ?>
 ===DONE===
 <?php exit(0); ?>
 --EXPECTF--
-%a
+%A[%s]     PHONGO: DEBUG   > Connection string: '%s'
 [%s]     PHONGO: DEBUG   > Creating Manager, phongo-1.%d.%d%S[%s] - mongoc-1.%s(%s), libbson-1.%s(%s), php-%s
-%a
-===DONE===
-%a
+%A===DONE===%A