From 007685a39d6460c1cfbc665df3d46f82b0e25592 Mon Sep 17 00:00:00 2001 From: andy wharmby Date: Wed, 18 Mar 2009 11:32:53 +0000 Subject: [PATCH] New tests for date extension DateTime methods Tested on Windows, Linux and linux 64 --- ext/date/tests/DateTime_clone_basic1.phpt | 29 ++ ext/date/tests/DateTime_clone_basic2.phpt | 66 +++++ ext/date/tests/DateTime_clone_basic3.phpt | 75 +++++ ext/date/tests/DateTime_clone_basic4.phpt | 31 +++ ext/date/tests/DateTime_compare_basic1.phpt | 77 ++++++ ext/date/tests/DateTime_construct_basic1.phpt | 34 +++ ext/date/tests/DateTime_construct_error.phpt | 33 +++ .../tests/DateTime_construct_variation1.phpt | 257 ++++++++++++++++++ .../tests/DateTime_construct_variation2.phpt | 204 ++++++++++++++ ext/date/tests/DateTime_extends_basic1.phpt | 49 ++++ ext/date/tests/DateTime_extends_basic2.phpt | 31 +++ ext/date/tests/DateTime_extends_basic3.phpt | 26 ++ ext/date/tests/DateTime_format_basic1.phpt | 40 +++ ext/date/tests/DateTime_format_basic2.phpt | 44 +++ ext/date/tests/DateTime_format_error.phpt | 41 +++ .../tests/DateTime_format_variation1.phpt | 208 ++++++++++++++ ext/date/tests/DateTime_getOffset_basic1.phpt | 28 ++ ext/date/tests/DateTime_getOffset_error.phpt | 33 +++ .../tests/DateTime_getTimeZone_basic1.phpt | 33 +++ ext/date/tests/DateTime_modify_basic1.phpt | 39 +++ ext/date/tests/DateTime_modify_error.phpt | 42 +++ .../tests/DateTime_modify_variation1.phpt | 208 ++++++++++++++ ext/date/tests/DateTime_serialize.phpt | 29 ++ ext/date/tests/DateTime_setDate_basic1.phpt | 30 ++ ext/date/tests/DateTime_setDate_error.phpt | 53 ++++ .../tests/DateTime_setDate_variation1.phpt | 224 +++++++++++++++ .../tests/DateTime_setDate_variation2.phpt | 225 +++++++++++++++ .../tests/DateTime_setDate_variation3.phpt | 224 +++++++++++++++ .../tests/DateTime_setISODate_basic1.phpt | 38 +++ ext/date/tests/DateTime_setISODate_error.phpt | 51 ++++ .../tests/DateTime_setISODate_variation1.phpt | 224 +++++++++++++++ .../tests/DateTime_setISODate_variation2.phpt | 224 +++++++++++++++ .../tests/DateTime_setISODate_variation3.phpt | 224 +++++++++++++++ ext/date/tests/DateTime_setTime_basic1.phpt | 46 ++++ ext/date/tests/DateTime_setTime_error.phpt | 49 ++++ .../tests/DateTime_setTime_variation1.phpt | 224 +++++++++++++++ .../tests/DateTime_setTime_variation2.phpt | 224 +++++++++++++++ .../tests/DateTime_setTime_variation3.phpt | 224 +++++++++++++++ .../tests/DateTime_setTimezone_basic1.phpt | 29 ++ .../tests/DateTime_setTimezone_error.phpt | 39 +++ .../DateTime_setTimezone_variation1.phpt | 252 +++++++++++++++++ ext/date/tests/DateTime_verify.phpt | 120 ++++++++ 42 files changed, 4381 insertions(+) create mode 100644 ext/date/tests/DateTime_clone_basic1.phpt create mode 100644 ext/date/tests/DateTime_clone_basic2.phpt create mode 100644 ext/date/tests/DateTime_clone_basic3.phpt create mode 100644 ext/date/tests/DateTime_clone_basic4.phpt create mode 100644 ext/date/tests/DateTime_compare_basic1.phpt create mode 100644 ext/date/tests/DateTime_construct_basic1.phpt create mode 100644 ext/date/tests/DateTime_construct_error.phpt create mode 100644 ext/date/tests/DateTime_construct_variation1.phpt create mode 100644 ext/date/tests/DateTime_construct_variation2.phpt create mode 100644 ext/date/tests/DateTime_extends_basic1.phpt create mode 100644 ext/date/tests/DateTime_extends_basic2.phpt create mode 100644 ext/date/tests/DateTime_extends_basic3.phpt create mode 100644 ext/date/tests/DateTime_format_basic1.phpt create mode 100644 ext/date/tests/DateTime_format_basic2.phpt create mode 100644 ext/date/tests/DateTime_format_error.phpt create mode 100644 ext/date/tests/DateTime_format_variation1.phpt create mode 100644 ext/date/tests/DateTime_getOffset_basic1.phpt create mode 100644 ext/date/tests/DateTime_getOffset_error.phpt create mode 100644 ext/date/tests/DateTime_getTimeZone_basic1.phpt create mode 100644 ext/date/tests/DateTime_modify_basic1.phpt create mode 100644 ext/date/tests/DateTime_modify_error.phpt create mode 100644 ext/date/tests/DateTime_modify_variation1.phpt create mode 100644 ext/date/tests/DateTime_serialize.phpt create mode 100644 ext/date/tests/DateTime_setDate_basic1.phpt create mode 100644 ext/date/tests/DateTime_setDate_error.phpt create mode 100644 ext/date/tests/DateTime_setDate_variation1.phpt create mode 100644 ext/date/tests/DateTime_setDate_variation2.phpt create mode 100644 ext/date/tests/DateTime_setDate_variation3.phpt create mode 100644 ext/date/tests/DateTime_setISODate_basic1.phpt create mode 100644 ext/date/tests/DateTime_setISODate_error.phpt create mode 100644 ext/date/tests/DateTime_setISODate_variation1.phpt create mode 100644 ext/date/tests/DateTime_setISODate_variation2.phpt create mode 100644 ext/date/tests/DateTime_setISODate_variation3.phpt create mode 100644 ext/date/tests/DateTime_setTime_basic1.phpt create mode 100644 ext/date/tests/DateTime_setTime_error.phpt create mode 100644 ext/date/tests/DateTime_setTime_variation1.phpt create mode 100644 ext/date/tests/DateTime_setTime_variation2.phpt create mode 100644 ext/date/tests/DateTime_setTime_variation3.phpt create mode 100644 ext/date/tests/DateTime_setTimezone_basic1.phpt create mode 100644 ext/date/tests/DateTime_setTimezone_error.phpt create mode 100644 ext/date/tests/DateTime_setTimezone_variation1.phpt create mode 100644 ext/date/tests/DateTime_verify.phpt diff --git a/ext/date/tests/DateTime_clone_basic1.phpt b/ext/date/tests/DateTime_clone_basic1.phpt new file mode 100644 index 0000000000..cef6621a75 --- /dev/null +++ b/ext/date/tests/DateTime_clone_basic1.phpt @@ -0,0 +1,29 @@ +--TEST-- +Test clone on DateTime objects +--FILE-- +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=== diff --git a/ext/date/tests/DateTime_clone_basic2.phpt b/ext/date/tests/DateTime_clone_basic2.phpt new file mode 100644 index 0000000000..61f646a9bc --- /dev/null +++ b/ext/date/tests/DateTime_clone_basic2.phpt @@ -0,0 +1,66 @@ +--TEST-- +Test clone of objects whoose class derived from DateTime class +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing clone on objects whoose class derived from DateTime class *** +object(DateTimeExt1)#%d (2) { + ["property1"]=> + int(99) + ["property2"]=> + string(5) "Hello" +} +object(DateTimeExt1)#%d (2) { + ["property1"]=> + int(99) + ["property2"]=> + string(5) "Hello" +} +object(DateTimeExt2)#%d (4) { + ["property3"]=> + bool(true) + ["property4"]=> + float(10.5) + ["property1"]=> + int(99) + ["property2"]=> + string(5) "Hello" +} +object(DateTimeExt2)#%d (4) { + ["property3"]=> + bool(true) + ["property4"]=> + float(10.5) + ["property1"]=> + int(99) + ["property2"]=> + string(5) "Hello" +} +===DONE=== \ No newline at end of file diff --git a/ext/date/tests/DateTime_clone_basic3.phpt b/ext/date/tests/DateTime_clone_basic3.phpt new file mode 100644 index 0000000000..50826c5d91 --- /dev/null +++ b/ext/date/tests/DateTime_clone_basic3.phpt @@ -0,0 +1,75 @@ +--TEST-- +Test clone of DateTime objects +--FILE-- +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 (0) { +} + +-- Add some properties -- +object(DateTime)#%d (2) { + ["property1"]=> + int(99) + ["property2"]=> + string(5) "Hello" +} + +-- clone it -- +object(DateTime)#%d (2) { + ["property1"]=> + int(99) + ["property2"]=> + string(5) "Hello" +} + +-- Add some more properties -- +object(DateTime)#%d (4) { + ["property1"]=> + int(99) + ["property2"]=> + string(5) "Hello" + ["property3"]=> + bool(true) + ["property4"]=> + float(10.5) +} + +-- clone it -- +object(DateTime)#%d (4) { + ["property1"]=> + int(99) + ["property2"]=> + string(5) "Hello" + ["property3"]=> + bool(true) + ["property4"]=> + float(10.5) +} +===DONE=== diff --git a/ext/date/tests/DateTime_clone_basic4.phpt b/ext/date/tests/DateTime_clone_basic4.phpt new file mode 100644 index 0000000000..f19f23d97b --- /dev/null +++ b/ext/date/tests/DateTime_clone_basic4.phpt @@ -0,0 +1,31 @@ +--TEST-- +Test clone of DateTime derived objects with __clone magic method +--FILE-- +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=== diff --git a/ext/date/tests/DateTime_compare_basic1.phpt b/ext/date/tests/DateTime_compare_basic1.phpt new file mode 100644 index 0000000000..313dab1c25 --- /dev/null +++ b/ext/date/tests/DateTime_compare_basic1.phpt @@ -0,0 +1,77 @@ +--TEST-- +Test of compare object handler for DateTime objects +--FILE-- + +===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 diff --git a/ext/date/tests/DateTime_construct_basic1.phpt b/ext/date/tests/DateTime_construct_basic1.phpt new file mode 100644 index 0000000000..a49c5e64b9 --- /dev/null +++ b/ext/date/tests/DateTime_construct_basic1.phpt @@ -0,0 +1,34 @@ +--TEST-- +Test new DateTime() : basic functionality +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing new DateTime() : basic functionality *** +object(DateTime)#%d (0) { +} +object(DateTime)#%d (0) { +} +object(DateTime)#%d (0) { +} +object(DateTime)#%d (0) { +} +===DONE=== diff --git a/ext/date/tests/DateTime_construct_error.phpt b/ext/date/tests/DateTime_construct_error.phpt new file mode 100644 index 0000000000..21856c2de1 --- /dev/null +++ b/ext/date/tests/DateTime_construct_error.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test new DateTime() : error conditions +--FILE-- + +===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 diff --git a/ext/date/tests/DateTime_construct_variation1.phpt b/ext/date/tests/DateTime_construct_variation1.phpt new file mode 100644 index 0000000000..a641d7ac8b --- /dev/null +++ b/ext/date/tests/DateTime_construct_variation1.phpt @@ -0,0 +1,257 @@ +--TEST-- +Test new DateTime() function : usage variation - Passing unexpected values to first argument $time. +--FILE-- + 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 (0) { +} +object(DateTime)#%d (0) { +} + +-- 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 (0) { +} +object(DateTime)#%d (0) { +} + +-- 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 (0) { +} +object(DateTime)#%d (0) { +} + +-- lowercase null -- +object(DateTime)#%d (0) { +} +object(DateTime)#%d (0) { +} + +-- 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 (0) { +} +object(DateTime)#%d (0) { +} + +-- 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 (0) { +} +object(DateTime)#%d (0) { +} + +-- empty string DQ -- +object(DateTime)#%d (0) { +} +object(DateTime)#%d (0) { +} + +-- empty string SQ -- +object(DateTime)#%d (0) { +} +object(DateTime)#%d (0) { +} + +-- 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 (0) { +} +object(DateTime)#%d (0) { +} + +-- unset var -- +object(DateTime)#%d (0) { +} +object(DateTime)#%d (0) { +} + +-- resource -- +FAILED: DateTime::__construct() expects parameter 1 to be string, resource given +FAILED: DateTime::__construct() expects parameter 1 to be string, resource given +===DONE=== diff --git a/ext/date/tests/DateTime_construct_variation2.phpt b/ext/date/tests/DateTime_construct_variation2.phpt new file mode 100644 index 0000000000..5f754ecc02 --- /dev/null +++ b/ext/date/tests/DateTime_construct_variation2.phpt @@ -0,0 +1,204 @@ +--TEST-- +Test new DateTime() function : usage variation - Passing unexpected values to second argument $timezone. +--FILE-- + 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=== + diff --git a/ext/date/tests/DateTime_extends_basic1.phpt b/ext/date/tests/DateTime_extends_basic1.phpt new file mode 100644 index 0000000000..8fe53d69f8 --- /dev/null +++ b/ext/date/tests/DateTime_extends_basic1.phpt @@ -0,0 +1,49 @@ +--TEST-- +Test DateTime class inheritance +--FILE-- +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=== diff --git a/ext/date/tests/DateTime_extends_basic2.phpt b/ext/date/tests/DateTime_extends_basic2.phpt new file mode 100644 index 0000000000..0ea865c6bc --- /dev/null +++ b/ext/date/tests/DateTime_extends_basic2.phpt @@ -0,0 +1,31 @@ +--TEST-- +Test DateTime class inheritance : with user space __construct magic method +--FILE-- +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=== diff --git a/ext/date/tests/DateTime_extends_basic3.phpt b/ext/date/tests/DateTime_extends_basic3.phpt new file mode 100644 index 0000000000..bee395aa96 --- /dev/null +++ b/ext/date/tests/DateTime_extends_basic3.phpt @@ -0,0 +1,26 @@ +--TEST-- +Test DateTime class inheritance : with user space fromat() method +--FILE-- +format() . "\n"; + +?> +===DONE=== +--EXPECTF-- +*** Testing new DateTime() : with user format() method *** +May 1, 1967, 10:30:41 pm +===DONE=== diff --git a/ext/date/tests/DateTime_format_basic1.phpt b/ext/date/tests/DateTime_format_basic1.phpt new file mode 100644 index 0000000000..b5bbecfc03 --- /dev/null +++ b/ext/date/tests/DateTime_format_basic1.phpt @@ -0,0 +1,40 @@ +--TEST-- +Test DateTime::format() function : basic functionality +--FILE-- +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 diff --git a/ext/date/tests/DateTime_format_basic2.phpt b/ext/date/tests/DateTime_format_basic2.phpt new file mode 100644 index 0000000000..d7adaa5df8 --- /dev/null +++ b/ext/date/tests/DateTime_format_basic2.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test date_format() function : basic functionality +--FILE-- +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=== diff --git a/ext/date/tests/DateTime_format_error.phpt b/ext/date/tests/DateTime_format_error.phpt new file mode 100644 index 0000000000..db1be92290 --- /dev/null +++ b/ext/date/tests/DateTime_format_error.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test DateTime::format() function : error conditions +--FILE-- +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=== diff --git a/ext/date/tests/DateTime_format_variation1.phpt b/ext/date/tests/DateTime_format_variation1.phpt new file mode 100644 index 0000000000..87a99220a6 --- /dev/null +++ b/ext/date/tests/DateTime_format_variation1.phpt @@ -0,0 +1,208 @@ +--TEST-- +Test DateTime::format() function : usage variation - Passing unexpected values to first argument $format. +--FILE-- + 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=== diff --git a/ext/date/tests/DateTime_getOffset_basic1.phpt b/ext/date/tests/DateTime_getOffset_basic1.phpt new file mode 100644 index 0000000000..41b1a78d75 --- /dev/null +++ b/ext/date/tests/DateTime_getOffset_basic1.phpt @@ -0,0 +1,28 @@ +--TEST-- +Test DateTime::getOffset() function : basic functionality +--FILE-- +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=== diff --git a/ext/date/tests/DateTime_getOffset_error.phpt b/ext/date/tests/DateTime_getOffset_error.phpt new file mode 100644 index 0000000000..6e9c3f411d --- /dev/null +++ b/ext/date/tests/DateTime_getOffset_error.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test DateTime::getOffset() function : error conditions +--FILE-- +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=== + diff --git a/ext/date/tests/DateTime_getTimeZone_basic1.phpt b/ext/date/tests/DateTime_getTimeZone_basic1.phpt new file mode 100644 index 0000000000..ee8a0db9a3 --- /dev/null +++ b/ext/date/tests/DateTime_getTimeZone_basic1.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test DateTime::getTimezone() function : basic functionality +--FILE-- +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=== diff --git a/ext/date/tests/DateTime_modify_basic1.phpt b/ext/date/tests/DateTime_modify_basic1.phpt new file mode 100644 index 0000000000..052524d5a4 --- /dev/null +++ b/ext/date/tests/DateTime_modify_basic1.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test DateTime::modify() function : basic functionality +--FILE-- +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=== diff --git a/ext/date/tests/DateTime_modify_error.phpt b/ext/date/tests/DateTime_modify_error.phpt new file mode 100644 index 0000000000..bc4f2423f4 --- /dev/null +++ b/ext/date/tests/DateTime_modify_error.phpt @@ -0,0 +1,42 @@ +--TEST-- +Test DateTime::modify() function : error conditions +--FILE-- +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=== + diff --git a/ext/date/tests/DateTime_modify_variation1.phpt b/ext/date/tests/DateTime_modify_variation1.phpt new file mode 100644 index 0000000000..495a71778d --- /dev/null +++ b/ext/date/tests/DateTime_modify_variation1.phpt @@ -0,0 +1,208 @@ +--TEST-- +Test DateTime::modify() function : usage variation - Passing unexpected values to first argument $modify. +--FILE-- + 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 -- +NULL + +-- int 1 -- +NULL + +-- int 12345 -- +NULL + +-- int -12345 -- +NULL + +-- float 10.5 -- +NULL + +-- float -10.5 -- +NULL + +-- float .5 -- +NULL + +-- 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 -- +NULL + +-- lowercase null -- +NULL + +-- lowercase true -- +NULL + +-- lowercase false -- +NULL + +-- uppercase TRUE -- +NULL + +-- uppercase FALSE -- +NULL + +-- empty string DQ -- +NULL + +-- empty string SQ -- +NULL + +-- string DQ -- +NULL + +-- string SQ -- +NULL + +-- mixed case string -- +NULL + +-- heredoc -- +NULL + +-- instance of classWithToString -- +NULL + +-- instance of classWithoutToString -- + +Warning: DateTime::modify() expects parameter 1 to be string, object given in %s on line %d +bool(false) + +-- undefined var -- +NULL + +-- unset var -- +NULL + +-- resource -- + +Warning: DateTime::modify() expects parameter 1 to be string, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/DateTime_serialize.phpt b/ext/date/tests/DateTime_serialize.phpt new file mode 100644 index 0000000000..8bce70ce6a --- /dev/null +++ b/ext/date/tests/DateTime_serialize.phpt @@ -0,0 +1,29 @@ +--TEST-- +Test serialization of DateTime objects +--FILE-- +format( "F j, Y, g:i a") ); + +?> +===DONE=== +--EXPECTF-- +object(DateTime)#%d (0) { +} +string(19) "O:8:"DateTime":0:{}" +object(DateTime)#%d (0) { +} + +Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in %s on line %d +bool(false) +===DONE=== \ No newline at end of file diff --git a/ext/date/tests/DateTime_setDate_basic1.phpt b/ext/date/tests/DateTime_setDate_basic1.phpt new file mode 100644 index 0000000000..eec5d77a0b --- /dev/null +++ b/ext/date/tests/DateTime_setDate_basic1.phpt @@ -0,0 +1,30 @@ +--TEST-- +Test DateTime::setDate() function : basic functionality +--FILE-- +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 diff --git a/ext/date/tests/DateTime_setDate_error.phpt b/ext/date/tests/DateTime_setDate_error.phpt new file mode 100644 index 0000000000..c5e446253e --- /dev/null +++ b/ext/date/tests/DateTime_setDate_error.phpt @@ -0,0 +1,53 @@ +--TEST-- +Test DateTime::setDate() function : error conditions +--FILE-- +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=== diff --git a/ext/date/tests/DateTime_setDate_variation1.phpt b/ext/date/tests/DateTime_setDate_variation1.phpt new file mode 100644 index 0000000000..a84ccc6a97 --- /dev/null +++ b/ext/date/tests/DateTime_setDate_variation1.phpt @@ -0,0 +1,224 @@ +--TEST-- +Test DateTime::setDate() function : usage variation - Passing unexpected values to first argument $year. +--FILE-- + 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 -- +NULL + +-- int 1 -- +NULL + +-- int 12345 -- +NULL + +-- int -12345 -- +NULL + +-- float 10.5 -- +NULL + +-- float -10.5 -- +NULL + +-- float .5 -- +NULL + +-- 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 -- +NULL + +-- lowercase null -- +NULL + +-- lowercase true -- +NULL + +-- lowercase false -- +NULL + +-- uppercase TRUE -- +NULL + +-- uppercase FALSE -- +NULL + +-- 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 -- +NULL + +-- unset var -- +NULL + +-- resource -- + +Warning: DateTime::setDate() expects parameter 1 to be long, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/DateTime_setDate_variation2.phpt b/ext/date/tests/DateTime_setDate_variation2.phpt new file mode 100644 index 0000000000..656ee34990 --- /dev/null +++ b/ext/date/tests/DateTime_setDate_variation2.phpt @@ -0,0 +1,225 @@ +--TEST-- +Test DateTime::setDate() function : usage variation - Passing unexpected values to second argument $month. +--FILE-- + 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 -- +NULL + +-- int 1 -- +NULL + +-- int 12345 -- +NULL + +-- int -12345 -- +NULL + +-- float 10.5 -- +NULL + +-- float -10.5 -- +NULL + +-- float .5 -- +NULL + +-- 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 -- +NULL + +-- lowercase null -- +NULL + +-- lowercase true -- +NULL + +-- lowercase false -- +NULL + +-- uppercase TRUE -- +NULL + +-- uppercase FALSE -- +NULL + +-- 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 -- +NULL + +-- unset var -- +NULL + +-- resource -- + +Warning: DateTime::setDate() expects parameter 2 to be long, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/DateTime_setDate_variation3.phpt b/ext/date/tests/DateTime_setDate_variation3.phpt new file mode 100644 index 0000000000..ff313ad1c0 --- /dev/null +++ b/ext/date/tests/DateTime_setDate_variation3.phpt @@ -0,0 +1,224 @@ +--TEST-- +Test DateTime::setDate() function : usage variation - Passing unexpected values to third argument $day. +--FILE-- + 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 -- +NULL + +-- int 1 -- +NULL + +-- int 12345 -- +NULL + +-- int -12345 -- +NULL + +-- float 10.5 -- +NULL + +-- float -10.5 -- +NULL + +-- float .5 -- +NULL + +-- 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 -- +NULL + +-- lowercase null -- +NULL + +-- lowercase true -- +NULL + +-- lowercase false -- +NULL + +-- uppercase TRUE -- +NULL + +-- uppercase FALSE -- +NULL + +-- 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 -- +NULL + +-- unset var -- +NULL + +-- resource -- + +Warning: DateTime::setDate() expects parameter 3 to be long, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/DateTime_setISODate_basic1.phpt b/ext/date/tests/DateTime_setISODate_basic1.phpt new file mode 100644 index 0000000000..33d2624d38 --- /dev/null +++ b/ext/date/tests/DateTime_setISODate_basic1.phpt @@ -0,0 +1,38 @@ +--TEST-- +Test DateTime::setISODate() function : basic functionality +--FILE-- +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=== diff --git a/ext/date/tests/DateTime_setISODate_error.phpt b/ext/date/tests/DateTime_setISODate_error.phpt new file mode 100644 index 0000000000..a218dbc8f9 --- /dev/null +++ b/ext/date/tests/DateTime_setISODate_error.phpt @@ -0,0 +1,51 @@ +--TEST-- +Test DateTime::setISODate () function : error conditions +--FILE-- +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=== diff --git a/ext/date/tests/DateTime_setISODate_variation1.phpt b/ext/date/tests/DateTime_setISODate_variation1.phpt new file mode 100644 index 0000000000..0e738b49d6 --- /dev/null +++ b/ext/date/tests/DateTime_setISODate_variation1.phpt @@ -0,0 +1,224 @@ +--TEST-- +Test DateTime::setISODate() function : usage variation - Passing unexpected values to first argument $year. +--FILE-- + 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 -- +NULL + +-- int 1 -- +NULL + +-- int 12345 -- +NULL + +-- int -12345 -- +NULL + +-- float 10.5 -- +NULL + +-- float -10.5 -- +NULL + +-- float .5 -- +NULL + +-- 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 -- +NULL + +-- lowercase null -- +NULL + +-- lowercase true -- +NULL + +-- lowercase false -- +NULL + +-- uppercase TRUE -- +NULL + +-- uppercase FALSE -- +NULL + +-- 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 -- +NULL + +-- unset var -- +NULL + +-- resource -- + +Warning: DateTime::setISODate() expects parameter 1 to be long, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/DateTime_setISODate_variation2.phpt b/ext/date/tests/DateTime_setISODate_variation2.phpt new file mode 100644 index 0000000000..95aadd6531 --- /dev/null +++ b/ext/date/tests/DateTime_setISODate_variation2.phpt @@ -0,0 +1,224 @@ +--TEST-- +Test DateTime::setISODate() function : usage variation - Passing unexpected values to second argument $week. +--FILE-- + 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 -- +NULL + +-- int 1 -- +NULL + +-- int 12345 -- +NULL + +-- int -12345 -- +NULL + +-- float 10.5 -- +NULL + +-- float -10.5 -- +NULL + +-- float .5 -- +NULL + +-- 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 -- +NULL + +-- lowercase null -- +NULL + +-- lowercase true -- +NULL + +-- lowercase false -- +NULL + +-- uppercase TRUE -- +NULL + +-- uppercase FALSE -- +NULL + +-- 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 -- +NULL + +-- unset var -- +NULL + +-- resource -- + +Warning: DateTime::setISODate() expects parameter 2 to be long, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/DateTime_setISODate_variation3.phpt b/ext/date/tests/DateTime_setISODate_variation3.phpt new file mode 100644 index 0000000000..ef2188772c --- /dev/null +++ b/ext/date/tests/DateTime_setISODate_variation3.phpt @@ -0,0 +1,224 @@ +--TEST-- +Test DateTime::setISODate() function : usage variation - Passing unexpected values to third argument $day. +--FILE-- + 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 -- +NULL + +-- int 1 -- +NULL + +-- int 12345 -- +NULL + +-- int -12345 -- +NULL + +-- float 10.5 -- +NULL + +-- float -10.5 -- +NULL + +-- float .5 -- +NULL + +-- 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 -- +NULL + +-- lowercase null -- +NULL + +-- lowercase true -- +NULL + +-- lowercase false -- +NULL + +-- uppercase TRUE -- +NULL + +-- uppercase FALSE -- +NULL + +-- 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 -- +NULL + +-- unset var -- +NULL + +-- resource -- + +Warning: DateTime::setISODate() expects parameter 3 to be long, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/DateTime_setTime_basic1.phpt b/ext/date/tests/DateTime_setTime_basic1.phpt new file mode 100644 index 0000000000..cac067b39e --- /dev/null +++ b/ext/date/tests/DateTime_setTime_basic1.phpt @@ -0,0 +1,46 @@ +--TEST-- +Test DateTime::setTime() function : basic functionality +--FILE-- +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=== diff --git a/ext/date/tests/DateTime_setTime_error.phpt b/ext/date/tests/DateTime_setTime_error.phpt new file mode 100644 index 0000000000..4438fce40e --- /dev/null +++ b/ext/date/tests/DateTime_setTime_error.phpt @@ -0,0 +1,49 @@ +--TEST-- +Test DateTime::setTime() function : error conditions +--FILE-- +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=== diff --git a/ext/date/tests/DateTime_setTime_variation1.phpt b/ext/date/tests/DateTime_setTime_variation1.phpt new file mode 100644 index 0000000000..c9b12590b1 --- /dev/null +++ b/ext/date/tests/DateTime_setTime_variation1.phpt @@ -0,0 +1,224 @@ +--TEST-- +Test DateTime::setTime() function : usage variation - Passing unexpected values to first argument $hour. +--FILE-- + 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 -- +NULL + +-- int 1 -- +NULL + +-- int 12345 -- +NULL + +-- int -12345 -- +NULL + +-- float 10.5 -- +NULL + +-- float -10.5 -- +NULL + +-- float .5 -- +NULL + +-- 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 -- +NULL + +-- lowercase null -- +NULL + +-- lowercase true -- +NULL + +-- lowercase false -- +NULL + +-- uppercase TRUE -- +NULL + +-- uppercase FALSE -- +NULL + +-- 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 -- +NULL + +-- unset var -- +NULL + +-- resource -- + +Warning: DateTime::setTime() expects parameter 1 to be long, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/DateTime_setTime_variation2.phpt b/ext/date/tests/DateTime_setTime_variation2.phpt new file mode 100644 index 0000000000..54c4cebdd7 --- /dev/null +++ b/ext/date/tests/DateTime_setTime_variation2.phpt @@ -0,0 +1,224 @@ +--TEST-- +Test DateTime::setTime() function : usage variation - Passing unexpected values to second argument $minute. +--FILE-- + 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 -- +NULL + +-- int 1 -- +NULL + +-- int 12345 -- +NULL + +-- int -12345 -- +NULL + +-- float 10.5 -- +NULL + +-- float -10.5 -- +NULL + +-- float .5 -- +NULL + +-- 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 -- +NULL + +-- lowercase null -- +NULL + +-- lowercase true -- +NULL + +-- lowercase false -- +NULL + +-- uppercase TRUE -- +NULL + +-- uppercase FALSE -- +NULL + +-- 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 -- +NULL + +-- unset var -- +NULL + +-- resource -- + +Warning: DateTime::setTime() expects parameter 2 to be long, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/DateTime_setTime_variation3.phpt b/ext/date/tests/DateTime_setTime_variation3.phpt new file mode 100644 index 0000000000..4266d3d721 --- /dev/null +++ b/ext/date/tests/DateTime_setTime_variation3.phpt @@ -0,0 +1,224 @@ +--TEST-- +Test DateTime::setTime() function : usage variation - Passing unexpected values to third argument $second. +--FILE-- + 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 -- +NULL + +-- int 1 -- +NULL + +-- int 12345 -- +NULL + +-- int -12345 -- +NULL + +-- float 10.5 -- +NULL + +-- float -10.5 -- +NULL + +-- float .5 -- +NULL + +-- 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 -- +NULL + +-- lowercase null -- +NULL + +-- lowercase true -- +NULL + +-- lowercase false -- +NULL + +-- uppercase TRUE -- +NULL + +-- uppercase FALSE -- +NULL + +-- 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 -- +NULL + +-- unset var -- +NULL + +-- resource -- + +Warning: DateTime::setTime() expects parameter 3 to be long, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/DateTime_setTimezone_basic1.phpt b/ext/date/tests/DateTime_setTimezone_basic1.phpt new file mode 100644 index 0000000000..f4f479fe04 --- /dev/null +++ b/ext/date/tests/DateTime_setTimezone_basic1.phpt @@ -0,0 +1,29 @@ +--TEST-- +Test DateTime::setTimezone() function : basic functionality +--FILE-- +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=== diff --git a/ext/date/tests/DateTime_setTimezone_error.phpt b/ext/date/tests/DateTime_setTimezone_error.phpt new file mode 100644 index 0000000000..32d03fbec9 --- /dev/null +++ b/ext/date/tests/DateTime_setTimezone_error.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test DateTime::setTimezone () function : error conditions +--FILE-- +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=== diff --git a/ext/date/tests/DateTime_setTimezone_variation1.phpt b/ext/date/tests/DateTime_setTimezone_variation1.phpt new file mode 100644 index 0000000000..9ccfce0b76 --- /dev/null +++ b/ext/date/tests/DateTime_setTimezone_variation1.phpt @@ -0,0 +1,252 @@ +--TEST-- +Test DateTime::setTimezone() function : usage variation - Passing unexpected values to first argument $timezone. +--FILE-- + 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=== diff --git a/ext/date/tests/DateTime_verify.phpt b/ext/date/tests/DateTime_verify.phpt new file mode 100644 index 0000000000..c99a6680e8 --- /dev/null +++ b/ext/date/tests/DateTime_verify.phpt @@ -0,0 +1,120 @@ +--TEST-- +Test DateTime class registration +--FILE-- +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(9) { + [0]=> + &object(ReflectionMethod)#%d (2) { + ["name"]=> + string(11) "__construct" + ["class"]=> + string(8) "DateTime" + } + [1]=> + &object(ReflectionMethod)#%d (2) { + ["name"]=> + string(6) "format" + ["class"]=> + string(8) "DateTime" + } + [2]=> + &object(ReflectionMethod)#%d (2) { + ["name"]=> + string(6) "modify" + ["class"]=> + string(8) "DateTime" + } + [3]=> + &object(ReflectionMethod)#%d (2) { + ["name"]=> + string(11) "getTimezone" + ["class"]=> + string(8) "DateTime" + } + [4]=> + &object(ReflectionMethod)#%d (2) { + ["name"]=> + string(11) "setTimezone" + ["class"]=> + string(8) "DateTime" + } + [5]=> + &object(ReflectionMethod)#%d (2) { + ["name"]=> + string(9) "getOffset" + ["class"]=> + string(8) "DateTime" + } + [6]=> + &object(ReflectionMethod)#%d (2) { + ["name"]=> + string(7) "setTime" + ["class"]=> + string(8) "DateTime" + } + [7]=> + &object(ReflectionMethod)#%d (2) { + ["name"]=> + string(7) "setDate" + ["class"]=> + string(8) "DateTime" + } + [8]=> + &object(ReflectionMethod)#%d (2) { + ["name"]=> + string(10) "setISODate" + ["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=== -- 2.50.1