--- /dev/null
+--TEST--
+Test clone on DateTime objects
+--FILE--
+<?php
+
+//Set the default time zone
+date_default_timezone_set('Europe/London');
+
+echo "*** Testing clone on DateTime objects ***\n";
+
+// Create a DateTime object..
+$orig = new DateTime('2008-07-02 14:25:41');
+
+// ..create a clone of it ..Clone
+$clone = clone $orig;
+
+// ..and modify original
+$orig->setTime(22, 41, 50);
+
+echo "Original: " . $orig->format("H:i:s") . "\n";
+echo "Clone: " . $clone->format("H:i:s") . "\n";
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing clone on DateTime objects ***
+Original: 22:41:50
+Clone: 14:25:41
+===DONE===
--- /dev/null
+--TEST--
+Test clone of objects whoose class derived from DateTime class
+--FILE--
+<?php
+//Set the default time zone
+date_default_timezone_set("Europe/London");
+
+class DateTimeExt1 extends DateTime {
+ public $property1 = 99;
+ public $property2 = "Hello";
+
+}
+
+class DateTimeExt2 extends DateTimeExt1 {
+ public $property3 = true;
+ public $property4 = 10.5;
+}
+
+echo "*** Testing clone on objects whoose class derived from DateTime class ***\n";
+
+$d1 = new DateTimeExt1("2009-02-03 12:34:41 GMT");
+var_dump($d1);
+$d1_clone = clone $d1;
+var_dump($d1_clone);
+
+$d2 = new DateTimeExt2("2009-02-03 12:34:41 GMT");
+var_dump($d2);
+$d2_clone = clone $d2;
+var_dump($d2_clone);
+?>
+===DONE===
+--EXPECTF--
+*** Testing clone on objects whoose class derived from DateTime class ***
+object(DateTimeExt1)#%d (5) {
+ ["property1"]=>
+ int(99)
+ ["property2"]=>
+ string(5) "Hello"
+ ["date"]=>
+ string(19) "2009-02-03 12:34:41"
+ ["timezone_type"]=>
+ int(2)
+ ["timezone"]=>
+ string(3) "GMT"
+}
+object(DateTimeExt1)#%d (5) {
+ ["property1"]=>
+ int(99)
+ ["property2"]=>
+ string(5) "Hello"
+ ["date"]=>
+ string(19) "2009-02-03 12:34:41"
+ ["timezone_type"]=>
+ int(2)
+ ["timezone"]=>
+ string(3) "GMT"
+}
+object(DateTimeExt2)#%d (7) {
+ ["property3"]=>
+ bool(true)
+ ["property4"]=>
+ float(10.5)
+ ["property1"]=>
+ int(99)
+ ["property2"]=>
+ string(5) "Hello"
+ ["date"]=>
+ string(19) "2009-02-03 12:34:41"
+ ["timezone_type"]=>
+ int(2)
+ ["timezone"]=>
+ string(3) "GMT"
+}
+object(DateTimeExt2)#%d (7) {
+ ["property3"]=>
+ bool(true)
+ ["property4"]=>
+ float(10.5)
+ ["property1"]=>
+ int(99)
+ ["property2"]=>
+ string(5) "Hello"
+ ["date"]=>
+ string(19) "2009-02-03 12:34:41"
+ ["timezone_type"]=>
+ int(2)
+ ["timezone"]=>
+ string(3) "GMT"
+}
+===DONE===
--- /dev/null
+--TEST--
+Test clone of DateTime objects
+--FILE--
+<?php
+//Set the default time zone
+date_default_timezone_set("Europe/London");
+
+echo "*** Testing clone on DateTime objects ***\n";
+
+echo "\n-- Create a DateTime object --\n";
+$d1 = new DateTime("2009-02-03 12:34:41 GMT");
+var_dump($d1);
+echo "\n-- Add some properties --\n";
+$d1->property1 = 99;
+$d1->property2 = "Hello";
+var_dump($d1);
+echo "\n-- clone it --\n";
+$d1_clone = clone $d1;
+var_dump($d1_clone);
+echo "\n-- Add some more properties --\n";
+$d1_clone->property3 = true;
+$d1_clone->property4 = 10.5;
+var_dump($d1_clone);
+echo "\n-- clone it --\n";
+$d2_clone = clone $d1_clone;
+var_dump($d2_clone);
+?>
+===DONE===
+--EXPECTF--
+*** Testing clone on DateTime objects ***
+
+-- Create a DateTime object --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-02-03 12:34:41"
+ ["timezone_type"]=>
+ int(2)
+ ["timezone"]=>
+ string(3) "GMT"
+}
+
+-- Add some properties --
+object(DateTime)#%d (5) {
+ ["date"]=>
+ string(19) "2009-02-03 12:34:41"
+ ["timezone_type"]=>
+ int(2)
+ ["timezone"]=>
+ string(3) "GMT"
+ ["property1"]=>
+ int(99)
+ ["property2"]=>
+ string(5) "Hello"
+}
+
+-- clone it --
+object(DateTime)#%d (5) {
+ ["date"]=>
+ string(19) "2009-02-03 12:34:41"
+ ["timezone_type"]=>
+ int(2)
+ ["timezone"]=>
+ string(3) "GMT"
+ ["property1"]=>
+ int(99)
+ ["property2"]=>
+ string(5) "Hello"
+}
+
+-- Add some more properties --
+object(DateTime)#%d (7) {
+ ["date"]=>
+ string(19) "2009-02-03 12:34:41"
+ ["timezone_type"]=>
+ int(2)
+ ["timezone"]=>
+ string(3) "GMT"
+ ["property1"]=>
+ int(99)
+ ["property2"]=>
+ string(5) "Hello"
+ ["property3"]=>
+ bool(true)
+ ["property4"]=>
+ float(10.5)
+}
+
+-- clone it --
+object(DateTime)#%d (7) {
+ ["date"]=>
+ string(19) "2009-02-03 12:34:41"
+ ["timezone_type"]=>
+ int(2)
+ ["timezone"]=>
+ string(3) "GMT"
+ ["property1"]=>
+ int(99)
+ ["property2"]=>
+ string(5) "Hello"
+ ["property3"]=>
+ bool(true)
+ ["property4"]=>
+ float(10.5)
+}
+===DONE===
--- /dev/null
+--TEST--
+Test clone of DateTime derived objects with __clone magic method
+--FILE--
+<?php
+//Set the default time zone
+date_default_timezone_set("Europe/London");
+
+//Set the default time zone
+date_default_timezone_set("Europe/London");
+
+class DateTimeExt1 extends DateTime {
+ public function __clone() {
+ echo "-- DateTimeExt1 __clone magic method called --\n";
+ }
+}
+
+echo "*** Testing clone of objects derived from DateTime class with __clone magic method***\n";
+
+$d1 = new DateTimeExt1("2009-02-03 12:34:41 GMT");
+$d1_clone = clone $d1;
+
+//verify clone by calling method on new object
+var_dump( $d1_clone->format( "m.d.y") );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing clone of objects derived from DateTime class with __clone magic method***
+-- DateTimeExt1 __clone magic method called --
+string(8) "02.03.09"
+===DONE===
--- /dev/null
+--TEST--
+Test of compare object handler for DateTime objects
+--FILE--
+<?php
+
+echo "Simple test for DateTime compare object handler\n";
+
+//Set the default time zone
+date_default_timezone_set("Europe/London");
+
+class DateTimeExt1 extends DateTime {
+}
+
+class DateTimeExt2 extends DateTime{
+ public $foo = "Hello";
+ private $bar = 99;
+}
+
+class DateTimeExt3 extends DateTimeExt2 {
+}
+
+$obj1 = new DateTime("2009-02-12 12:47:41 GMT");
+$obj2 = new DateTimeExt1("2009-02-12 12:47:41 GMT");
+$obj3 = new DateTimeExt2("2009-02-12 12:47:41 GMT");
+$obj4 = new DateTimeExt3("2009-02-12 12:47:41 GMT");
+
+echo "\n-- All the following tests should compare equal --\n";
+var_dump($obj1 == $obj1);
+var_dump($obj1 == $obj2);
+var_dump($obj1 == $obj3);
+var_dump($obj1 == $obj4);
+var_dump($obj2 == $obj3);
+var_dump($obj2 == $obj4);
+var_dump($obj3 == $obj4);
+
+date_modify($obj1, "+1 day");
+echo "\n-- The following test should still compare equal --\n";
+var_dump($obj1 == $obj1);
+echo "\n-- All the following tests should now compare NOT equal --\n";
+var_dump($obj1 == $obj2);
+var_dump($obj1 == $obj3);
+var_dump($obj1 == $obj4);
+
+echo "\n-- All the following tests should again compare equal --\n";
+date_modify($obj2, "+1 day");
+date_modify($obj3, "+1 day");
+date_modify($obj4, "+1 day");
+var_dump($obj1 == $obj2);
+var_dump($obj1 == $obj3);
+var_dump($obj1 == $obj4);
+?>
+===DONE===
+--EXPECT--
+Simple test for DateTime compare object handler
+
+-- All the following tests should compare equal --
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+
+-- The following test should still compare equal --
+bool(true)
+
+-- All the following tests should now compare NOT equal --
+bool(false)
+bool(false)
+bool(false)
+
+-- All the following tests should again compare equal --
+bool(true)
+bool(true)
+bool(true)
+===DONE===
\ No newline at end of file
--- /dev/null
+--TEST--
+Test new DateTime() : basic functionality
+--FILE--
+<?php
+/* Prototype : DateTime::__construct ([ string $time="now" [, DateTimeZone $timezone=NULL ]] )
+ * Description: Returns new DateTime object
+ * Source code: ext/date/php_date.c
+ * Alias to functions:
+ */
+
+//Set the default time zone
+date_default_timezone_set("Europe/London");
+
+echo "*** Testing new DateTime() : basic functionality ***\n";
+
+var_dump( new DateTime('') );
+
+var_dump( new DateTime("GMT") );
+var_dump( new DateTime("2005-07-14 22:30:41") );
+var_dump( new DateTime("2005-07-14 22:30:41 GMT") );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing new DateTime() : basic functionality ***
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(%d) "%s"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(%d) "%s"
+ ["timezone_type"]=>
+ int(2)
+ ["timezone"]=>
+ string(3) "GMT"
+}
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2005-07-14 22:30:41"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2005-07-14 22:30:41"
+ ["timezone_type"]=>
+ int(2)
+ ["timezone"]=>
+ string(3) "GMT"
+}
+===DONE===
--- /dev/null
+--TEST--
+Test new DateTime() : error conditions
+--FILE--
+<?php
+/* Prototype : DateTime::__construct ([ string $time="now" [, DateTimeZone $timezone=NULL ]] )
+ * Description: Returns new DateTime object
+ * Source code: ext/date/php_date.c
+ * Alias to functions:
+ */
+//Set the default time zone
+date_default_timezone_set("GMT");
+
+echo "*** Testing date_create() : error conditions ***\n";
+
+echo "\n-- Testing new DateTime() with more than expected no. of arguments --\n";
+$time = "GMT";
+$timezone = timezone_open("GMT");
+$extra_arg = 99;
+var_dump( new DateTime($time, $timezone, $extra_arg) );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing date_create() : error conditions ***
+
+-- Testing new DateTime() with more than expected no. of arguments --
+
+Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct() expects at most 2 parameters, 3 given' in %s:%d
+Stack trace:
+#0 %s(%d): DateTime->__construct('GMT', Object(DateTimeZone), 99)
+#1 {main}
+ thrown in %s on line %d
\ No newline at end of file
--- /dev/null
+--TEST--
+Test new DateTime() function : usage variation - Passing unexpected values to first argument $time.
+--FILE--
+<?php
+/* Prototype : DateTime::__construct ([ string $time="now" [, DateTimeZone $timezone=NULL ]] )
+ * Description: Returns new DateTime object
+ * Source code: ext/date/php_date.c
+ * Alias to functions: date_create
+ */
+
+echo "*** Testing new DateTime(): usage variation - unexpected values to first argument \$time***\n";
+
+//Set the default time zone
+date_default_timezone_set("Europe/London");
+
+//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);
+
+// resource
+$file_handle = fopen(__FILE__, 'r');
+
+//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 .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,
+
+ // resource
+ 'resource' => $file_handle
+);
+
+$timezone = new DateTimeZone("Europe/London");
+
+foreach($inputs as $variation =>$time) {
+ echo "\n-- $variation --\n";
+
+ try {
+ var_dump( new DateTime($time) );
+ } catch(Exception $e) {
+ $msg = $e->getMessage();
+ echo "FAILED: " . $msg . "\n";
+ }
+
+ try {
+ var_dump( new DateTime($time, $timezone) );
+ } catch(Exception$e) {
+ $msg = $e->getMessage();
+ echo "FAILED: " . $msg . "\n";
+ }
+};
+
+// closing the resource
+fclose( $file_handle);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing new DateTime(): usage variation - unexpected values to first argument $time***
+
+-- int 0 --
+FAILED: DateTime::__construct(): Failed to parse time string (0) at position 0 (0): Unexpected character
+FAILED: DateTime::__construct(): Failed to parse time string (0) at position 0 (0): Unexpected character
+
+-- int 1 --
+FAILED: DateTime::__construct(): Failed to parse time string (1) at position 0 (1): Unexpected character
+FAILED: DateTime::__construct(): Failed to parse time string (1) at position 0 (1): Unexpected character
+
+-- int 12345 --
+FAILED: DateTime::__construct(): Failed to parse time string (12345) at position 4 (5): Unexpected character
+FAILED: DateTime::__construct(): Failed to parse time string (12345) at position 4 (5): Unexpected character
+
+-- int -12345 --
+FAILED: DateTime::__construct(): Failed to parse time string (-12345) at position 5 (5): Unexpected character
+FAILED: DateTime::__construct(): Failed to parse time string (-12345) at position 5 (5): Unexpected character
+
+-- float 10.5 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "%s"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "%s"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- float -10.5 --
+FAILED: DateTime::__construct(): Failed to parse time string (-10.5) at position 4 (5): Unexpected character
+FAILED: DateTime::__construct(): Failed to parse time string (-10.5) at position 4 (5): Unexpected character
+
+-- float .5 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "%s"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "%s"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- empty array --
+FAILED: DateTime::__construct() expects parameter 1 to be string, array given
+FAILED: DateTime::__construct() expects parameter 1 to be string, array given
+
+-- int indexed array --
+FAILED: DateTime::__construct() expects parameter 1 to be string, array given
+FAILED: DateTime::__construct() expects parameter 1 to be string, array given
+
+-- associative array --
+FAILED: DateTime::__construct() expects parameter 1 to be string, array given
+FAILED: DateTime::__construct() expects parameter 1 to be string, array given
+
+-- nested arrays --
+FAILED: DateTime::__construct() expects parameter 1 to be string, array given
+FAILED: DateTime::__construct() expects parameter 1 to be string, array given
+
+-- uppercase NULL --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "%s"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "%s"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- lowercase null --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "%s"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "%s"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- lowercase true --
+FAILED: DateTime::__construct(): Failed to parse time string (1) at position 0 (1): Unexpected character
+FAILED: DateTime::__construct(): Failed to parse time string (1) at position 0 (1): Unexpected character
+
+-- lowercase false --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "%s"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "%s"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- uppercase TRUE --
+FAILED: DateTime::__construct(): Failed to parse time string (1) at position 0 (1): Unexpected character
+FAILED: DateTime::__construct(): Failed to parse time string (1) at position 0 (1): Unexpected character
+
+-- uppercase FALSE --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "%s"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "%s"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- empty string DQ --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "%s"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "%s"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- empty string SQ --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "%s"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "%s"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- string DQ --
+FAILED: DateTime::__construct(): Failed to parse time string (string) at position 0 (s): The timezone could not be found in the database
+FAILED: DateTime::__construct(): Failed to parse time string (string) at position 0 (s): The timezone could not be found in the database
+
+-- string SQ --
+FAILED: DateTime::__construct(): Failed to parse time string (string) at position 0 (s): The timezone could not be found in the database
+FAILED: DateTime::__construct(): Failed to parse time string (string) at position 0 (s): The timezone could not be found in the database
+
+-- mixed case string --
+FAILED: DateTime::__construct(): Failed to parse time string (sTrInG) at position 0 (s): The timezone could not be found in the database
+FAILED: DateTime::__construct(): Failed to parse time string (sTrInG) at position 0 (s): The timezone could not be found in the database
+
+-- heredoc --
+FAILED: DateTime::__construct(): Failed to parse time string (hello world) at position 0 (h): The timezone could not be found in the database
+FAILED: DateTime::__construct(): Failed to parse time string (hello world) at position 0 (h): The timezone could not be found in the database
+
+-- instance of classWithToString --
+FAILED: DateTime::__construct(): Failed to parse time string (Class A object) at position 0 (C): The timezone could not be found in the database
+FAILED: DateTime::__construct(): Failed to parse time string (Class A object) at position 0 (C): The timezone could not be found in the database
+
+-- instance of classWithoutToString --
+FAILED: DateTime::__construct() expects parameter 1 to be string, object given
+FAILED: DateTime::__construct() expects parameter 1 to be string, object given
+
+-- undefined var --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "%s"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "%s"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- unset var --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "%s"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "%s"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- resource --
+FAILED: DateTime::__construct() expects parameter 1 to be string, resource given
+FAILED: DateTime::__construct() expects parameter 1 to be string, resource given
+===DONE===
--- /dev/null
+--TEST--
+Test new DateTime() function : usage variation - Passing unexpected values to second argument $timezone.
+--FILE--
+<?php
+/* Prototype : DateTime::__construct ([ string $time="now" [, DateTimeZone $timezone=NULL ]] )
+ * Description: Returns new DateTime object
+ * Source code: ext/date/php_date.c
+ * Alias to functions: date_create
+ */
+
+echo "*** Testing new DateTime() : usage variation - unexpected values to second argument \$timezone***\n";
+
+//Set the default time zone
+date_default_timezone_set("Europe/London");
+
+//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);
+
+// resource
+$file_handle = fopen(__FILE__, 'r');
+
+//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 .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,
+
+ // resource
+ 'resource' => $file_handle
+);
+
+$time = "2005-07-14 22:30:41";
+
+foreach($inputs as $variation =>$timezone) {
+ echo "\n-- $variation --\n";
+
+ try {
+ var_dump( new DateTime($time, $timezone) );
+ } catch(Exception $e) {
+ $msg = $e->getMessage();
+ echo "FAILED: " . $msg . "\n";
+ }
+
+};
+
+// closing the resource
+fclose( $file_handle);
+
+?>
+===DONE===
+--EXPECT--
+*** Testing new DateTime() : usage variation - unexpected values to second argument $timezone***
+
+-- int 0 --
+FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, integer given
+
+-- int 1 --
+FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, integer given
+
+-- int 12345 --
+FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, integer given
+
+-- int -12345 --
+FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, integer given
+
+-- float 10.5 --
+FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, double given
+
+-- float -10.5 --
+FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, double given
+
+-- float .5 --
+FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, double given
+
+-- empty array --
+FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, array given
+
+-- int indexed array --
+FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, array given
+
+-- associative array --
+FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, array given
+
+-- nested arrays --
+FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, array given
+
+-- uppercase NULL --
+FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, null given
+
+-- lowercase null --
+FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, null given
+
+-- lowercase true --
+FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, boolean given
+
+-- lowercase false --
+FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, boolean given
+
+-- uppercase TRUE --
+FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, boolean given
+
+-- uppercase FALSE --
+FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, boolean given
+
+-- empty string DQ --
+FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, string given
+
+-- empty string SQ --
+FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, string given
+
+-- string DQ --
+FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, string given
+
+-- string SQ --
+FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, string given
+
+-- mixed case string --
+FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, string given
+
+-- heredoc --
+FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, string given
+
+-- instance of classWithToString --
+FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, object given
+
+-- instance of classWithoutToString --
+FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, object given
+
+-- undefined var --
+FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, null given
+
+-- unset var --
+FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, null given
+
+-- resource --
+FAILED: DateTime::__construct() expects parameter 2 to be DateTimeZone, resource given
+===DONE===
+
--- /dev/null
+--TEST--
+Test DateTime class inheritance
+--FILE--
+<?php
+
+//Set the default time zone
+date_default_timezone_set("Europe/London");
+
+echo "*** Testing basic DateTime inheritance() ***\n";
+
+
+class DateTimeExt extends DateTime
+{
+ public static $format = "F j, Y, g:i:s a";
+
+ public function __toString()
+ {
+ return parent::format(self::$format);
+ }
+}
+
+echo "\n-- Create an instance of DateTimeExt --\n";
+$d = new DateTimeExt("1967-05-01 22:30:41");
+
+echo "\n-- Invoke __toString --\n";
+echo $d . "\n";
+
+echo "\n -- modify date and time --\n";
+$d->setDate(1963, 7, 2);
+$d->setTime(10, 45, 30);
+
+echo "\n-- Invoke __toString again --\n";
+echo $d . "\n";
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing basic DateTime inheritance() ***
+
+-- Create an instance of DateTimeExt --
+
+-- Invoke __toString --
+May 1, 1967, 10:30:41 pm
+
+ -- modify date and time --
+
+-- Invoke __toString again --
+July 2, 1963, 10:45:30 am
+===DONE===
--- /dev/null
+--TEST--
+Test DateTime class inheritance : with user space __construct magic method
+--FILE--
+<?php
+
+//Set the default time zone
+date_default_timezone_set("Europe/London");
+
+echo "*** Testing new DateTime() : with user space __construct magic method ***\n";
+
+class DateTimeExt extends DateTime
+{
+ public function __construct ($date = null, DateTimeZone $dtz = null)
+ {
+ if($dtz === null)
+ {
+ $dtz = new DateTimeZone(date_default_timezone_get());
+ }
+ parent::__construct($date, $dtz);
+ }
+}
+
+$d = new DateTimeExt("1967-05-01 22:30:41");
+echo $d->format("F j, Y, g:i:s a") . "\n";
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing new DateTime() : with user space __construct magic method ***
+May 1, 1967, 10:30:41 pm
+===DONE===
\ No newline at end of file
--- /dev/null
+--TEST--
+Test DateTime class inheritance : with user space fromat() method
+--FILE--
+<?php
+//Set the default time zone
+date_default_timezone_set("Europe/London");
+
+echo "*** Testing new DateTime() : with user format() method ***\n";
+
+class DateTimeExt extends DateTime
+{
+ public function format($format = "F j, Y, g:i:s a")
+ {
+ return parent::format($format);
+ }
+}
+
+$d = new DateTimeExt("1967-05-01 22:30:41");
+echo $d->format() . "\n";
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing new DateTime() : with user format() method ***
+May 1, 1967, 10:30:41 pm
+===DONE===
--- /dev/null
+--TEST--
+Test DateTime::format() function : basic functionality
+--FILE--
+<?php
+/* Prototype : public string DateTime::format ( string $format )
+ * Description: Returns date formatted according to given format
+ * Source code: ext/date/php_date.c
+ * Alias to functions: date_format
+ */
+
+//Set the default time zone
+date_default_timezone_set("Europe/London");
+
+echo "*** Testing DateTime::format() : basic functionality ***\n";
+$date = new DateTime("2005-07-14 22:30:41");
+
+var_dump( $date->format( "F j, Y, g:i a") );
+var_dump( $date->format( "m.d.y") );
+var_dump( $date->format( "j, n, Y") );
+var_dump( $date->format( "Ymd") );
+var_dump( $date->format( 'h-i-s, j-m-y, it is w Day') );
+var_dump( $date->format( '\i\t \i\s \t\h\e jS \d\a\y.') );
+var_dump( $date->format( "D M j G:i:s T Y") );
+var_dump( $date->format( 'H:m:s \m \i\s\ \m\o\n\t\h') );
+var_dump( $date->format( "H:i:s") );
+
+?>
+===DONE===
+--EXPECT--
+*** Testing DateTime::format() : basic functionality ***
+string(23) "July 14, 2005, 10:30 pm"
+string(8) "07.14.05"
+string(11) "14, 7, 2005"
+string(8) "20050714"
+string(39) "10-30-41, 14-07-05, 3031 3041 4 Thupm05"
+string(19) "it is the 14th day."
+string(28) "Thu Jul 14 22:30:41 BST 2005"
+string(19) "22:07:41 m is month"
+string(8) "22:30:41"
+===DONE===
\ No newline at end of file
--- /dev/null
+--TEST--
+Test date_format() function : basic functionality
+--FILE--
+<?php
+/* Prototype : public string DateTime::format ( string $format )
+ * Description: Returns date formatted according to given format
+ * Source code: ext/date/php_date.c
+ * Alias to functions: date_format
+ */
+
+//Set the default time zone
+date_default_timezone_set("Europe/London");
+
+echo "*** Testing date_format() : basic functionality - formatting coinstants ***\n";
+$date = new DateTime("2005-07-14 22:30:41");
+
+var_dump( $date->format( DateTime::ATOM) ) ;
+var_dump( $date->format( DateTime::COOKIE) ) ;
+var_dump( $date->format( DateTime::ISO8601) ) ;
+var_dump( $date->format( DateTime::RFC822) ) ;
+var_dump( $date->format( DateTime::RFC850) ) ;
+var_dump( $date->format( DateTime::RFC1036) ) ;
+var_dump( $date->format( DateTime::RFC1123) ) ;
+var_dump( $date->format( DateTime:: RFC2822) ) ;
+var_dump( $date->format( DateTime::RFC3339) ) ;
+var_dump( $date->format( DateTime::RSS) ) ;
+var_dump( $date->format( DateTime::W3C) ) ;
+
+?>
+===DONE===
+--EXPECT--
+*** Testing date_format() : basic functionality - formatting coinstants ***
+string(25) "2005-07-14T22:30:41+01:00"
+string(32) "Thursday, 14-Jul-05 22:30:41 BST"
+string(24) "2005-07-14T22:30:41+0100"
+string(29) "Thu, 14 Jul 05 22:30:41 +0100"
+string(32) "Thursday, 14-Jul-05 22:30:41 BST"
+string(29) "Thu, 14 Jul 05 22:30:41 +0100"
+string(31) "Thu, 14 Jul 2005 22:30:41 +0100"
+string(31) "Thu, 14 Jul 2005 22:30:41 +0100"
+string(25) "2005-07-14T22:30:41+01:00"
+string(31) "Thu, 14 Jul 2005 22:30:41 +0100"
+string(25) "2005-07-14T22:30:41+01:00"
+===DONE===
--- /dev/null
+--TEST--
+Test DateTime::format() function : error conditions
+--FILE--
+<?php
+/* Prototype : public string DateTime::format ( string $format )
+ * Description: Returns date formatted according to given format
+ * Source code: ext/date/php_date.c
+ * Alias to functions: date_format
+ */
+
+//Set the default time zone
+date_default_timezone_set("Europe/London");
+
+// Craete a date object
+$date = new DateTime("2005-07-14 22:30:41");
+
+echo "*** Testing DateTime::format() : error conditions ***\n";
+
+echo "\n-- Testing date_date_formatcreate() function with zero arguments --\n";
+var_dump( $date->format() );
+
+echo "\n-- Testing date_date_formatcreate() function with more than expected no. of arguments --\n";
+$format = "F j, Y, g:i a";
+$extra_arg = 10;
+var_dump( $date->format($format, $extra_arg) );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing DateTime::format() : error conditions ***
+
+-- Testing date_date_formatcreate() function with zero arguments --
+
+Warning: DateTime::format() expects exactly 1 parameter, 0 given in %s on line %d
+bool(false)
+
+-- Testing date_date_formatcreate() function with more than expected no. of arguments --
+
+Warning: DateTime::format() expects exactly 1 parameter, 2 given in %s on line %d
+bool(false)
+===DONE===
--- /dev/null
+--TEST--
+Test DateTime::format() function : usage variation - Passing unexpected values to first argument $format.
+--FILE--
+<?php
+/* Prototype : public string DateTime::format ( string $format )
+ * Description: Returns date formatted according to given format
+ * Source code: ext/date/php_date.c
+ * Alias to functions: date_format
+ */
+
+echo "*** Testing DateTime::format() : usage variation - unexpected values to first argument \$format***\n";
+
+//Set the default time zone
+date_default_timezone_set("Europe/London");
+
+//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);
+
+// resource
+$file_handle = fopen(__FILE__, 'r');
+
+//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 .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,
+
+ // resource
+ 'resource' => $file_handle
+);
+
+$object = new DateTime("2005-07-14 22:30:41");
+
+foreach($inputs as $variation =>$format) {
+ echo "\n-- $variation --\n";
+ var_dump( $object->format($format) );
+};
+
+// closing the resource
+fclose( $file_handle );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing DateTime::format() : usage variation - unexpected values to first argument $format***
+
+-- int 0 --
+string(1) "0"
+
+-- int 1 --
+string(1) "1"
+
+-- int 12345 --
+string(5) "12345"
+
+-- int -12345 --
+string(6) "-12345"
+
+-- float 10.5 --
+string(4) "10.5"
+
+-- float -10.5 --
+string(5) "-10.5"
+
+-- float .5 --
+string(3) "0.5"
+
+-- empty array --
+
+Warning: DateTime::format() expects parameter 1 to be string, array given in %s on line %d
+bool(false)
+
+-- int indexed array --
+
+Warning: DateTime::format() expects parameter 1 to be string, array given in %s on line %d
+bool(false)
+
+-- associative array --
+
+Warning: DateTime::format() expects parameter 1 to be string, array given in %s on line %d
+bool(false)
+
+-- nested arrays --
+
+Warning: DateTime::format() expects parameter 1 to be string, array given in %s on line %d
+bool(false)
+
+-- uppercase NULL --
+string(0) ""
+
+-- lowercase null --
+string(0) ""
+
+-- lowercase true --
+string(1) "1"
+
+-- lowercase false --
+string(0) ""
+
+-- uppercase TRUE --
+string(1) "1"
+
+-- uppercase FALSE --
+string(0) ""
+
+-- empty string DQ --
+string(0) ""
+
+-- empty string SQ --
+string(0) ""
+
+-- string DQ --
+string(40) "4131Thu, 14 Jul 2005 22:30:41 +010030710"
+
+-- string SQ --
+string(40) "4131Thu, 14 Jul 2005 22:30:41 +010030710"
+
+-- mixed case string --
+string(40) "41BSTThu, 14 Jul 2005 22:30:41 +01001722"
+
+-- heredoc --
+string(82) "10Europe/LondonThursdayThursday2005 42005Thu, 14 Jul 2005 22:30:41 +0100Thursday14"
+
+-- instance of classWithToString --
+string(66) "CThursdaypm4141 PM 2005b14Europe/London2005-07-14T22:30:41+01:0031"
+
+-- instance of classWithoutToString --
+
+Warning: DateTime::format() expects parameter 1 to be string, object given in %s on line %d
+bool(false)
+
+-- undefined var --
+string(0) ""
+
+-- unset var --
+string(0) ""
+
+-- resource --
+
+Warning: DateTime::format() expects parameter 1 to be string, resource given in %s on line %d
+bool(false)
+===DONE===
--- /dev/null
+--TEST--
+Test DateTime::getOffset() function : basic functionality
+--FILE--
+<?php
+/* Prototype : public int DateTime::getOffset ( void )
+ * Description: Returns the daylight saving time offset
+ * Source code: ext/date/php_date.c
+ * Alias to functions: date_offset_get
+ */
+
+//Set the default time zone
+date_default_timezone_set('Europe/London');
+
+echo "*** Testing DateTime::getOffset() : basic functionality ***\n";
+
+$winter = new DateTime('2008-12-25 14:25:41');
+$summer = new DateTime('2008-07-02 14:25:41');
+
+echo "Winter offset: " . $winter->getOffset() / 3600 . " hours\n";
+echo "Summer offset: " . $summer->getOffset() / 3600 . " hours\n";
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing DateTime::getOffset() : basic functionality ***
+Winter offset: 0 hours
+Summer offset: 1 hours
+===DONE===
--- /dev/null
+--TEST--
+Test DateTime::getOffset() function : error conditions
+--FILE--
+<?php
+
+/* Prototype : public int DateTime::getOffset ( void )
+ * Description: Returns the daylight saving time offset
+ * Source code: ext/date/php_date.c
+ * Alias to functions: date_offset_get
+ */
+
+ //Set the default time zone
+date_default_timezone_set("Europe/London");
+
+echo "*** Testing DateTime::getOffset() : error conditions ***\n";
+
+echo "\n-- Testing DateTime::getOffset() function with more than expected no. of arguments --\n";
+$datetime = new DateTime("2009-01-30 19:34:10");
+$extra_arg = 30;
+
+var_dump( $datetime->getOffset($extra_arg) );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing DateTime::getOffset() : error conditions ***
+
+-- Testing DateTime::getOffset() function with more than expected no. of arguments --
+
+Warning: DateTime::getOffset() expects exactly 0 parameters, 1 given in %s on line %d
+bool(false)
+===DONE===
+
--- /dev/null
+--TEST--
+Test DateTime::getTimezone() function : basic functionality
+--FILE--
+<?php
+/* Prototype : public DateTimeZone DateTime::getTimezone ( void )
+ * Description: Return time zone relative to given DateTime
+ * Source code: ext/date/php_date.c
+ * Alias to functions: date_timezone_get
+ */
+
+echo "*** Testing DateTime::getTimezone() : basic functionality ***\n";
+
+date_default_timezone_set("Europe/London");
+$object = new DateTime("2009-01-30 17:57:32");
+var_dump( $object->getTimeZone()->getName() );
+
+
+date_default_timezone_set("America/New_York");
+$object = new DateTime("2009-01-30 17:57:32");
+var_dump( $object->getTimeZone()->getName() );
+
+$la_time = new DateTimeZone("America/Los_Angeles");
+$object->setTimeZone($la_time);
+var_dump( $object->getTimeZone()->getName() );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing DateTime::getTimezone() : basic functionality ***
+string(13) "Europe/London"
+string(16) "America/New_York"
+string(19) "America/Los_Angeles"
+===DONE===
--- /dev/null
+--TEST--
+Test DateTime::modify() function : basic functionality
+--FILE--
+<?php
+/* Prototype : public DateTime DateTime::modify ( string $modify )
+ * Description: Alter the timestamp of a DateTime object by incrementing or decrementing in a format accepted by strtotime().
+ * Source code: ext/date/php_date.c
+ * Alias to functions: public date_modify()
+ */
+
+ //Set the default time zone
+date_default_timezone_set("Europe/London");
+
+echo "*** Testing DateTime::modify() : basic functionality ***\n";
+
+// Create a date object to modify
+$datetime = new DateTime("2009-01-31 14:28:41");
+
+$datetime->modify("+1 day");
+echo "After modification 1: " . $datetime->format("D, d M Y") . "\n";
+
+$datetime->modify("+1 week 2 days 4 hours 2 seconds");
+echo "After modification 2: " . $datetime->format("D, d M Y H:i:s") . "\n";
+
+$datetime->modify("next Thursday");
+echo "After modification 3: " . $datetime->format("D, d M Y") . "\n";
+
+$datetime->modify("last Sunday");
+echo "After modification 4: " . $datetime->format("D, d M Y") . "\n";
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing DateTime::modify() : basic functionality ***
+After modification 1: Sun, 01 Feb 2009
+After modification 2: Tue, 10 Feb 2009 18:28:43
+After modification 3: Thu, 12 Feb 2009
+After modification 4: Sun, 08 Feb 2009
+===DONE===
--- /dev/null
+--TEST--
+Test DateTime::modify() function : error conditions
+--FILE--
+<?php
+/* Prototype : public DateTime DateTime::modify ( string $modify )
+ * Description: Alter the timestamp of a DateTime object by incrementing or decrementing in a format accepted by strtotime().
+ * Source code: ext/date/php_date.c
+ * Alias to functions: public date_modify()
+ */
+
+//Set the default time zone
+date_default_timezone_set("Europe/London");
+
+echo "*** Testing DateTime::modify() : error conditions ***\n";
+
+// Create a date object
+$object = new DateTime("2009-01-30 19:34:10");
+
+echo "\n-- Testing DateTime::modify() function with less than expected no. of arguments --\n";
+var_dump( $object->modify() );
+
+echo "\n-- Testing DateTime::modify() function with more than expected no. of arguments --\n";
+$modify = "+1 day";
+$extra_arg = 99;
+var_dump( $object->modify($modify, $extra_arg) );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing DateTime::modify() : error conditions ***
+
+-- Testing DateTime::modify() function with less than expected no. of arguments --
+
+Warning: DateTime::modify() expects exactly 1 parameter, 0 given in %s on line %d
+bool(false)
+
+-- Testing DateTime::modify() function with more than expected no. of arguments --
+
+Warning: DateTime::modify() expects exactly 1 parameter, 2 given in %s on line %d
+bool(false)
+===DONE===
+
--- /dev/null
+--TEST--
+Test DateTime::modify() function : usage variation - Passing unexpected values to first argument $modify.
+--FILE--
+<?php
+/* Prototype : public DateTime DateTime::modify ( string $modify )
+ * Description: Alter the timestamp of a DateTime object by incrementing or decrementing in a format accepted by strtotime().
+ * Source code: ext/date/php_date.c
+ * Alias to functions: public date_modify()
+ */
+
+echo "*** Testing DateTime::modify() : usage variation - unexpected values to first argument \$modify***\n";
+
+//Set the default time zone
+date_default_timezone_set("Europe/London");
+
+//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);
+
+// resource
+$file_handle = fopen(__FILE__, 'r');
+
+//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 .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,
+
+ // resource
+ 'resource' => $file_handle
+);
+
+$object = new DateTime("2009-01-31 14:28:41");
+
+foreach($inputs as $variation =>$format) {
+ echo "\n-- $variation --\n";
+ var_dump( $object->modify($format) );
+};
+
+// closing the resource
+fclose( $file_handle );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing DateTime::modify() : usage variation - unexpected values to first argument $modify***
+
+-- int 0 --
+object(DateTime)#3 (3) {
+ ["date"]=>
+ string(19) "2009-01-31 14:28:41"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- int 1 --
+object(DateTime)#3 (3) {
+ ["date"]=>
+ string(19) "2009-01-31 14:28:41"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- int 12345 --
+object(DateTime)#3 (3) {
+ ["date"]=>
+ string(19) "2009-01-31 14:28:41"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- int -12345 --
+object(DateTime)#3 (3) {
+ ["date"]=>
+ string(19) "2009-01-31 14:28:41"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- float 10.5 --
+object(DateTime)#3 (3) {
+ ["date"]=>
+ string(19) "2009-01-31 14:28:41"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- float -10.5 --
+object(DateTime)#3 (3) {
+ ["date"]=>
+ string(19) "2009-01-31 14:28:41"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- float .5 --
+object(DateTime)#3 (3) {
+ ["date"]=>
+ string(19) "2009-01-31 14:28:41"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- empty array --
+
+Warning: DateTime::modify() expects parameter 1 to be string, array given in %s on line %d
+bool(false)
+
+-- int indexed array --
+
+Warning: DateTime::modify() expects parameter 1 to be string, array given in %s on line %d
+bool(false)
+
+-- associative array --
+
+Warning: DateTime::modify() expects parameter 1 to be string, array given in %s on line %d
+bool(false)
+
+-- nested arrays --
+
+Warning: DateTime::modify() expects parameter 1 to be string, array given in %s on line %d
+bool(false)
+
+-- uppercase NULL --
+object(DateTime)#3 (3) {
+ ["date"]=>
+ string(19) "2009-01-31 14:28:41"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- lowercase null --
+object(DateTime)#3 (3) {
+ ["date"]=>
+ string(19) "2009-01-31 14:28:41"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- lowercase true --
+object(DateTime)#3 (3) {
+ ["date"]=>
+ string(19) "2009-01-31 14:28:41"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- lowercase false --
+object(DateTime)#3 (3) {
+ ["date"]=>
+ string(19) "2009-01-31 14:28:41"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- uppercase TRUE --
+object(DateTime)#3 (3) {
+ ["date"]=>
+ string(19) "2009-01-31 14:28:41"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- uppercase FALSE --
+object(DateTime)#3 (3) {
+ ["date"]=>
+ string(19) "2009-01-31 14:28:41"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- empty string DQ --
+object(DateTime)#3 (3) {
+ ["date"]=>
+ string(19) "2009-01-31 14:28:41"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- empty string SQ --
+object(DateTime)#3 (3) {
+ ["date"]=>
+ string(19) "2009-01-31 14:28:41"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- string DQ --
+object(DateTime)#3 (3) {
+ ["date"]=>
+ string(19) "2009-01-31 14:28:41"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- string SQ --
+object(DateTime)#3 (3) {
+ ["date"]=>
+ string(19) "2009-01-31 14:28:41"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- mixed case string --
+object(DateTime)#3 (3) {
+ ["date"]=>
+ string(19) "2009-01-31 14:28:41"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- heredoc --
+object(DateTime)#3 (3) {
+ ["date"]=>
+ string(19) "2009-01-31 14:28:41"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- instance of classWithToString --
+object(DateTime)#3 (3) {
+ ["date"]=>
+ string(19) "2009-01-31 14:28:41"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- instance of classWithoutToString --
+
+Warning: DateTime::modify() expects parameter 1 to be string, object given in %s on line %d
+bool(false)
+
+-- undefined var --
+object(DateTime)#3 (3) {
+ ["date"]=>
+ string(19) "2009-01-31 14:28:41"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- unset var --
+object(DateTime)#3 (3) {
+ ["date"]=>
+ string(19) "2009-01-31 14:28:41"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- resource --
+
+Warning: DateTime::modify() expects parameter 1 to be string, resource given in %s on line %d
+bool(false)
+===DONE===
--- /dev/null
+--TEST--
+Test serialization of DateTime objects
+--FILE--
+<?php
+//Set the default time zone
+date_default_timezone_set("Europe/London");
+
+$date1 = new DateTime("2005-07-14 22:30:41");
+var_dump($date1);
+$serialized = serialize($date1);
+var_dump($serialized);
+
+$date2 = unserialize($serialized);
+var_dump($date2);
+// Try to use unserialzied object
+var_dump( $date2->format( "F j, Y, g:i a") );
+
+?>
+===DONE===
+--EXPECTF--
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2005-07-14 22:30:41"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+string(118) "O:8:"DateTime":3:{s:4:"date";s:19:"2005-07-14 22:30:41";s:13:"timezone_type";i:3;s:8:"timezone";s:13:"Europe/London";}"
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2005-07-14 22:30:41"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+string(23) "July 14, 2005, 10:30 pm"
+===DONE===
\ No newline at end of file
--- /dev/null
+--TEST--
+Test DateTime::setDate() function : basic functionality
+--FILE--
+<?php
+/* Prototype : public DateTime DateTime::setDate ( int $year , int $month , int $day )
+ * Description: Resets the current date of the DateTime object to a different date.
+ * Source code: ext/date/php_date.c
+ * Alias to functions: date_date_set()
+ */
+
+ //Set the default time zone
+date_default_timezone_set("Europe/London");
+
+echo "*** Testing DateTime::setDate() : basic functionality ***\n";
+
+$datetime = new DateTime("2009-01-30 19:34:10");
+
+echo $datetime->format(DATE_RFC2822) . "\n";
+
+$datetime->setDate(2008, 02, 01);
+
+echo $datetime->format(DATE_RFC2822) . "\n";
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing DateTime::setDate() : basic functionality ***
+Fri, 30 Jan 2009 19:34:10 +0000
+Fri, 01 Feb 2008 19:34:10 +0000
+===DONE===
\ No newline at end of file
--- /dev/null
+--TEST--
+Test DateTime::setDate() function : error conditions
+--FILE--
+<?php
+/* Prototype : public DateTime DateTime::setDate ( int $year , int $month , int $day )
+ * Description: Resets the current date of the DateTime object to a different date.
+ * Source code: ext/date/php_date.c
+ * Alias to functions: date_date_set()
+ */
+
+date_default_timezone_set("Europe/London");
+
+echo "*** Testing DateTime::setDate() : error conditions ***\n";
+
+$datetime = new DateTime("2009-01-30 19:34:10");
+
+echo "\n-- Testing DateTime::setDate() function with zero arguments --\n";
+var_dump( $datetime->setDate() );
+
+echo "\n-- Testing DateTime::setDate() function with less than expected no. of arguments --\n";
+$year = 2009;
+$month = 1;
+$day = 30;
+var_dump( $datetime->setDate($year) );
+var_dump( $datetime->setDate($year, $month) );
+
+echo "\n-- Testing DateTime::setDate() function with more than expected no. of arguments --\n";
+$extra_arg = 10;
+var_dump( $datetime->setDate($year, $month, $day, $extra_arg) );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing DateTime::setDate() : error conditions ***
+
+-- Testing DateTime::setDate() function with zero arguments --
+
+Warning: DateTime::setDate() expects exactly 3 parameters, 0 given in %s on line %d
+bool(false)
+
+-- Testing DateTime::setDate() function with less than expected no. of arguments --
+
+Warning: DateTime::setDate() expects exactly 3 parameters, 1 given in %s on line %d
+bool(false)
+
+Warning: DateTime::setDate() expects exactly 3 parameters, 2 given in %s on line %d
+bool(false)
+
+-- Testing DateTime::setDate() function with more than expected no. of arguments --
+
+Warning: DateTime::setDate() expects exactly 3 parameters, 4 given in %s on line %d
+bool(false)
+===DONE===
--- /dev/null
+--TEST--
+Test DateTime::setDate() function : usage variation - Passing unexpected values to first argument $year.
+--FILE--
+<?php
+/* Prototype : public DateTime DateTime::setDate ( int $year , int $month , int $day )
+ * Description: Resets the current date of the DateTime object to a different date.
+ * Source code: ext/date/php_date.c
+ * Alias to functions: date_date_set
+ */
+
+echo "*** Testing DateTime::setDate() : usage variation - unexpected values to first argument \$year***\n";
+
+//Set the default time zone
+date_default_timezone_set("Europe/London");
+
+//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);
+
+// resource
+$file_handle = fopen(__FILE__, 'r');
+
+//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 .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,
+
+ // resource
+ 'resource' => $file_handle
+);
+
+$object = new DateTime("2009-02-27 08:34:10");
+$day = 2;
+$month = 7;
+
+foreach($inputs as $variation =>$year) {
+ echo "\n-- $variation --\n";
+ var_dump( $object->setDate($year, $month, $day) );
+};
+
+// closing the resource
+fclose( $file_handle );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing DateTime::setDate() : usage variation - unexpected values to first argument $year***
+
+-- int 0 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "0000-07-02 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- int 1 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "0001-07-02 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- int 12345 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(20) "12345-07-02 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- int -12345 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(21) "-12345-07-02 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- float 10.5 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "0010-07-02 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- float -10.5 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(20) "-0010-07-02 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- float .5 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "0000-07-02 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- empty array --
+
+Warning: DateTime::setDate() expects parameter 1 to be long, array given in %s on line %d
+bool(false)
+
+-- int indexed array --
+
+Warning: DateTime::setDate() expects parameter 1 to be long, array given in %s on line %d
+bool(false)
+
+-- associative array --
+
+Warning: DateTime::setDate() expects parameter 1 to be long, array given in %s on line %d
+bool(false)
+
+-- nested arrays --
+
+Warning: DateTime::setDate() expects parameter 1 to be long, array given in %s on line %d
+bool(false)
+
+-- uppercase NULL --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "0000-07-02 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- lowercase null --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "0000-07-02 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- lowercase true --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "0001-07-02 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- lowercase false --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "0000-07-02 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- uppercase TRUE --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "0001-07-02 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- uppercase FALSE --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "0000-07-02 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- empty string DQ --
+
+Warning: DateTime::setDate() expects parameter 1 to be long, string given in %s on line %d
+bool(false)
+
+-- empty string SQ --
+
+Warning: DateTime::setDate() expects parameter 1 to be long, string given in %s on line %d
+bool(false)
+
+-- string DQ --
+
+Warning: DateTime::setDate() expects parameter 1 to be long, string given in %s on line %d
+bool(false)
+
+-- string SQ --
+
+Warning: DateTime::setDate() expects parameter 1 to be long, string given in %s on line %d
+bool(false)
+
+-- mixed case string --
+
+Warning: DateTime::setDate() expects parameter 1 to be long, string given in %s on line %d
+bool(false)
+
+-- heredoc --
+
+Warning: DateTime::setDate() expects parameter 1 to be long, string given in %s on line %d
+bool(false)
+
+-- instance of classWithToString --
+
+Warning: DateTime::setDate() expects parameter 1 to be long, object given in %s on line %d
+bool(false)
+
+-- instance of classWithoutToString --
+
+Warning: DateTime::setDate() expects parameter 1 to be long, object given in %s on line %d
+bool(false)
+
+-- undefined var --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "0000-07-02 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- unset var --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "0000-07-02 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- resource --
+
+Warning: DateTime::setDate() expects parameter 1 to be long, resource given in %s on line %d
+bool(false)
+===DONE===
\ No newline at end of file
--- /dev/null
+--TEST--
+Test DateTime::setDate() function : usage variation - Passing unexpected values to second argument $month.
+--FILE--
+<?php
+/* Prototype : public DateTime DateTime::setDate ( int $year , int $month , int $day )
+ * Description: Resets the current date of the DateTime object to a different date.
+ * Source code: ext/date/php_date.c
+ * Alias to functions: date_date_set
+ */
+
+echo "*** Testing DateTime::setDate() : usage variation - unexpected values to second argument \$month***\n";
+
+//Set the default time zone
+date_default_timezone_set("Europe/London");
+
+//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);
+
+// resource
+$file_handle = fopen(__FILE__, 'r');
+
+//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 .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,
+
+ // resource
+ 'resource' => $file_handle
+);
+
+$object = new DateTime("2009-02-27 08:34:10");
+$day = 2;
+$year = 1963;
+
+foreach($inputs as $variation =>$month) {
+ echo "\n-- $variation --\n";
+ var_dump( $object->setDate($year, $month, $day) );
+};
+
+// closing the resource
+fclose( $file_handle );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing DateTime::setDate() : usage variation - unexpected values to second argument $month***
+
+-- int 0 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1962-12-02 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- int 1 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1963-01-02 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- int 12345 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2991-09-02 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- int -12345 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "0934-03-02 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- float 10.5 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1963-10-02 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- float -10.5 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1962-02-02 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- float .5 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1962-12-02 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- empty array --
+
+Warning: DateTime::setDate() expects parameter 2 to be long, array given in %s on line %d
+bool(false)
+
+-- int indexed array --
+
+Warning: DateTime::setDate() expects parameter 2 to be long, array given in %s on line %d
+bool(false)
+
+-- associative array --
+
+Warning: DateTime::setDate() expects parameter 2 to be long, array given in %s on line %d
+bool(false)
+
+-- nested arrays --
+
+Warning: DateTime::setDate() expects parameter 2 to be long, array given in %s on line %d
+bool(false)
+
+-- uppercase NULL --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1962-12-02 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- lowercase null --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1962-12-02 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- lowercase true --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1963-01-02 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- lowercase false --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1962-12-02 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- uppercase TRUE --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1963-01-02 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- uppercase FALSE --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1962-12-02 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- empty string DQ --
+
+Warning: DateTime::setDate() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+
+-- empty string SQ --
+
+Warning: DateTime::setDate() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+
+-- string DQ --
+
+Warning: DateTime::setDate() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+
+-- string SQ --
+
+Warning: DateTime::setDate() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+
+-- mixed case string --
+
+Warning: DateTime::setDate() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+
+-- heredoc --
+
+Warning: DateTime::setDate() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+
+-- instance of classWithToString --
+
+Warning: DateTime::setDate() expects parameter 2 to be long, object given in %s on line %d
+bool(false)
+
+-- instance of classWithoutToString --
+
+Warning: DateTime::setDate() expects parameter 2 to be long, object given in %s on line %d
+bool(false)
+
+-- undefined var --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1962-12-02 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- unset var --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1962-12-02 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- resource --
+
+Warning: DateTime::setDate() expects parameter 2 to be long, resource given in %s on line %d
+bool(false)
+===DONE===
--- /dev/null
+--TEST--
+Test DateTime::setDate() function : usage variation - Passing unexpected values to third argument $day.
+--FILE--
+<?php
+/* Prototype : public DateTime DateTime::setDate ( int $year , int $month , int $day )
+ * Description: Resets the current date of the DateTime object to a different date.
+ * Source code: ext/date/php_date.c
+ * Alias to functions: date_date_set
+ */
+
+echo "*** Testing DateTime::setDate() : usage variation - unexpected values to third argument \$day***\n";
+
+//Set the default time zone
+date_default_timezone_set("Europe/London");
+
+//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);
+
+// resource
+$file_handle = fopen(__FILE__, 'r');
+
+//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 .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,
+
+ // resource
+ 'resource' => $file_handle
+);
+
+$object = new DateTime("2009-02-27 08:34:10");
+$month = 7;
+$year = 1963;
+
+foreach($inputs as $variation =>$day) {
+ echo "\n-- $variation --\n";
+ var_dump( $object->setDate($year, $month, $day) );
+};
+
+// closing the resource
+fclose( $file_handle );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing DateTime::setDate() : usage variation - unexpected values to third argument $day***
+
+-- int 0 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1963-06-30 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- int 1 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1963-07-01 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- int 12345 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1997-04-17 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- int -12345 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1929-09-11 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- float 10.5 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1963-07-10 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- float -10.5 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1963-06-20 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- float .5 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1963-06-30 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- empty array --
+
+Warning: DateTime::setDate() expects parameter 3 to be long, array given in %s on line %d
+bool(false)
+
+-- int indexed array --
+
+Warning: DateTime::setDate() expects parameter 3 to be long, array given in %s on line %d
+bool(false)
+
+-- associative array --
+
+Warning: DateTime::setDate() expects parameter 3 to be long, array given in %s on line %d
+bool(false)
+
+-- nested arrays --
+
+Warning: DateTime::setDate() expects parameter 3 to be long, array given in %s on line %d
+bool(false)
+
+-- uppercase NULL --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1963-06-30 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- lowercase null --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1963-06-30 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- lowercase true --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1963-07-01 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- lowercase false --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1963-06-30 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- uppercase TRUE --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1963-07-01 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- uppercase FALSE --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1963-06-30 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- empty string DQ --
+
+Warning: DateTime::setDate() expects parameter 3 to be long, string given in %s on line %d
+bool(false)
+
+-- empty string SQ --
+
+Warning: DateTime::setDate() expects parameter 3 to be long, string given in %s on line %d
+bool(false)
+
+-- string DQ --
+
+Warning: DateTime::setDate() expects parameter 3 to be long, string given in %s on line %d
+bool(false)
+
+-- string SQ --
+
+Warning: DateTime::setDate() expects parameter 3 to be long, string given in %s on line %d
+bool(false)
+
+-- mixed case string --
+
+Warning: DateTime::setDate() expects parameter 3 to be long, string given in %s on line %d
+bool(false)
+
+-- heredoc --
+
+Warning: DateTime::setDate() expects parameter 3 to be long, string given in %s on line %d
+bool(false)
+
+-- instance of classWithToString --
+
+Warning: DateTime::setDate() expects parameter 3 to be long, object given in %s on line %d
+bool(false)
+
+-- instance of classWithoutToString --
+
+Warning: DateTime::setDate() expects parameter 3 to be long, object given in %s on line %d
+bool(false)
+
+-- undefined var --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1963-06-30 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- unset var --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1963-06-30 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- resource --
+
+Warning: DateTime::setDate() expects parameter 3 to be long, resource given in %s on line %d
+bool(false)
+===DONE===
--- /dev/null
+--TEST--
+Test DateTime::setISODate() function : basic functionality
+--FILE--
+<?php
+/* Prototype : public DateTime DateTime::setISODate ( int $year , int $week [, int $day ] )
+ * Description: Set a date according to the ISO 8601 standard - using weeks and day offsets rather than specific dates.
+ * Source code: ext/date/php_date.c
+ * Alias to functions: date_isodate_set
+ */
+
+echo "*** Testing DateTime::setISODate() : basic functionality ***\n";
+
+//Set the default time zone
+date_default_timezone_set("Europe/London");
+
+// Create a deate object
+$datetime = new DateTime("2009-01-30 17:57:32");
+
+// Which month is week 40 ?
+$datetime->setISODate(2008, 40);
+echo "Week 40 of 2009 is in \"" . $datetime->format("F") . "\"\n";
+
+// What date is week week 30 day 3 ?
+$datetime->setISODate(2009, 30, 3);
+echo "Week 30 day 3 of 2009 is \"" . $datetime->format("D M j") . "\"\n";
+
+// What date was is last year ?
+$datetime->setISODate(2008, 30, 3);
+echo "..same day last year was \"" . $datetime->format("D M j") . "\"\n";
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing DateTime::setISODate() : basic functionality ***
+Week 40 of 2009 is in "September"
+Week 30 day 3 of 2009 is "Wed Jul 22"
+..same day last year was "Wed Jul 23"
+===DONE===
--- /dev/null
+--TEST--
+Test DateTime::setISODate () function : error conditions
+--FILE--
+<?php
+
+/* Prototype : public DateTime DateTime::setISODate ( int $year , int $week [, int $day ] )
+ * Description: Set a date according to the ISO 8601 standard - using weeks and day offsets rather than specific dates.
+ * Source code: ext/date/php_date.c
+ * Alias to functions: date_isodate_set
+ */
+
+ //Set the default time zone
+date_default_timezone_set("Europe/London");
+
+$datetime = new DateTime("2009-01-30 19:34:10");
+
+echo "*** Testing DateTime::setISODate () : error conditions ***\n";
+
+echo "\n-- Testing DateTime::setISODate() function with zero arguments --\n";
+var_dump( $datetime->setISODate() );
+
+$year = 2009;
+echo "\n-- Testing DateTime::setISODate() function with less than expected no. of arguments --\n";
+var_dump( $datetime->setISODate($year) );
+
+echo "\n-- Testing date_isodate_set() function with more than expected no. of arguments --\n";
+$week = 30;
+$day = 7;
+$extra_arg = 30;
+var_dump( $datetime->setISODate($year, $week, $day, $extra_arg) );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing DateTime::setISODate () : error conditions ***
+
+-- Testing DateTime::setISODate() function with zero arguments --
+
+Warning: DateTime::setISODate() expects at least 2 parameters, 0 given in %s on line %d
+bool(false)
+
+-- Testing DateTime::setISODate() function with less than expected no. of arguments --
+
+Warning: DateTime::setISODate() expects at least 2 parameters, 1 given in %s on line %d
+bool(false)
+
+-- Testing date_isodate_set() function with more than expected no. of arguments --
+
+Warning: DateTime::setISODate() expects at most 3 parameters, 4 given in %s on line %d
+bool(false)
+===DONE===
--- /dev/null
+--TEST--
+Test DateTime::setISODate() function : usage variation - Passing unexpected values to first argument $year.
+--FILE--
+<?php
+/* Prototype : public DateTime DateTime::setISODate ( int $year , int $week [, int $day ] )
+ * Description: Set a date according to the ISO 8601 standard - using weeks and day offsets rather than specific dates.
+ * Source code: ext/date/php_date.c
+ * Alias to functions: date_isodate_set
+ */
+
+echo "*** Testing DateTime::setISODate() : usage variation - unexpected values to first argument \$year***\n";
+
+//Set the default time zone
+date_default_timezone_set("Europe/London");
+
+//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);
+
+// resource
+$file_handle = fopen(__FILE__, 'r');
+
+//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 .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,
+
+ // resource
+ 'resource' => $file_handle
+);
+
+$object = new DateTime("2009-02-27 08:34:10");
+$day = 2;
+$month = 7;
+
+foreach($inputs as $variation =>$year) {
+ echo "\n-- $variation --\n";
+ var_dump( $object->setISODate($year, $month, $day) );
+};
+
+// closing the resource
+fclose( $file_handle );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing DateTime::setISODate() : usage variation - unexpected values to first argument $year***
+
+-- int 0 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "0000-02-15 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- int 1 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "0001-02-13 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- int 12345 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(20) "12345-02-13 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- int -12345 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(21) "-12345-02-15 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- float 10.5 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "0010-02-16 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- float -10.5 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(20) "-0010-02-19 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- float .5 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "0000-02-15 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- empty array --
+
+Warning: DateTime::setISODate() expects parameter 1 to be long, array given in %s on line %d
+bool(false)
+
+-- int indexed array --
+
+Warning: DateTime::setISODate() expects parameter 1 to be long, array given in %s on line %d
+bool(false)
+
+-- associative array --
+
+Warning: DateTime::setISODate() expects parameter 1 to be long, array given in %s on line %d
+bool(false)
+
+-- nested arrays --
+
+Warning: DateTime::setISODate() expects parameter 1 to be long, array given in %s on line %d
+bool(false)
+
+-- uppercase NULL --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "0000-02-15 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- lowercase null --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "0000-02-15 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- lowercase true --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "0001-02-13 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- lowercase false --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "0000-02-15 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- uppercase TRUE --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "0001-02-13 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- uppercase FALSE --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "0000-02-15 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- empty string DQ --
+
+Warning: DateTime::setISODate() expects parameter 1 to be long, string given in %s on line %d
+bool(false)
+
+-- empty string SQ --
+
+Warning: DateTime::setISODate() expects parameter 1 to be long, string given in %s on line %d
+bool(false)
+
+-- string DQ --
+
+Warning: DateTime::setISODate() expects parameter 1 to be long, string given in %s on line %d
+bool(false)
+
+-- string SQ --
+
+Warning: DateTime::setISODate() expects parameter 1 to be long, string given in %s on line %d
+bool(false)
+
+-- mixed case string --
+
+Warning: DateTime::setISODate() expects parameter 1 to be long, string given in %s on line %d
+bool(false)
+
+-- heredoc --
+
+Warning: DateTime::setISODate() expects parameter 1 to be long, string given in %s on line %d
+bool(false)
+
+-- instance of classWithToString --
+
+Warning: DateTime::setISODate() expects parameter 1 to be long, object given in %s on line %d
+bool(false)
+
+-- instance of classWithoutToString --
+
+Warning: DateTime::setISODate() expects parameter 1 to be long, object given in %s on line %d
+bool(false)
+
+-- undefined var --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "0000-02-15 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- unset var --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "0000-02-15 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- resource --
+
+Warning: DateTime::setISODate() expects parameter 1 to be long, resource given in %s on line %d
+bool(false)
+===DONE===
--- /dev/null
+--TEST--
+Test DateTime::setISODate() function : usage variation - Passing unexpected values to second argument $week.
+--FILE--
+<?php
+/* Prototype : public DateTime DateTime::setISODate ( int $year , int $week [, int $day ] )
+ * Description: Set a date according to the ISO 8601 standard - using weeks and day offsets rather than specific dates.
+ * Source code: ext/date/php_date.c
+ * Alias to functions: date_isodate_set
+ */
+
+echo "*** Testing DateTime::setISODate() : usage variation - unexpected values to second argument \$week***\n";
+
+//Set the default time zone
+date_default_timezone_set("Europe/London");
+
+//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);
+
+// resource
+$file_handle = fopen(__FILE__, 'r');
+
+//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 .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,
+
+ // resource
+ 'resource' => $file_handle
+);
+
+$object = date_create("2009-02-27 08:34:10");
+$day = 2;
+$year = 1963;
+
+foreach($inputs as $variation =>$month) {
+ echo "\n-- $variation --\n";
+ var_dump( $object->setISODate($year, $month, $day) );
+};
+
+// closing the resource
+fclose( $file_handle );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing DateTime::setISODate() : usage variation - unexpected values to second argument $week***
+
+-- int 0 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1962-12-25 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- int 1 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1963-01-01 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- int 12345 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2199-07-30 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- int -12345 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1726-05-21 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- float 10.5 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1963-03-05 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- float -10.5 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1962-10-16 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- float .5 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1962-12-25 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- empty array --
+
+Warning: DateTime::setISODate() expects parameter 2 to be long, array given in %s on line %d
+bool(false)
+
+-- int indexed array --
+
+Warning: DateTime::setISODate() expects parameter 2 to be long, array given in %s on line %d
+bool(false)
+
+-- associative array --
+
+Warning: DateTime::setISODate() expects parameter 2 to be long, array given in %s on line %d
+bool(false)
+
+-- nested arrays --
+
+Warning: DateTime::setISODate() expects parameter 2 to be long, array given in %s on line %d
+bool(false)
+
+-- uppercase NULL --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1962-12-25 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- lowercase null --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1962-12-25 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- lowercase true --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1963-01-01 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- lowercase false --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1962-12-25 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- uppercase TRUE --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1963-01-01 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- uppercase FALSE --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1962-12-25 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- empty string DQ --
+
+Warning: DateTime::setISODate() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+
+-- empty string SQ --
+
+Warning: DateTime::setISODate() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+
+-- string DQ --
+
+Warning: DateTime::setISODate() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+
+-- string SQ --
+
+Warning: DateTime::setISODate() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+
+-- mixed case string --
+
+Warning: DateTime::setISODate() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+
+-- heredoc --
+
+Warning: DateTime::setISODate() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+
+-- instance of classWithToString --
+
+Warning: DateTime::setISODate() expects parameter 2 to be long, object given in %s on line %d
+bool(false)
+
+-- instance of classWithoutToString --
+
+Warning: DateTime::setISODate() expects parameter 2 to be long, object given in %s on line %d
+bool(false)
+
+-- undefined var --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1962-12-25 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- unset var --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1962-12-25 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- resource --
+
+Warning: DateTime::setISODate() expects parameter 2 to be long, resource given in %s on line %d
+bool(false)
+===DONE===
--- /dev/null
+--TEST--
+Test DateTime::setISODate() function : usage variation - Passing unexpected values to third argument $day.
+--FILE--
+<?php
+/* Prototype : public DateTime DateTime::setISODate ( int $year , int $week [, int $day ] )
+ * Description: Set a date according to the ISO 8601 standard - using weeks and day offsets rather than specific dates.
+ * Source code: ext/date/php_date.c
+ * Alias to functions: date_isodate_set
+ */
+
+echo "*** Testing DateTime::setISODate() : usage variation - unexpected values to third argument \$day***\n";
+
+//Set the default time zone
+date_default_timezone_set("Europe/London");
+
+//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);
+
+// resource
+$file_handle = fopen(__FILE__, 'r');
+
+//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 .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,
+
+ // resource
+ 'resource' => $file_handle
+);
+
+$object = date_create("2009-02-27 08:34:10");
+$year = 1963;
+$month = 7;
+
+foreach($inputs as $variation =>$day) {
+ echo "\n-- $variation --\n";
+ var_dump( $object->setISODate($year, $month, $day) );
+};
+
+// closing the resource
+fclose( $file_handle );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing DateTime::setISODate() : usage variation - unexpected values to third argument $day***
+
+-- int 0 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1963-02-10 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- int 1 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1963-02-11 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- int 12345 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1996-11-28 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- int -12345 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1929-04-24 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- float 10.5 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1963-02-20 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- float -10.5 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1963-01-31 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- float .5 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1963-02-10 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- empty array --
+
+Warning: DateTime::setISODate() expects parameter 3 to be long, array given in %s on line %d
+bool(false)
+
+-- int indexed array --
+
+Warning: DateTime::setISODate() expects parameter 3 to be long, array given in %s on line %d
+bool(false)
+
+-- associative array --
+
+Warning: DateTime::setISODate() expects parameter 3 to be long, array given in %s on line %d
+bool(false)
+
+-- nested arrays --
+
+Warning: DateTime::setISODate() expects parameter 3 to be long, array given in %s on line %d
+bool(false)
+
+-- uppercase NULL --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1963-02-10 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- lowercase null --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1963-02-10 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- lowercase true --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1963-02-11 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- lowercase false --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1963-02-10 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- uppercase TRUE --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1963-02-11 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- uppercase FALSE --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1963-02-10 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- empty string DQ --
+
+Warning: DateTime::setISODate() expects parameter 3 to be long, string given in %s on line %d
+bool(false)
+
+-- empty string SQ --
+
+Warning: DateTime::setISODate() expects parameter 3 to be long, string given in %s on line %d
+bool(false)
+
+-- string DQ --
+
+Warning: DateTime::setISODate() expects parameter 3 to be long, string given in %s on line %d
+bool(false)
+
+-- string SQ --
+
+Warning: DateTime::setISODate() expects parameter 3 to be long, string given in %s on line %d
+bool(false)
+
+-- mixed case string --
+
+Warning: DateTime::setISODate() expects parameter 3 to be long, string given in %s on line %d
+bool(false)
+
+-- heredoc --
+
+Warning: DateTime::setISODate() expects parameter 3 to be long, string given in %s on line %d
+bool(false)
+
+-- instance of classWithToString --
+
+Warning: DateTime::setISODate() expects parameter 3 to be long, object given in %s on line %d
+bool(false)
+
+-- instance of classWithoutToString --
+
+Warning: DateTime::setISODate() expects parameter 3 to be long, object given in %s on line %d
+bool(false)
+
+-- undefined var --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1963-02-10 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- unset var --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "1963-02-10 08:34:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- resource --
+
+Warning: DateTime::setISODate() expects parameter 3 to be long, resource given in %s on line %d
+bool(false)
+===DONE===
--- /dev/null
+--TEST--
+Test DateTime::setTime() function : basic functionality
+--FILE--
+<?php
+/* Prototype : public DateTime DateTime::setTime ( int $hour , int $minute [, int $second ] )
+ * Description: Resets the current time of the DateTime object to a different time.
+ * Source code: ext/date/php_date.c
+ * Alias to functions: date_time_set
+ */
+
+ //Set the default time zone
+date_default_timezone_set("Europe/London");
+
+echo "*** Testing DateTime::setTime() : basic functionality ***\n";
+
+// Create a DateTime object
+$datetime = new DateTime("2009-01-31 15:14:10");
+
+echo "Initial date: " . $datetime ->format(DATE_RFC2822) . "\n";
+
+$datetime->setTime(17, 20);
+echo "After modification1 " . $datetime ->format(DATE_RFC2822) . "\n";
+
+$datetime->setTime(19, 05, 59);
+echo "After modification2 " . $datetime ->format(DATE_RFC2822) . "\n";
+
+$datetime->setTime(24, 10);
+echo "After modification3 " . $datetime ->format(DATE_RFC2822) . "\n";
+
+$datetime->setTime(47, 35, 47);
+echo "After modification4 " . $datetime ->format(DATE_RFC2822) . "\n";
+
+$datetime->setTime(54, 25);
+echo "After modification5 " . $datetime ->format(DATE_RFC2822) . "\n";
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing DateTime::setTime() : basic functionality ***
+Initial date: Sat, 31 Jan 2009 15:14:10 +0000
+After modification1 Sat, 31 Jan 2009 17:20:00 +0000
+After modification2 Sat, 31 Jan 2009 19:05:59 +0000
+After modification3 Sun, 01 Feb 2009 00:10:00 +0000
+After modification4 Mon, 02 Feb 2009 23:35:47 +0000
+After modification5 Wed, 04 Feb 2009 06:25:00 +0000
+===DONE===
--- /dev/null
+--TEST--
+Test DateTime::setTime() function : error conditions
+--FILE--
+<?php
+/* Prototype : public DateTime DateTime::setTime ( int $hour , int $minute [, int $second ] )
+ * Description: Resets the current time of the DateTime object to a different time.
+ * Source code: ext/date/php_date.c
+ * Alias to functions: date_time_set
+ */
+
+date_default_timezone_set("Europe/London");
+
+echo "*** Testing DateTime::setTime() : error conditions ***\n";
+
+$datetime = date_create("2009-01-31 15:34:10");
+
+echo "\n-- Testing DateTime::setTime() function with zero arguments --\n";
+var_dump( $datetime->setTime() );
+
+echo "\n-- Testing DateTime::setTime() function with less than expected no. of arguments --\n";
+$hour = 18;
+var_dump( $datetime->setTime($hour) );
+
+echo "\n-- Testing DateTime::setTime() function with more than expected no. of arguments --\n";
+$min = 15;
+$sec = 30;
+$extra_arg = 10;
+var_dump( $datetime->setTime($hour, $min, $sec, $extra_arg) );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing DateTime::setTime() : error conditions ***
+
+-- Testing DateTime::setTime() function with zero arguments --
+
+Warning: DateTime::setTime() expects at least 2 parameters, 0 given in %s on line %d
+bool(false)
+
+-- Testing DateTime::setTime() function with less than expected no. of arguments --
+
+Warning: DateTime::setTime() expects at least 2 parameters, 1 given in %s on line %d
+bool(false)
+
+-- Testing DateTime::setTime() function with more than expected no. of arguments --
+
+Warning: DateTime::setTime() expects at most 3 parameters, 4 given in %s on line %d
+bool(false)
+===DONE===
--- /dev/null
+--TEST--
+Test DateTime::setTime() function : usage variation - Passing unexpected values to first argument $hour.
+--FILE--
+<?php
+/* Prototype : public DateTime DateTime::setTime ( int $hour , int $minute [, int $second ] )
+ * Description: Resets the current time of the DateTime object to a different time.
+ * Source code: ext/date/php_date.c
+ * Alias to functions: date_time_set
+ */
+
+echo "*** Testing DateTime::setTime() : usage variation - unexpected values to first argument \$hour***\n";
+
+//Set the default time zone
+date_default_timezone_set("Europe/London");
+
+//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);
+
+// resource
+$file_handle = fopen(__FILE__, 'r');
+
+//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 .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,
+
+ // resource
+ 'resource' => $file_handle
+);
+
+$object = new DateTime("2009-01-31 15:14:10");
+$minute = 13;
+$sec = 45;
+
+foreach($inputs as $variation =>$hour) {
+ echo "\n-- $variation --\n";
+ var_dump( $object->setTime($hour, $minute, $sec) );
+};
+
+// closing the resource
+fclose( $file_handle );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing DateTime::setTime() : usage variation - unexpected values to first argument $hour***
+
+-- int 0 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-31 00:13:45"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- int 1 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-31 01:13:45"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- int 12345 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2010-06-29 09:13:45"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- int -12345 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-30 15:13:45"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- float 10.5 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-30 10:13:45"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- float -10.5 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-29 14:13:45"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- float .5 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-29 00:13:45"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- empty array --
+
+Warning: DateTime::setTime() expects parameter 1 to be long, array given in %s on line %d
+bool(false)
+
+-- int indexed array --
+
+Warning: DateTime::setTime() expects parameter 1 to be long, array given in %s on line %d
+bool(false)
+
+-- associative array --
+
+Warning: DateTime::setTime() expects parameter 1 to be long, array given in %s on line %d
+bool(false)
+
+-- nested arrays --
+
+Warning: DateTime::setTime() expects parameter 1 to be long, array given in %s on line %d
+bool(false)
+
+-- uppercase NULL --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-29 00:13:45"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- lowercase null --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-29 00:13:45"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- lowercase true --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-29 01:13:45"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- lowercase false --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-29 00:13:45"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- uppercase TRUE --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-29 01:13:45"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- uppercase FALSE --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-29 00:13:45"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- empty string DQ --
+
+Warning: DateTime::setTime() expects parameter 1 to be long, string given in %s on line %d
+bool(false)
+
+-- empty string SQ --
+
+Warning: DateTime::setTime() expects parameter 1 to be long, string given in %s on line %d
+bool(false)
+
+-- string DQ --
+
+Warning: DateTime::setTime() expects parameter 1 to be long, string given in %s on line %d
+bool(false)
+
+-- string SQ --
+
+Warning: DateTime::setTime() expects parameter 1 to be long, string given in %s on line %d
+bool(false)
+
+-- mixed case string --
+
+Warning: DateTime::setTime() expects parameter 1 to be long, string given in %s on line %d
+bool(false)
+
+-- heredoc --
+
+Warning: DateTime::setTime() expects parameter 1 to be long, string given in %s on line %d
+bool(false)
+
+-- instance of classWithToString --
+
+Warning: DateTime::setTime() expects parameter 1 to be long, object given in %s on line %d
+bool(false)
+
+-- instance of classWithoutToString --
+
+Warning: DateTime::setTime() expects parameter 1 to be long, object given in %s on line %d
+bool(false)
+
+-- undefined var --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-29 00:13:45"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- unset var --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-29 00:13:45"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- resource --
+
+Warning: DateTime::setTime() expects parameter 1 to be long, resource given in %s on line %d
+bool(false)
+===DONE===
--- /dev/null
+--TEST--
+Test DateTime::setTime() function : usage variation - Passing unexpected values to second argument $minute.
+--FILE--
+<?php
+/* Prototype : public DateTime DateTime::setTime ( int $hour , int $minute [, int $second ] )
+ * Description: Resets the current time of the DateTime object to a different time.
+ * Source code: ext/date/php_date.c
+ * Alias to functions: date_time_set
+ */
+
+echo "*** Testing DateTime::setTime() : usage variation - unexpected values to second argument \$minute***\n";
+
+//Set the default time zone
+date_default_timezone_set("Europe/London");
+
+//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);
+
+// resource
+$file_handle = fopen(__FILE__, 'r');
+
+//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 .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,
+
+ // resource
+ 'resource' => $file_handle
+);
+
+$object = new DateTime("2009-01-31 15:14:10");
+$hour = 10;
+$sec = 45;
+
+foreach($inputs as $variation =>$minute) {
+ echo "\n-- $variation --\n";
+ var_dump( $object->setTime($hour, $minute, $sec) );
+};
+
+// closing the resource
+fclose( $file_handle );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing DateTime::setTime() : usage variation - unexpected values to second argument $minute***
+
+-- int 0 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-31 10:00:45"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- int 1 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-31 10:01:45"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- int 12345 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-02-08 23:45:45"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- int -12345 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-30 20:15:45"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- float 10.5 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-30 10:10:45"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- float -10.5 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-30 09:50:45"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- float .5 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-30 10:00:45"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- empty array --
+
+Warning: DateTime::setTime() expects parameter 2 to be long, array given in %s on line %d
+bool(false)
+
+-- int indexed array --
+
+Warning: DateTime::setTime() expects parameter 2 to be long, array given in %s on line %d
+bool(false)
+
+-- associative array --
+
+Warning: DateTime::setTime() expects parameter 2 to be long, array given in %s on line %d
+bool(false)
+
+-- nested arrays --
+
+Warning: DateTime::setTime() expects parameter 2 to be long, array given in %s on line %d
+bool(false)
+
+-- uppercase NULL --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-30 10:00:45"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- lowercase null --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-30 10:00:45"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- lowercase true --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-30 10:01:45"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- lowercase false --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-30 10:00:45"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- uppercase TRUE --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-30 10:01:45"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- uppercase FALSE --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-30 10:00:45"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- empty string DQ --
+
+Warning: DateTime::setTime() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+
+-- empty string SQ --
+
+Warning: DateTime::setTime() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+
+-- string DQ --
+
+Warning: DateTime::setTime() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+
+-- string SQ --
+
+Warning: DateTime::setTime() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+
+-- mixed case string --
+
+Warning: DateTime::setTime() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+
+-- heredoc --
+
+Warning: DateTime::setTime() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+
+-- instance of classWithToString --
+
+Warning: DateTime::setTime() expects parameter 2 to be long, object given in %s on line %d
+bool(false)
+
+-- instance of classWithoutToString --
+
+Warning: DateTime::setTime() expects parameter 2 to be long, object given in %s on line %d
+bool(false)
+
+-- undefined var --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-30 10:00:45"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- unset var --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-30 10:00:45"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- resource --
+
+Warning: DateTime::setTime() expects parameter 2 to be long, resource given in %s on line %d
+bool(false)
+===DONE===
--- /dev/null
+--TEST--
+Test DateTime::setTime() function : usage variation - Passing unexpected values to third argument $second.
+--FILE--
+<?php
+/* Prototype : public DateTime DateTime::setTime ( int $hour , int $minute [, int $second ] )
+ * Description: Resets the current time of the DateTime object to a different time.
+ * Source code: ext/date/php_date.c
+ * Alias to functions: date_time_set
+ */
+
+echo "*** Testing DateTime::setTime() : usage variation - unexpected values to third argument \$second***\n";
+
+//Set the default time zone
+date_default_timezone_set("Europe/London");
+
+//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);
+
+// resource
+$file_handle = fopen(__FILE__, 'r');
+
+//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 .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,
+
+ // resource
+ 'resource' => $file_handle
+);
+
+$object = new DateTime("2009-01-31 15:14:10");
+$hour = 10;
+$minute = 13;
+
+foreach($inputs as $variation =>$sec) {
+ echo "\n-- $variation --\n";
+ var_dump( $object->setTime($hour, $minute, $sec) );
+};
+
+// closing the resource
+fclose( $file_handle );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing DateTime::setTime() : usage variation - unexpected values to third argument $second***
+
+-- int 0 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-31 10:13:00"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- int 1 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-31 10:13:01"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- int 12345 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-31 13:38:45"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- int -12345 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-31 06:47:15"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- float 10.5 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-31 10:13:10"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- float -10.5 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-31 10:12:50"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- float .5 --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-31 10:13:00"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- empty array --
+
+Warning: DateTime::setTime() expects parameter 3 to be long, array given in %s on line %d
+bool(false)
+
+-- int indexed array --
+
+Warning: DateTime::setTime() expects parameter 3 to be long, array given in %s on line %d
+bool(false)
+
+-- associative array --
+
+Warning: DateTime::setTime() expects parameter 3 to be long, array given in %s on line %d
+bool(false)
+
+-- nested arrays --
+
+Warning: DateTime::setTime() expects parameter 3 to be long, array given in %s on line %d
+bool(false)
+
+-- uppercase NULL --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-31 10:13:00"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- lowercase null --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-31 10:13:00"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- lowercase true --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-31 10:13:01"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- lowercase false --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-31 10:13:00"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- uppercase TRUE --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-31 10:13:01"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- uppercase FALSE --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-31 10:13:00"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- empty string DQ --
+
+Warning: DateTime::setTime() expects parameter 3 to be long, string given in %s on line %d
+bool(false)
+
+-- empty string SQ --
+
+Warning: DateTime::setTime() expects parameter 3 to be long, string given in %s on line %d
+bool(false)
+
+-- string DQ --
+
+Warning: DateTime::setTime() expects parameter 3 to be long, string given in %s on line %d
+bool(false)
+
+-- string SQ --
+
+Warning: DateTime::setTime() expects parameter 3 to be long, string given in %s on line %d
+bool(false)
+
+-- mixed case string --
+
+Warning: DateTime::setTime() expects parameter 3 to be long, string given in %s on line %d
+bool(false)
+
+-- heredoc --
+
+Warning: DateTime::setTime() expects parameter 3 to be long, string given in %s on line %d
+bool(false)
+
+-- instance of classWithToString --
+
+Warning: DateTime::setTime() expects parameter 3 to be long, object given in %s on line %d
+bool(false)
+
+-- instance of classWithoutToString --
+
+Warning: DateTime::setTime() expects parameter 3 to be long, object given in %s on line %d
+bool(false)
+
+-- undefined var --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-31 10:13:00"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- unset var --
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(19) "2009-01-31 10:13:00"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
+}
+
+-- resource --
+
+Warning: DateTime::setTime() expects parameter 3 to be long, resource given in %s on line %d
+bool(false)
+===DONE===
--- /dev/null
+--TEST--
+Test DateTime::setTimezone() function : basic functionality
+--FILE--
+<?php
+/* Prototype : public DateTime DateTime::setTimezone ( DateTimeZone $timezone )
+ * Description: Sets the time zone for the DateTime object
+ * Source code: ext/date/php_date.c
+ * Alias to functions: date_timezone_set
+ */
+
+echo "*** Testing DateTime::setTimezone() : basic functionality ***\n";
+
+//Set the default time zone
+date_default_timezone_set("Europe/London");
+
+$datetime = new DateTime("2009-01-30 17:57:32");
+echo "Default timezone: " . date_timezone_get($datetime)->getName() . "\n";
+
+$la_time = new DateTimezone("America/Los_Angeles");
+$datetime->setTimezone($la_time);
+echo "New timezone: " . date_timezone_get($datetime)->getName() . "\n";
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing DateTime::setTimezone() : basic functionality ***
+Default timezone: Europe/London
+New timezone: America/Los_Angeles
+===DONE===
--- /dev/null
+--TEST--
+Test DateTime::setTimezone () function : error conditions
+--FILE--
+<?php
+/* Prototype : public DateTime DateTime::setTimezone ( DateTimeZone $timezone )
+ * Description: Sets the time zone for the DateTime object
+ * Source code: ext/date/php_date.c
+ * Alias to functions: date_timezone_set
+ */
+
+date_default_timezone_set("UTC");
+
+echo "*** Testing DateTime::setTimezone () : error conditions ***\n";
+
+$datetime = new DateTime("2009-01-30 17:57:32");
+
+echo "\n-- Testing DateTime::setTimezone () function with zero arguments --\n";
+var_dump( $datetime->setTimezone() );
+
+echo "\n-- Testing DateTime::setTimezone () function with more than expected no. of arguments --\n";
+$timezone = new DateTimezone("GMT");
+$extra_arg = 99;
+var_dump( $datetime->setTimezone($timezone, $extra_arg) );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing DateTime::setTimezone () : error conditions ***
+
+-- Testing DateTime::setTimezone () function with zero arguments --
+
+Warning: DateTime::setTimezone() expects exactly 1 parameter, 0 given in %s on line %d
+bool(false)
+
+-- Testing DateTime::setTimezone () function with more than expected no. of arguments --
+
+Warning: DateTime::setTimezone() expects exactly 1 parameter, 2 given in %s on line %d
+bool(false)
+===DONE===
--- /dev/null
+--TEST--
+Test DateTime::setTimezone() function : usage variation - Passing unexpected values to first argument $timezone.
+--FILE--
+<?php
+/* Prototype : public DateTime DateTime::setTimezone ( DateTimeZone $timezone )
+ * Description: Sets the time zone for the DateTime object
+ * Source code: ext/date/php_date.c
+ * Alias to functions: date_timezone_set
+ */
+
+echo "*** Testing DateTime::setTimezone() : usage variation - unexpected values to first argument \$timezone***\n";
+
+//Set the default time zone
+date_default_timezone_set("Europe/London");
+
+//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);
+
+// resource
+$file_handle = fopen(__FILE__, 'r');
+
+//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 .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,
+
+ // resource
+ 'resource' => $file_handle
+);
+
+$object = new DateTime("2009-01-30 17:57:32");
+
+foreach($inputs as $variation =>$timezone) {
+ echo "\n-- $variation --\n";
+ var_dump( $object->setTimezone($timezone) );
+};
+
+// closing the resource
+fclose( $file_handle );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing DateTime::setTimezone() : usage variation - unexpected values to first argument $timezone***
+
+-- int 0 --
+
+Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, integer given in %s on line %d
+bool(false)
+
+-- int 1 --
+
+Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, integer given in %s on line %d
+bool(false)
+
+-- int 12345 --
+
+Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, integer given in %s on line %d
+bool(false)
+
+-- int -12345 --
+
+Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, integer given in %s on line %d
+bool(false)
+
+-- float 10.5 --
+
+Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, double given in %s on line %d
+bool(false)
+
+-- float -10.5 --
+
+Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, double given in %s on line %d
+bool(false)
+
+-- float .5 --
+
+Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, double given in %s on line %d
+bool(false)
+
+-- empty array --
+
+Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, array given in %s on line %d
+bool(false)
+
+-- int indexed array --
+
+Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, array given in %s on line %d
+bool(false)
+
+-- associative array --
+
+Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, array given in %s on line %d
+bool(false)
+
+-- nested arrays --
+
+Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, array given in %s on line %d
+bool(false)
+
+-- uppercase NULL --
+
+Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, null given in %s on line %d
+bool(false)
+
+-- lowercase null --
+
+Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, null given in %s on line %d
+bool(false)
+
+-- lowercase true --
+
+Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, boolean given in %s on line %d
+bool(false)
+
+-- lowercase false --
+
+Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, boolean given in %s on line %d
+bool(false)
+
+-- uppercase TRUE --
+
+Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, boolean given in %s on line %d
+bool(false)
+
+-- uppercase FALSE --
+
+Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, boolean given in %s on line %d
+bool(false)
+
+-- empty string DQ --
+
+Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in %s on line %d
+bool(false)
+
+-- empty string SQ --
+
+Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in %s on line %d
+bool(false)
+
+-- string DQ --
+
+Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in %s on line %d
+bool(false)
+
+-- string SQ --
+
+Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in %s on line %d
+bool(false)
+
+-- mixed case string --
+
+Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in %s on line %d
+bool(false)
+
+-- heredoc --
+
+Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in %s on line %d
+bool(false)
+
+-- instance of classWithToString --
+
+Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, object given in %s on line %d
+bool(false)
+
+-- instance of classWithoutToString --
+
+Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, object given in %s on line %d
+bool(false)
+
+-- undefined var --
+
+Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, null given in %s on line %d
+bool(false)
+
+-- unset var --
+
+Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, null given in %s on line %d
+bool(false)
+
+-- resource --
+
+Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, resource given in %s on line %d
+bool(false)
+===DONE===
--- /dev/null
+--TEST--
+Test DateTime class registration
+--FILE--
+<?php
+
+echo "*** Verify DateTime class ***\n";
+
+echo "Verify DateTime class registered OK\n";
+$class = new ReflectionClass('DateTime');
+var_dump($class);
+
+echo "..and get names of all its methods\n";
+$methods = $class->getMethods();
+var_dump($methods);
+
+echo "..and get names of all its class constants\n";
+$constants = $class->getConstants();
+var_dump($constants);
+
+?>
+===DONE===
+--EXPECTF--
+*** Verify DateTime class ***
+Verify DateTime class registered OK
+object(ReflectionClass)#%d (1) {
+ ["name"]=>
+ string(8) "DateTime"
+}
+..and get names of all its methods
+array(18) {
+ [0]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(11) "__construct"
+ ["class"]=>
+ string(8) "DateTime"
+ }
+ [1]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(8) "__wakeup"
+ ["class"]=>
+ string(8) "DateTime"
+ }
+ [2]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(11) "__set_state"
+ ["class"]=>
+ string(8) "DateTime"
+ }
+ [3]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(16) "createFromFormat"
+ ["class"]=>
+ string(8) "DateTime"
+ }
+ [4]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(13) "getLastErrors"
+ ["class"]=>
+ string(8) "DateTime"
+ }
+ [5]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(6) "format"
+ ["class"]=>
+ string(8) "DateTime"
+ }
+ [6]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(6) "modify"
+ ["class"]=>
+ string(8) "DateTime"
+ }
+ [7]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(3) "add"
+ ["class"]=>
+ string(8) "DateTime"
+ }
+ [8]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(3) "sub"
+ ["class"]=>
+ string(8) "DateTime"
+ }
+ [9]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(11) "getTimezone"
+ ["class"]=>
+ string(8) "DateTime"
+ }
+ [10]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(11) "setTimezone"
+ ["class"]=>
+ string(8) "DateTime"
+ }
+ [11]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(9) "getOffset"
+ ["class"]=>
+ string(8) "DateTime"
+ }
+ [12]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(7) "setTime"
+ ["class"]=>
+ string(8) "DateTime"
+ }
+ [13]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(7) "setDate"
+ ["class"]=>
+ string(8) "DateTime"
+ }
+ [14]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(10) "setISODate"
+ ["class"]=>
+ string(8) "DateTime"
+ }
+ [15]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(12) "setTimestamp"
+ ["class"]=>
+ string(8) "DateTime"
+ }
+ [16]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(12) "getTimestamp"
+ ["class"]=>
+ string(8) "DateTime"
+ }
+ [17]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(4) "diff"
+ ["class"]=>
+ string(8) "DateTime"
+ }
+}
+..and get names of all its class constants
+array(11) {
+ ["ATOM"]=>
+ string(13) "Y-m-d\TH:i:sP"
+ ["COOKIE"]=>
+ string(16) "l, d-M-y H:i:s T"
+ ["ISO8601"]=>
+ string(13) "Y-m-d\TH:i:sO"
+ ["RFC822"]=>
+ string(16) "D, d M y H:i:s O"
+ ["RFC850"]=>
+ string(16) "l, d-M-y H:i:s T"
+ ["RFC1036"]=>
+ string(16) "D, d M y H:i:s O"
+ ["RFC1123"]=>
+ string(16) "D, d M Y H:i:s O"
+ ["RFC2822"]=>
+ string(16) "D, d M Y H:i:s O"
+ ["RFC3339"]=>
+ string(13) "Y-m-d\TH:i:sP"
+ ["RSS"]=>
+ string(16) "D, d M Y H:i:s O"
+ ["W3C"]=>
+ string(13) "Y-m-d\TH:i:sP"
+}
+===DONE===
\ No newline at end of file