@@ -8,12 +8,19 @@ require_once __DIR__ . '/../utils/basic.inc';
8
8
/* UTCDateTime::__construct() internally converts floats to integers, so we will
9
9
* not use a float to test for an invalid value. We also don't test an object,
10
10
* 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
+ ];
12
18
13
19
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 ;
17
24
}
18
25
19
26
?>
@@ -24,4 +31,8 @@ OK: Got MongoDB\Driver\Exception\InvalidArgumentException
24
31
Expected integer or object, bool given
25
32
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
26
33
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
27
38
===DONE===
0 commit comments