diff options
| author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2013-03-14 05:42:27 +0000 |
|---|---|---|
| committer | <> | 2013-04-03 16:25:08 +0000 |
| commit | c4dd7a1a684490673e25aaf4fabec5df138854c4 (patch) | |
| tree | 4d57c44caae4480efff02b90b9be86f44bf25409 /ext/date/tests/localtime_variation1.phpt | |
| download | php2-master.tar.gz | |
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/date/tests/localtime_variation1.phpt')
| -rw-r--r-- | ext/date/tests/localtime_variation1.phpt | 658 |
1 files changed, 658 insertions, 0 deletions
diff --git a/ext/date/tests/localtime_variation1.phpt b/ext/date/tests/localtime_variation1.phpt new file mode 100644 index 0000000..472b32b --- /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-- +<?php +/* Prototype : array localtime([int timestamp [, bool associative_array]]) + * Description: Returns the results of the C system call localtime as an associative array + * if the associative_array argument is set to 1 other wise it is a regular array + * Source code: ext/date/php_date.c + * Alias to functions: + */ + +echo "*** Testing localtime() : usage variation ***\n"; + +date_default_timezone_set("UTC"); +// Initialise function arguments not being substituted (if any) +$is_associative = true; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 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) { + ["tm_sec"]=> + int(10) + ["tm_min"]=> + int(0) + ["tm_hour"]=> + int(0) + ["tm_mday"]=> + int(1) + ["tm_mon"]=> + int(0) + ["tm_year"]=> + int(70) + ["tm_wday"]=> + int(4) + ["tm_yday"]=> + int(0) + ["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) { + ["tm_sec"]=> + int(50) + ["tm_min"]=> + int(59) + ["tm_hour"]=> + int(23) + ["tm_mday"]=> + int(31) + ["tm_mon"]=> + int(11) + ["tm_year"]=> + int(69) + ["tm_wday"]=> + int(3) + ["tm_yday"]=> + int(364) + ["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) { + ["tm_sec"]=> + int(0) + ["tm_min"]=> + int(0) + ["tm_hour"]=> + int(0) + ["tm_mday"]=> + int(1) + ["tm_mon"]=> + int(0) + ["tm_year"]=> + int(70) + ["tm_wday"]=> + int(4) + ["tm_yday"]=> + int(0) + ["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) { + ["tm_sec"]=> + int(0) + ["tm_min"]=> + int(0) + ["tm_hour"]=> + int(0) + ["tm_mday"]=> + int(1) + ["tm_mon"]=> + int(0) + ["tm_year"]=> + int(70) + ["tm_wday"]=> + int(4) + ["tm_yday"]=> + int(0) + ["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) { + ["tm_sec"]=> + int(0) + ["tm_min"]=> + int(0) + ["tm_hour"]=> + int(0) + ["tm_mday"]=> + int(1) + ["tm_mon"]=> + int(0) + ["tm_year"]=> + int(70) + ["tm_wday"]=> + int(4) + ["tm_yday"]=> + int(0) + ["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) { + ["tm_sec"]=> + int(1) + ["tm_min"]=> + int(0) + ["tm_hour"]=> + int(0) + ["tm_mday"]=> + int(1) + ["tm_mon"]=> + int(0) + ["tm_year"]=> + int(70) + ["tm_wday"]=> + int(4) + ["tm_yday"]=> + int(0) + ["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) { + ["tm_sec"]=> + int(0) + ["tm_min"]=> + int(0) + ["tm_hour"]=> + int(0) + ["tm_mday"]=> + int(1) + ["tm_mon"]=> + int(0) + ["tm_year"]=> + int(70) + ["tm_wday"]=> + int(4) + ["tm_yday"]=> + int(0) + ["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) { + ["tm_sec"]=> + int(1) + ["tm_min"]=> + int(0) + ["tm_hour"]=> + int(0) + ["tm_mday"]=> + int(1) + ["tm_mon"]=> + int(0) + ["tm_year"]=> + int(70) + ["tm_wday"]=> + int(4) + ["tm_yday"]=> + int(0) + ["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) { + ["tm_sec"]=> + int(0) + ["tm_min"]=> + int(0) + ["tm_hour"]=> + int(0) + ["tm_mday"]=> + int(1) + ["tm_mon"]=> + int(0) + ["tm_year"]=> + int(70) + ["tm_wday"]=> + int(4) + ["tm_yday"]=> + int(0) + ["tm_isdst"]=> + int(0) +} + +--empty string DQ-- + +Warning: localtime() expects parameter 1 to be long, string given in %s on line %d +bool(false) + +Warning: localtime() expects parameter 1 to be long, string given in %s on line %d +bool(false) + +--empty string SQ-- + +Warning: localtime() expects parameter 1 to be long, string given in %s on line %d +bool(false) + +Warning: localtime() expects parameter 1 to be long, string given in %s on line %d +bool(false) + +--string DQ-- + +Warning: localtime() expects parameter 1 to be long, string given in %s on line %d +bool(false) + +Warning: localtime() expects parameter 1 to be long, string given in %s on line %d +bool(false) + +--string SQ-- + +Warning: localtime() expects parameter 1 to be long, string given in %s on line %d +bool(false) + +Warning: localtime() expects parameter 1 to be long, string given in %s on line %d +bool(false) + +--mixed case string-- + +Warning: localtime() expects parameter 1 to be long, string given in %s on line %d +bool(false) + +Warning: localtime() expects parameter 1 to be long, string given in %s on line %d +bool(false) + +--heredoc-- + +Warning: localtime() expects parameter 1 to be long, string given in %s on line %d +bool(false) + +Warning: localtime() expects parameter 1 to be long, 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) { + ["tm_sec"]=> + int(0) + ["tm_min"]=> + int(0) + ["tm_hour"]=> + int(0) + ["tm_mday"]=> + int(1) + ["tm_mon"]=> + int(0) + ["tm_year"]=> + int(70) + ["tm_wday"]=> + int(4) + ["tm_yday"]=> + int(0) + ["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) { + ["tm_sec"]=> + int(0) + ["tm_min"]=> + int(0) + ["tm_hour"]=> + int(0) + ["tm_mday"]=> + int(1) + ["tm_mon"]=> + int(0) + ["tm_year"]=> + int(70) + ["tm_wday"]=> + int(4) + ["tm_yday"]=> + int(0) + ["tm_isdst"]=> + int(0) +} +===DONE=== |
