Updates to Tomato RAF including NGINX && PHP
[tomato.git] / release / src / router / php / ext / date / tests / strftime_variation2.phpt
blobb02423495bd88858735a9db6111b37ae5683c5fe
1 --TEST--
2 Test strftime() function : usage variation - Passing unexpected values to second argument 'timestamp'.
3 --FILE--
4 <?php
5 /* Prototype  : string strftime(string format [, int timestamp])
6  * Description: Format a local time/date according to locale settings 
7  * Source code: ext/date/php_date.c
8  * Alias to functions: 
9  */
11 echo "*** Testing strftime() : usage variation ***\n";
13 date_default_timezone_set("Asia/Calcutta");
14 // Initialise all required variables
15 $format = '%b %d %Y %H:%M:%S';
17 //get an unset variable
18 $unset_var = 10;
19 unset ($unset_var);
21 // define some classes
22 class classWithToString
24         public function __toString() {
25                 return "Class A object";
26         }
29 class classWithoutToString
33 // heredoc string
34 $heredoc = <<<EOT
35 hello world
36 EOT;
38 // add arrays
39 $index_array = array (1, 2, 3);
40 $assoc_array = array ('one' => 1, 'two' => 2);
42 //array of values to iterate over
43 $inputs = array(
45       // float data
46       'float 10.5' => 10.5,
47       'float -10.5' => -10.5,
48       'float .5' => .5,
50       // array data
51       'empty array' => array(),
52       'int indexed array' => $index_array,
53       'associative array' => $assoc_array,
54       'nested arrays' => array('foo', $index_array, $assoc_array),
56       // null data
57       'uppercase NULL' => NULL,
58       'lowercase null' => null,
60       // boolean data
61       'lowercase true' => true,
62       'lowercase false' =>false,
63       'uppercase TRUE' =>TRUE,
64       'uppercase FALSE' =>FALSE,
66       // empty data
67       'empty string DQ' => "",
68       'empty string SQ' => '',
70       // string data
71       'string DQ' => "string",
72       'string SQ' => 'string',
73       'mixed case string' => "sTrInG",
74       'heredoc' => $heredoc,
76       // object data
77       'instance of classWithToString' => new classWithToString(),
78       'instance of classWithoutToString' => new classWithoutToString(),
80       // undefined data
81       'undefined var' => @$undefined_var,
83       // unset data
84       'unset var' => @$unset_var,
87 // loop through each element of the array for timestamp
89 foreach($inputs as $key =>$value) {
90       echo "\n--$key--\n";
91       var_dump( strftime($format, $value) );
95 ===DONE===
96 --EXPECTF--
97 *** Testing strftime() : usage variation ***
99 --float 10.5--
100 string(20) "Jan 01 1970 05:30:10"
102 --float -10.5--
103 string(20) "Jan 01 1970 05:29:50"
105 --float .5--
106 string(20) "Jan 01 1970 05:30:00"
108 --empty array--
110 Warning: strftime() expects parameter 2 to be long, array given in %s on line %d
111 bool(false)
113 --int indexed array--
115 Warning: strftime() expects parameter 2 to be long, array given in %s on line %d
116 bool(false)
118 --associative array--
120 Warning: strftime() expects parameter 2 to be long, array given in %s on line %d
121 bool(false)
123 --nested arrays--
125 Warning: strftime() expects parameter 2 to be long, array given in %s on line %d
126 bool(false)
128 --uppercase NULL--
129 string(20) "Jan 01 1970 05:30:00"
131 --lowercase null--
132 string(20) "Jan 01 1970 05:30:00"
134 --lowercase true--
135 string(20) "Jan 01 1970 05:30:01"
137 --lowercase false--
138 string(20) "Jan 01 1970 05:30:00"
140 --uppercase TRUE--
141 string(20) "Jan 01 1970 05:30:01"
143 --uppercase FALSE--
144 string(20) "Jan 01 1970 05:30:00"
146 --empty string DQ--
148 Warning: strftime() expects parameter 2 to be long, string given in %s on line %d
149 bool(false)
151 --empty string SQ--
153 Warning: strftime() expects parameter 2 to be long, string given in %s on line %d
154 bool(false)
156 --string DQ--
158 Warning: strftime() expects parameter 2 to be long, string given in %s on line %d
159 bool(false)
161 --string SQ--
163 Warning: strftime() expects parameter 2 to be long, string given in %s on line %d
164 bool(false)
166 --mixed case string--
168 Warning: strftime() expects parameter 2 to be long, string given in %s on line %d
169 bool(false)
171 --heredoc--
173 Warning: strftime() expects parameter 2 to be long, string given in %s on line %d
174 bool(false)
176 --instance of classWithToString--
178 Warning: strftime() expects parameter 2 to be long, object given in %s on line %d
179 bool(false)
181 --instance of classWithoutToString--
183 Warning: strftime() expects parameter 2 to be long, object given in %s on line %d
184 bool(false)
186 --undefined var--
187 string(20) "Jan 01 1970 05:30:00"
189 --unset var--
190 string(20) "Jan 01 1970 05:30:00"
191 ===DONE===