xref: /PHP-8.0/ext/date/tests/mktime_error.phpt (revision 9975986b)
1--TEST--
2Test mktime() function : error conditions
3--FILE--
4<?php
5//Set the default time zone
6date_default_timezone_set("Europe/London");
7
8echo "*** Testing mktime() : error conditions ***\n";
9
10echo "\n-- Testing mktime() function with Zero arguments --\n";
11try {
12    var_dump( mktime() );
13} catch (TypeError $e) {
14    echo $e->getMessage(), "\n";
15}
16
17echo "\n-- Testing mktime() function with more than expected no. of arguments --\n";
18$hour = 10;
19$minute = 30;
20$sec = 45;
21$month = 7;
22$day = 2;
23$year = 1963;
24$extra_arg = 10;
25try {
26    var_dump( mktime($hour, $minute, $sec, $month, $day, $year, $extra_arg) );
27} catch (TypeError $e) {
28    echo $e->getMessage(), "\n";
29}
30
31?>
32--EXPECT--
33*** Testing mktime() : error conditions ***
34
35-- Testing mktime() function with Zero arguments --
36mktime() expects at least 1 argument, 0 given
37
38-- Testing mktime() function with more than expected no. of arguments --
39mktime() expects at most 6 arguments, 7 given
40