Merge branch 'v1.2'

This commit is contained in:
Jeremy Mikola
2017-02-10 15:37:56 -05:00
9 changed files with 17 additions and 270 deletions
+2 -3
View File
@@ -5,14 +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
Got parse error at 'o', position 1: SPECIAL_EXPECTED
===DONE===
+1 -19
View File
@@ -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===
+1 -19
View File
@@ -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===
+10 -21
View File
@@ -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);
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;
}
ini_set('mongodb.debug', $name);
$manager = new MongoDB\Driver\Manager;
ini_set('mongodb.debug', 'off');
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
+3 -10
View File
@@ -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
@@ -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===
@@ -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===
-29
View File
@@ -1,29 +0,0 @@
--TEST--
PHPC-487: check_closed stream handler should not report open socket as closed
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"; SLOW(); ?>
--FILE--
<?php
require_once __DIR__ . "/../utils/basic.inc";
$m = new MongoDB\Driver\Manager(STANDALONE);
$bulk = new MongoDB\Driver\BulkWrite;
$bulk->insert(['x' => 1]);
$wr = $m->executeBulkWrite(NS, $bulk);
var_dump($wr->getInsertedCount());
sleep(1);
$bulk = new MongoDB\Driver\BulkWrite;
$bulk->insert(['x' => 1]);
$wr = $m->executeBulkWrite(NS, $bulk);
var_dump($wr->getInsertedCount());
?>
===DONE===
<?php exit(0); ?>
--EXPECT--
int(1)
int(1)
===DONE===
-92
View File
@@ -1,92 +0,0 @@
--TEST--
PHPC-487: Stream handler should report closed socket as closed
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"; SLOW(); ?>
--FILE--
<?php
require_once __DIR__ . "/../utils/basic.inc";
function mo_delete($id) {
$url = getMOUri() . $id;
$opts = array("http" =>
array(
"method" => "DELETE",
"timeout" => 60,
"header" => "Accept: application/json\r\n" .
"Content-type: application/x-www-form-urlencoded",
"ignore_errors" => true,
),
);
$context = stream_context_create($opts);
$out = file_get_contents($url, false, $context);
}
function mo_post($url, $body) {
global $KILLLIST;
$url = getMOUri() . $url;
$opts = array("http" =>
array(
"method" => "POST",
"timeout" => 60,
"header" => "Accept: application/json\r\n" .
"Content-type: application/x-www-form-urlencoded",
"content" => json_encode($body),
"ignore_errors" => true,
),
);
$context = stream_context_create($opts);
$out = file_get_contents($url, false, $context);
$array = json_decode($out, true);
if ($array && !empty($array["mongodb_uri"])) {
$KILLLIST[] = $array["id"];
return $array["mongodb_uri"];
}
}
$KILLLIST = array();
$dsn = mo_post("/servers", [
'id' => 'serverA',
'name' => 'mongod',
]);
$m = new MongoDB\Driver\Manager($dsn);
$bulk = new MongoDB\Driver\BulkWrite;
$bulk->insert(['x' => 1]);
$wr = $m->executeBulkWrite(NS, $bulk);
var_dump($wr->getInsertedCount());
mo_post("/servers/serverA", ['action' => 'stop']);
echo throws(function() use ($m) {
$bulk = new MongoDB\Driver\BulkWrite;
$bulk->insert(['x' => 1]);
$wr = $m->executeBulkWrite(NS, $bulk);
var_dump($wr->getInsertedCount());
}, 'MongoDB\Driver\Exception\RuntimeException'), "\n";
mo_post("/servers/serverA", ['action' => 'restart']);
$bulk = new MongoDB\Driver\BulkWrite;
$bulk->insert(['x' => 1]);
$wr = $m->executeBulkWrite(NS, $bulk);
var_dump($wr->getInsertedCount());
foreach($KILLLIST as $id) {
mo_delete("/servers/$id");
}
?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
int(1)
OK: Got MongoDB\Driver\Exception\RuntimeException
Failed to send "insert" command with database "phongo": socket error or timeout
int(1)
===DONE===