Skip to content

Test fixes for libmongoc 1.9.0-dev (post rc1) #701

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Dec 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libmongoc
3 changes: 0 additions & 3 deletions tests/apm/overview.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ object(MongoDB\Driver\Monitoring\CommandStartedEvent)#%d (%d) {
object(stdClass)#%d (%d) {
["insert"]=>
string(12) "apm_overview"
["writeConcern"]=>
object(stdClass)#%d (%d) {
}
["ordered"]=>
bool(false)%A
}
Expand Down
8 changes: 4 additions & 4 deletions tests/bulk/bulkwrite-insert_error-001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ echo throws(function() use ($bulk) {
<?php exit(0); ?>
--EXPECT--
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
document to insert contains invalid key: empty key
invalid document for insert: empty key

OK: Got MongoDB\Driver\Exception\InvalidArgumentException
document to insert contains invalid key: keys cannot contain ".": "x.y"
invalid document for insert: keys cannot contain ".": "x.y"

OK: Got MongoDB\Driver\Exception\InvalidArgumentException
document to insert contains invalid key: keys cannot begin with "$": "$x"
invalid document for insert: keys cannot begin with "$": "$x"

OK: Got MongoDB\Driver\Exception\InvalidArgumentException
document to insert contains invalid key: corrupt BSON
invalid document for insert: corrupt BSON
===DONE===
8 changes: 4 additions & 4 deletions tests/bulk/bulkwrite-update_error-001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ echo throws(function() use ($bulk) {
<?php exit(0); ?>
--EXPECT--
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
replacement document contains invalid key: empty key
invalid argument for replace: empty key

OK: Got MongoDB\Driver\Exception\InvalidArgumentException
replacement document contains invalid key: keys cannot contain ".": "x.y"
invalid argument for replace: keys cannot contain ".": "x.y"

OK: Got MongoDB\Driver\Exception\InvalidArgumentException
replacement document contains invalid key: keys cannot begin with "$": "$x"
invalid argument for replace: keys cannot begin with "$": "$x"

OK: Got MongoDB\Driver\Exception\InvalidArgumentException
replacement document contains invalid key: corrupt BSON
invalid argument for replace: corrupt BSON
===DONE===
4 changes: 2 additions & 2 deletions tests/bulk/bulkwrite-update_error-002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ echo throws(function() use ($bulk) {
<?php exit(0); ?>
--EXPECT--
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
update document contains invalid key: empty key
invalid argument for update: empty key

OK: Got MongoDB\Driver\Exception\InvalidArgumentException
update document contains invalid key: corrupt BSON
invalid argument for update: corrupt BSON

OK: Got MongoDB\Driver\Exception\InvalidArgumentException
Invalid key 'z': update only works with $ operators
Expand Down
2 changes: 1 addition & 1 deletion tests/manager/manager-ctor-read_preference-error-001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ echo throws(function() {
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
Failed to parse MongoDB URI: 'mongodb://127.0.0.1/?readPreference=1'. Unsupported readPreference value [readPreference=1].
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
Failed to parse MongoDB URI: 'mongodb://127.0.0.1/?readPreference=secondary&readPreferenceTags=invalid'. Unknown option or value for 'readPreferenceTags=invalid'.
Failed to parse MongoDB URI: 'mongodb://127.0.0.1/?readPreference=secondary&readPreferenceTags=invalid'. Unsupported value for "readPreferenceTags": "invalid".
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
Expected string for "readPreference" URI option, 32-bit integer given
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
Expand Down
4 changes: 2 additions & 2 deletions tests/manager/manager-ctor-read_preference-error-002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ echo throws(function() {
<?php exit(0); ?>
--EXPECT--
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
Failed to parse MongoDB URI: 'mongodb://127.0.0.1/?readPreference=secondary&maxStalenessSeconds=invalid'. Unknown option or value for 'maxStalenessSeconds=invalid'.
Failed to parse MongoDB URI: 'mongodb://127.0.0.1/?readPreference=secondary&maxStalenessSeconds=invalid'. Unsupported value for "maxStalenessSeconds": "invalid".
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
Expected integer for "maxStalenessSeconds" URI option, string given
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
Failed to parse MongoDB URI: 'mongodb://127.0.0.1/?readPreference=secondary&maxStalenessSeconds=2147483648'. Unknown option or value for 'maxStalenessSeconds=2147483648'.
Failed to parse MongoDB URI: 'mongodb://127.0.0.1/?readPreference=secondary&maxStalenessSeconds=2147483648'. Unsupported value for "maxStalenessSeconds": "2147483648".
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
Failed to parse MongoDB URI: 'mongodb://127.0.0.1/?maxstalenessseconds=1231'. Invalid readPreferences.
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
Expand Down
2 changes: 1 addition & 1 deletion tests/manager/manager-ctor-read_preference-error-003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ echo throws(function() {
<?php exit(0); ?>
--EXPECT--
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
Failed to parse MongoDB URI: 'mongodb://127.0.0.1/?slaveok=other'. Unknown option or value for 'slaveok=other'.
Failed to parse MongoDB URI: 'mongodb://127.0.0.1/?slaveok=other'. Unsupported value for "slaveok": "other".
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
Expected boolean for "slaveOk" URI option, 32-bit integer given
===DONE===
2 changes: 1 addition & 1 deletion tests/manager/manager-ctor-write_concern-error-003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ echo throws(function() {
<?php exit(0); ?>
--EXPECT--
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
Failed to parse MongoDB URI: 'mongodb://127.0.0.1/?wtimeoutms=invalid'. Unknown option or value for 'wtimeoutms=invalid'.
Failed to parse MongoDB URI: 'mongodb://127.0.0.1/?wtimeoutms=invalid'. Unsupported value for "wtimeoutms": "invalid".
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
Expected 32-bit integer for "wTimeoutMS" URI option, string given
===DONE===
2 changes: 1 addition & 1 deletion tests/manager/manager-ctor-write_concern-error-005.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ echo throws(function() {
<?php exit(0); ?>
--EXPECT--
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
Failed to parse MongoDB URI: 'mongodb://127.0.0.1/?journal=invalid'. Unknown option or value for 'journal=invalid'.
Failed to parse MongoDB URI: 'mongodb://127.0.0.1/?journal=invalid'. Unsupported value for "journal": "invalid".
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
Expected boolean for "journal" URI option, string given
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
Expand Down
2 changes: 1 addition & 1 deletion tests/manager/manager-ctor-write_concern-error-006.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ echo throws(function() {
<?php exit(0); ?>
--EXPECT--
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
Failed to parse MongoDB URI: 'mongodb://127.0.0.1/?safe=invalid'. Unknown option or value for 'safe=invalid'.
Failed to parse MongoDB URI: 'mongodb://127.0.0.1/?safe=invalid'. Unsupported value for "safe": "invalid".
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
Expected boolean for "safe" URI option, string given
===DONE===
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
MongoDB\Driver\Manager::executeRawCommand()
MongoDB\Driver\Manager::executeCommand() options (MONGOC_CMD_RAW)
--SKIPIF--
<?php if (getenv("TRAVIS")) exit("skip This currently tails on Travis because it doesn't run 3.6 yet"); ?>
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
Expand Down
2 changes: 1 addition & 1 deletion tests/manager/manager-executeCommand_error-002.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
MongoDB\Driver\Manager::executeCommand(): wrong options and values
MongoDB\Driver\Manager::executeCommand(): wrong options and values (MONGOC_CMD_RAW)
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
<?php NEEDS('REPLICASET'); CLEANUP(REPLICASET); ?>
Expand Down
49 changes: 49 additions & 0 deletions tests/server/server-executeCommand-006.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
--TEST--
MongoDB\Driver\Server::executeCommand() options (MONGO_CMD_RAW)
--SKIPIF--
<?php if (getenv("TRAVIS")) exit("skip This currently tails on Travis because it doesn't run 3.6 yet"); ?>
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
<?php NEEDS('STANDALONE'); CLEANUP(STANDALONE); ?>
--FILE--
<?php
require_once __DIR__ . "/../utils/basic.inc";
require_once __DIR__ . "/../utils/observer.php";

$manager = new MongoDB\Driver\Manager(STANDALONE);
$server = $manager->selectServer(new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_PRIMARY));

(new CommandObserver)->observe(
function() use ($server) {
$command = new MongoDB\Driver\Command([
'ping' => true,
]);

try {
$server->executeCommand(
DATABASE_NAME,
$command,
[
'readPreference' => new \MongoDB\Driver\ReadPreference(\MongoDB\Driver\ReadPreference::RP_SECONDARY),
'readConcern' => new \MongoDB\Driver\ReadConcern(\MongoDB\Driver\ReadConcern::LOCAL),
'writeConcern' => new \MongoDB\Driver\WriteConcern(\MongoDB\Driver\WriteConcern::MAJORITY),
]
);
} catch ( Exception $e ) {
// Ignore exception that ping doesn't support writeConcern
}
},
function(stdClass $command) {
echo "Read Preference: ", $command->{'$readPreference'}->mode, "\n";
echo "Read Concern: ", $command->readConcern->level, "\n";
echo "Write Concern: ", $command->writeConcern->w, "\n";
}
);

?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
Read Preference: secondary
Read Concern: local
Write Concern: majority
===DONE===
2 changes: 1 addition & 1 deletion tests/server/server-executeCommand_error-001.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
MongoDB\Driver\Server::executeCommand(): wrong options and values
MongoDB\Driver\Server::executeCommand(): wrong options and values (MONGOC_CMD_RAW)
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
<?php NEEDS('REPLICASET'); CLEANUP(REPLICASET); ?>
Expand Down