Skip to content

Commit 2057018

Browse files
committed
Consolidate tests for invalid values
1 parent 9ccf13b commit 2057018

File tree

3 files changed

+15
-58
lines changed

3 files changed

+15
-58
lines changed

tests/bson/bson-utcdatetime-008.phpt

Lines changed: 0 additions & 16 deletions
This file was deleted.

tests/bson/bson-utcdatetime_error-003.phpt

Lines changed: 0 additions & 38 deletions
This file was deleted.

tests/bson/bson-utcdatetime_error-004.phpt

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,19 @@ require_once __DIR__ . '/../utils/basic.inc';
88
/* UTCDateTime::__construct() internally converts floats to integers, so we will
99
* not use a float to test for an invalid value. We also don't test an object,
1010
* since that is used for validating a possible DateTimeInterface argument. */
11-
$invalidValues = [true, []];
11+
$invalidValues = [
12+
true,
13+
[],
14+
// Numeric strings are no longer supported as of 2.0
15+
'1416445411987',
16+
'1234.5678',
17+
];
1218

1319
foreach ($invalidValues as $invalidValue) {
14-
echo throws(function() use ($invalidValue) {
15-
new MongoDB\BSON\UTCDateTime($invalidValue);
16-
}, 'MongoDB\Driver\Exception\InvalidArgumentException'), "\n";
20+
echo throws(
21+
fn () => new MongoDB\BSON\UTCDateTime($invalidValue),
22+
MongoDB\Driver\Exception\InvalidArgumentException::class,
23+
), PHP_EOL;
1724
}
1825

1926
?>
@@ -24,4 +31,8 @@ OK: Got MongoDB\Driver\Exception\InvalidArgumentException
2431
Expected integer or object, bool given
2532
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
2633
Expected integer or object, array given
34+
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
35+
Expected integer or object, string given
36+
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
37+
Expected integer or object, string given
2738
===DONE===

0 commit comments

Comments
 (0)