]> granicus.if.org Git - php/commitdiff
New testcases for gmmktime function
authorSanjay Mantoor <smantoor@php.net>
Fri, 21 Nov 2008 06:21:51 +0000 (06:21 +0000)
committerSanjay Mantoor <smantoor@php.net>
Fri, 21 Nov 2008 06:21:51 +0000 (06:21 +0000)
ext/date/tests/gmmktime_basic.phpt [new file with mode: 0644]
ext/date/tests/gmmktime_error.phpt [new file with mode: 0644]
ext/date/tests/gmmktime_variation1.phpt [new file with mode: 0644]
ext/date/tests/gmmktime_variation2.phpt [new file with mode: 0644]
ext/date/tests/gmmktime_variation3.phpt [new file with mode: 0644]
ext/date/tests/gmmktime_variation4.phpt [new file with mode: 0644]
ext/date/tests/gmmktime_variation5.phpt [new file with mode: 0644]
ext/date/tests/gmmktime_variation6.phpt [new file with mode: 0644]
ext/date/tests/gmmktime_variation7.phpt [new file with mode: 0644]
ext/date/tests/gmmktime_variation8.phpt [new file with mode: 0644]
ext/date/tests/gmmktime_variation9.phpt [new file with mode: 0644]

diff --git a/ext/date/tests/gmmktime_basic.phpt b/ext/date/tests/gmmktime_basic.phpt
new file mode 100644 (file)
index 0000000..81abb5f
--- /dev/null
@@ -0,0 +1,35 @@
+--TEST--
+Test gmmktime() function : basic functionality 
+--FILE--
+<?php
+/* Prototype  : int gmmktime([int hour [, int min [, int sec [, int mon [, int day [, int year]]]]]])
+ * Description: Get UNIX timestamp for a GMT date 
+ * Source code: ext/date/php_date.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing gmmktime() : basic functionality ***\n";
+
+// Initialise all required variables
+$hour = 8;
+$min = 8;
+$sec = 8;
+$mon = 8;
+$day = 8;
+$year = 2008;
+
+// Calling gmmktime() with all possible arguments
+var_dump( gmmktime($hour, $min, $sec, $mon, $day, $year) );
+
+// Calling gmmktime() with mandatory arguments
+var_dump( gmmktime() );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing gmmktime() : basic functionality ***
+int(1218182888)
+
+Strict Standards: gmmktime(): You should be using the time() function instead in %s on line %d
+int(%d)
+===DONE===
diff --git a/ext/date/tests/gmmktime_error.phpt b/ext/date/tests/gmmktime_error.phpt
new file mode 100644 (file)
index 0000000..9f5882d
--- /dev/null
@@ -0,0 +1,39 @@
+--TEST--
+Test gmmktime() function : error conditions 
+--FILE--
+<?php
+/* Prototype  : int gmmktime([int hour [, int min [, int sec [, int mon [, int day [, int year]]]]]])
+ * Description: Get UNIX timestamp for a GMT date 
+ * Source code: ext/date/php_date.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing gmmktime() : error conditions ***\n";
+
+//Test gmmktime with one more than the expected number of arguments
+echo "\n-- Testing gmmktime() function with more than expected no. of arguments --\n";
+$hour = 8;
+$min = 8;
+$sec = 8;
+$mon = 8;
+$day = 8;
+$year = 2008;
+$extra_arg1 = 10;
+$extra_arg2 = 10;
+
+var_dump( gmmktime($hour, $min, $sec, $mon, $day, $year, $extra_arg1) );
+
+var_dump( gmmktime($hour, $min, $sec, $mon, $day, $year, $extra_arg1, $extra_arg2) );
+?>
+===DONE===
+--EXPECTF--
+*** Testing gmmktime() : error conditions ***
+
+-- Testing gmmktime() function with more than expected no. of arguments --
+
+Deprecated: gmmktime(): The is_dst parameter is deprecated in %s on line %d
+int(1218182888)
+
+Warning: gmmktime() expects at most 7 parameters, 8 given in %s on line %d
+bool(false)
+===DONE===
diff --git a/ext/date/tests/gmmktime_variation1.phpt b/ext/date/tests/gmmktime_variation1.phpt
new file mode 100644 (file)
index 0000000..0030ed0
--- /dev/null
@@ -0,0 +1,194 @@
+--TEST--
+Test gmmktime() function : usage variation - Passing unexpected values to first argument hour.
+--FILE--
+<?php
+/* Prototype  : int gmmktime([int hour [, int min [, int sec [, int mon [, int day [, int year]]]]]])
+ * Description: Get UNIX timestamp for a GMT date 
+ * Source code: ext/date/php_date.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing gmmktime() : usage variation ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$min = 8;
+$sec = 8;
+$mon = 8;
+$day = 8;
+$year = 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(
+
+      // 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 hour
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      var_dump( gmmktime($value, $min, $sec, $mon, $day, $year) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing gmmktime() : usage variation ***
+
+--float 10.5--
+int(1218190088)
+
+--float -10.5--
+int(1218118088)
+
+--float .5--
+int(1218154088)
+
+--empty array--
+
+Warning: gmmktime() expects parameter 1 to be long, array given in %s on line %d
+bool(false)
+
+--int indexed array--
+
+Warning: gmmktime() expects parameter 1 to be long, array given in %s on line %d
+bool(false)
+
+--associative array--
+
+Warning: gmmktime() expects parameter 1 to be long, array given in %s on line %d
+bool(false)
+
+--nested arrays--
+
+Warning: gmmktime() expects parameter 1 to be long, array given in %s on line %d
+bool(false)
+
+--uppercase NULL--
+int(1218154088)
+
+--lowercase null--
+int(1218154088)
+
+--lowercase true--
+int(1218157688)
+
+--lowercase false--
+int(1218154088)
+
+--uppercase TRUE--
+int(1218157688)
+
+--uppercase FALSE--
+int(1218154088)
+
+--empty string DQ--
+
+Warning: gmmktime() expects parameter 1 to be long, Unicode string given in %s on line %d
+bool(false)
+
+--empty string SQ--
+
+Warning: gmmktime() expects parameter 1 to be long, Unicode string given in %s on line %d
+bool(false)
+
+--string DQ--
+
+Warning: gmmktime() expects parameter 1 to be long, Unicode string given in %s on line %d
+bool(false)
+
+--string SQ--
+
+Warning: gmmktime() expects parameter 1 to be long, Unicode string given in %s on line %d
+bool(false)
+
+--mixed case string--
+
+Warning: gmmktime() expects parameter 1 to be long, Unicode string given in %s on line %d
+bool(false)
+
+--heredoc--
+
+Warning: gmmktime() expects parameter 1 to be long, Unicode string given in %s on line %d
+bool(false)
+
+--instance of classWithToString--
+
+Warning: gmmktime() expects parameter 1 to be long, object given in %s on line %d
+bool(false)
+
+--instance of classWithoutToString--
+
+Warning: gmmktime() expects parameter 1 to be long, object given in %s on line %d
+bool(false)
+
+--undefined var--
+int(1218154088)
+
+--unset var--
+int(1218154088)
+===DONE===
diff --git a/ext/date/tests/gmmktime_variation2.phpt b/ext/date/tests/gmmktime_variation2.phpt
new file mode 100644 (file)
index 0000000..45e57fc
--- /dev/null
@@ -0,0 +1,194 @@
+--TEST--
+Test gmmktime() function : usage variation - Passing unexpected values to second argument minute.
+--FILE--
+<?php
+/* Prototype  : int gmmktime([int hour [, int min [, int sec [, int mon [, int day [, int year]]]]]])
+ * Description: Get UNIX timestamp for a GMT date 
+ * Source code: ext/date/php_date.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing gmmktime() : usage variation ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$hour = 8;
+$sec = 8;
+$mon = 8;
+$day = 8;
+$year = 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(
+
+      // 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 min
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      var_dump( gmmktime($hour, $value, $sec, $mon, $day, $year) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing gmmktime() : usage variation ***
+
+--float 10.5--
+int(1218183008)
+
+--float -10.5--
+int(1218181808)
+
+--float .5--
+int(1218182408)
+
+--empty array--
+
+Warning: gmmktime() expects parameter 2 to be long, array given in %s on line %d
+bool(false)
+
+--int indexed array--
+
+Warning: gmmktime() expects parameter 2 to be long, array given in %s on line %d
+bool(false)
+
+--associative array--
+
+Warning: gmmktime() expects parameter 2 to be long, array given in %s on line %d
+bool(false)
+
+--nested arrays--
+
+Warning: gmmktime() expects parameter 2 to be long, array given in %s on line %d
+bool(false)
+
+--uppercase NULL--
+int(1218182408)
+
+--lowercase null--
+int(1218182408)
+
+--lowercase true--
+int(1218182468)
+
+--lowercase false--
+int(1218182408)
+
+--uppercase TRUE--
+int(1218182468)
+
+--uppercase FALSE--
+int(1218182408)
+
+--empty string DQ--
+
+Warning: gmmktime() expects parameter 2 to be long, Unicode string given in %s on line %d
+bool(false)
+
+--empty string SQ--
+
+Warning: gmmktime() expects parameter 2 to be long, Unicode string given in %s on line %d
+bool(false)
+
+--string DQ--
+
+Warning: gmmktime() expects parameter 2 to be long, Unicode string given in %s on line %d
+bool(false)
+
+--string SQ--
+
+Warning: gmmktime() expects parameter 2 to be long, Unicode string given in %s on line %d
+bool(false)
+
+--mixed case string--
+
+Warning: gmmktime() expects parameter 2 to be long, Unicode string given in %s on line %d
+bool(false)
+
+--heredoc--
+
+Warning: gmmktime() expects parameter 2 to be long, Unicode string given in %s on line %d
+bool(false)
+
+--instance of classWithToString--
+
+Warning: gmmktime() expects parameter 2 to be long, object given in %s on line %d
+bool(false)
+
+--instance of classWithoutToString--
+
+Warning: gmmktime() expects parameter 2 to be long, object given in %s on line %d
+bool(false)
+
+--undefined var--
+int(1218182408)
+
+--unset var--
+int(1218182408)
+===DONE===
diff --git a/ext/date/tests/gmmktime_variation3.phpt b/ext/date/tests/gmmktime_variation3.phpt
new file mode 100644 (file)
index 0000000..573bef0
--- /dev/null
@@ -0,0 +1,194 @@
+--TEST--
+Test gmmktime() function : usage variation - Passing unexpected values to third argument seconds.
+--FILE--
+<?php
+/* Prototype  : int gmmktime([int hour [, int min [, int sec [, int mon [, int day [, int year]]]]]])
+ * Description: Get UNIX timestamp for a GMT date 
+ * Source code: ext/date/php_date.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing gmmktime() : usage variation ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$hour = 8;
+$min = 8;
+$mon = 8;
+$day = 8;
+$year = 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(
+
+      // 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 sec
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      var_dump( gmmktime($hour, $min, $value, $mon, $day, $year) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing gmmktime() : usage variation ***
+
+--float 10.5--
+int(1218182890)
+
+--float -10.5--
+int(1218182870)
+
+--float .5--
+int(1218182880)
+
+--empty array--
+
+Warning: gmmktime() expects parameter 3 to be long, array given in %s on line %d
+bool(false)
+
+--int indexed array--
+
+Warning: gmmktime() expects parameter 3 to be long, array given in %s on line %d
+bool(false)
+
+--associative array--
+
+Warning: gmmktime() expects parameter 3 to be long, array given in %s on line %d
+bool(false)
+
+--nested arrays--
+
+Warning: gmmktime() expects parameter 3 to be long, array given in %s on line %d
+bool(false)
+
+--uppercase NULL--
+int(1218182880)
+
+--lowercase null--
+int(1218182880)
+
+--lowercase true--
+int(1218182881)
+
+--lowercase false--
+int(1218182880)
+
+--uppercase TRUE--
+int(1218182881)
+
+--uppercase FALSE--
+int(1218182880)
+
+--empty string DQ--
+
+Warning: gmmktime() expects parameter 3 to be long, Unicode string given in %s on line %d
+bool(false)
+
+--empty string SQ--
+
+Warning: gmmktime() expects parameter 3 to be long, Unicode string given in %s on line %d
+bool(false)
+
+--string DQ--
+
+Warning: gmmktime() expects parameter 3 to be long, Unicode string given in %s on line %d
+bool(false)
+
+--string SQ--
+
+Warning: gmmktime() expects parameter 3 to be long, Unicode string given in %s on line %d
+bool(false)
+
+--mixed case string--
+
+Warning: gmmktime() expects parameter 3 to be long, Unicode string given in %s on line %d
+bool(false)
+
+--heredoc--
+
+Warning: gmmktime() expects parameter 3 to be long, Unicode string given in %s on line %d
+bool(false)
+
+--instance of classWithToString--
+
+Warning: gmmktime() expects parameter 3 to be long, object given in %s on line %d
+bool(false)
+
+--instance of classWithoutToString--
+
+Warning: gmmktime() expects parameter 3 to be long, object given in %s on line %d
+bool(false)
+
+--undefined var--
+int(1218182880)
+
+--unset var--
+int(1218182880)
+===DONE===
diff --git a/ext/date/tests/gmmktime_variation4.phpt b/ext/date/tests/gmmktime_variation4.phpt
new file mode 100644 (file)
index 0000000..871883a
--- /dev/null
@@ -0,0 +1,194 @@
+--TEST--
+Test gmmktime() function : usage variation - Passing unexpected values to fourth argument month.
+--FILE--
+<?php
+/* Prototype  : int gmmktime([int hour [, int min [, int sec [, int mon [, int day [, int year]]]]]])
+ * Description: Get UNIX timestamp for a GMT date 
+ * Source code: ext/date/php_date.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing gmmktime() : usage variation ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$hour = 8;
+$min = 8;
+$sec = 8;
+$day = 8;
+$year = 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(
+
+      // 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 mon
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      var_dump( gmmktime($hour, $min, $sec, $value, $day, $year) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing gmmktime() : usage variation ***
+
+--float 10.5--
+int(1223453288)
+
+--float -10.5--
+int(1170922088)
+
+--float .5--
+int(1197101288)
+
+--empty array--
+
+Warning: gmmktime() expects parameter 4 to be long, array given in %s on line %d
+bool(false)
+
+--int indexed array--
+
+Warning: gmmktime() expects parameter 4 to be long, array given in %s on line %d
+bool(false)
+
+--associative array--
+
+Warning: gmmktime() expects parameter 4 to be long, array given in %s on line %d
+bool(false)
+
+--nested arrays--
+
+Warning: gmmktime() expects parameter 4 to be long, array given in %s on line %d
+bool(false)
+
+--uppercase NULL--
+int(1197101288)
+
+--lowercase null--
+int(1197101288)
+
+--lowercase true--
+int(1199779688)
+
+--lowercase false--
+int(1197101288)
+
+--uppercase TRUE--
+int(1199779688)
+
+--uppercase FALSE--
+int(1197101288)
+
+--empty string DQ--
+
+Warning: gmmktime() expects parameter 4 to be long, Unicode string given in %s on line %d
+bool(false)
+
+--empty string SQ--
+
+Warning: gmmktime() expects parameter 4 to be long, Unicode string given in %s on line %d
+bool(false)
+
+--string DQ--
+
+Warning: gmmktime() expects parameter 4 to be long, Unicode string given in %s on line %d
+bool(false)
+
+--string SQ--
+
+Warning: gmmktime() expects parameter 4 to be long, Unicode string given in %s on line %d
+bool(false)
+
+--mixed case string--
+
+Warning: gmmktime() expects parameter 4 to be long, Unicode string given in %s on line %d
+bool(false)
+
+--heredoc--
+
+Warning: gmmktime() expects parameter 4 to be long, Unicode string given in %s on line %d
+bool(false)
+
+--instance of classWithToString--
+
+Warning: gmmktime() expects parameter 4 to be long, object given in %s on line %d
+bool(false)
+
+--instance of classWithoutToString--
+
+Warning: gmmktime() expects parameter 4 to be long, object given in %s on line %d
+bool(false)
+
+--undefined var--
+int(1197101288)
+
+--unset var--
+int(1197101288)
+===DONE===
diff --git a/ext/date/tests/gmmktime_variation5.phpt b/ext/date/tests/gmmktime_variation5.phpt
new file mode 100644 (file)
index 0000000..839cbf9
--- /dev/null
@@ -0,0 +1,194 @@
+--TEST--
+Test gmmktime() function : usage variation - Passing unexpected values to fifth argument day.
+--FILE--
+<?php
+/* Prototype  : int gmmktime([int hour [, int min [, int sec [, int mon [, int day [, int year]]]]]])
+ * Description: Get UNIX timestamp for a GMT date 
+ * Source code: ext/date/php_date.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing gmmktime() : usage variation ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$hour = 8;
+$min = 8;
+$sec = 8;
+$mon = 8;
+$year = 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(
+
+      // 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 day
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      var_dump( gmmktime($hour, $min, $sec, $mon, $value, $year) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing gmmktime() : usage variation ***
+
+--float 10.5--
+int(1218355688)
+
+--float -10.5--
+int(1216627688)
+
+--float .5--
+int(1217491688)
+
+--empty array--
+
+Warning: gmmktime() expects parameter 5 to be long, array given in %s on line %d
+bool(false)
+
+--int indexed array--
+
+Warning: gmmktime() expects parameter 5 to be long, array given in %s on line %d
+bool(false)
+
+--associative array--
+
+Warning: gmmktime() expects parameter 5 to be long, array given in %s on line %d
+bool(false)
+
+--nested arrays--
+
+Warning: gmmktime() expects parameter 5 to be long, array given in %s on line %d
+bool(false)
+
+--uppercase NULL--
+int(1217491688)
+
+--lowercase null--
+int(1217491688)
+
+--lowercase true--
+int(1217578088)
+
+--lowercase false--
+int(1217491688)
+
+--uppercase TRUE--
+int(1217578088)
+
+--uppercase FALSE--
+int(1217491688)
+
+--empty string DQ--
+
+Warning: gmmktime() expects parameter 5 to be long, Unicode string given in %s on line %d
+bool(false)
+
+--empty string SQ--
+
+Warning: gmmktime() expects parameter 5 to be long, Unicode string given in %s on line %d
+bool(false)
+
+--string DQ--
+
+Warning: gmmktime() expects parameter 5 to be long, Unicode string given in %s on line %d
+bool(false)
+
+--string SQ--
+
+Warning: gmmktime() expects parameter 5 to be long, Unicode string given in %s on line %d
+bool(false)
+
+--mixed case string--
+
+Warning: gmmktime() expects parameter 5 to be long, Unicode string given in %s on line %d
+bool(false)
+
+--heredoc--
+
+Warning: gmmktime() expects parameter 5 to be long, Unicode string given in %s on line %d
+bool(false)
+
+--instance of classWithToString--
+
+Warning: gmmktime() expects parameter 5 to be long, object given in %s on line %d
+bool(false)
+
+--instance of classWithoutToString--
+
+Warning: gmmktime() expects parameter 5 to be long, object given in %s on line %d
+bool(false)
+
+--undefined var--
+int(1217491688)
+
+--unset var--
+int(1217491688)
+===DONE===
diff --git a/ext/date/tests/gmmktime_variation6.phpt b/ext/date/tests/gmmktime_variation6.phpt
new file mode 100644 (file)
index 0000000..6ba3410
--- /dev/null
@@ -0,0 +1,190 @@
+--TEST--
+Test gmmktime() function : usage variation - Passing unexpected values to sixth argument year.
+--FILE--
+<?php
+/* Prototype  : int gmmktime([int hour [, int min [, int sec [, int mon [, int day [, int year]]]]]])
+ * Description: Get UNIX timestamp for a GMT date 
+ * Source code: ext/date/php_date.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing gmmktime() : usage variation ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$hour = 8;
+$min = 8;
+$sec = 8;
+$mon = 8;
+$day = 8;
+
+//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 .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 year
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      var_dump( gmmktime($hour, $min, $sec, $mon, $day, $value) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing gmmktime() : usage variation ***
+
+--float 10.5--
+int(1281254888)
+
+--float .5--
+int(965722088)
+
+--empty array--
+
+Warning: gmmktime() expects parameter 6 to be long, array given in %s on line %d
+bool(false)
+
+--int indexed array--
+
+Warning: gmmktime() expects parameter 6 to be long, array given in %s on line %d
+bool(false)
+
+--associative array--
+
+Warning: gmmktime() expects parameter 6 to be long, array given in %s on line %d
+bool(false)
+
+--nested arrays--
+
+Warning: gmmktime() expects parameter 6 to be long, array given in %s on line %d
+bool(false)
+
+--uppercase NULL--
+int(965722088)
+
+--lowercase null--
+int(965722088)
+
+--lowercase true--
+int(997258088)
+
+--lowercase false--
+int(965722088)
+
+--uppercase TRUE--
+int(997258088)
+
+--uppercase FALSE--
+int(965722088)
+
+--empty string DQ--
+
+Warning: gmmktime() expects parameter 6 to be long, Unicode string given in %s on line %d
+bool(false)
+
+--empty string SQ--
+
+Warning: gmmktime() expects parameter 6 to be long, Unicode string given in %s on line %d
+bool(false)
+
+--string DQ--
+
+Warning: gmmktime() expects parameter 6 to be long, Unicode string given in %s on line %d
+bool(false)
+
+--string SQ--
+
+Warning: gmmktime() expects parameter 6 to be long, Unicode string given in %s on line %d
+bool(false)
+
+--mixed case string--
+
+Warning: gmmktime() expects parameter 6 to be long, Unicode string given in %s on line %d
+bool(false)
+
+--heredoc--
+
+Warning: gmmktime() expects parameter 6 to be long, Unicode string given in %s on line %d
+bool(false)
+
+--instance of classWithToString--
+
+Warning: gmmktime() expects parameter 6 to be long, object given in %s on line %d
+bool(false)
+
+--instance of classWithoutToString--
+
+Warning: gmmktime() expects parameter 6 to be long, object given in %s on line %d
+bool(false)
+
+--undefined var--
+int(965722088)
+
+--unset var--
+int(965722088)
+===DONE===
diff --git a/ext/date/tests/gmmktime_variation7.phpt b/ext/date/tests/gmmktime_variation7.phpt
new file mode 100644 (file)
index 0000000..3d0d25a
--- /dev/null
@@ -0,0 +1,54 @@
+--TEST--
+Test gmmktime() function : usage variation - Checking with few optional arguments.
+--FILE--
+<?php
+/* Prototype  : int gmmktime([int hour [, int min [, int sec [, int mon [, int day [, int year]]]]]])
+ * Description: Get UNIX timestamp for a GMT date 
+ * Source code: ext/date/php_date.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing gmmktime() : usage variation ***\n";
+
+// Initialise all required variables
+$hour = 8;
+$min = 8;
+$sec = 8;
+$mon = 8;
+$day = 8;
+
+echo "\n-- Testing gmmktime() function with one optional argument --\n";
+var_dump( gmmktime($hour) );
+
+echo "\n-- Testing gmmktime() function with two optional argument --\n";
+var_dump( gmmktime($hour, $min) );
+
+echo "\n-- Testing gmmktime() function with three optional argument --\n";
+var_dump( gmmktime($hour, $min, $sec) );
+
+echo "\n-- Testing gmmktime() function with four optional argument --\n";
+var_dump( gmmktime($hour, $min, $sec, $mon) );
+
+echo "\n-- Testing gmmktime() function with five optional argument --\n";
+var_dump( gmmktime($hour, $min, $sec, $mon, $day) );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing gmmktime() : usage variation ***
+
+-- Testing gmmktime() function with one optional argument --
+int(%d)
+
+-- Testing gmmktime() function with two optional argument --
+int(%d)
+
+-- Testing gmmktime() function with three optional argument --
+int(%d)
+
+-- Testing gmmktime() function with four optional argument --
+int(%d)
+
+-- Testing gmmktime() function with five optional argument --
+int(%d)
+===DONE===
diff --git a/ext/date/tests/gmmktime_variation8.phpt b/ext/date/tests/gmmktime_variation8.phpt
new file mode 100644 (file)
index 0000000..b0c56a1
--- /dev/null
@@ -0,0 +1,44 @@
+--TEST--
+Test gmmktime() function : usage variation - Passing octal and hexadecimal values to arguments.
+--FILE--
+<?php
+/* Prototype  : int gmmktime([int hour [, int min [, int sec [, int mon [, int day [, int year]]]]]])
+ * Description: Get UNIX timestamp for a GMT date 
+ * Source code: ext/date/php_date.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing gmmktime() : usage variation ***\n";
+
+// Initialise all required variables
+$hour = 010;
+$min = 010;
+$sec = 010;
+$mon = 010;
+$day = 010;
+$year = 03730;
+
+echo "\n-- Testing gmmktime() function with supplying octal values to arguments --\n";
+var_dump( gmmktime($hour, $min, $sec, $mon, $day, $year) );
+
+// Initialise all required variables
+$hour = 0x8;
+$min = 0x8;
+$sec = 0x8;
+$mon = 0x8;
+$day = 0x8;
+$year = 0x7D8;
+
+echo "\n-- Testing gmmktime() function with supplying hexa decimal values to arguments --\n";
+var_dump( gmmktime($hour, $min, $sec, $mon, $day, $year) );
+?>
+===DONE===
+--EXPECTF--
+*** Testing gmmktime() : usage variation ***
+
+-- Testing gmmktime() function with supplying octal values to arguments --
+int(1218182888)
+
+-- Testing gmmktime() function with supplying hexa decimal values to arguments --
+int(1218182888)
+===DONE===
diff --git a/ext/date/tests/gmmktime_variation9.phpt b/ext/date/tests/gmmktime_variation9.phpt
new file mode 100644 (file)
index 0000000..95f4796
--- /dev/null
@@ -0,0 +1,62 @@
+--TEST--
+Test gmmktime() function : usage variation - Passing positive and negetive float values to arguments.
+--FILE--
+<?php
+/* Prototype  : int gmmktime([int hour [, int min [, int sec [, int mon [, int day [, int year]]]]]])
+ * Description: Get UNIX timestamp for a GMT date 
+ * Source code: ext/date/php_date.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing gmmktime() : usage variation ***\n";
+
+//Initialise variables 
+$hour = 8;
+$min = 8;
+$sec = 8;
+$mon = 8;
+$day = 8;
+$year = 2008;
+
+$inputs = array(
+
+         'float 12.3456789000e10' => 12.3456789000e10,
+      'float -12.3456789000e10' => -12.3456789000e10,
+      'float -10.5' => -10.5,
+);
+
+// loop through each element of the array for min
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+         var_dump( gmmktime($value, $min, $sec, $mon, $day, $year) );
+         var_dump( gmmktime($hour, $value, $sec, $mon, $day, $year) );
+         var_dump( gmmktime($hour, $min, $value, $mon, $day, $year) );
+         var_dump( gmmktime($hour, $min, $sec, $value, $day, $year) );
+         var_dump( gmmktime($hour, $min, $sec, $mon, $value, $value) );
+}        
+?>
+===DONE===
+--EXPECTREGEX--
+\*\*\* Testing gmmktime\(\) : usage variation \*\*\*
+
+--float 12.3456789000e10--
+(bool|int)\((false|444445658554088)\)
+(bool|int)\((false|7408625522408)\)
+(bool|int)\((false|124674971880)\)
+(bool|int)\((false|324659998242749288)\)
+(bool|int)\((false|3906586568967811688)\)
+
+--float -12.3456789000e10--
+(bool|int)\((false|-444443222245912)\)
+(bool|int)\((false|-7406189157592)\)
+int\((-929300768|-122238606120)\)
+(bool|int)\((false|-324659995848460312)\)
+(bool|int)\((false|-3906586693265644312)\)
+
+--float -10.5--
+int\(1218118088\)
+int\(1218181808\)
+int\(1218182870\)
+int\(1170922088\)
+(bool|int)\((false|-62465356312)\)
+===DONE===