php-src/ext/date/tests/DateTime_setTime_error.phpt
Derick Rethans 55626549d8 Improve support for microseconds with Date/Time
It fixes several bugs:

- Fixed bug #45554 (Inconsistent behavior of the u format char).
- Fixed bug #48225 (DateTime parser doesn't set microseconds for "now").
- Fixed bug #52514 (microseconds are missing in DateTime class).
- Fixed bug #52519 (microseconds in DateInterval are missing).
- Fixed bug #68506 (General DateTime improvments needed for microseconds to become useful).
- Fixed bug #73109 (timelib_meridian doesn't parse dots correctly).
- Fixed bug #73247 (DateTime constructor does not initialise microseconds property).

It also updates timelib to 2016.04, and updates a data mapping file, which
causes changes to the volatile abbreviations tests.
2016-10-05 15:03:06 -04:00

51 lines
1.6 KiB
PHP

--TEST--
Test DateTime::setTime() function : error conditions
--FILE--
<?php
/* Prototype : public DateTime DateTime::setTime ( int $hour , int $minute [, int $second ] )
* Description: Resets the current time of the DateTime object to a different time.
* Source code: ext/date/php_date.c
* Alias to functions: date_time_set
*/
date_default_timezone_set("Europe/London");
echo "*** Testing DateTime::setTime() : error conditions ***\n";
$datetime = date_create("2009-01-31 15:34:10");
echo "\n-- Testing DateTime::setTime() function with zero arguments --\n";
var_dump( $datetime->setTime() );
echo "\n-- Testing DateTime::setTime() function with less than expected no. of arguments --\n";
$hour = 18;
var_dump( $datetime->setTime($hour) );
echo "\n-- Testing DateTime::setTime() function with more than expected no. of arguments --\n";
$min = 15;
$sec = 30;
$extra_arg = 10;
$microseconds = 123123;
var_dump( $datetime->setTime($hour, $min, $sec, $microseconds, $extra_arg) );
?>
===DONE===
--EXPECTF--
*** Testing DateTime::setTime() : error conditions ***
-- Testing DateTime::setTime() function with zero arguments --
Warning: DateTime::setTime() expects at least 2 parameters, 0 given in %s on line %d
bool(false)
-- Testing DateTime::setTime() function with less than expected no. of arguments --
Warning: DateTime::setTime() expects at least 2 parameters, 1 given in %s on line %d
bool(false)
-- Testing DateTime::setTime() function with more than expected no. of arguments --
Warning: DateTime::setTime() expects at most 4 parameters, 5 given in %s on line %d
bool(false)
===DONE===