Skip to content

Commit 6e5b657

Browse files
committed
PHPC-1548: Add tests for empty authSource URI option
1 parent f397629 commit 6e5b657

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
MongoDB\Driver\Manager::__construct(): empty authSource option causes error
3+
--FILE--
4+
<?php
5+
6+
require_once __DIR__ . '/../utils/basic.inc';
7+
8+
$tests = [
9+
['mongodb://[email protected]/?authSource=', []],
10+
[null, ['authSource' => '']],
11+
];
12+
13+
foreach ($tests as $test) {
14+
[$uri, $options] = $test;
15+
16+
echo throws(function() use ($uri, $options) {
17+
new MongoDB\Driver\Manager($uri, $options);
18+
}, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n";
19+
}
20+
21+
?>
22+
===DONE===
23+
<?php exit(0); ?>
24+
--EXPECT--
25+
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
26+
Failed to parse MongoDB URI: 'mongodb://[email protected]/?authSource='. authSource may not be specified as an empty string.
27+
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
28+
Failed to parse URI options: authSource may not be specified as an empty string
29+
===DONE===

0 commit comments

Comments
 (0)