From: Sanjay Mantoor Date: Fri, 9 Jan 2009 05:10:33 +0000 (+0000) Subject: New testcases for localtime function X-Git-Tag: php-5.4.0alpha1~191^2~4581 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=44fd24fe0fb0f1f93fa84e954d2a19a0cc7914c6;p=php New testcases for localtime function --- diff --git a/ext/date/tests/localtime_basic.phpt b/ext/date/tests/localtime_basic.phpt new file mode 100644 index 0000000000..b5bcfac94e --- /dev/null +++ b/ext/date/tests/localtime_basic.phpt @@ -0,0 +1,93 @@ +--TEST-- +Test localtime() function : basic functionality +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing localtime() : basic functionality *** +array(9) { + [u"tm_sec"]=> + int(10) + [u"tm_min"]=> + int(0) + [u"tm_hour"]=> + int(0) + [u"tm_mday"]=> + int(1) + [u"tm_mon"]=> + int(0) + [u"tm_year"]=> + int(70) + [u"tm_wday"]=> + int(4) + [u"tm_yday"]=> + int(0) + [u"tm_isdst"]=> + int(0) +} +array(9) { + [0]=> + int(10) + [1]=> + int(0) + [2]=> + int(0) + [3]=> + int(1) + [4]=> + int(0) + [5]=> + int(70) + [6]=> + int(4) + [7]=> + int(0) + [8]=> + int(0) +} +array(9) { + [0]=> + int(%d) + [1]=> + int(%d) + [2]=> + int(%d) + [3]=> + int(%d) + [4]=> + int(%d) + [5]=> + int(%d) + [6]=> + int(%d) + [7]=> + int(%d) + [8]=> + int(%d) +} +===DONE=== diff --git a/ext/date/tests/localtime_variation1.phpt b/ext/date/tests/localtime_variation1.phpt new file mode 100644 index 0000000000..9becf086fd --- /dev/null +++ b/ext/date/tests/localtime_variation1.phpt @@ -0,0 +1,658 @@ +--TEST-- +Test localtime() function : usage variation - Passing unexpected values to first argument 'timestamp'. +--FILE-- + 1, 'two' => 2); + +//array of values to iterate over +$inputs = array( + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, +); + +// loop through each element of the array for timestamp + +foreach($inputs as $key =>$value) { + echo "\n--$key--\n"; + var_dump( localtime($value) ); + var_dump( localtime($value, $is_associative) ); +}; + +?> +===DONE=== +--EXPECTF-- +*** Testing localtime() : usage variation *** + +--float 10.5-- +array(9) { + [0]=> + int(10) + [1]=> + int(0) + [2]=> + int(0) + [3]=> + int(1) + [4]=> + int(0) + [5]=> + int(70) + [6]=> + int(4) + [7]=> + int(0) + [8]=> + int(0) +} +array(9) { + [u"tm_sec"]=> + int(10) + [u"tm_min"]=> + int(0) + [u"tm_hour"]=> + int(0) + [u"tm_mday"]=> + int(1) + [u"tm_mon"]=> + int(0) + [u"tm_year"]=> + int(70) + [u"tm_wday"]=> + int(4) + [u"tm_yday"]=> + int(0) + [u"tm_isdst"]=> + int(0) +} + +--float -10.5-- +array(9) { + [0]=> + int(50) + [1]=> + int(59) + [2]=> + int(23) + [3]=> + int(31) + [4]=> + int(11) + [5]=> + int(69) + [6]=> + int(3) + [7]=> + int(364) + [8]=> + int(0) +} +array(9) { + [u"tm_sec"]=> + int(50) + [u"tm_min"]=> + int(59) + [u"tm_hour"]=> + int(23) + [u"tm_mday"]=> + int(31) + [u"tm_mon"]=> + int(11) + [u"tm_year"]=> + int(69) + [u"tm_wday"]=> + int(3) + [u"tm_yday"]=> + int(364) + [u"tm_isdst"]=> + int(0) +} + +--float .5-- +array(9) { + [0]=> + int(0) + [1]=> + int(0) + [2]=> + int(0) + [3]=> + int(1) + [4]=> + int(0) + [5]=> + int(70) + [6]=> + int(4) + [7]=> + int(0) + [8]=> + int(0) +} +array(9) { + [u"tm_sec"]=> + int(0) + [u"tm_min"]=> + int(0) + [u"tm_hour"]=> + int(0) + [u"tm_mday"]=> + int(1) + [u"tm_mon"]=> + int(0) + [u"tm_year"]=> + int(70) + [u"tm_wday"]=> + int(4) + [u"tm_yday"]=> + int(0) + [u"tm_isdst"]=> + int(0) +} + +--empty array-- + +Warning: localtime() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Warning: localtime() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +--int indexed array-- + +Warning: localtime() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Warning: localtime() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +--associative array-- + +Warning: localtime() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Warning: localtime() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +--nested arrays-- + +Warning: localtime() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Warning: localtime() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +--uppercase NULL-- +array(9) { + [0]=> + int(0) + [1]=> + int(0) + [2]=> + int(0) + [3]=> + int(1) + [4]=> + int(0) + [5]=> + int(70) + [6]=> + int(4) + [7]=> + int(0) + [8]=> + int(0) +} +array(9) { + [u"tm_sec"]=> + int(0) + [u"tm_min"]=> + int(0) + [u"tm_hour"]=> + int(0) + [u"tm_mday"]=> + int(1) + [u"tm_mon"]=> + int(0) + [u"tm_year"]=> + int(70) + [u"tm_wday"]=> + int(4) + [u"tm_yday"]=> + int(0) + [u"tm_isdst"]=> + int(0) +} + +--lowercase null-- +array(9) { + [0]=> + int(0) + [1]=> + int(0) + [2]=> + int(0) + [3]=> + int(1) + [4]=> + int(0) + [5]=> + int(70) + [6]=> + int(4) + [7]=> + int(0) + [8]=> + int(0) +} +array(9) { + [u"tm_sec"]=> + int(0) + [u"tm_min"]=> + int(0) + [u"tm_hour"]=> + int(0) + [u"tm_mday"]=> + int(1) + [u"tm_mon"]=> + int(0) + [u"tm_year"]=> + int(70) + [u"tm_wday"]=> + int(4) + [u"tm_yday"]=> + int(0) + [u"tm_isdst"]=> + int(0) +} + +--lowercase true-- +array(9) { + [0]=> + int(1) + [1]=> + int(0) + [2]=> + int(0) + [3]=> + int(1) + [4]=> + int(0) + [5]=> + int(70) + [6]=> + int(4) + [7]=> + int(0) + [8]=> + int(0) +} +array(9) { + [u"tm_sec"]=> + int(1) + [u"tm_min"]=> + int(0) + [u"tm_hour"]=> + int(0) + [u"tm_mday"]=> + int(1) + [u"tm_mon"]=> + int(0) + [u"tm_year"]=> + int(70) + [u"tm_wday"]=> + int(4) + [u"tm_yday"]=> + int(0) + [u"tm_isdst"]=> + int(0) +} + +--lowercase false-- +array(9) { + [0]=> + int(0) + [1]=> + int(0) + [2]=> + int(0) + [3]=> + int(1) + [4]=> + int(0) + [5]=> + int(70) + [6]=> + int(4) + [7]=> + int(0) + [8]=> + int(0) +} +array(9) { + [u"tm_sec"]=> + int(0) + [u"tm_min"]=> + int(0) + [u"tm_hour"]=> + int(0) + [u"tm_mday"]=> + int(1) + [u"tm_mon"]=> + int(0) + [u"tm_year"]=> + int(70) + [u"tm_wday"]=> + int(4) + [u"tm_yday"]=> + int(0) + [u"tm_isdst"]=> + int(0) +} + +--uppercase TRUE-- +array(9) { + [0]=> + int(1) + [1]=> + int(0) + [2]=> + int(0) + [3]=> + int(1) + [4]=> + int(0) + [5]=> + int(70) + [6]=> + int(4) + [7]=> + int(0) + [8]=> + int(0) +} +array(9) { + [u"tm_sec"]=> + int(1) + [u"tm_min"]=> + int(0) + [u"tm_hour"]=> + int(0) + [u"tm_mday"]=> + int(1) + [u"tm_mon"]=> + int(0) + [u"tm_year"]=> + int(70) + [u"tm_wday"]=> + int(4) + [u"tm_yday"]=> + int(0) + [u"tm_isdst"]=> + int(0) +} + +--uppercase FALSE-- +array(9) { + [0]=> + int(0) + [1]=> + int(0) + [2]=> + int(0) + [3]=> + int(1) + [4]=> + int(0) + [5]=> + int(70) + [6]=> + int(4) + [7]=> + int(0) + [8]=> + int(0) +} +array(9) { + [u"tm_sec"]=> + int(0) + [u"tm_min"]=> + int(0) + [u"tm_hour"]=> + int(0) + [u"tm_mday"]=> + int(1) + [u"tm_mon"]=> + int(0) + [u"tm_year"]=> + int(70) + [u"tm_wday"]=> + int(4) + [u"tm_yday"]=> + int(0) + [u"tm_isdst"]=> + int(0) +} + +--empty string DQ-- + +Warning: localtime() expects parameter 1 to be long, Unicode string given in %s on line %d +bool(false) + +Warning: localtime() expects parameter 1 to be long, Unicode string given in %s on line %d +bool(false) + +--empty string SQ-- + +Warning: localtime() expects parameter 1 to be long, Unicode string given in %s on line %d +bool(false) + +Warning: localtime() expects parameter 1 to be long, Unicode string given in %s on line %d +bool(false) + +--string DQ-- + +Warning: localtime() expects parameter 1 to be long, Unicode string given in %s on line %d +bool(false) + +Warning: localtime() expects parameter 1 to be long, Unicode string given in %s on line %d +bool(false) + +--string SQ-- + +Warning: localtime() expects parameter 1 to be long, Unicode string given in %s on line %d +bool(false) + +Warning: localtime() expects parameter 1 to be long, Unicode string given in %s on line %d +bool(false) + +--mixed case string-- + +Warning: localtime() expects parameter 1 to be long, Unicode string given in %s on line %d +bool(false) + +Warning: localtime() expects parameter 1 to be long, Unicode string given in %s on line %d +bool(false) + +--heredoc-- + +Warning: localtime() expects parameter 1 to be long, Unicode string given in %s on line %d +bool(false) + +Warning: localtime() expects parameter 1 to be long, Unicode string given in %s on line %d +bool(false) + +--instance of classWithToString-- + +Warning: localtime() expects parameter 1 to be long, object given in %s on line %d +bool(false) + +Warning: localtime() expects parameter 1 to be long, object given in %s on line %d +bool(false) + +--instance of classWithoutToString-- + +Warning: localtime() expects parameter 1 to be long, object given in %s on line %d +bool(false) + +Warning: localtime() expects parameter 1 to be long, object given in %s on line %d +bool(false) + +--undefined var-- +array(9) { + [0]=> + int(0) + [1]=> + int(0) + [2]=> + int(0) + [3]=> + int(1) + [4]=> + int(0) + [5]=> + int(70) + [6]=> + int(4) + [7]=> + int(0) + [8]=> + int(0) +} +array(9) { + [u"tm_sec"]=> + int(0) + [u"tm_min"]=> + int(0) + [u"tm_hour"]=> + int(0) + [u"tm_mday"]=> + int(1) + [u"tm_mon"]=> + int(0) + [u"tm_year"]=> + int(70) + [u"tm_wday"]=> + int(4) + [u"tm_yday"]=> + int(0) + [u"tm_isdst"]=> + int(0) +} + +--unset var-- +array(9) { + [0]=> + int(0) + [1]=> + int(0) + [2]=> + int(0) + [3]=> + int(1) + [4]=> + int(0) + [5]=> + int(70) + [6]=> + int(4) + [7]=> + int(0) + [8]=> + int(0) +} +array(9) { + [u"tm_sec"]=> + int(0) + [u"tm_min"]=> + int(0) + [u"tm_hour"]=> + int(0) + [u"tm_mday"]=> + int(1) + [u"tm_mon"]=> + int(0) + [u"tm_year"]=> + int(70) + [u"tm_wday"]=> + int(4) + [u"tm_yday"]=> + int(0) + [u"tm_isdst"]=> + int(0) +} +===DONE=== diff --git a/ext/date/tests/localtime_variation2.phpt b/ext/date/tests/localtime_variation2.phpt new file mode 100644 index 0000000000..39523155d4 --- /dev/null +++ b/ext/date/tests/localtime_variation2.phpt @@ -0,0 +1,643 @@ +--TEST-- +Test localtime() function : usage variation - Passing unexpected values to second argument 'associative_array'. +--FILE-- + 1, 'two' => 2); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -2345, + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float 12.3456789000e10' => 12.3456789000e10, + 'float -12.3456789000e10' => -12.3456789000e10, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, +); + +// loop through each element of the array for associative_array + +foreach($inputs as $key =>$value) { + echo "\n--$key--\n"; + var_dump( localtime($timestamp, $value) ); +}; + +?> +===DONE=== +--EXPECTF-- +*** Testing localtime() : usage variation *** + +--int 0-- +array(9) { + [0]=> + int(10) + [1]=> + int(0) + [2]=> + int(0) + [3]=> + int(1) + [4]=> + int(0) + [5]=> + int(70) + [6]=> + int(4) + [7]=> + int(0) + [8]=> + int(0) +} + +--int 1-- +array(9) { + [u"tm_sec"]=> + int(10) + [u"tm_min"]=> + int(0) + [u"tm_hour"]=> + int(0) + [u"tm_mday"]=> + int(1) + [u"tm_mon"]=> + int(0) + [u"tm_year"]=> + int(70) + [u"tm_wday"]=> + int(4) + [u"tm_yday"]=> + int(0) + [u"tm_isdst"]=> + int(0) +} + +--int 12345-- +array(9) { + [u"tm_sec"]=> + int(10) + [u"tm_min"]=> + int(0) + [u"tm_hour"]=> + int(0) + [u"tm_mday"]=> + int(1) + [u"tm_mon"]=> + int(0) + [u"tm_year"]=> + int(70) + [u"tm_wday"]=> + int(4) + [u"tm_yday"]=> + int(0) + [u"tm_isdst"]=> + int(0) +} + +--int -12345-- +array(9) { + [u"tm_sec"]=> + int(10) + [u"tm_min"]=> + int(0) + [u"tm_hour"]=> + int(0) + [u"tm_mday"]=> + int(1) + [u"tm_mon"]=> + int(0) + [u"tm_year"]=> + int(70) + [u"tm_wday"]=> + int(4) + [u"tm_yday"]=> + int(0) + [u"tm_isdst"]=> + int(0) +} + +--float 10.5-- +array(9) { + [u"tm_sec"]=> + int(10) + [u"tm_min"]=> + int(0) + [u"tm_hour"]=> + int(0) + [u"tm_mday"]=> + int(1) + [u"tm_mon"]=> + int(0) + [u"tm_year"]=> + int(70) + [u"tm_wday"]=> + int(4) + [u"tm_yday"]=> + int(0) + [u"tm_isdst"]=> + int(0) +} + +--float -10.5-- +array(9) { + [u"tm_sec"]=> + int(10) + [u"tm_min"]=> + int(0) + [u"tm_hour"]=> + int(0) + [u"tm_mday"]=> + int(1) + [u"tm_mon"]=> + int(0) + [u"tm_year"]=> + int(70) + [u"tm_wday"]=> + int(4) + [u"tm_yday"]=> + int(0) + [u"tm_isdst"]=> + int(0) +} + +--float 12.3456789000e10-- +array(9) { + [u"tm_sec"]=> + int(10) + [u"tm_min"]=> + int(0) + [u"tm_hour"]=> + int(0) + [u"tm_mday"]=> + int(1) + [u"tm_mon"]=> + int(0) + [u"tm_year"]=> + int(70) + [u"tm_wday"]=> + int(4) + [u"tm_yday"]=> + int(0) + [u"tm_isdst"]=> + int(0) +} + +--float -12.3456789000e10-- +array(9) { + [u"tm_sec"]=> + int(10) + [u"tm_min"]=> + int(0) + [u"tm_hour"]=> + int(0) + [u"tm_mday"]=> + int(1) + [u"tm_mon"]=> + int(0) + [u"tm_year"]=> + int(70) + [u"tm_wday"]=> + int(4) + [u"tm_yday"]=> + int(0) + [u"tm_isdst"]=> + int(0) +} + +--float .5-- +array(9) { + [u"tm_sec"]=> + int(10) + [u"tm_min"]=> + int(0) + [u"tm_hour"]=> + int(0) + [u"tm_mday"]=> + int(1) + [u"tm_mon"]=> + int(0) + [u"tm_year"]=> + int(70) + [u"tm_wday"]=> + int(4) + [u"tm_yday"]=> + int(0) + [u"tm_isdst"]=> + int(0) +} + +--empty array-- + +Warning: localtime() expects parameter 2 to be boolean, array given in %s on line %d +bool(false) + +--int indexed array-- + +Warning: localtime() expects parameter 2 to be boolean, array given in %s on line %d +bool(false) + +--associative array-- + +Warning: localtime() expects parameter 2 to be boolean, array given in %s on line %d +bool(false) + +--nested arrays-- + +Warning: localtime() expects parameter 2 to be boolean, array given in %s on line %d +bool(false) + +--uppercase NULL-- +array(9) { + [0]=> + int(10) + [1]=> + int(0) + [2]=> + int(0) + [3]=> + int(1) + [4]=> + int(0) + [5]=> + int(70) + [6]=> + int(4) + [7]=> + int(0) + [8]=> + int(0) +} + +--lowercase null-- +array(9) { + [0]=> + int(10) + [1]=> + int(0) + [2]=> + int(0) + [3]=> + int(1) + [4]=> + int(0) + [5]=> + int(70) + [6]=> + int(4) + [7]=> + int(0) + [8]=> + int(0) +} + +--lowercase true-- +array(9) { + [u"tm_sec"]=> + int(10) + [u"tm_min"]=> + int(0) + [u"tm_hour"]=> + int(0) + [u"tm_mday"]=> + int(1) + [u"tm_mon"]=> + int(0) + [u"tm_year"]=> + int(70) + [u"tm_wday"]=> + int(4) + [u"tm_yday"]=> + int(0) + [u"tm_isdst"]=> + int(0) +} + +--lowercase false-- +array(9) { + [0]=> + int(10) + [1]=> + int(0) + [2]=> + int(0) + [3]=> + int(1) + [4]=> + int(0) + [5]=> + int(70) + [6]=> + int(4) + [7]=> + int(0) + [8]=> + int(0) +} + +--uppercase TRUE-- +array(9) { + [u"tm_sec"]=> + int(10) + [u"tm_min"]=> + int(0) + [u"tm_hour"]=> + int(0) + [u"tm_mday"]=> + int(1) + [u"tm_mon"]=> + int(0) + [u"tm_year"]=> + int(70) + [u"tm_wday"]=> + int(4) + [u"tm_yday"]=> + int(0) + [u"tm_isdst"]=> + int(0) +} + +--uppercase FALSE-- +array(9) { + [0]=> + int(10) + [1]=> + int(0) + [2]=> + int(0) + [3]=> + int(1) + [4]=> + int(0) + [5]=> + int(70) + [6]=> + int(4) + [7]=> + int(0) + [8]=> + int(0) +} + +--empty string DQ-- +array(9) { + [0]=> + int(10) + [1]=> + int(0) + [2]=> + int(0) + [3]=> + int(1) + [4]=> + int(0) + [5]=> + int(70) + [6]=> + int(4) + [7]=> + int(0) + [8]=> + int(0) +} + +--empty string SQ-- +array(9) { + [0]=> + int(10) + [1]=> + int(0) + [2]=> + int(0) + [3]=> + int(1) + [4]=> + int(0) + [5]=> + int(70) + [6]=> + int(4) + [7]=> + int(0) + [8]=> + int(0) +} + +--string DQ-- +array(9) { + [u"tm_sec"]=> + int(10) + [u"tm_min"]=> + int(0) + [u"tm_hour"]=> + int(0) + [u"tm_mday"]=> + int(1) + [u"tm_mon"]=> + int(0) + [u"tm_year"]=> + int(70) + [u"tm_wday"]=> + int(4) + [u"tm_yday"]=> + int(0) + [u"tm_isdst"]=> + int(0) +} + +--string SQ-- +array(9) { + [u"tm_sec"]=> + int(10) + [u"tm_min"]=> + int(0) + [u"tm_hour"]=> + int(0) + [u"tm_mday"]=> + int(1) + [u"tm_mon"]=> + int(0) + [u"tm_year"]=> + int(70) + [u"tm_wday"]=> + int(4) + [u"tm_yday"]=> + int(0) + [u"tm_isdst"]=> + int(0) +} + +--mixed case string-- +array(9) { + [u"tm_sec"]=> + int(10) + [u"tm_min"]=> + int(0) + [u"tm_hour"]=> + int(0) + [u"tm_mday"]=> + int(1) + [u"tm_mon"]=> + int(0) + [u"tm_year"]=> + int(70) + [u"tm_wday"]=> + int(4) + [u"tm_yday"]=> + int(0) + [u"tm_isdst"]=> + int(0) +} + +--heredoc-- +array(9) { + [u"tm_sec"]=> + int(10) + [u"tm_min"]=> + int(0) + [u"tm_hour"]=> + int(0) + [u"tm_mday"]=> + int(1) + [u"tm_mon"]=> + int(0) + [u"tm_year"]=> + int(70) + [u"tm_wday"]=> + int(4) + [u"tm_yday"]=> + int(0) + [u"tm_isdst"]=> + int(0) +} + +--instance of classWithToString-- + +Warning: localtime() expects parameter 2 to be boolean, object given in %s on line %d +bool(false) + +--instance of classWithoutToString-- + +Warning: localtime() expects parameter 2 to be boolean, object given in %s on line %d +bool(false) + +--undefined var-- +array(9) { + [0]=> + int(10) + [1]=> + int(0) + [2]=> + int(0) + [3]=> + int(1) + [4]=> + int(0) + [5]=> + int(70) + [6]=> + int(4) + [7]=> + int(0) + [8]=> + int(0) +} + +--unset var-- +array(9) { + [0]=> + int(10) + [1]=> + int(0) + [2]=> + int(0) + [3]=> + int(1) + [4]=> + int(0) + [5]=> + int(70) + [6]=> + int(4) + [7]=> + int(0) + [8]=> + int(0) +} +===DONE=== diff --git a/ext/date/tests/localtime_variation3.phpt b/ext/date/tests/localtime_variation3.phpt new file mode 100644 index 0000000000..c9d792472b --- /dev/null +++ b/ext/date/tests/localtime_variation3.phpt @@ -0,0 +1,116 @@ +--TEST-- +Test localtime() function : usage variation - Passing higher positive and negetive float values to timestamp. +--FILE-- + +===DONE=== +--EXPECTREGEX-- +\*\*\* Testing localtime\(\) : usage variation \*\*\* + +-- Testing localtime\(\) function with 'float 12.3456789000e10' to timestamp -- +array\(9\) { + \[0\]=> + int\((7|0)\) + \[1\]=> + int\((14|30)\) + \[2\]=> + int\((3|0)\) + \[3\]=> + int\((19|11)\) + \[4\]=> + int\((0|2)\) + \[5\]=> + int\((138|3982)\) + \[6\]=> + int\((2|6)\) + \[7\]=> + int\((18|69)\) + \[8\]=> + int\(0\) +} +array\(9\) { + \[u"tm_sec"\]=> + int\((7|0)\) + \[u"tm_min"\]=> + int\((14|30)\) + \[u"tm_hour"\]=> + int\((3|0)\) + \[u"tm_mday"\]=> + int\((19|11)\) + \[u"tm_mon"\]=> + int\((0|2)\) + \[u"tm_year"\]=> + int\((138|3982)\) + \[u"tm_wday"\]=> + int\((2|6)\) + \[u"tm_yday"\]=> + int\((18|69)\) + \[u"tm_isdst"\]=> + int\(0\) +} + +-- Testing localtime\(\) function with 'float -12.3456789000e10' to timestamp -- +array\(9\) { + \[0\]=> + int\((52|0)\) + \[1\]=> + int\((45|30)\) + \[2\]=> + int\((20|23)\) + \[3\]=> + int\((13|22)\) + \[4\]=> + int\((11|9)\) + \[5\]=> + int\((1|-3843)\) + \[6\]=> + int\((5|-5)\) + \[7\]=> + int\((346|294)\) + \[8\]=> + int\(0\) +} +array\(9\) { + \[u"tm_sec"\]=> + int\((52|0)\) + \[u"tm_min"\]=> + int\((45|30)\) + \[u"tm_hour"\]=> + int\((20|23)\) + \[u"tm_mday"\]=> + int\((13|22)\) + \[u"tm_mon"\]=> + int\((11|9)\) + \[u"tm_year"\]=> + int\((1|-3843)\) + \[u"tm_wday"\]=> + int\((5|-5)\) + \[u"tm_yday"\]=> + int\((346|294)\) + \[u"tm_isdst"\]=> + int\(0\) +} +===DONE=== diff --git a/ext/date/tests/localtime_variation4.phpt b/ext/date/tests/localtime_variation4.phpt new file mode 100644 index 0000000000..87fe3c46c0 --- /dev/null +++ b/ext/date/tests/localtime_variation4.phpt @@ -0,0 +1,162 @@ +--TEST-- +Test localtime() function : usage variation - Passing octal values to timestamp. +--FILE-- + 00, + 'Octal 10' => 012, + 'Octal -10' => -012 +); + +foreach($inputs as $key =>$value) { + echo "\n--$key--\n"; + var_dump( localtime($value) ); + var_dump( localtime($value, $is_associative) ); +} + +?> +===DONE=== +--EXPECTF-- +*** Testing localtime() : usage variation *** + +--Octal 0-- +array(9) { + [0]=> + int(0) + [1]=> + int(0) + [2]=> + int(0) + [3]=> + int(1) + [4]=> + int(0) + [5]=> + int(70) + [6]=> + int(4) + [7]=> + int(0) + [8]=> + int(0) +} +array(9) { + [u"tm_sec"]=> + int(0) + [u"tm_min"]=> + int(0) + [u"tm_hour"]=> + int(0) + [u"tm_mday"]=> + int(1) + [u"tm_mon"]=> + int(0) + [u"tm_year"]=> + int(70) + [u"tm_wday"]=> + int(4) + [u"tm_yday"]=> + int(0) + [u"tm_isdst"]=> + int(0) +} + +--Octal 10-- +array(9) { + [0]=> + int(10) + [1]=> + int(0) + [2]=> + int(0) + [3]=> + int(1) + [4]=> + int(0) + [5]=> + int(70) + [6]=> + int(4) + [7]=> + int(0) + [8]=> + int(0) +} +array(9) { + [u"tm_sec"]=> + int(10) + [u"tm_min"]=> + int(0) + [u"tm_hour"]=> + int(0) + [u"tm_mday"]=> + int(1) + [u"tm_mon"]=> + int(0) + [u"tm_year"]=> + int(70) + [u"tm_wday"]=> + int(4) + [u"tm_yday"]=> + int(0) + [u"tm_isdst"]=> + int(0) +} + +--Octal -10-- +array(9) { + [0]=> + int(50) + [1]=> + int(59) + [2]=> + int(23) + [3]=> + int(31) + [4]=> + int(11) + [5]=> + int(69) + [6]=> + int(3) + [7]=> + int(364) + [8]=> + int(0) +} +array(9) { + [u"tm_sec"]=> + int(50) + [u"tm_min"]=> + int(59) + [u"tm_hour"]=> + int(23) + [u"tm_mday"]=> + int(31) + [u"tm_mon"]=> + int(11) + [u"tm_year"]=> + int(69) + [u"tm_wday"]=> + int(3) + [u"tm_yday"]=> + int(364) + [u"tm_isdst"]=> + int(0) +} +===DONE=== diff --git a/ext/date/tests/localtime_variation5.phpt b/ext/date/tests/localtime_variation5.phpt new file mode 100644 index 0000000000..55a7f760bc --- /dev/null +++ b/ext/date/tests/localtime_variation5.phpt @@ -0,0 +1,162 @@ +--TEST-- +Test localtime() function : usage variation - Passing hexa decimal values to timestamp. +--FILE-- + 0x0, + 'Hexa-decimal 10' => 0xA, + 'Hexa-decimal -10' => -0XA +); + +foreach($inputs as $key =>$value) { + echo "\n--$key--\n"; + var_dump( localtime($value) ); + var_dump( localtime($value, $is_associative) ); +} + +?> +===DONE=== +--EXPECTF-- +*** Testing localtime() : usage variation *** + +--Hexa-decimal 0-- +array(9) { + [0]=> + int(0) + [1]=> + int(0) + [2]=> + int(0) + [3]=> + int(1) + [4]=> + int(0) + [5]=> + int(70) + [6]=> + int(4) + [7]=> + int(0) + [8]=> + int(0) +} +array(9) { + [u"tm_sec"]=> + int(0) + [u"tm_min"]=> + int(0) + [u"tm_hour"]=> + int(0) + [u"tm_mday"]=> + int(1) + [u"tm_mon"]=> + int(0) + [u"tm_year"]=> + int(70) + [u"tm_wday"]=> + int(4) + [u"tm_yday"]=> + int(0) + [u"tm_isdst"]=> + int(0) +} + +--Hexa-decimal 10-- +array(9) { + [0]=> + int(10) + [1]=> + int(0) + [2]=> + int(0) + [3]=> + int(1) + [4]=> + int(0) + [5]=> + int(70) + [6]=> + int(4) + [7]=> + int(0) + [8]=> + int(0) +} +array(9) { + [u"tm_sec"]=> + int(10) + [u"tm_min"]=> + int(0) + [u"tm_hour"]=> + int(0) + [u"tm_mday"]=> + int(1) + [u"tm_mon"]=> + int(0) + [u"tm_year"]=> + int(70) + [u"tm_wday"]=> + int(4) + [u"tm_yday"]=> + int(0) + [u"tm_isdst"]=> + int(0) +} + +--Hexa-decimal -10-- +array(9) { + [0]=> + int(50) + [1]=> + int(59) + [2]=> + int(23) + [3]=> + int(31) + [4]=> + int(11) + [5]=> + int(69) + [6]=> + int(3) + [7]=> + int(364) + [8]=> + int(0) +} +array(9) { + [u"tm_sec"]=> + int(50) + [u"tm_min"]=> + int(59) + [u"tm_hour"]=> + int(23) + [u"tm_mday"]=> + int(31) + [u"tm_mon"]=> + int(11) + [u"tm_year"]=> + int(69) + [u"tm_wday"]=> + int(3) + [u"tm_yday"]=> + int(364) + [u"tm_isdst"]=> + int(0) +} +===DONE===