summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandy wharmby <wharmby@php.net>2009-01-22 18:47:46 +0000
committerandy wharmby <wharmby@php.net>2009-01-22 18:47:46 +0000
commit023db079102edbfff62172211c6141060210640d (patch)
tree7c4144f342ac802ebb168591c8e9e8ab94d65af0
parentea61c335e45fd2ccd8dd46dbe08a210987ec997e (diff)
downloadphp-git-023db079102edbfff62172211c6141060210640d.tar.gz
New date tests for getdate() and gmstrftime(). Tested on WIndows, Linux and Linux 64 bit
-rw-r--r--ext/date/tests/getdate_basic.phpt76
-rw-r--r--ext/date/tests/getdate_error.phpt31
-rw-r--r--ext/date/tests/getdate_variation1.phpt443
-rw-r--r--ext/date/tests/getdate_variation2.phpt114
-rw-r--r--ext/date/tests/getdate_variation3.phpt114
-rw-r--r--ext/date/tests/getdate_variation4.phpt141
-rw-r--r--ext/date/tests/getdate_variation5.phpt223
-rw-r--r--ext/date/tests/getdate_variation6.phpt109
-rw-r--r--ext/date/tests/getdate_variation7.phpt78
-rw-r--r--ext/date/tests/gmstrftime_basic.phpt29
-rw-r--r--ext/date/tests/gmstrftime_error.phpt38
-rw-r--r--ext/date/tests/gmstrftime_variation1.phpt220
-rw-r--r--ext/date/tests/gmstrftime_variation10.phpt50
-rw-r--r--ext/date/tests/gmstrftime_variation11.phpt37
-rw-r--r--ext/date/tests/gmstrftime_variation12.phpt37
-rw-r--r--ext/date/tests/gmstrftime_variation13.phpt60
-rw-r--r--ext/date/tests/gmstrftime_variation14.phpt60
-rw-r--r--ext/date/tests/gmstrftime_variation15.phpt55
-rw-r--r--ext/date/tests/gmstrftime_variation16.phpt55
-rw-r--r--ext/date/tests/gmstrftime_variation17.phpt37
-rw-r--r--ext/date/tests/gmstrftime_variation18.phpt37
-rw-r--r--ext/date/tests/gmstrftime_variation19.phpt50
-rw-r--r--ext/date/tests/gmstrftime_variation2.phpt206
-rw-r--r--ext/date/tests/gmstrftime_variation20.phpt52
-rw-r--r--ext/date/tests/gmstrftime_variation21.phpt55
-rw-r--r--ext/date/tests/gmstrftime_variation22.phpt55
-rw-r--r--ext/date/tests/gmstrftime_variation3.phpt52
-rw-r--r--ext/date/tests/gmstrftime_variation4.phpt47
-rw-r--r--ext/date/tests/gmstrftime_variation5.phpt51
-rw-r--r--ext/date/tests/gmstrftime_variation6.phpt59
-rw-r--r--ext/date/tests/gmstrftime_variation7.phpt49
-rw-r--r--ext/date/tests/gmstrftime_variation8.phpt39
-rw-r--r--ext/date/tests/gmstrftime_variation9.phpt50
33 files changed, 2809 insertions, 0 deletions
diff --git a/ext/date/tests/getdate_basic.phpt b/ext/date/tests/getdate_basic.phpt
new file mode 100644
index 0000000000..5d6cc815dc
--- /dev/null
+++ b/ext/date/tests/getdate_basic.phpt
@@ -0,0 +1,76 @@
+--TEST--
+Test getdate() function : basic functionality
+--FILE--
+<?php
+/* Prototype : array getdate([int timestamp])
+ * Description: Get date/time information
+ * Source code: ext/date/php_date.c
+ */
+
+echo "*** Testing getdate() : basic functionality ***\n";
+
+//Set the default time zone
+date_default_timezone_set("Asia/Calcutta");
+
+// Initialise all required variables
+$timestamp = 10;
+
+// Calling getdate() with all possible arguments
+var_dump( getdate($timestamp) );
+
+// Calling getdate() with mandatory arguments
+var_dump( getdate() );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing getdate() : basic functionality ***
+array(11) {
+ ["seconds"]=>
+ int(10)
+ ["minutes"]=>
+ int(30)
+ ["hours"]=>
+ int(5)
+ ["mday"]=>
+ int(1)
+ ["wday"]=>
+ int(4)
+ ["mon"]=>
+ int(1)
+ ["year"]=>
+ int(1970)
+ ["yday"]=>
+ int(0)
+ ["weekday"]=>
+ string(8) "Thursday"
+ ["month"]=>
+ string(7) "January"
+ [0]=>
+ int(10)
+}
+array(11) {
+ ["seconds"]=>
+ int(%d)
+ ["minutes"]=>
+ int(%d)
+ ["hours"]=>
+ int(%d)
+ ["mday"]=>
+ int(%d)
+ ["wday"]=>
+ int(%d)
+ ["mon"]=>
+ int(%d)
+ ["year"]=>
+ int(%d)
+ ["yday"]=>
+ int(%d)
+ ["weekday"]=>
+ string(%d) %s
+ ["month"]=>
+ string(%d) %s
+ [0]=>
+ int(%d)
+}
+===DONE===
diff --git a/ext/date/tests/getdate_error.phpt b/ext/date/tests/getdate_error.phpt
new file mode 100644
index 0000000000..149d06695b
--- /dev/null
+++ b/ext/date/tests/getdate_error.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Test getdate() function : error conditions
+--FILE--
+<?php
+/* Prototype : array getdate([int timestamp])
+ * Description: Get date/time information
+ * Source code: ext/date/php_date.c
+ * Alias to functions:
+ */
+
+echo "*** Testing getdate() : error conditions ***\n";
+
+//Set the default time zone
+date_default_timezone_set("America/Chicago");
+
+//Test getdate with one more than the expected number of arguments
+echo "\n-- Testing getdate() function with more than expected no. of arguments --\n";
+$timestamp = 10;
+$extra_arg = 10;
+var_dump( getdate($timestamp, $extra_arg) );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing getdate() : error conditions ***
+
+-- Testing getdate() function with more than expected no. of arguments --
+
+Warning: getdate() expects at most 1 parameter, 2 given in %s on line %d
+bool(false)
+===DONE===
diff --git a/ext/date/tests/getdate_variation1.phpt b/ext/date/tests/getdate_variation1.phpt
new file mode 100644
index 0000000000..74754c944a
--- /dev/null
+++ b/ext/date/tests/getdate_variation1.phpt
@@ -0,0 +1,443 @@
+--TEST--
+Test getdate() function : usage variation - Passing unexpected values to first argument timestamp.
+--FILE--
+<?php
+/* Prototype : array getdate([int timestamp])
+ * Description: Get date/time information
+ * Source code: ext/date/php_date.c
+ * Alias to functions:
+ */
+
+echo "*** Testing getdate() : usage variation ***\n";
+
+//Set the default time zone
+date_default_timezone_set("Asia/Calcutta");
+
+//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( getdate($value) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing getdate() : usage variation ***
+
+--float 10.5--
+array(11) {
+ ["seconds"]=>
+ int(10)
+ ["minutes"]=>
+ int(30)
+ ["hours"]=>
+ int(5)
+ ["mday"]=>
+ int(1)
+ ["wday"]=>
+ int(4)
+ ["mon"]=>
+ int(1)
+ ["year"]=>
+ int(1970)
+ ["yday"]=>
+ int(0)
+ ["weekday"]=>
+ string(8) "Thursday"
+ ["month"]=>
+ string(7) "January"
+ [0]=>
+ int(10)
+}
+
+--float -10.5--
+array(11) {
+ ["seconds"]=>
+ int(50)
+ ["minutes"]=>
+ int(29)
+ ["hours"]=>
+ int(5)
+ ["mday"]=>
+ int(1)
+ ["wday"]=>
+ int(4)
+ ["mon"]=>
+ int(1)
+ ["year"]=>
+ int(1970)
+ ["yday"]=>
+ int(0)
+ ["weekday"]=>
+ string(8) "Thursday"
+ ["month"]=>
+ string(7) "January"
+ [0]=>
+ int(-10)
+}
+
+--float .5--
+array(11) {
+ ["seconds"]=>
+ int(0)
+ ["minutes"]=>
+ int(30)
+ ["hours"]=>
+ int(5)
+ ["mday"]=>
+ int(1)
+ ["wday"]=>
+ int(4)
+ ["mon"]=>
+ int(1)
+ ["year"]=>
+ int(1970)
+ ["yday"]=>
+ int(0)
+ ["weekday"]=>
+ string(8) "Thursday"
+ ["month"]=>
+ string(7) "January"
+ [0]=>
+ int(0)
+}
+
+--empty array--
+
+Warning: getdate() expects parameter 1 to be long, array given in %s on line %d
+bool(false)
+
+--int indexed array--
+
+Warning: getdate() expects parameter 1 to be long, array given in %s on line %d
+bool(false)
+
+--associative array--
+
+Warning: getdate() expects parameter 1 to be long, array given in %s on line %d
+bool(false)
+
+--nested arrays--
+
+Warning: getdate() expects parameter 1 to be long, array given in %s on line %d
+bool(false)
+
+--uppercase NULL--
+array(11) {
+ ["seconds"]=>
+ int(0)
+ ["minutes"]=>
+ int(30)
+ ["hours"]=>
+ int(5)
+ ["mday"]=>
+ int(1)
+ ["wday"]=>
+ int(4)
+ ["mon"]=>
+ int(1)
+ ["year"]=>
+ int(1970)
+ ["yday"]=>
+ int(0)
+ ["weekday"]=>
+ string(8) "Thursday"
+ ["month"]=>
+ string(7) "January"
+ [0]=>
+ int(0)
+}
+
+--lowercase null--
+array(11) {
+ ["seconds"]=>
+ int(0)
+ ["minutes"]=>
+ int(30)
+ ["hours"]=>
+ int(5)
+ ["mday"]=>
+ int(1)
+ ["wday"]=>
+ int(4)
+ ["mon"]=>
+ int(1)
+ ["year"]=>
+ int(1970)
+ ["yday"]=>
+ int(0)
+ ["weekday"]=>
+ string(8) "Thursday"
+ ["month"]=>
+ string(7) "January"
+ [0]=>
+ int(0)
+}
+
+--lowercase true--
+array(11) {
+ ["seconds"]=>
+ int(1)
+ ["minutes"]=>
+ int(30)
+ ["hours"]=>
+ int(5)
+ ["mday"]=>
+ int(1)
+ ["wday"]=>
+ int(4)
+ ["mon"]=>
+ int(1)
+ ["year"]=>
+ int(1970)
+ ["yday"]=>
+ int(0)
+ ["weekday"]=>
+ string(8) "Thursday"
+ ["month"]=>
+ string(7) "January"
+ [0]=>
+ int(1)
+}
+
+--lowercase false--
+array(11) {
+ ["seconds"]=>
+ int(0)
+ ["minutes"]=>
+ int(30)
+ ["hours"]=>
+ int(5)
+ ["mday"]=>
+ int(1)
+ ["wday"]=>
+ int(4)
+ ["mon"]=>
+ int(1)
+ ["year"]=>
+ int(1970)
+ ["yday"]=>
+ int(0)
+ ["weekday"]=>
+ string(8) "Thursday"
+ ["month"]=>
+ string(7) "January"
+ [0]=>
+ int(0)
+}
+
+--uppercase TRUE--
+array(11) {
+ ["seconds"]=>
+ int(1)
+ ["minutes"]=>
+ int(30)
+ ["hours"]=>
+ int(5)
+ ["mday"]=>
+ int(1)
+ ["wday"]=>
+ int(4)
+ ["mon"]=>
+ int(1)
+ ["year"]=>
+ int(1970)
+ ["yday"]=>
+ int(0)
+ ["weekday"]=>
+ string(8) "Thursday"
+ ["month"]=>
+ string(7) "January"
+ [0]=>
+ int(1)
+}
+
+--uppercase FALSE--
+array(11) {
+ ["seconds"]=>
+ int(0)
+ ["minutes"]=>
+ int(30)
+ ["hours"]=>
+ int(5)
+ ["mday"]=>
+ int(1)
+ ["wday"]=>
+ int(4)
+ ["mon"]=>
+ int(1)
+ ["year"]=>
+ int(1970)
+ ["yday"]=>
+ int(0)
+ ["weekday"]=>
+ string(8) "Thursday"
+ ["month"]=>
+ string(7) "January"
+ [0]=>
+ int(0)
+}
+
+--empty string DQ--
+
+Warning: getdate() expects parameter 1 to be long, string given in %s on line %d
+bool(false)
+
+--empty string SQ--
+
+Warning: getdate() expects parameter 1 to be long, string given in %s on line %d
+bool(false)
+
+--string DQ--
+
+Warning: getdate() expects parameter 1 to be long, string given in %s on line %d
+bool(false)
+
+--string SQ--
+
+Warning: getdate() expects parameter 1 to be long, string given in %s on line %d
+bool(false)
+
+--mixed case string--
+
+Warning: getdate() expects parameter 1 to be long, string given in %s on line %d
+bool(false)
+
+--heredoc--
+
+Warning: getdate() expects parameter 1 to be long, string given in %s on line %d
+bool(false)
+
+--instance of classWithToString--
+
+Warning: getdate() expects parameter 1 to be long, object given in %s on line %d
+bool(false)
+
+--instance of classWithoutToString--
+
+Warning: getdate() expects parameter 1 to be long, object given in %s on line %d
+bool(false)
+
+--undefined var--
+array(11) {
+ ["seconds"]=>
+ int(0)
+ ["minutes"]=>
+ int(30)
+ ["hours"]=>
+ int(5)
+ ["mday"]=>
+ int(1)
+ ["wday"]=>
+ int(4)
+ ["mon"]=>
+ int(1)
+ ["year"]=>
+ int(1970)
+ ["yday"]=>
+ int(0)
+ ["weekday"]=>
+ string(8) "Thursday"
+ ["month"]=>
+ string(7) "January"
+ [0]=>
+ int(0)
+}
+
+--unset var--
+array(11) {
+ ["seconds"]=>
+ int(0)
+ ["minutes"]=>
+ int(30)
+ ["hours"]=>
+ int(5)
+ ["mday"]=>
+ int(1)
+ ["wday"]=>
+ int(4)
+ ["mon"]=>
+ int(1)
+ ["year"]=>
+ int(1970)
+ ["yday"]=>
+ int(0)
+ ["weekday"]=>
+ string(8) "Thursday"
+ ["month"]=>
+ string(7) "January"
+ [0]=>
+ int(0)
+}
+===DONE===
diff --git a/ext/date/tests/getdate_variation2.phpt b/ext/date/tests/getdate_variation2.phpt
new file mode 100644
index 0000000000..f987d2134d
--- /dev/null
+++ b/ext/date/tests/getdate_variation2.phpt
@@ -0,0 +1,114 @@
+--TEST--
+Test getdate() function : usage variation - Passing octal timestamp values
+--FILE--
+<?php
+/* Prototype : array getdate([int timestamp])
+ * Description: Get date/time information
+ * Source code: ext/date/php_date.c
+ * Alias to functions:
+ */
+
+echo "*** Testing getdate() : usage variation ***\n";
+
+//Set the default time zone
+date_default_timezone_set("Asia/Calcutta");
+
+//array of values to iterate over
+$inputs = array(
+
+ //octal values
+ 'octal 05' => 05,
+ 'octal 010' => 010,
+ 'octal -010' => -010,
+);
+
+// loop through each element of the array for timestamp
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( getdate($value) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing getdate() : usage variation ***
+
+--octal 05--
+array(11) {
+ ["seconds"]=>
+ int(5)
+ ["minutes"]=>
+ int(30)
+ ["hours"]=>
+ int(5)
+ ["mday"]=>
+ int(1)
+ ["wday"]=>
+ int(4)
+ ["mon"]=>
+ int(1)
+ ["year"]=>
+ int(1970)
+ ["yday"]=>
+ int(0)
+ ["weekday"]=>
+ string(8) "Thursday"
+ ["month"]=>
+ string(7) "January"
+ [0]=>
+ int(5)
+}
+
+--octal 010--
+array(11) {
+ ["seconds"]=>
+ int(8)
+ ["minutes"]=>
+ int(30)
+ ["hours"]=>
+ int(5)
+ ["mday"]=>
+ int(1)
+ ["wday"]=>
+ int(4)
+ ["mon"]=>
+ int(1)
+ ["year"]=>
+ int(1970)
+ ["yday"]=>
+ int(0)
+ ["weekday"]=>
+ string(8) "Thursday"
+ ["month"]=>
+ string(7) "January"
+ [0]=>
+ int(8)
+}
+
+--octal -010--
+array(11) {
+ ["seconds"]=>
+ int(52)
+ ["minutes"]=>
+ int(29)
+ ["hours"]=>
+ int(5)
+ ["mday"]=>
+ int(1)
+ ["wday"]=>
+ int(4)
+ ["mon"]=>
+ int(1)
+ ["year"]=>
+ int(1970)
+ ["yday"]=>
+ int(0)
+ ["weekday"]=>
+ string(8) "Thursday"
+ ["month"]=>
+ string(7) "January"
+ [0]=>
+ int(-8)
+}
+===DONE===
diff --git a/ext/date/tests/getdate_variation3.phpt b/ext/date/tests/getdate_variation3.phpt
new file mode 100644
index 0000000000..f7d6863208
--- /dev/null
+++ b/ext/date/tests/getdate_variation3.phpt
@@ -0,0 +1,114 @@
+--TEST--
+Test getdate() function : usage variation - Passing hexadcimal timestamp values
+--FILE--
+<?php
+/* Prototype : array getdate([int timestamp])
+ * Description: Get date/time information
+ * Source code: ext/date/php_date.c
+ * Alias to functions:
+ */
+
+echo "*** Testing getdate() : usage variation ***\n";
+
+//Set the default time zone
+date_default_timezone_set("Asia/Calcutta");
+
+//array of values to iterate over
+$inputs = array(
+
+ //octal values
+ 'hexadcimal 0x5' => 0x5,
+ 'hexadcimal 0xCAFE' => 0xCAFE,
+ 'octal -0xCAFE' => -0xCAFE,
+);
+
+// loop through each element of the array for timestamp
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( getdate($value) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing getdate() : usage variation ***
+
+--hexadcimal 0x5--
+array(11) {
+ ["seconds"]=>
+ int(5)
+ ["minutes"]=>
+ int(30)
+ ["hours"]=>
+ int(5)
+ ["mday"]=>
+ int(1)
+ ["wday"]=>
+ int(4)
+ ["mon"]=>
+ int(1)
+ ["year"]=>
+ int(1970)
+ ["yday"]=>
+ int(0)
+ ["weekday"]=>
+ string(8) "Thursday"
+ ["month"]=>
+ string(7) "January"
+ [0]=>
+ int(5)
+}
+
+--hexadcimal 0xCAFE--
+array(11) {
+ ["seconds"]=>
+ int(6)
+ ["minutes"]=>
+ int(56)
+ ["hours"]=>
+ int(19)
+ ["mday"]=>
+ int(1)
+ ["wday"]=>
+ int(4)
+ ["mon"]=>
+ int(1)
+ ["year"]=>
+ int(1970)
+ ["yday"]=>
+ int(0)
+ ["weekday"]=>
+ string(8) "Thursday"
+ ["month"]=>
+ string(7) "January"
+ [0]=>
+ int(51966)
+}
+
+--octal -0xCAFE--
+array(11) {
+ ["seconds"]=>
+ int(54)
+ ["minutes"]=>
+ int(3)
+ ["hours"]=>
+ int(15)
+ ["mday"]=>
+ int(31)
+ ["wday"]=>
+ int(3)
+ ["mon"]=>
+ int(12)
+ ["year"]=>
+ int(1969)
+ ["yday"]=>
+ int(364)
+ ["weekday"]=>
+ string(9) "Wednesday"
+ ["month"]=>
+ string(8) "December"
+ [0]=>
+ int(-51966)
+}
+===DONE===
diff --git a/ext/date/tests/getdate_variation4.phpt b/ext/date/tests/getdate_variation4.phpt
new file mode 100644
index 0000000000..92719ac650
--- /dev/null
+++ b/ext/date/tests/getdate_variation4.phpt
@@ -0,0 +1,141 @@
+--TEST--
+Test getdate() function : usage variation - Verifyig by supplying year-wise sample time stamps since Unix epoch time
+--FILE--
+<?php
+/* Prototype : array getdate([int timestamp])
+ * Description: Get date/time information
+ * Source code: ext/date/php_date.c
+ * Alias to functions:
+ */
+
+echo "*** Testing getdate() : usage variation ***\n";
+
+//Set the default time zone
+date_default_timezone_set("Asia/Calcutta");
+
+//array of values to iterate over
+$inputs = array(
+
+ //Year wise time stamps
+ '01 Jan 1970' => 0,
+ '01 Jan 1971' => 31536000,
+ '01 Jan 1972' => 63072000,
+ '01 Jan 1973' => 94694400,
+);
+
+// loop through each element of the array for timestamp
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( getdate($value) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing getdate() : usage variation ***
+
+--01 Jan 1970--
+array(11) {
+ ["seconds"]=>
+ int(0)
+ ["minutes"]=>
+ int(30)
+ ["hours"]=>
+ int(5)
+ ["mday"]=>
+ int(1)
+ ["wday"]=>
+ int(4)
+ ["mon"]=>
+ int(1)
+ ["year"]=>
+ int(1970)
+ ["yday"]=>
+ int(0)
+ ["weekday"]=>
+ string(8) "Thursday"
+ ["month"]=>
+ string(7) "January"
+ [0]=>
+ int(0)
+}
+
+--01 Jan 1971--
+array(11) {
+ ["seconds"]=>
+ int(0)
+ ["minutes"]=>
+ int(30)
+ ["hours"]=>
+ int(5)
+ ["mday"]=>
+ int(1)
+ ["wday"]=>
+ int(5)
+ ["mon"]=>
+ int(1)
+ ["year"]=>
+ int(1971)
+ ["yday"]=>
+ int(0)
+ ["weekday"]=>
+ string(6) "Friday"
+ ["month"]=>
+ string(7) "January"
+ [0]=>
+ int(31536000)
+}
+
+--01 Jan 1972--
+array(11) {
+ ["seconds"]=>
+ int(0)
+ ["minutes"]=>
+ int(30)
+ ["hours"]=>
+ int(5)
+ ["mday"]=>
+ int(1)
+ ["wday"]=>
+ int(6)
+ ["mon"]=>
+ int(1)
+ ["year"]=>
+ int(1972)
+ ["yday"]=>
+ int(0)
+ ["weekday"]=>
+ string(8) "Saturday"
+ ["month"]=>
+ string(7) "January"
+ [0]=>
+ int(63072000)
+}
+
+--01 Jan 1973--
+array(11) {
+ ["seconds"]=>
+ int(0)
+ ["minutes"]=>
+ int(30)
+ ["hours"]=>
+ int(5)
+ ["mday"]=>
+ int(1)
+ ["wday"]=>
+ int(1)
+ ["mon"]=>
+ int(1)
+ ["year"]=>
+ int(1973)
+ ["yday"]=>
+ int(0)
+ ["weekday"]=>
+ string(6) "Monday"
+ ["month"]=>
+ string(7) "January"
+ [0]=>
+ int(94694400)
+}
+===DONE===
diff --git a/ext/date/tests/getdate_variation5.phpt b/ext/date/tests/getdate_variation5.phpt
new file mode 100644
index 0000000000..e4524a8659
--- /dev/null
+++ b/ext/date/tests/getdate_variation5.phpt
@@ -0,0 +1,223 @@
+--TEST--
+Test getdate() function : usage variation - Verifyig with different timezones on Unix epoch timestamp
+--FILE--
+<?php
+/* Prototype : array getdate([int timestamp])
+ * Description: Get date/time information
+ * Source code: ext/date/php_date.c
+ * Alias to functions:
+ */
+
+echo "*** Testing getdate() : usage variation ***\n";
+
+//Timezones with required data for date_sunrise
+$inputs = array (
+ //GMT-11
+ "Pacific/Samoa",
+ //GMT-9
+ "US/Alaska",
+ //GMT-0
+ "Africa/Casablanca",
+ //GMT+4
+ "Europe/Moscow",
+ //GMT+8
+ "Asia/Hong_Kong",
+ //GMT+10
+ "Australia/Brisbane",
+ //GMT+12
+ "Pacific/Wallis",
+);
+
+// loop through each element of the array for timestamp
+foreach($inputs as $timezone) {
+ echo "\n--$timezone--\n";
+ date_default_timezone_set($timezone);
+ var_dump( getdate(0) );
+};
+?>
+===DONE===
+--EXPECTF--
+*** Testing getdate() : usage variation ***
+
+--Pacific/Samoa--
+array(11) {
+ ["seconds"]=>
+ int(0)
+ ["minutes"]=>
+ int(0)
+ ["hours"]=>
+ int(13)
+ ["mday"]=>
+ int(31)
+ ["wday"]=>
+ int(3)
+ ["mon"]=>
+ int(12)
+ ["year"]=>
+ int(1969)
+ ["yday"]=>
+ int(364)
+ ["weekday"]=>
+ string(9) "Wednesday"
+ ["month"]=>
+ string(8) "December"
+ [0]=>
+ int(0)
+}
+
+--US/Alaska--
+array(11) {
+ ["seconds"]=>
+ int(0)
+ ["minutes"]=>
+ int(0)
+ ["hours"]=>
+ int(14)
+ ["mday"]=>
+ int(31)
+ ["wday"]=>
+ int(3)
+ ["mon"]=>
+ int(12)
+ ["year"]=>
+ int(1969)
+ ["yday"]=>
+ int(364)
+ ["weekday"]=>
+ string(9) "Wednesday"
+ ["month"]=>
+ string(8) "December"
+ [0]=>
+ int(0)
+}
+
+--Africa/Casablanca--
+array(11) {
+ ["seconds"]=>
+ int(0)
+ ["minutes"]=>
+ int(0)
+ ["hours"]=>
+ int(0)
+ ["mday"]=>
+ int(1)
+ ["wday"]=>
+ int(4)
+ ["mon"]=>
+ int(1)
+ ["year"]=>
+ int(1970)
+ ["yday"]=>
+ int(0)
+ ["weekday"]=>
+ string(8) "Thursday"
+ ["month"]=>
+ string(7) "January"
+ [0]=>
+ int(0)
+}
+
+--Europe/Moscow--
+array(11) {
+ ["seconds"]=>
+ int(0)
+ ["minutes"]=>
+ int(0)
+ ["hours"]=>
+ int(3)
+ ["mday"]=>
+ int(1)
+ ["wday"]=>
+ int(4)
+ ["mon"]=>
+ int(1)
+ ["year"]=>
+ int(1970)
+ ["yday"]=>
+ int(0)
+ ["weekday"]=>
+ string(8) "Thursday"
+ ["month"]=>
+ string(7) "January"
+ [0]=>
+ int(0)
+}
+
+--Asia/Hong_Kong--
+array(11) {
+ ["seconds"]=>
+ int(0)
+ ["minutes"]=>
+ int(0)
+ ["hours"]=>
+ int(8)
+ ["mday"]=>
+ int(1)
+ ["wday"]=>
+ int(4)
+ ["mon"]=>
+ int(1)
+ ["year"]=>
+ int(1970)
+ ["yday"]=>
+ int(0)
+ ["weekday"]=>
+ string(8) "Thursday"
+ ["month"]=>
+ string(7) "January"
+ [0]=>
+ int(0)
+}
+
+--Australia/Brisbane--
+array(11) {
+ ["seconds"]=>
+ int(0)
+ ["minutes"]=>
+ int(0)
+ ["hours"]=>
+ int(10)
+ ["mday"]=>
+ int(1)
+ ["wday"]=>
+ int(4)
+ ["mon"]=>
+ int(1)
+ ["year"]=>
+ int(1970)
+ ["yday"]=>
+ int(0)
+ ["weekday"]=>
+ string(8) "Thursday"
+ ["month"]=>
+ string(7) "January"
+ [0]=>
+ int(0)
+}
+
+--Pacific/Wallis--
+array(11) {
+ ["seconds"]=>
+ int(0)
+ ["minutes"]=>
+ int(0)
+ ["hours"]=>
+ int(12)
+ ["mday"]=>
+ int(1)
+ ["wday"]=>
+ int(4)
+ ["mon"]=>
+ int(1)
+ ["year"]=>
+ int(1970)
+ ["yday"]=>
+ int(0)
+ ["weekday"]=>
+ string(8) "Thursday"
+ ["month"]=>
+ string(7) "January"
+ [0]=>
+ int(0)
+}
+===DONE===
diff --git a/ext/date/tests/getdate_variation6.phpt b/ext/date/tests/getdate_variation6.phpt
new file mode 100644
index 0000000000..5c03a3bb71
--- /dev/null
+++ b/ext/date/tests/getdate_variation6.phpt
@@ -0,0 +1,109 @@
+--TEST--
+Test getdate() function : usage variation - Passing strings containing numbers
+--FILE--
+<?php
+/* Prototype : array getdate([int timestamp])
+ * Description: Get date/time information
+ * Source code: ext/date/php_date.c
+ * Alias to functions:
+ */
+
+echo "*** Testing getdate() : usage variation ***\n";
+
+date_default_timezone_set("Asia/Calcutta");
+
+//Timezones with required data for date_sunrise
+$inputs = array (
+ 'String 0' => '0',
+ 'String 10.5' => "10.5",
+ 'String -10.5' => '-10.5',
+);
+
+// loop through each element of the array for timestamp
+foreach($inputs as $key => $value) {
+ echo "\n--$key--\n";
+ var_dump( getdate($value) );
+};
+?>
+===DONE===
+--EXPECTF--
+*** Testing getdate() : usage variation ***
+
+--String 0--
+array(11) {
+ ["seconds"]=>
+ int(0)
+ ["minutes"]=>
+ int(30)
+ ["hours"]=>
+ int(5)
+ ["mday"]=>
+ int(1)
+ ["wday"]=>
+ int(4)
+ ["mon"]=>
+ int(1)
+ ["year"]=>
+ int(1970)
+ ["yday"]=>
+ int(0)
+ ["weekday"]=>
+ string(8) "Thursday"
+ ["month"]=>
+ string(7) "January"
+ [0]=>
+ int(0)
+}
+
+--String 10.5--
+array(11) {
+ ["seconds"]=>
+ int(10)
+ ["minutes"]=>
+ int(30)
+ ["hours"]=>
+ int(5)
+ ["mday"]=>
+ int(1)
+ ["wday"]=>
+ int(4)
+ ["mon"]=>
+ int(1)
+ ["year"]=>
+ int(1970)
+ ["yday"]=>
+ int(0)
+ ["weekday"]=>
+ string(8) "Thursday"
+ ["month"]=>
+ string(7) "January"
+ [0]=>
+ int(10)
+}
+
+--String -10.5--
+array(11) {
+ ["seconds"]=>
+ int(50)
+ ["minutes"]=>
+ int(29)
+ ["hours"]=>
+ int(5)
+ ["mday"]=>
+ int(1)
+ ["wday"]=>
+ int(4)
+ ["mon"]=>
+ int(1)
+ ["year"]=>
+ int(1970)
+ ["yday"]=>
+ int(0)
+ ["weekday"]=>
+ string(8) "Thursday"
+ ["month"]=>
+ string(7) "January"
+ [0]=>
+ int(-10)
+}
+===DONE===
diff --git a/ext/date/tests/getdate_variation7.phpt b/ext/date/tests/getdate_variation7.phpt
new file mode 100644
index 0000000000..bccd8d3abb
--- /dev/null
+++ b/ext/date/tests/getdate_variation7.phpt
@@ -0,0 +1,78 @@
+--TEST--
+Test getdate() function : usage variation - Passing high positive and negative float values to timestamp.
+--FILE--
+<?php
+/* Prototype : array getdate([int timestamp])
+ * Description: Get date/time information
+ * Source code: ext/date/php_date.c
+ * Alias to functions:
+ */
+
+echo "*** Testing getdate() : usage variation ***\n";
+date_default_timezone_set("Asia/Calcutta");
+
+echo "\n-- Testing getdate() function by passing float 12.3456789000e10 value to timestamp --\n";
+$timestamp = 12.3456789000e10;
+var_dump( getdate($timestamp) );
+
+echo "\n-- Testing getdate() function by passing float -12.3456789000e10 value to timestamp --\n";
+$timestamp = -12.3456789000e10;
+var_dump( getdate($timestamp) );
+?>
+===DONE===
+--EXPECTREGEX--
+
+\*\*\* Testing getdate\(\) : usage variation \*\*\*
+
+-- Testing getdate\(\) function by passing float 12.3456789000e10 value to timestamp --
+array\(11\) {
+ \["seconds"\]=>
+ int\((7|0)\)
+ \["minutes"\]=>
+ int\((44|0)\)
+ \["hours"\]=>
+ int\((8|6)\)
+ \["mday"\]=>
+ int\((19|11)\)
+ \["wday"\]=>
+ int\((2|6)\)
+ \["mon"\]=>
+ int\((1|3)\)
+ \["year"\]=>
+ int\((2038|5882)\)
+ \["yday"\]=>
+ int\((18|69)\)
+ \["weekday"\]=>
+ string\((7|8)\) "(Tuesday|Saturday)"
+ \["month"\]=>
+ string\((7|5)\) "(January|March)"
+ \[0\]=>
+ int\((2147483647|123456789000)\)
+}
+
+-- Testing getdate\(\) function by passing float -12.3456789000e10 value to timestamp --
+array\(11\) {
+ \["seconds"\]=>
+ int\((12|20)\)
+ \["minutes"\]=>
+ int\((39|23)\)
+ \["hours"\]=>
+ int\((2|5)\)
+ \["mday"\]=>
+ int\((14|23)\)
+ \["wday"\]=>
+ int\((6|-4)\)
+ \["mon"\]=>
+ int\((12|10)\)
+ \["year"\]=>
+ int\((1901|-1943)\)
+ \["yday"\]=>
+ int\((347|295)\)
+ \["weekday"\]=>
+ string\((8|7)\) "(Saturday|Unknown)"
+ \["month"\]=>
+ string\((8|7)\) "(December|October)"
+ \[0\]=>
+ int\((-2147483648|-123456789000)\)
+}
+===DONE===
diff --git a/ext/date/tests/gmstrftime_basic.phpt b/ext/date/tests/gmstrftime_basic.phpt
new file mode 100644
index 0000000000..17bad69d06
--- /dev/null
+++ b/ext/date/tests/gmstrftime_basic.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Test gmstrftime() function : basic functionality
+--FILE--
+<?php
+/* Prototype : string gmstrftime(string format [, int timestamp])
+ * Description: Format a GMT/UCT time/date according to locale settings
+ * Source code: ext/date/php_date.c
+ * Alias to functions:
+ */
+
+echo "*** Testing gmstrftime() : basic functionality ***\n";
+
+// Initialise all required variables
+$format = '%b %d %Y %H:%M:%S';
+$timestamp = gmmktime(8, 8, 8, 8, 8, 2008);
+
+// Calling gmstrftime() with all possible arguments
+var_dump( gmstrftime($format, $timestamp) );
+
+// Calling gmstrftime() with mandatory arguments
+var_dump( gmstrftime($format) );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing gmstrftime() : basic functionality ***
+string(20) "Aug 08 2008 08:08:08"
+string(%d) "%s %d %d %d:%d:%d"
+===DONE===
diff --git a/ext/date/tests/gmstrftime_error.phpt b/ext/date/tests/gmstrftime_error.phpt
new file mode 100644
index 0000000000..d28780fe03
--- /dev/null
+++ b/ext/date/tests/gmstrftime_error.phpt
@@ -0,0 +1,38 @@
+--TEST--
+Test gmstrftime() function : error conditions
+--FILE--
+<?php
+/* Prototype : string gmstrftime(string format [, int timestamp])
+ * Description: Format a GMT/UCT time/date according to locale settings
+ * Source code: ext/date/php_date.c
+ * Alias to functions:
+ */
+
+echo "*** Testing gmstrftime() : error conditions ***\n";
+
+// Zero arguments
+echo "\n-- Testing gmstrftime() function with Zero arguments --\n";
+var_dump( gmstrftime() );
+
+//Test gmstrftime with one more than the expected number of arguments
+echo "\n-- Testing gmstrftime() function with more than expected no. of arguments --\n";
+$format = '%b %d %Y %H:%M:%S';
+$timestamp = gmmktime(8, 8, 8, 8, 8, 2008);
+$extra_arg = 10;
+var_dump( gmstrftime($format, $timestamp, $extra_arg) );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing gmstrftime() : error conditions ***
+
+-- Testing gmstrftime() function with Zero arguments --
+
+Warning: gmstrftime() expects at least 1 parameter, 0 given in %s on line %d
+bool(false)
+
+-- Testing gmstrftime() function with more than expected no. of arguments --
+
+Warning: gmstrftime() expects at most 2 parameters, 3 given in %s on line %d
+bool(false)
+===DONE===
diff --git a/ext/date/tests/gmstrftime_variation1.phpt b/ext/date/tests/gmstrftime_variation1.phpt
new file mode 100644
index 0000000000..d123fb2542
--- /dev/null
+++ b/ext/date/tests/gmstrftime_variation1.phpt
@@ -0,0 +1,220 @@
+--TEST--
+Test gmstrftime() function : usage variation - Passing unexpected values to first argument 'format'.
+--FILE--
+<?php
+/* Prototype : string gmstrftime(string format [, int timestamp])
+ * Description: Format a GMT/UCT time/date according to locale settings
+ * Source code: ext/date/php_date.c
+ * Alias to functions:
+ */
+
+echo "*** Testing gmstrftime() : usage variation ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$timestamp = gmmktime(8, 8, 8, 8, 8, 2008);
+
+//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(
+
+ // int data
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -12345,
+
+ // 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' => '',
+
+ // 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 format
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( gmstrftime($value) );
+ var_dump( gmstrftime($value, $timestamp) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing gmstrftime() : usage variation ***
+
+--int 0--
+string(1) "0"
+string(1) "0"
+
+--int 1--
+string(1) "1"
+string(1) "1"
+
+--int 12345--
+string(5) "12345"
+string(5) "12345"
+
+--int -12345--
+string(6) "-12345"
+string(6) "-12345"
+
+--float 10.5--
+string(4) "10.5"
+string(4) "10.5"
+
+--float -10.5--
+string(5) "-10.5"
+string(5) "-10.5"
+
+--float 12.3456789000e10--
+string(12) "123456789000"
+string(12) "123456789000"
+
+--float -12.3456789000e10--
+string(13) "-123456789000"
+string(13) "-123456789000"
+
+--float .5--
+string(3) "0.5"
+string(3) "0.5"
+
+--empty array--
+
+Warning: gmstrftime() expects parameter 1 to be string, array given in %s on line %d
+bool(false)
+
+Warning: gmstrftime() expects parameter 1 to be string, array given in %s on line %d
+bool(false)
+
+--int indexed array--
+
+Warning: gmstrftime() expects parameter 1 to be string, array given in %s on line %d
+bool(false)
+
+Warning: gmstrftime() expects parameter 1 to be string, array given in %s on line %d
+bool(false)
+
+--associative array--
+
+Warning: gmstrftime() expects parameter 1 to be string, array given in %s on line %d
+bool(false)
+
+Warning: gmstrftime() expects parameter 1 to be string, array given in %s on line %d
+bool(false)
+
+--nested arrays--
+
+Warning: gmstrftime() expects parameter 1 to be string, array given in %s on line %d
+bool(false)
+
+Warning: gmstrftime() expects parameter 1 to be string, array given in %s on line %d
+bool(false)
+
+--uppercase NULL--
+bool(false)
+bool(false)
+
+--lowercase null--
+bool(false)
+bool(false)
+
+--lowercase true--
+string(1) "1"
+string(1) "1"
+
+--lowercase false--
+bool(false)
+bool(false)
+
+--uppercase TRUE--
+string(1) "1"
+string(1) "1"
+
+--uppercase FALSE--
+bool(false)
+bool(false)
+
+--empty string DQ--
+bool(false)
+bool(false)
+
+--empty string SQ--
+bool(false)
+bool(false)
+
+--instance of classWithToString--
+string(14) "Class A object"
+string(14) "Class A object"
+
+--instance of classWithoutToString--
+
+Warning: gmstrftime() expects parameter 1 to be string, object given in %s on line %d
+bool(false)
+
+Warning: gmstrftime() expects parameter 1 to be string, object given in %s on line %d
+bool(false)
+
+--undefined var--
+bool(false)
+bool(false)
+
+--unset var--
+bool(false)
+bool(false)
+===DONE===
diff --git a/ext/date/tests/gmstrftime_variation10.phpt b/ext/date/tests/gmstrftime_variation10.phpt
new file mode 100644
index 0000000000..0e54d846ea
--- /dev/null
+++ b/ext/date/tests/gmstrftime_variation10.phpt
@@ -0,0 +1,50 @@
+--TEST--
+Test gmstrftime() function : usage variation - Checking week related formats which are supported other than on Windows.
+--SKIPIF--
+<?php
+if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
+ die("skip Test is not valid for Windows");
+}
+?>
+--FILE--
+<?php
+/* Prototype : string gmstrftime(string format [, int timestamp])
+ * Description: Format a GMT/UCT time/date according to locale settings
+ * Source code: ext/date/php_date.c
+ * Alias to functions:
+ */
+
+echo "*** Testing gmstrftime() : usage variation ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$timestamp = gmmktime(8, 8, 8, 8, 8, 2008);
+setlocale(LC_ALL, "en_US");
+date_default_timezone_set("Asia/Calcutta");
+
+//array of values to iterate over
+$inputs = array(
+ 'The ISO 8601:1988 week number' => "%V",
+ 'Weekday as decimal' => "%u",
+);
+
+// loop through each element of the array for timestamp
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( gmstrftime($value) );
+ var_dump( gmstrftime($value, $timestamp) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing gmstrftime() : usage variation ***
+
+--The ISO 8601:1988 week number--
+string(%d) "%d"
+string(2) "32"
+
+--Weekday as decimal--
+string(%d) "%d"
+string(1) "5"
+===DONE===
diff --git a/ext/date/tests/gmstrftime_variation11.phpt b/ext/date/tests/gmstrftime_variation11.phpt
new file mode 100644
index 0000000000..482ff6d2d7
--- /dev/null
+++ b/ext/date/tests/gmstrftime_variation11.phpt
@@ -0,0 +1,37 @@
+--TEST--
+Test gmstrftime() function : usage variation - Checking month related formats which are not supported on Windows.
+--SKIPIF--
+<?php
+if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
+ die("skip Test is valid for Windows");
+}
+?>
+--FILE--
+<?php
+/* Prototype : string gmstrftime(string format [, int timestamp])
+ * Description: Format a GMT/UCT time/date according to locale settings
+ * Source code: ext/date/php_date.c
+ * Alias to functions:
+ */
+
+echo "*** Testing gmstrftime() : usage variation ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$timestamp = gmmktime(8, 8, 8, 8, 8, 2008);
+setlocale(LC_ALL, "en_US");
+date_default_timezone_set("Asia/Calcutta");
+
+echo "\n-- Testing gmstrftime() function with Abbreviated month name format %h --\n";
+$format = "%h";
+var_dump( gmstrftime($format) );
+var_dump( gmstrftime($format, $timestamp) );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing gmstrftime() : usage variation ***
+
+-- Testing gmstrftime() function with Abbreviated month name format %h --
+bool(false)
+bool(false)
+===DONE===
diff --git a/ext/date/tests/gmstrftime_variation12.phpt b/ext/date/tests/gmstrftime_variation12.phpt
new file mode 100644
index 0000000000..2c25af6e2a
--- /dev/null
+++ b/ext/date/tests/gmstrftime_variation12.phpt
@@ -0,0 +1,37 @@
+--TEST--
+Test gmstrftime() function : usage variation - Checking month related formats which are supported other than on Windows.
+--SKIPIF--
+<?php
+if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
+ die("skip Test is not valid for Windows");
+}
+?>
+--FILE--
+<?php
+/* Prototype : string gmstrftime(string format [, int timestamp])
+ * Description: Format a GMT/UCT time/date according to locale settings
+ * Source code: ext/date/php_date.c
+ * Alias to functions:
+ */
+
+echo "*** Testing gmstrftime() : usage variation ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$timestamp = gmmktime(8, 8, 8, 8, 8, 2008);
+setlocale(LC_ALL, "en_US");
+date_default_timezone_set("Asia/Calcutta");
+
+echo "\n-- Testing gmstrftime() function with Abbreviated month name format %h --\n";
+$format = "%h";
+var_dump( gmstrftime($format) );
+var_dump( gmstrftime($format, $timestamp) );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing gmstrftime() : usage variation ***
+
+-- Testing gmstrftime() function with Abbreviated month name format %h --
+string(%d) "%s"
+string(3) "Aug"
+===DONE===
diff --git a/ext/date/tests/gmstrftime_variation13.phpt b/ext/date/tests/gmstrftime_variation13.phpt
new file mode 100644
index 0000000000..42f33f01ea
--- /dev/null
+++ b/ext/date/tests/gmstrftime_variation13.phpt
@@ -0,0 +1,60 @@
+--TEST--
+Test gmstrftime() function : usage variation - Checking date related formats which are not supported on Windows.
+--SKIPIF--
+<?php
+if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
+ die("skip Test is valid for Windows");
+}
+?>
+--FILE--
+<?php
+/* Prototype : string gmstrftime(string format [, int timestamp])
+ * Description: Format a GMT/UCT time/date according to locale settings
+ * Source code: ext/date/php_date.c
+ * Alias to functions:
+ */
+
+echo "*** Testing gmstrftime() : usage variation ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$timestamp = gmmktime(8, 8, 8, 8, 8, 2008);
+setlocale(LC_ALL, "en_US");
+date_default_timezone_set("Asia/Calcutta");
+
+//array of values to iterate over
+$inputs = array(
+ 'Century number' => "%C",
+ 'Month Date Year' => "%D",
+ 'Year with century' => "%G",
+ 'Year without century' => "%g",
+);
+
+// loop through each element of the array for timestamp
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( gmstrftime($value) );
+ var_dump( gmstrftime($value, $timestamp) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing gmstrftime() : usage variation ***
+
+--Century number--
+bool(false)
+bool(false)
+
+--Month Date Year--
+bool(false)
+bool(false)
+
+--Year with century--
+bool(false)
+bool(false)
+
+--Year without century--
+bool(false)
+bool(false)
+===DONE===
diff --git a/ext/date/tests/gmstrftime_variation14.phpt b/ext/date/tests/gmstrftime_variation14.phpt
new file mode 100644
index 0000000000..880b4330c5
--- /dev/null
+++ b/ext/date/tests/gmstrftime_variation14.phpt
@@ -0,0 +1,60 @@
+--TEST--
+Test gmstrftime() function : usage variation - Checking date related formats which are supported other than on Windows.
+--SKIPIF--
+<?php
+if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
+ die("skip Test is not valid for Windows");
+}
+?>
+--FILE--
+<?php
+/* Prototype : string gmstrftime(string format [, int timestamp])
+ * Description: Format a GMT/UCT time/date according to locale settings
+ * Source code: ext/date/php_date.c
+ * Alias to functions:
+ */
+
+echo "*** Testing gmstrftime() : usage variation ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$timestamp = gmmktime(8, 8, 8, 8, 8, 2008);
+setlocale(LC_ALL, "en_US");
+date_default_timezone_set("Asia/Calcutta");
+
+//array of values to iterate over
+$inputs = array(
+ 'Century number' => "%C",
+ 'Month Date Year' => "%D",
+ 'Year with century' => "%G",
+ 'Year without century' => "%g",
+);
+
+// loop through each element of the array for timestamp
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( gmstrftime($value) );
+ var_dump( gmstrftime($value, $timestamp) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing gmstrftime() : usage variation ***
+
+--Century number--
+string(%d) "%d"
+string(2) "20"
+
+--Month Date Year--
+string(%d) "%d/%d/%d"
+string(8) "08/08/08"
+
+--Year with century--
+string(%d) "%d"
+string(4) "2008"
+
+--Year without century--
+string(%d) "%d"
+string(2) "08"
+===DONE===
diff --git a/ext/date/tests/gmstrftime_variation15.phpt b/ext/date/tests/gmstrftime_variation15.phpt
new file mode 100644
index 0000000000..c0df364789
--- /dev/null
+++ b/ext/date/tests/gmstrftime_variation15.phpt
@@ -0,0 +1,55 @@
+--TEST--
+Test gmstrftime() function : usage variation - Checking time related formats which are not supported on Windows.
+--SKIPIF--
+<?php
+if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
+ die("skip Test is valid for Windows");
+}
+?>
+--FILE--
+<?php
+/* Prototype : string gmstrftime(string format [, int timestamp])
+ * Description: Format a GMT/UCT time/date according to locale settings
+ * Source code: ext/date/php_date.c
+ * Alias to functions:
+ */
+
+echo "*** Testing gmstrftime() : usage variation ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$timestamp = gmmktime(8, 8, 8, 8, 8, 2008);
+setlocale(LC_ALL, "en_US");
+date_default_timezone_set("Asia/Calcutta");
+
+//array of values to iterate over
+$inputs = array(
+ 'Time in a.m/p.m notation' => "%r",
+ 'Time in 24 hour notation' => "%R",
+ 'Current time %H:%M:%S format' => "%T",
+);
+
+// loop through each element of the array for timestamp
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( gmstrftime($value) );
+ var_dump( gmstrftime($value, $timestamp) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing gmstrftime() : usage variation ***
+
+--Time in a.m/p.m notation--
+bool(false)
+bool(false)
+
+--Time in 24 hour notation--
+bool(false)
+bool(false)
+
+--Current time %H:%M:%S format--
+bool(false)
+bool(false)
+===DONE===
diff --git a/ext/date/tests/gmstrftime_variation16.phpt b/ext/date/tests/gmstrftime_variation16.phpt
new file mode 100644
index 0000000000..fd9f809ea7
--- /dev/null
+++ b/ext/date/tests/gmstrftime_variation16.phpt
@@ -0,0 +1,55 @@
+--TEST--
+Test gmstrftime() function : usage variation - Checking time related formats which are supported other than on Windows.
+--SKIPIF--
+<?php
+if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
+ die("skip Test is not valid for Windows");
+}
+?>
+--FILE--
+<?php
+/* Prototype : string gmstrftime(string format [, int timestamp])
+ * Description: Format a GMT/UCT time/date according to locale settings
+ * Source code: ext/date/php_date.c
+ * Alias to functions:
+ */
+
+echo "*** Testing gmstrftime() : usage variation ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$timestamp = gmmktime(14, 8, 8, 8, 8, 2008);
+setlocale(LC_ALL, "en_US");
+date_default_timezone_set("Asia/Calcutta");
+
+//array of values to iterate over
+$inputs = array(
+ 'Time in a.m/p.m notation' => "%r",
+ 'Time in 24 hour notation' => "%R",
+ 'Current time %H:%M:%S format' => "%T",
+);
+
+// loop through each element of the array for timestamp
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( gmstrftime($value) );
+ var_dump( gmstrftime($value, $timestamp) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing gmstrftime() : usage variation ***
+
+--Time in a.m/p.m notation--
+string(%d) "%d:%d:%d %s"
+string(11) "02:08:08 PM"
+
+--Time in 24 hour notation--
+string(%d) "%d:%d"
+string(5) "14:08"
+
+--Current time %H:%M:%S format--
+string(%d) "%d:%d:%d"
+string(8) "14:08:08"
+===DONE===
diff --git a/ext/date/tests/gmstrftime_variation17.phpt b/ext/date/tests/gmstrftime_variation17.phpt
new file mode 100644
index 0000000000..e3070a5144
--- /dev/null
+++ b/ext/date/tests/gmstrftime_variation17.phpt
@@ -0,0 +1,37 @@
+--TEST--
+Test gmstrftime() function : usage variation - Checking day related formats which are not supported on Windows.
+--SKIPIF--
+<?php
+if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
+ die("skip Test is valid for Windows");
+}
+?>
+--FILE--
+<?php
+/* Prototype : string gmstrftime(string format [, int timestamp])
+ * Description: Format a GMT/UCT time/date according to locale settings
+ * Source code: ext/date/php_date.c
+ * Alias to functions:
+ */
+
+echo "*** Testing gmstrftime() : usage variation ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$timestamp = gmmktime(8, 8, 8, 8, 8, 2008);
+setlocale(LC_ALL, "en_US");
+date_default_timezone_set("Asia/Calcutta");
+
+echo "\n-- Testing gmstrftime() function with Day of the month as decimal single digit format --\n";
+$format = "%e";
+var_dump( gmstrftime($format) );
+var_dump( gmstrftime($format, $timestamp) );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing gmstrftime() : usage variation ***
+
+-- Testing gmstrftime() function with Day of the month as decimal single digit format --
+bool(false)
+bool(false)
+===DONE===
diff --git a/ext/date/tests/gmstrftime_variation18.phpt b/ext/date/tests/gmstrftime_variation18.phpt
new file mode 100644
index 0000000000..7567b42d02
--- /dev/null
+++ b/ext/date/tests/gmstrftime_variation18.phpt
@@ -0,0 +1,37 @@
+--TEST--
+Test gmstrftime() function : usage variation - Checking day related formats which are supported other than on Windows.
+--SKIPIF--
+<?php
+if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
+ die("skip Test is not valid for Windows");
+}
+?>
+--FILE--
+<?php
+/* Prototype : string gmstrftime(string format [, int timestamp])
+ * Description: Format a GMT/UCT time/date according to locale settings
+ * Source code: ext/date/php_date.c
+ * Alias to functions:
+ */
+
+echo "*** Testing gmstrftime() : usage variation ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$timestamp = gmmktime(8, 8, 8, 8, 8, 2008);
+setlocale(LC_ALL, "en_US");
+date_default_timezone_set("Asia/Calcutta");
+
+echo "\n-- Testing gmstrftime() function with Day of the month as decimal single digit format --\n";
+$format = "%e";
+var_dump( gmstrftime($format) );
+var_dump( gmstrftime($format, $timestamp) );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing gmstrftime() : usage variation ***
+
+-- Testing gmstrftime() function with Day of the month as decimal single digit format --
+string(%d) "%d"
+string(2) " 8"
+===DONE===
diff --git a/ext/date/tests/gmstrftime_variation19.phpt b/ext/date/tests/gmstrftime_variation19.phpt
new file mode 100644
index 0000000000..3131e01ca1
--- /dev/null
+++ b/ext/date/tests/gmstrftime_variation19.phpt
@@ -0,0 +1,50 @@
+--TEST--
+Test gmstrftime() function : usage variation - Checking newline and tab formats which are not supported on Windows.
+--SKIPIF--
+<?php
+if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
+ die("skip Test is valid for Windows");
+}
+?>
+--FILE--
+<?php
+/* Prototype : string gmstrftime(string format [, int timestamp])
+ * Description: Format a GMT/UCT time/date according to locale settings
+ * Source code: ext/date/php_date.c
+ * Alias to functions:
+ */
+
+echo "*** Testing gmstrftime() : usage variation ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$timestamp = gmmktime(8, 8, 8, 8, 8, 2008);
+setlocale(LC_ALL, "en_US");
+date_default_timezone_set("Asia/Calcutta");
+
+//array of values to iterate over
+$inputs = array(
+ 'Newline character' => "%n",
+ 'Tab character' => "%t"
+);
+
+// loop through each element of the array for timestamp
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( gmstrftime($value) );
+ var_dump( gmstrftime($value, $timestamp) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing gmstrftime() : usage variation ***
+
+--Newline character--
+bool(false)
+bool(false)
+
+--Tab character--
+bool(false)
+bool(false)
+===DONE===
diff --git a/ext/date/tests/gmstrftime_variation2.phpt b/ext/date/tests/gmstrftime_variation2.phpt
new file mode 100644
index 0000000000..b01de97599
--- /dev/null
+++ b/ext/date/tests/gmstrftime_variation2.phpt
@@ -0,0 +1,206 @@
+--TEST--
+Test gmstrftime() function : usage variation - Passing unexpected values to second argument 'timestamp'.
+--SKIPIF--
+<?php
+if(PHP_INT_SIZE != 4 ) {
+ die("skip Test is not valid for 64-bit");
+}
+?>
+--FILE--
+<?php
+/* Prototype : string gmstrftime(string format [, int timestamp])
+ * Description: Format a GMT/UCT time/date according to locale settings
+ * Source code: ext/date/php_date.c
+ * Alias to functions:
+ */
+
+echo "*** Testing gmstrftime() : usage variation ***\n";
+
+date_default_timezone_set("Asia/Calcutta");
+
+// Initialise function arguments not being substituted (if any)
+$format = '%b %d %Y %H:%M:%S';
+
+//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 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 timestamp
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( gmstrftime($format, $value) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing gmstrftime() : usage variation ***
+
+--float 10.5--
+string(20) "Jan 01 1970 00:00:10"
+
+--float -10.5--
+string(20) "Dec 31 1969 23:59:50"
+
+--float 12.3456789000e10--
+string(20) "Jan 19 2038 03:14:07"
+
+--float -12.3456789000e10--
+string(20) "Dec 13 1901 20:45:52"
+
+--float .5--
+string(20) "Jan 01 1970 00:00:00"
+
+--empty array--
+
+Warning: gmstrftime() expects parameter 2 to be long, array given in %s on line %d
+bool(false)
+
+--int indexed array--
+
+Warning: gmstrftime() expects parameter 2 to be long, array given in %s on line %d
+bool(false)
+
+--associative array--
+
+Warning: gmstrftime() expects parameter 2 to be long, array given in %s on line %d
+bool(false)
+
+--nested arrays--
+
+Warning: gmstrftime() expects parameter 2 to be long, array given in %s on line %d
+bool(false)
+
+--uppercase NULL--
+string(20) "Jan 01 1970 00:00:00"
+
+--lowercase null--
+string(20) "Jan 01 1970 00:00:00"
+
+--lowercase true--
+string(20) "Jan 01 1970 00:00:01"
+
+--lowercase false--
+string(20) "Jan 01 1970 00:00:00"
+
+--uppercase TRUE--
+string(20) "Jan 01 1970 00:00:01"
+
+--uppercase FALSE--
+string(20) "Jan 01 1970 00:00:00"
+
+--empty string DQ--
+
+Warning: gmstrftime() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+
+--empty string SQ--
+
+Warning: gmstrftime() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+
+--string DQ--
+
+Warning: gmstrftime() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+
+--string SQ--
+
+Warning: gmstrftime() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+
+--mixed case string--
+
+Warning: gmstrftime() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+
+--heredoc--
+
+Warning: gmstrftime() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+
+--instance of classWithToString--
+
+Warning: gmstrftime() expects parameter 2 to be long, object given in %s on line %d
+bool(false)
+
+--instance of classWithoutToString--
+
+Warning: gmstrftime() expects parameter 2 to be long, object given in %s on line %d
+bool(false)
+
+--undefined var--
+string(20) "Jan 01 1970 00:00:00"
+
+--unset var--
+string(20) "Jan 01 1970 00:00:00"
+===DONE===
diff --git a/ext/date/tests/gmstrftime_variation20.phpt b/ext/date/tests/gmstrftime_variation20.phpt
new file mode 100644
index 0000000000..a8898d8ec8
--- /dev/null
+++ b/ext/date/tests/gmstrftime_variation20.phpt
@@ -0,0 +1,52 @@
+--TEST--
+Test gmstrftime() function : usage variation - Checking newline and tab formats which are supported other than on Windows.
+--SKIPIF--
+<?php
+if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
+ die("skip Test is not valid for Windows");
+}
+?>
+--FILE--
+<?php
+/* Prototype : string gmstrftime(string format [, int timestamp])
+ * Description: Format a GMT/UCT time/date according to locale settings
+ * Source code: ext/date/php_date.c
+ * Alias to functions:
+ */
+
+echo "*** Testing gmstrftime() : usage variation ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$timestamp = gmmktime(8, 8, 8, 8, 8, 2008);
+setlocale(LC_ALL, "en_US");
+date_default_timezone_set("Asia/Calcutta");
+
+//array of values to iterate over
+$inputs = array(
+ 'Newline character' => "%n",
+ 'Tab character' => "%t"
+);
+
+// loop through each element of the array for timestamp
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( gmstrftime($value) );
+ var_dump( gmstrftime($value, $timestamp) );
+};
+
+?>
+===DONE===
+--EXPECTREGEX--
+\*\*\* Testing gmstrftime\(\) : usage variation \*\*\*
+
+--Newline character--
+string\(1\) "
+"
+string\(1\) "
+"
+
+--Tab character--
+string\(1\) "\s"
+string\(1\) "\s"
+===DONE===
diff --git a/ext/date/tests/gmstrftime_variation21.phpt b/ext/date/tests/gmstrftime_variation21.phpt
new file mode 100644
index 0000000000..26ed157c3f
--- /dev/null
+++ b/ext/date/tests/gmstrftime_variation21.phpt
@@ -0,0 +1,55 @@
+--TEST--
+Test gmstrftime() function : usage variation - Checking Preferred date and time representation on Windows.
+--SKIPIF--
+<?php
+if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
+ die("skip Test is valid for Windows");
+}
+?>
+--FILE--
+<?php
+/* Prototype : string gmstrftime(string format [, int timestamp])
+ * Description: Format a GMT/UCT time/date according to locale settings
+ * Source code: ext/date/php_date.c
+ * Alias to functions:
+ */
+
+echo "*** Testing gmstrftime() : usage variation ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$timestamp = gmmktime(8, 8, 8, 8, 8, 2008);
+setlocale(LC_ALL, "en_US");
+date_default_timezone_set("Asia/Calcutta");
+
+//array of values to iterate over
+$inputs = array(
+ 'Preferred date and time representation' => "%c",
+ 'Preferred date representation' => "%x",
+ 'Preferred time representation' => "%X",
+);
+
+// loop through each element of the array for timestamp
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( gmstrftime($value) );
+ var_dump( gmstrftime($value, $timestamp) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing gmstrftime() : usage variation ***
+
+--Preferred date and time representation--
+string(%d) "%d/%d/%d %d:%d:%d"
+string(17) "08/08/08 08:08:08"
+
+--Preferred date representation--
+string(%d) "%d/%d/%d"
+string(8) "08/08/08"
+
+--Preferred time representation--
+string(%d) "%d:%d:%d"
+string(8) "08:08:08"
+===DONE===
diff --git a/ext/date/tests/gmstrftime_variation22.phpt b/ext/date/tests/gmstrftime_variation22.phpt
new file mode 100644
index 0000000000..2d37a414a9
--- /dev/null
+++ b/ext/date/tests/gmstrftime_variation22.phpt
@@ -0,0 +1,55 @@
+--TEST--
+Test gmstrftime() function : usage variation - Checking Preferred date and time representation other than on Windows.
+--SKIPIF--
+<?php
+if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
+ die("skip Test is not valid for Windows");
+}
+?>
+--FILE--
+<?php
+/* Prototype : string gmstrftime(string format [, int timestamp])
+ * Description: Format a GMT/UCT time/date according to locale settings
+ * Source code: ext/date/php_date.c
+ * Alias to functions:
+ */
+
+echo "*** Testing gmstrftime() : usage variation ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$timestamp = gmmktime(8, 8, 8, 8, 8, 2008);
+setlocale(LC_ALL, "en_US");
+date_default_timezone_set("Asia/Calcutta");
+
+//array of values to iterate over
+$inputs = array(
+ 'Preferred date and time representation' => "%c",
+ 'Preferred date representation' => "%x",
+ 'Preferred time representation' => "%X",
+);
+
+// loop through each element of the array for timestamp
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( gmstrftime($value) );
+ var_dump( gmstrftime($value, $timestamp) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing gmstrftime() : usage variation ***
+
+--Preferred date and time representation--
+string(%d) "%s %d %s %d %d:%d:%d %s GMT"
+string(31) "Fri 08 Aug 2008 08:08:08 AM GMT"
+
+--Preferred date representation--
+string(%d) "%d/%d/%d"
+string(10) "08/08/2008"
+
+--Preferred time representation--
+string(%d) "%d:%d:%d %s"
+string(11) "08:08:08 AM"
+===DONE===
diff --git a/ext/date/tests/gmstrftime_variation3.phpt b/ext/date/tests/gmstrftime_variation3.phpt
new file mode 100644
index 0000000000..bc05c7b4c0
--- /dev/null
+++ b/ext/date/tests/gmstrftime_variation3.phpt
@@ -0,0 +1,52 @@
+--TEST--
+Test gmstrftime() function : usage variation - Passing week related format strings to format argument.
+--FILE--
+<?php
+/* Prototype : string gmstrftime(string format [, int timestamp])
+ * Description: Format a GMT/UCT time/date according to locale settings
+ * Source code: ext/date/php_date.c
+ * Alias to functions:
+ */
+
+echo "*** Testing gmstrftime() : usage variation ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$timestamp = gmmktime(8, 8, 8, 8, 8, 2008);
+
+//array of values to iterate over
+$inputs = array(
+ 'Abbreviated weekday name' => "%a",
+ 'Full weekday name' => "%A",
+ 'Week number of the year' => "%U",
+ 'Week number of the year in decimal number' => "%W",
+);
+
+// loop through each element of the array for timestamp
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( gmstrftime($value) );
+ var_dump( gmstrftime($value, $timestamp) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing gmstrftime() : usage variation ***
+
+--Abbreviated weekday name--
+string(%d) "%s"
+string(3) "Fri"
+
+--Full weekday name--
+string(%d) "%s"
+string(6) "Friday"
+
+--Week number of the year--
+string(%d) "%d"
+string(2) "31"
+
+--Week number of the year in decimal number--
+string(%d) "%d"
+string(2) "31"
+===DONE===
diff --git a/ext/date/tests/gmstrftime_variation4.phpt b/ext/date/tests/gmstrftime_variation4.phpt
new file mode 100644
index 0000000000..619e633a9c
--- /dev/null
+++ b/ext/date/tests/gmstrftime_variation4.phpt
@@ -0,0 +1,47 @@
+--TEST--
+Test gmstrftime() function : usage variation - Passing month related format strings to format argument.
+--FILE--
+<?php
+/* Prototype : string gmstrftime(string format [, int timestamp])
+ * Description: Format a GMT/UCT time/date according to locale settings
+ * Source code: ext/date/php_date.c
+ * Alias to functions:
+ */
+
+echo "*** Testing gmstrftime() : usage variation ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$timestamp = gmmktime(8, 8, 8, 8, 8, 2008);
+
+//array of values to iterate over
+$inputs = array(
+ 'Abbreviated month name' => "%b",
+ 'Full month name' => "%B",
+ 'Month as decimal' => "%m",
+);
+
+// loop through each element of the array for timestamp
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( gmstrftime($value) );
+ var_dump( gmstrftime($value, $timestamp) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing gmstrftime() : usage variation ***
+
+--Abbreviated month name--
+string(%d) "%s"
+string(3) "Aug"
+
+--Full month name--
+string(%d) "%s"
+string(6) "August"
+
+--Month as decimal--
+string(%d) "%d"
+string(2) "08"
+===DONE===
diff --git a/ext/date/tests/gmstrftime_variation5.phpt b/ext/date/tests/gmstrftime_variation5.phpt
new file mode 100644
index 0000000000..95e3bd2396
--- /dev/null
+++ b/ext/date/tests/gmstrftime_variation5.phpt
@@ -0,0 +1,51 @@
+--TEST--
+Test gmstrftime() function : usage variation - Passing date related format strings to format argument.
+--FILE--
+<?php
+/* Prototype : string gmstrftime(string format [, int timestamp])
+ * Description: Format a GMT/UCT time/date according to locale settings
+ * Source code: ext/date/php_date.c
+ * Alias to functions:
+ */
+
+echo "*** Testing gmstrftime() : usage variation ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$timestamp = gmmktime(8, 8, 8, 8, 8, 2008);
+setlocale(LC_ALL, "en_US");
+date_default_timezone_set("Asia/Calcutta");
+
+
+//array of values to iterate over
+$inputs = array(
+ 'Year as decimal number without a century' => "%y",
+ 'Year as decimal number including the century' => "%Y",
+ 'Time zone offset' => "%Z",
+ 'Time zone offset' => "%z",
+);
+
+// loop through each element of the array for timestamp
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( gmstrftime($value) );
+ var_dump( gmstrftime($value, $timestamp) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing gmstrftime() : usage variation ***
+
+--Year as decimal number without a century--
+string(%d) "%d"
+string(2) "08"
+
+--Year as decimal number including the century--
+string(%d) "%d"
+string(4) "2008"
+
+--Time zone offset--
+string(%s) "%s"
+string(%s) "%s"
+===DONE===
diff --git a/ext/date/tests/gmstrftime_variation6.phpt b/ext/date/tests/gmstrftime_variation6.phpt
new file mode 100644
index 0000000000..92dd1ede30
--- /dev/null
+++ b/ext/date/tests/gmstrftime_variation6.phpt
@@ -0,0 +1,59 @@
+--TEST--
+Test gmstrftime() function : usage variation - Passing time related format strings to format argument.
+--FILE--
+<?php
+/* Prototype : string gmstrftime(string format [, int timestamp])
+ * Description: Format a GMT/UCT time/date according to locale settings
+ * Source code: ext/date/php_date.c
+ * Alias to functions:
+ */
+
+echo "*** Testing gmstrftime() : usage variation ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$timestamp = gmmktime(8, 8, 8, 8, 8, 2008);
+setlocale(LC_ALL, "en_US");
+date_default_timezone_set("Asia/Calcutta");
+
+//array of values to iterate over
+$inputs = array(
+ 'Hour as decimal by 24-hour format' => "%H",
+ 'Hour as decimal by 12-hour format' => "%I",
+ 'Minute as decimal number' => "%M",
+ 'AM/PM format for a time' => "%p",
+ 'Second as decimal number' => "%S",
+);
+
+// loop through each element of the array for timestamp
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( gmstrftime($value) );
+ var_dump( gmstrftime($value, $timestamp) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing gmstrftime() : usage variation ***
+
+--Hour as decimal by 24-hour format--
+string(2) "%d"
+string(2) "08"
+
+--Hour as decimal by 12-hour format--
+string(2) "%d"
+string(2) "08"
+
+--Minute as decimal number--
+string(%d) "%d"
+string(2) "08"
+
+--AM/PM format for a time--
+string(2) "%s"
+string(2) "AM"
+
+--Second as decimal number--
+string(%d) "%d"
+string(2) "08"
+===DONE===
diff --git a/ext/date/tests/gmstrftime_variation7.phpt b/ext/date/tests/gmstrftime_variation7.phpt
new file mode 100644
index 0000000000..dd0584b702
--- /dev/null
+++ b/ext/date/tests/gmstrftime_variation7.phpt
@@ -0,0 +1,49 @@
+--TEST--
+Test gmstrftime() function : usage variation - Passing day related format strings to format argument.
+--FILE--
+<?php
+/* Prototype : string gmstrftime(string format [, int timestamp])
+ * Description: Format a GMT/UCT time/date according to locale settings
+ * Source code: ext/date/php_date.c
+ * Alias to functions:
+ */
+
+echo "*** Testing gmstrftime() : usage variation ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$timestamp = gmmktime(8, 8, 8, 8, 8, 2008);
+setlocale(LC_ALL, "en_US");
+date_default_timezone_set("Asia/Calcutta");
+
+//array of values to iterate over
+$inputs = array(
+ 'Day of the month as a decimal number' => "%d",
+ 'Day of the year as a decimal number' => "%j",
+ 'Day of the week as a decimal number' => "%w"
+);
+
+// loop through each element of the array for timestamp
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( gmstrftime($value) );
+ var_dump( gmstrftime($value, $timestamp) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing gmstrftime() : usage variation ***
+
+--Day of the month as a decimal number--
+string(%d) "%d"
+string(2) "08"
+
+--Day of the year as a decimal number--
+string(%d) "%d"
+string(3) "221"
+
+--Day of the week as a decimal number--
+string(%d) "%d"
+string(1) "5"
+===DONE===
diff --git a/ext/date/tests/gmstrftime_variation8.phpt b/ext/date/tests/gmstrftime_variation8.phpt
new file mode 100644
index 0000000000..59057aa173
--- /dev/null
+++ b/ext/date/tests/gmstrftime_variation8.phpt
@@ -0,0 +1,39 @@
+--TEST--
+Test gmstrftime() function : usage variation - Passing literal related strings to format argument.
+--FILE--
+<?php
+/* Prototype : string gmstrftime(string format [, int timestamp])
+ * Description: Format a GMT/UCT time/date according to locale settings
+ * Source code: ext/date/php_date.c
+ * Alias to functions:
+ */
+
+echo "*** Testing gmstrftime() : usage variation ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$timestamp = gmmktime(8, 8, 8, 8, 8, 2008);
+setlocale(LC_ALL, "en_US");
+date_default_timezone_set("Asia/Calcutta");
+
+//array of values to iterate over
+$inputs = array(
+ 'A literal % character' => "%%",
+);
+
+// loop through each element of the array for timestamp
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( gmstrftime($value) );
+ var_dump( gmstrftime($value, $timestamp) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing gmstrftime() : usage variation ***
+
+--A literal % character--
+string(1) "%"
+string(1) "%"
+===DONE===
diff --git a/ext/date/tests/gmstrftime_variation9.phpt b/ext/date/tests/gmstrftime_variation9.phpt
new file mode 100644
index 0000000000..95b6c904f9
--- /dev/null
+++ b/ext/date/tests/gmstrftime_variation9.phpt
@@ -0,0 +1,50 @@
+--TEST--
+Test gmstrftime() function : usage variation - Checking week related formats which are not supported on Windows.
+--SKIPIF--
+<?php
+if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
+ die("skip Test is not valid for Windows");
+}
+?>
+--FILE--
+<?php
+/* Prototype : string gmstrftime(string format [, int timestamp])
+ * Description: Format a GMT/UCT time/date according to locale settings
+ * Source code: ext/date/php_date.c
+ * Alias to functions:
+ */
+
+echo "*** Testing gmstrftime() : usage variation ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$timestamp = gmmktime(8, 8, 8, 8, 8, 2008);
+setlocale(LC_ALL, "en_US");
+date_default_timezone_set("Asia/Calcutta");
+
+//array of values to iterate over
+$inputs = array(
+ 'The ISO 8601:1988 week number' => "%V",
+ 'Weekday as decimal' => "%u",
+);
+
+// loop through each element of the array for timestamp
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( gmstrftime($value) );
+ var_dump( gmstrftime($value, $timestamp) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing gmstrftime() : usage variation ***
+
+--The ISO 8601:1988 week number--
+bool(false)
+bool(false)
+
+--Weekday as decimal--
+bool(false)
+bool(false)
+===DONE===