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
|
--TEST--
Test for PHP-602: Use real error codes for MongoConnectionException on ctor failure.
--FILE--
<?php
echo "ARRAY:\n";
try {
$m = new MongoClient("localhost", array("connect" => false, "timeou" => 4));
} catch(Exception $e) {
var_dump($e->getCode(), $e->getMessage());
}
try {
$m = new MongoClient("localhost", array("connect" => false, "readPreference" => "nearest", "slaveOkay" => true));
} catch(Exception $e) {
var_dump($e->getCode(), $e->getMessage());
}
try {
$m = new MongoClient("localhost", array("connect" => false, "bogus"));
} catch(Exception $e) {
var_dump($e->getCode(), $e->getMessage());
}
echo "STRING:\n";
try {
$m = new MongoClient("mongodb://localhost/?readPreference");
} catch(Exception $e) {
var_dump($e->getCode(), $e->getMessage());
}
try {
$m = new MongoClient("mongodb://localhost/?=true");
} catch(Exception $e) {
var_dump($e->getCode(), $e->getMessage());
}
try {
$m = new MongoClient("mongodb://localhost/?timeou=4");
} catch(Exception $e) {
var_dump($e->getCode(), $e->getMessage());
}
try {
$m = new MongoClient("mongodb://localhost/?readPreference=nearest;slaveOkay=true");
} catch(Exception $e) {
var_dump($e->getCode(), $e->getMessage());
}
echo "OTHERS:\n";
MongoCursor::$slaveOkay = true;
try {
$m = new MongoClient("localhost", array("connect" => false, "readPreference" => "nearest"));
} catch(Exception $e) {
var_dump($e->getCode(), $e->getMessage());
}
?>
--EXPECT--
ARRAY:
int(22)
string(64) "- Found unknown connection string option 'timeou' with value '4'"
int(23)
string(87) "You can not use both slaveOkay and read-preferences. Please switch to read-preferences."
int(25)
string(34) "Unrecognized or unsupported option"
STRING:
int(21)
string(29) "- Found an empty option value"
int(21)
string(28) "- Found an empty option name"
int(22)
string(64) "- Found unknown connection string option 'timeou' with value '4'"
int(23)
string(87) "You can not use both slaveOkay and read-preferences. Please switch to read-preferences."
OTHERS:
int(23)
string(87) "You can not use both slaveOkay and read-preferences. Please switch to read-preferences."
|