Skip to content

Commit 860c696

Browse files
committed
PHPC-1248: Add test to ensure that URI constant is successfully parsed
1 parent 99383ba commit 860c696

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

tests/manager/manager-ctor-005.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
MongoDB\Driver\Manager::__construct(): Ensure environmental URI is parsable
3+
--FILE--
4+
<?php
5+
require_once __DIR__ . "/../utils/basic.inc";
6+
7+
$manager = new MongoDB\Driver\Manager(URI);
8+
?>
9+
===DONE===
10+
<?php exit(0); ?>
11+
--EXPECT--
12+
===DONE===

tests/manager/manager-ctor-006.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
MongoDB\Driver\Manager::__construct(): Unparsable environmental URI
3+
--ENV--
4+
MONGODB_URI=invalid
5+
--FILE--
6+
<?php
7+
require_once __DIR__ . "/../utils/basic.inc";
8+
9+
echo throws(function() {
10+
$manager = new MongoDB\Driver\Manager(URI);
11+
}, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n";
12+
?>
13+
===DONE===
14+
<?php exit(0); ?>
15+
--EXPECT--
16+
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
17+
Failed to parse MongoDB URI: 'invalid'. Invalid URI Schema, expecting 'mongodb://' or 'mongodb+srv://'.
18+
===DONE===

0 commit comments

Comments
 (0)