mirror of
https://github.com/macintoshplus/mongo-php-driver.git
synced 2026-03-25 17:32:28 +01:00
* Introduce MongoDB\Driver\ServerApi * Accept serverApi driver option * Introduce create_test_manager factory to create manager A centralised entry point is required to inject the API_VERSION env variable later. * Add build variant to test with requireApiVersion=true * Fix wrong configuration for auth variable This changed when migrating from our own scripts to drivers-evergreen-tools and was not updated properly, causing all tests to run with auth disabled. * Declare ZEND_PARSE_PARAMETERS_NONE macro This macro is missing on PHP < 7.3 * Remove duplicated API param storage * Add missing semicolons * Add ZEND_PARSE_PARAMETERS_NON_EX macro * Extract error handling functionality to separate macros * Throw if internal mongoc_server_api_t is already initialised * Use imported namespaces in tools file * Fix type info for reflection * Use American English spelling * Only use typed serialize signature on PHP 8+ * Update PHONGO_PARSE_PARAMETERS_NONE macro for PHP < 7.3 * Remove usage of ZEND_STRL within zend_hash_str_add This causes compile failures on PHP < 7.3 that I have yet to understand. * Fix errors in new PHONGO_PARSE_PARAMETERS macros
266 lines
12 KiB
PHP
266 lines
12 KiB
PHP
--TEST--
|
|
MongoDB\Driver\Manager::__construct(): invalid types in URI options arrays
|
|
--FILE--
|
|
<?php
|
|
|
|
require_once __DIR__ . '/../utils/basic.inc';
|
|
|
|
/* Note: generic boolean options (e.g. "ssl") are not tested because the driver
|
|
* uses bson_iter_as_bool() to cast the value to a boolean for assignment.
|
|
*
|
|
* Read concern, read preference, and write concern options are tested in their
|
|
* respective test files. */
|
|
|
|
echo "Testing 32-bit integer options:\n";
|
|
|
|
$integerOptions = [
|
|
'connectTimeoutMS',
|
|
'heartbeatFrequencyMS',
|
|
'localThresholdMS',
|
|
'serverSelectionTimeoutMS',
|
|
'socketCheckIntervalMS',
|
|
'socketTimeoutMS',
|
|
];
|
|
|
|
$invalidIntegerValues = [
|
|
true,
|
|
1.0,
|
|
'string',
|
|
new MongoDB\BSON\ObjectId,
|
|
[ 1, 2, 3 ],
|
|
['x' => 1],
|
|
];
|
|
|
|
foreach ($integerOptions as $option) {
|
|
foreach ($invalidIntegerValues as $value) {
|
|
echo throws(function() use ($option, $value) {
|
|
create_test_manager(null, [$option => $value]);
|
|
}, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n";
|
|
}
|
|
}
|
|
|
|
echo "\nTesting string options:\n";
|
|
|
|
$stringOptions = [
|
|
'appname',
|
|
'authMechanism',
|
|
'authSource',
|
|
'gssapiServiceName',
|
|
'password',
|
|
'replicaSet',
|
|
'username',
|
|
];
|
|
|
|
$invalidStringValues = [
|
|
true,
|
|
1.0,
|
|
42,
|
|
new MongoDB\BSON\ObjectId,
|
|
[ 1, 2, 3 ],
|
|
['x' => 1],
|
|
];
|
|
|
|
foreach ($stringOptions as $option) {
|
|
foreach ($invalidStringValues as $value) {
|
|
echo throws(function() use ($option, $value) {
|
|
create_test_manager(null, [$option => $value]);
|
|
}, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n";
|
|
}
|
|
}
|
|
|
|
echo "\nTesting document options:\n";
|
|
|
|
$invalidDocumentValues = [
|
|
true,
|
|
1.0,
|
|
42,
|
|
'string',
|
|
new MongoDB\BSON\ObjectId,
|
|
[ 1, 2, 3 ],
|
|
];
|
|
|
|
foreach ($invalidDocumentValues as $value) {
|
|
echo throws(function() use ($value) {
|
|
create_test_manager(null, ['authMechanismProperties' => $value]);
|
|
}, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n";
|
|
}
|
|
|
|
?>
|
|
===DONE===
|
|
<?php exit(0); ?>
|
|
--EXPECT--
|
|
Testing 32-bit integer options:
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected 32-bit integer for "connectTimeoutMS" URI option, boolean given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected 32-bit integer for "connectTimeoutMS" URI option, double given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected 32-bit integer for "connectTimeoutMS" URI option, string given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected 32-bit integer for "connectTimeoutMS" URI option, ObjectId given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected 32-bit integer for "connectTimeoutMS" URI option, array given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected 32-bit integer for "connectTimeoutMS" URI option, document given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected 32-bit integer for "heartbeatFrequencyMS" URI option, boolean given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected 32-bit integer for "heartbeatFrequencyMS" URI option, double given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected 32-bit integer for "heartbeatFrequencyMS" URI option, string given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected 32-bit integer for "heartbeatFrequencyMS" URI option, ObjectId given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected 32-bit integer for "heartbeatFrequencyMS" URI option, array given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected 32-bit integer for "heartbeatFrequencyMS" URI option, document given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected 32-bit integer for "localThresholdMS" URI option, boolean given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected 32-bit integer for "localThresholdMS" URI option, double given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected 32-bit integer for "localThresholdMS" URI option, string given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected 32-bit integer for "localThresholdMS" URI option, ObjectId given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected 32-bit integer for "localThresholdMS" URI option, array given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected 32-bit integer for "localThresholdMS" URI option, document given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected 32-bit integer for "serverSelectionTimeoutMS" URI option, boolean given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected 32-bit integer for "serverSelectionTimeoutMS" URI option, double given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected 32-bit integer for "serverSelectionTimeoutMS" URI option, string given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected 32-bit integer for "serverSelectionTimeoutMS" URI option, ObjectId given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected 32-bit integer for "serverSelectionTimeoutMS" URI option, array given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected 32-bit integer for "serverSelectionTimeoutMS" URI option, document given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected 32-bit integer for "socketCheckIntervalMS" URI option, boolean given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected 32-bit integer for "socketCheckIntervalMS" URI option, double given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected 32-bit integer for "socketCheckIntervalMS" URI option, string given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected 32-bit integer for "socketCheckIntervalMS" URI option, ObjectId given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected 32-bit integer for "socketCheckIntervalMS" URI option, array given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected 32-bit integer for "socketCheckIntervalMS" URI option, document given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected 32-bit integer for "socketTimeoutMS" URI option, boolean given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected 32-bit integer for "socketTimeoutMS" URI option, double given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected 32-bit integer for "socketTimeoutMS" URI option, string given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected 32-bit integer for "socketTimeoutMS" URI option, ObjectId given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected 32-bit integer for "socketTimeoutMS" URI option, array given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected 32-bit integer for "socketTimeoutMS" URI option, document given
|
|
|
|
Testing string options:
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "appname" URI option, boolean given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "appname" URI option, double given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "appname" URI option, 32-bit integer given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "appname" URI option, ObjectId given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "appname" URI option, array given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "appname" URI option, document given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "authMechanism" URI option, boolean given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "authMechanism" URI option, double given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "authMechanism" URI option, 32-bit integer given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "authMechanism" URI option, ObjectId given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "authMechanism" URI option, array given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "authMechanism" URI option, document given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "authSource" URI option, boolean given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "authSource" URI option, double given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "authSource" URI option, 32-bit integer given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "authSource" URI option, ObjectId given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "authSource" URI option, array given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "authSource" URI option, document given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "gssapiServiceName" URI option, boolean given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "gssapiServiceName" URI option, double given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "gssapiServiceName" URI option, 32-bit integer given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "gssapiServiceName" URI option, ObjectId given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "gssapiServiceName" URI option, array given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "gssapiServiceName" URI option, document given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "password" URI option, boolean given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "password" URI option, double given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "password" URI option, 32-bit integer given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "password" URI option, ObjectId given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "password" URI option, array given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "password" URI option, document given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "replicaSet" URI option, boolean given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "replicaSet" URI option, double given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "replicaSet" URI option, 32-bit integer given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "replicaSet" URI option, ObjectId given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "replicaSet" URI option, array given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "replicaSet" URI option, document given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "username" URI option, boolean given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "username" URI option, double given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "username" URI option, 32-bit integer given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "username" URI option, ObjectId given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "username" URI option, array given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected string for "username" URI option, document given
|
|
|
|
Testing document options:
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected array or object for "authMechanismProperties" URI option, boolean given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected array or object for "authMechanismProperties" URI option, double given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected array or object for "authMechanismProperties" URI option, 32-bit integer given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected array or object for "authMechanismProperties" URI option, string given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected array or object for "authMechanismProperties" URI option, ObjectId given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected array or object for "authMechanismProperties" URI option, array given
|
|
===DONE===
|