diff options
83 files changed, 14258 insertions, 0 deletions
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-- +<?php +/* Prototype : public string DateTime::format ( string $format ) + * Description: Returns date formatted according to given format + * Source code: ext/date/php_date.c + * Alias to functions: date_format + */ + +echo "*** Testing DateTime::format() : usage variation - unexpected values to first argument \$format***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -12345, + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + // resource + 'resource' => $file_handle +); + +$object = new DateTime("2005-07-14 22:30:41"); + +foreach($inputs as $variation =>$format) { + echo "\n-- $variation --\n"; + var_dump( $object->format($format) ); +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing DateTime::format() : usage variation - unexpected values to first argument $format*** + +-- int 0 -- +string(1) "0" + +-- int 1 -- +string(1) "1" + +-- int 12345 -- +string(5) "12345" + +-- int -12345 -- +string(6) "-12345" + +-- float 10.5 -- +string(4) "10.5" + +-- float -10.5 -- +string(5) "-10.5" + +-- float .5 -- +string(3) "0.5" + +-- empty array -- + +Warning: DateTime::format() expects parameter 1 to be string, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: DateTime::format() expects parameter 1 to be string, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: DateTime::format() expects parameter 1 to be string, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: DateTime::format() expects parameter 1 to be string, array given in %s on line %d +bool(false) + +-- uppercase NULL -- +string(0) "" + +-- lowercase null -- +string(0) "" + +-- lowercase true -- +string(1) "1" + +-- lowercase false -- +string(0) "" + +-- uppercase TRUE -- +string(1) "1" + +-- uppercase FALSE -- +string(0) "" + +-- empty string DQ -- +string(0) "" + +-- empty string SQ -- +string(0) "" + +-- string DQ -- +string(40) "4131Thu, 14 Jul 2005 22:30:41 +010030710" + +-- string SQ -- +string(40) "4131Thu, 14 Jul 2005 22:30:41 +010030710" + +-- mixed case string -- +string(40) "41BSTThu, 14 Jul 2005 22:30:41 +01001722" + +-- heredoc -- +string(82) "10Europe/LondonThursdayThursday2005 42005Thu, 14 Jul 2005 22:30:41 +0100Thursday14" + +-- instance of classWithToString -- +string(66) "CThursdaypm4141 PM 2005b14Europe/London2005-07-14T22:30:41+01:0031" + +-- instance of classWithoutToString -- + +Warning: DateTime::format() expects parameter 1 to be string, object given in %s on line %d +bool(false) + +-- undefined var -- +string(0) "" + +-- unset var -- +string(0) "" + +-- resource -- + +Warning: DateTime::format() expects parameter 1 to be string, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/checkdate_basic1.phpt b/ext/date/tests/checkdate_basic1.phpt new file mode 100644 index 0000000000..2937f29a8e --- /dev/null +++ b/ext/date/tests/checkdate_basic1.phpt @@ -0,0 +1,54 @@ +--TEST-- +Test date_create() function : basic functionality +--FILE-- +<?php +/* Prototype : bool checkdate ( int $month , int $day , int $year ) + * Description: Checks the validity of the date formed by the arguments. + * A date is considered valid if each parameter is properly defined. + * Source code: ext/date/php_date.c + */ + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +echo "*** Testing checkdate() : basic functionality ***\n"; + +echo "-- The following are all valid dates --\n"; +var_dump( checkdate(1, 1, 2009) ); +var_dump( checkdate(12, 31, 2009) ); +var_dump( checkdate(7, 2, 1963) ); +var_dump( checkdate(5, 31, 2009) ); +var_dump( checkdate(2, 28, 2009) ); // non-leap year +var_dump( checkdate(2, 29, 2008) ); // leap year +var_dump( checkdate(7, 2, 1) ); // min year +var_dump( checkdate(7, 2, 32767) ); // max year + +echo "-- The following are all invalid dates --\n"; +var_dump( checkdate(13, 1, 2009) ); +var_dump( checkdate(2, 31, 2009) ); +var_dump( checkdate(1, 32, 2009) ); +var_dump( checkdate(2, 29, 2009) ); // non-leap year +var_dump( checkdate(7, 2, 32768) ); // >max year +var_dump( checkdate(7, 2, 0) ); // <min year + +?> +===DONE=== +--EXPECT-- +*** Testing checkdate() : basic functionality *** +-- The following are all valid dates -- +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +-- The following are all invalid dates -- +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +===DONE=== diff --git a/ext/date/tests/checkdate_error.phpt b/ext/date/tests/checkdate_error.phpt new file mode 100644 index 0000000000..4546408304 --- /dev/null +++ b/ext/date/tests/checkdate_error.phpt @@ -0,0 +1,49 @@ +--TEST-- +Test checkdate() function : error conditions +--FILE-- +<?php +/* Prototype : bool checkdate ( int $month , int $day , int $year ) + * Description: Validate a Gregorian date + * Source code: ext/date/php_date.c + * Alias to functions: + */ + +echo "*** Testing checkdate() : error conditions ***\n"; + +//Set the default time zone +date_default_timezone_set("America/Chicago"); + +$arg_0 = 1; +$arg_1 = 1; +$arg_2 = 1; +$extra_arg = 1; + +echo "\n-- Testing checkdate() function with more than expected no. of arguments --\n"; +var_dump (checkdate($arg_0, $arg_1, $arg_2, $extra_arg)); + +echo "\n-- Testing checkdate() function with less than expected no. of arguments --\n"; +var_dump (checkdate()); +var_dump (checkdate($arg_0)); +var_dump (checkdate($arg_0, $arg_1)); + +?> +===DONE=== +--EXPECTF-- +*** Testing checkdate() : error conditions *** + +-- Testing checkdate() function with more than expected no. of arguments -- + +Warning: checkdate() expects exactly 3 parameters, 4 given in %s on line %d +bool(false) + +-- Testing checkdate() function with less than expected no. of arguments -- + +Warning: checkdate() expects exactly 3 parameters, 0 given in %s on line %d +bool(false) + +Warning: checkdate() expects exactly 3 parameters, 1 given in %s on line %d +bool(false) + +Warning: checkdate() expects exactly 3 parameters, 2 given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/checkdate_variation1.phpt b/ext/date/tests/checkdate_variation1.phpt new file mode 100644 index 0000000000..0c83fa391e --- /dev/null +++ b/ext/date/tests/checkdate_variation1.phpt @@ -0,0 +1,201 @@ +--TEST-- +Test checkdate() function : usage variation - Passing unexpected values to first argument $month. +--FILE-- +<?php +/* Prototype : bool checkdate ( int $month , int $day , int $year ) + * Description: Checks the validity of the date formed by the arguments. + * A date is considered valid if each parameter is properly defined. + * Source code: ext/date/php_date.c + */ + +echo "*** Testing checkdate() : usage variation - unexpected values to first argument \$month***\n"; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + // 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 +); + +$day = 2; +$year = 1963; + +foreach($inputs as $variation =>$month) { + echo "\n-- $variation --\n"; + var_dump( checkdate($month, $day, $year) ); +}; + +// closing the resource +fclose( $file_handle); + +?> +===DONE=== +--EXPECTF-- +*** Testing checkdate() : usage variation - unexpected values to first argument $month*** + +-- float 10.5 -- +bool(true) + +-- float -10.5 -- +bool(false) + +-- float .5 -- +bool(false) + +-- empty array -- + +Warning: checkdate() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: checkdate() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: checkdate() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: checkdate() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +-- uppercase NULL -- +bool(false) + +-- lowercase null -- +bool(false) + +-- lowercase true -- +bool(true) + +-- lowercase false -- +bool(false) + +-- uppercase TRUE -- +bool(true) + +-- uppercase FALSE -- +bool(false) + +-- empty string DQ -- + +Warning: checkdate() expects parameter 1 to be long, Unicode string given in %s on line %d +bool(false) + +-- empty string SQ -- + +Warning: checkdate() expects parameter 1 to be long, Unicode string given in %s on line %d +bool(false) + +-- string DQ -- + +Warning: checkdate() expects parameter 1 to be long, Unicode string given in %s on line %d +bool(false) + +-- string SQ -- + +Warning: checkdate() expects parameter 1 to be long, Unicode string given in %s on line %d +bool(false) + +-- mixed case string -- + +Warning: checkdate() expects parameter 1 to be long, Unicode string given in %s on line %d +bool(false) + +-- heredoc -- + +Warning: checkdate() expects parameter 1 to be long, Unicode string given in %s on line %d +bool(false) + +-- instance of classWithToString -- + +Warning: checkdate() expects parameter 1 to be long, object given in %s on line %d +bool(false) + +-- instance of classWithoutToString -- + +Warning: checkdate() expects parameter 1 to be long, object given in %s on line %d +bool(false) + +-- undefined var -- +bool(false) + +-- unset var -- +bool(false) + +-- resource -- + +Warning: checkdate() expects parameter 1 to be long, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/checkdate_variation2.phpt b/ext/date/tests/checkdate_variation2.phpt new file mode 100644 index 0000000000..626852879e --- /dev/null +++ b/ext/date/tests/checkdate_variation2.phpt @@ -0,0 +1,201 @@ +--TEST-- +Test checkdate() function : usage variation - Passing unexpected values to second argument $day. +--FILE-- +<?php +/* Prototype : bool checkdate ( int $month , int $day , int $year ) + * Description: Checks the validity of the date formed by the arguments. + * A date is considered valid if each parameter is properly defined. + * Source code: ext/date/php_date.c + */ + +echo "*** Testing checkdate() : usage variation - unexpected values to second argument \$day***\n"; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + // 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 +); + +$month = 7; +$year = 1963; + +foreach($inputs as $variation =>$day) { + echo "\n-- $variation --\n"; + var_dump( checkdate($month, $day, $year) ); +}; + +// closing the resource +fclose( $file_handle); + +?> +===DONE=== +--EXPECTF-- +*** Testing checkdate() : usage variation - unexpected values to second argument $day*** + +-- float 10.5 -- +bool(true) + +-- float -10.5 -- +bool(false) + +-- float .5 -- +bool(false) + +-- empty array -- + +Warning: checkdate() expects parameter 2 to be long, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: checkdate() expects parameter 2 to be long, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: checkdate() expects parameter 2 to be long, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: checkdate() expects parameter 2 to be long, array given in %s on line %d +bool(false) + +-- uppercase NULL -- +bool(false) + +-- lowercase null -- +bool(false) + +-- lowercase true -- +bool(true) + +-- lowercase false -- +bool(false) + +-- uppercase TRUE -- +bool(true) + +-- uppercase FALSE -- +bool(false) + +-- empty string DQ -- + +Warning: checkdate() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- empty string SQ -- + +Warning: checkdate() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- string DQ -- + +Warning: checkdate() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- string SQ -- + +Warning: checkdate() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- mixed case string -- + +Warning: checkdate() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- heredoc -- + +Warning: checkdate() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- instance of classWithToString -- + +Warning: checkdate() expects parameter 2 to be long, object given in %s on line %d +bool(false) + +-- instance of classWithoutToString -- + +Warning: checkdate() expects parameter 2 to be long, object given in %s on line %d +bool(false) + +-- undefined var -- +bool(false) + +-- unset var -- +bool(false) + +-- resource -- + +Warning: checkdate() expects parameter 2 to be long, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/checkdate_variation3.phpt b/ext/date/tests/checkdate_variation3.phpt new file mode 100644 index 0000000000..091e02215b --- /dev/null +++ b/ext/date/tests/checkdate_variation3.phpt @@ -0,0 +1,201 @@ +--TEST-- +Test checkdate() function : usage variation - Passing unexpected values to third argument $year. +--FILE-- +<?php +/* Prototype : bool checkdate ( int $month , int $day , int $year ) + * Description: Checks the validity of the date formed by the arguments. + * A date is considered valid if each parameter is properly defined. + * Source code: ext/date/php_date.c + */ + +echo "*** Testing checkdate() : usage variation - unexpected values to third argument \$year***\n"; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + // 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 +); + +$day = 2; +$month = 7; + +foreach($inputs as $variation =>$year) { + echo "\n-- $variation --\n"; + var_dump( checkdate($month, $day, $year) ); +}; + +// closing the resource +fclose( $file_handle); + +?> +===DONE=== +--EXPECTF-- +*** Testing checkdate() : usage variation - unexpected values to third argument $year*** + +-- float 10.5 -- +bool(true) + +-- float -10.5 -- +bool(false) + +-- float .5 -- +bool(false) + +-- empty array -- + +Warning: checkdate() expects parameter 3 to be long, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: checkdate() expects parameter 3 to be long, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: checkdate() expects parameter 3 to be long, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: checkdate() expects parameter 3 to be long, array given in %s on line %d +bool(false) + +-- uppercase NULL -- +bool(false) + +-- lowercase null -- +bool(false) + +-- lowercase true -- +bool(true) + +-- lowercase false -- +bool(false) + +-- uppercase TRUE -- +bool(true) + +-- uppercase FALSE -- +bool(false) + +-- empty string DQ -- + +Warning: checkdate() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- empty string SQ -- + +Warning: checkdate() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- string DQ -- + +Warning: checkdate() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- string SQ -- + +Warning: checkdate() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- mixed case string -- + +Warning: checkdate() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- heredoc -- + +Warning: checkdate() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- instance of classWithToString -- + +Warning: checkdate() expects parameter 3 to be long, object given in %s on line %d +bool(false) + +-- instance of classWithoutToString -- + +Warning: checkdate() expects parameter 3 to be long, object given in %s on line %d +bool(false) + +-- undefined var -- +bool(false) + +-- unset var -- +bool(false) + +-- resource -- + +Warning: checkdate() expects parameter 3 to be long, resource given in %s on line %d +bool(false) +===DONE===
\ No newline at end of file diff --git a/ext/date/tests/date_basic1.phpt b/ext/date/tests/date_basic1.phpt new file mode 100644 index 0000000000..45af1fef76 --- /dev/null +++ b/ext/date/tests/date_basic1.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test date() function : basic functionality +--FILE-- +<?php +/* Prototype : string date ( string $format [, int $timestamp ] ) + * Description: Format a local time/date. + * Source code: ext/date/php_date.c + */ + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +echo "*** Testing date() : basic functionality ***\n"; + +$timestamp = mktime(10, 44, 30, 2, 27, 2009); + +var_dump( date("F j, Y, g:i a", $timestamp) ); +var_dump( date("m.d.y", $timestamp) ); +var_dump( date("j, n, Y", $timestamp) ); +var_dump( date("Ymd", $timestamp) ); +var_dump( date('h-i-s, j-m-y, it is w Day', $timestamp) ); +var_dump( date('\i\t \i\s \t\h\e jS \d\a\y.', $timestamp) ); +var_dump( date("D M j G:i:s T Y", $timestamp) ); +var_dump( date('H:m:s \m \i\s\ \m\o\n\t\h', $timestamp) ); +var_dump( date("H:i:s", $timestamp) ); + +?> +===DONE=== +--EXPECT-- +*** Testing date() : basic functionality *** +unicode(27) "February 27, 2009, 10:44 am" +unicode(8) "02.27.09" +unicode(11) "27, 2, 2009" +unicode(8) "20090227" +unicode(39) "10-44-30, 27-02-09, 4428 4430 5 Friam09" +unicode(19) "it is the 27th day." +unicode(28) "Fri Feb 27 10:44:30 GMT 2009" +unicode(19) "10:02:30 m is month" +unicode(8) "10:44:30" +===DONE=== + diff --git a/ext/date/tests/date_create_basic.phpt b/ext/date/tests/date_create_basic.phpt new file mode 100644 index 0000000000..8a250cbb64 --- /dev/null +++ b/ext/date/tests/date_create_basic.phpt @@ -0,0 +1,58 @@ +--TEST-- +Test date_create() function : basic functionality +--FILE-- +<?php +/* Prototype : DateTime date_create ([ string $time [, DateTimeZone $timezone ]] ) + * Description: Returns new DateTime object + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::__construct + */ + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +echo "*** Testing date_create() : basic functionality ***\n"; + +var_dump( date_create() ); + +var_dump( date_create("GMT") ); +var_dump( date_create("2005-07-14 22:30:41") ); +var_dump( date_create("2005-07-14 22:30:41 GMT") ); + +?> +===DONE=== +--EXPECTF-- +*** Testing date_create() : basic functionality *** +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "%s" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "%s" + [u"timezone_type"]=> + int(2) + [u"timezone"]=> + unicode(3) "GMT" +} +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2005-07-14 22:30:41" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2005-07-14 22:30:41" + [u"timezone_type"]=> + int(2) + [u"timezone"]=> + unicode(3) "GMT" +} +===DONE===
\ No newline at end of file diff --git a/ext/date/tests/date_create_error.phpt b/ext/date/tests/date_create_error.phpt new file mode 100644 index 0000000000..0a42f28810 --- /dev/null +++ b/ext/date/tests/date_create_error.phpt @@ -0,0 +1,28 @@ +--TEST-- +Test date_create() function : error conditions +--FILE-- +<?php +/* Prototype : DateTime date_create ([ string $time [, DateTimeZone $timezone ]] ) + * Description: Returns new DateTime object + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::__construct + */ + +echo "*** Testing date_create() : error conditions ***\n"; + +echo "\n-- Testing date_create() function with more than expected no. of arguments --\n"; +$time = "GMT"; +$timezone = timezone_open("GMT"); +$extra_arg = 99; +var_dump( date_create($time, $timezone, $extra_arg) ); + +?> +===DONE=== +--EXPECTF-- +*** Testing date_create() : error conditions *** + +-- Testing date_create() function with more than expected no. of arguments -- + +Warning: date_create() expects at most 2 parameters, 3 given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/date_create_variation1.phpt b/ext/date/tests/date_create_variation1.phpt new file mode 100644 index 0000000000..36ffa15b53 --- /dev/null +++ b/ext/date/tests/date_create_variation1.phpt @@ -0,0 +1,389 @@ +--TEST-- +Test date_create() function : usage variation - Passing unexpected values to first argument $time. +--FILE-- +<?php +/* Prototype : DateTime date_create ([ string $time [, DateTimeZone $timezone ]] ) + * Description: Returns new DateTime object + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::__construct + */ + +echo "*** Testing date_create() : usage variation - unexpected values to first argument \$time***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -12345, + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + // resource + 'resource' => $file_handle +); + +$timezone = new DateTimeZone("Europe/London"); + +foreach($inputs as $variation =>$time) { + echo "\n-- $variation --\n"; + var_dump( date_create($time) ); + var_dump( date_create($time, $timezone) ); +}; + +// closing the resource +fclose( $file_handle); + +?> +===DONE=== +--EXPECTF-- +*** Testing date_create() : usage variation - unexpected values to first argument $time*** + +-- int 0 -- +bool(false) +bool(false) + +-- int 1 -- +bool(false) +bool(false) + +-- int 12345 -- +bool(false) +bool(false) + +-- int -12345 -- +bool(false) +bool(false) + +-- float 10.5 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "%s" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "%s" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- float -10.5 -- +bool(false) +bool(false) + +-- float .5 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "%s" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "%s" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- empty array -- + +Warning: date_create() expects parameter 1 to be binary string, array given in %s on line %d +bool(false) + +Warning: date_create() expects parameter 1 to be binary string, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: date_create() expects parameter 1 to be binary string, array given in %s on line %d +bool(false) + +Warning: date_create() expects parameter 1 to be binary string, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: date_create() expects parameter 1 to be binary string, array given in %s on line %d +bool(false) + +Warning: date_create() expects parameter 1 to be binary string, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: date_create() expects parameter 1 to be binary string, array given in %s on line %d +bool(false) + +Warning: date_create() expects parameter 1 to be binary string, array given in %s on line %d +bool(false) + +-- uppercase NULL -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "%s" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "%s" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- lowercase null -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "%s" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "%s" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- lowercase true -- +bool(false) +bool(false) + +-- lowercase false -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "%s" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "%s" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- uppercase TRUE -- +bool(false) +bool(false) + +-- uppercase FALSE -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "%s" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "%s" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- empty string DQ -- +object(DateTime)#18 (3) { + [u"date"]=> + unicode(19) "%s" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "%s" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- empty string SQ -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "%s" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "%s" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- string DQ -- +bool(false) +bool(false) + +-- string SQ -- +bool(false) +bool(false) + +-- mixed case string -- +bool(false) +bool(false) + +-- heredoc -- +bool(false) +bool(false) + +-- instance of classWithToString -- +bool(false) +bool(false) + +-- instance of classWithoutToString -- + +Warning: date_create() expects parameter 1 to be binary string, object given in %s on line %d +bool(false) + +Warning: date_create() expects parameter 1 to be binary string, object given in %s on line %d +bool(false) + +-- undefined var -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "%s" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "%s" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- unset var -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "%s" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "%s" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- resource -- + +Warning: date_create() expects parameter 1 to be binary string, resource given in %s on line %d +bool(false) + +Warning: date_create() expects parameter 1 to be binary string, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/date_create_variation2.phpt b/ext/date/tests/date_create_variation2.phpt new file mode 100644 index 0000000000..dceed873ac --- /dev/null +++ b/ext/date/tests/date_create_variation2.phpt @@ -0,0 +1,252 @@ +--TEST-- +Test date_create() function : usage variation - Passing unexpected values to second argument $timezone. +--FILE-- +<?php +/* Prototype : DateTime date_create ([ string $time [, DateTimeZone $timezone ]] ) + * Description: Returns new DateTime object + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::__construct + */ + +echo "*** Testing date_create() : usage variation - unexpected values to second argument \$timezone***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -12345, + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + // resource + 'resource' => $file_handle +); + +$time = "2005-07-14 22:30:41"; + +foreach($inputs as $variation =>$timezone) { + echo "\n-- $variation --\n"; + var_dump( date_create($time, $timezone) ); +}; + +// closing the resource +fclose( $file_handle); + +?> +===DONE=== +--EXPECTF-- +*** Testing date_create() : usage variation - unexpected values to second argument $timezone*** + +-- int 0 -- + +Warning: date_create() expects parameter 2 to be DateTimeZone, integer given in %s on line %d +bool(false) + +-- int 1 -- + +Warning: date_create() expects parameter 2 to be DateTimeZone, integer given in %s on line %d +bool(false) + +-- int 12345 -- + +Warning: date_create() expects parameter 2 to be DateTimeZone, integer given in %s on line %d +bool(false) + +-- int -12345 -- + +Warning: date_create() expects parameter 2 to be DateTimeZone, integer given in %s on line %d +bool(false) + +-- float 10.5 -- + +Warning: date_create() expects parameter 2 to be DateTimeZone, double given in %s on line %d +bool(false) + +-- float -10.5 -- + +Warning: date_create() expects parameter 2 to be DateTimeZone, double given in %s on line %d +bool(false) + +-- float .5 -- + +Warning: date_create() expects parameter 2 to be DateTimeZone, double given in %s on line %d +bool(false) + +-- empty array -- + +Warning: date_create() expects parameter 2 to be DateTimeZone, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: date_create() expects parameter 2 to be DateTimeZone, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: date_create() expects parameter 2 to be DateTimeZone, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: date_create() expects parameter 2 to be DateTimeZone, array given in %s on line %d +bool(false) + +-- uppercase NULL -- + +Warning: date_create() expects parameter 2 to be DateTimeZone, null given in %s on line %d +bool(false) + +-- lowercase null -- + +Warning: date_create() expects parameter 2 to be DateTimeZone, null given in %s on line %d +bool(false) + +-- lowercase true -- + +Warning: date_create() expects parameter 2 to be DateTimeZone, boolean given in %s on line %d +bool(false) + +-- lowercase false -- + +Warning: date_create() expects parameter 2 to be DateTimeZone, boolean given in %s on line %d +bool(false) + +-- uppercase TRUE -- + +Warning: date_create() expects parameter 2 to be DateTimeZone, boolean given in %s on line %d +bool(false) + +-- uppercase FALSE -- + +Warning: date_create() expects parameter 2 to be DateTimeZone, boolean given in %s on line %d +bool(false) + +-- empty string DQ -- + +Warning: date_create() expects parameter 2 to be DateTimeZone, Unicode string given in %s on line %d +bool(false) + +-- empty string SQ -- + +Warning: date_create() expects parameter 2 to be DateTimeZone, Unicode string given in %s on line %d +bool(false) + +-- string DQ -- + +Warning: date_create() expects parameter 2 to be DateTimeZone, Unicode string given in %s on line %d +bool(false) + +-- string SQ -- + +Warning: date_create() expects parameter 2 to be DateTimeZone, Unicode string given in %s on line %d +bool(false) + +-- mixed case string -- + +Warning: date_create() expects parameter 2 to be DateTimeZone, Unicode string given in %s on line %d +bool(false) + +-- heredoc -- + +Warning: date_create() expects parameter 2 to be DateTimeZone, Unicode string given in %s on line %d +bool(false) + +-- instance of classWithToString -- + +Warning: date_create() expects parameter 2 to be DateTimeZone, object given in %s on line %d +bool(false) + +-- instance of classWithoutToString -- + +Warning: date_create() expects parameter 2 to be DateTimeZone, object given in %s on line %d +bool(false) + +-- undefined var -- + +Warning: date_create() expects parameter 2 to be DateTimeZone, null given in %s on line %d +bool(false) + +-- unset var -- + +Warning: date_create() expects parameter 2 to be DateTimeZone, null given in %s on line %d +bool(false) + +-- resource -- + +Warning: date_create() expects parameter 2 to be DateTimeZone, resource given in %s on line %d +bool(false) +===DONE===
\ No newline at end of file diff --git a/ext/date/tests/date_date_set_basic1.phpt b/ext/date/tests/date_date_set_basic1.phpt new file mode 100644 index 0000000000..64802125f6 --- /dev/null +++ b/ext/date/tests/date_date_set_basic1.phpt @@ -0,0 +1,30 @@ +--TEST-- +Test date_date_set() function : basic functionality +--FILE-- +<?php +/* Prototype : DateTime date_date_set ( DateTime $object , int $year , int $month , int $day ) + * Description: Resets the current date of the DateTime object to a different date. + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::setDate + */ + + //Set the default time zone +date_default_timezone_set("Europe/London"); + +echo "*** Testing date_date_set() : basic functionality ***\n"; + +$datetime = date_create("2009-01-30 19:34:10"); + +echo date_format($datetime, DATE_RFC2822) . "\n"; + +date_date_set($datetime, 2008, 02, 01); + +echo date_format($datetime, DATE_RFC2822) . "\n"; + +?> +===DONE=== +--EXPECTF-- +*** Testing date_date_set() : basic functionality *** +Fri, 30 Jan 2009 19:34:10 +0000 +Fri, 01 Feb 2008 19:34:10 +0000 +===DONE=== diff --git a/ext/date/tests/date_date_set_error.phpt b/ext/date/tests/date_date_set_error.phpt new file mode 100644 index 0000000000..a44d36e34c --- /dev/null +++ b/ext/date/tests/date_date_set_error.phpt @@ -0,0 +1,56 @@ +--TEST-- +Test date_date_set() function : error conditions +--FILE-- +<?php +/* Prototype : DateTime date_date_set ( DateTime $object , int $year , int $month , int $day ) + * Description: Resets the current date of the DateTime object to a different date. + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::setDate + */ + +date_default_timezone_set("Europe/London"); + +echo "*** Testing date_date_set() : error conditions ***\n"; + +echo "\n-- Testing date_date_set() function with zero arguments --\n"; +var_dump( date_date_set() ); + +echo "\n-- Testing date_date_set() function with less than expected no. of arguments --\n"; +$datetime = date_create("2009-01-30 19:34:10"); +$year = 2009; +$month = 1; +$day = 30; +var_dump( date_date_set($datetime) ); +var_dump( date_date_set($datetime, $year) ); +var_dump( date_date_set($datetime, $year, $month) ); + +echo "\n-- Testing date_date_set() function with more than expected no. of arguments --\n"; +$extra_arg = 10; +var_dump( date_date_set($datetime, $year, $month, $day, $extra_arg) ); + +?> +===DONE=== +--EXPECTF-- +*** Testing date_date_set() : error conditions *** + +-- Testing date_date_set() function with zero arguments -- + +Warning: date_date_set() expects exactly 4 parameters, 0 given in %s on line %d +bool(false) + +-- Testing date_date_set() function with less than expected no. of arguments -- + +Warning: date_date_set() expects exactly 4 parameters, 1 given in %s on line %d +bool(false) + +Warning: date_date_set() expects exactly 4 parameters, 2 given in %s on line %d +bool(false) + +Warning: date_date_set() expects exactly 4 parameters, 3 given in %s on line %d +bool(false) + +-- Testing date_date_set() function with more than expected no. of arguments -- + +Warning: date_date_set() expects exactly 4 parameters, 5 given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/date_date_set_variation1.phpt b/ext/date/tests/date_date_set_variation1.phpt new file mode 100644 index 0000000000..f1a5d7517a --- /dev/null +++ b/ext/date/tests/date_date_set_variation1.phpt @@ -0,0 +1,254 @@ +--TEST-- +Test date_date_set() function : usage variation - Passing unexpected values to first argument $object. +--FILE-- +<?php +/* Prototype : DateTime date_date_set ( DateTime $object , int $year , int $month , int $day ) + * Description: Resets the current date of the DateTime object to a different date. + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::setDate + */ + +echo "*** Testing date_date_set() : usage variation - unexpected values to first argument \$object***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -12345, + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + // resource + 'resource' => $file_handle +); + +$day = 2; +$month = 7; +$year = 1963; + +foreach($inputs as $variation =>$object) { + echo "\n-- $variation --\n"; + var_dump( date_date_set($object, $year, $month, $day) ); +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing date_date_set() : usage variation - unexpected values to first argument $object*** + +-- int 0 -- + +Warning: date_date_set() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +-- int 1 -- + +Warning: date_date_set() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +-- int 12345 -- + +Warning: date_date_set() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +-- int -12345 -- + +Warning: date_date_set() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +-- float 10.5 -- + +Warning: date_date_set() expects parameter 1 to be DateTime, double given in %s on line %d +bool(false) + +-- float -10.5 -- + +Warning: date_date_set() expects parameter 1 to be DateTime, double given in %s on line %d +bool(false) + +-- float .5 -- + +Warning: date_date_set() expects parameter 1 to be DateTime, double given in %s on line %d +bool(false) + +-- empty array -- + +Warning: date_date_set() expects parameter 1 to be DateTime, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: date_date_set() expects parameter 1 to be DateTime, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: date_date_set() expects parameter 1 to be DateTime, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: date_date_set() expects parameter 1 to be DateTime, array given in %s on line %d +bool(false) + +-- uppercase NULL -- + +Warning: date_date_set() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) + +-- lowercase null -- + +Warning: date_date_set() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) + +-- lowercase true -- + +Warning: date_date_set() expects parameter 1 to be DateTime, boolean given in %s on line %d +bool(false) + +-- lowercase false -- + +Warning: date_date_set() expects parameter 1 to be DateTime, boolean given in %s on line %d +bool(false) + +-- uppercase TRUE -- + +Warning: date_date_set() expects parameter 1 to be DateTime, boolean given in %s on line %d +bool(false) + +-- uppercase FALSE -- + +Warning: date_date_set() expects parameter 1 to be DateTime, boolean given in %s on line %d +bool(false) + +-- empty string DQ -- + +Warning: date_date_set() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- empty string SQ -- + +Warning: date_date_set() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- string DQ -- + +Warning: date_date_set() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- string SQ -- + +Warning: date_date_set() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- mixed case string -- + +Warning: date_date_set() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- heredoc -- + +Warning: date_date_set() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- instance of classWithToString -- + +Warning: date_date_set() expects parameter 1 to be DateTime, object given in %s on line %d +bool(false) + +-- instance of classWithoutToString -- + +Warning: date_date_set() expects parameter 1 to be DateTime, object given in %s on line %d +bool(false) + +-- undefined var -- + +Warning: date_date_set() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) + +-- unset var -- + +Warning: date_date_set() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) + +-- resource -- + +Warning: date_date_set() expects parameter 1 to be DateTime, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/date_date_set_variation2.phpt b/ext/date/tests/date_date_set_variation2.phpt new file mode 100644 index 0000000000..4ace92f0d0 --- /dev/null +++ b/ext/date/tests/date_date_set_variation2.phpt @@ -0,0 +1,329 @@ +--TEST-- +Test date_date_set() function : usage variation - Passing unexpected values to second argument $year. +--FILE-- +<?php +/* Prototype : DateTime date_date_set ( DateTime $object , int $year , int $month , int $day ) + * Description: Resets the current date of the DateTime object to a different date. + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::setDate + */ + +echo "*** Testing date_date_set() : usage variation - unexpected values to second argument \$year***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -12345, + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + // resource + 'resource' => $file_handle +); + +$object = date_create("2009-02-27 08:34:10"); +$day = 2; +$month = 7; + +foreach($inputs as $variation =>$year) { + echo "\n-- $variation --\n"; + var_dump( date_date_set($object, $year, $month, $day) ); +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing date_date_set() : usage variation - unexpected values to second argument $year*** + +-- int 0 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "0000-07-02 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- int 1 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "0001-07-02 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- int 12345 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(20) "12345-07-02 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- int -12345 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(21) "-12345-07-02 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- float 10.5 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "0010-07-02 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- float -10.5 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(20) "-0010-07-02 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- float .5 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "0000-07-02 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- empty array -- + +Warning: date_date_set() expects parameter 2 to be long, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: date_date_set() expects parameter 2 to be long, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: date_date_set() expects parameter 2 to be long, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: date_date_set() expects parameter 2 to be long, array given in %s on line %d +bool(false) + +-- uppercase NULL -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "0000-07-02 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- lowercase null -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "0000-07-02 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- lowercase true -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "0001-07-02 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- lowercase false -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "0000-07-02 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- uppercase TRUE -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "0001-07-02 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- uppercase FALSE -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "0000-07-02 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- empty string DQ -- + +Warning: date_date_set() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- empty string SQ -- + +Warning: date_date_set() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- string DQ -- + +Warning: date_date_set() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- string SQ -- + +Warning: date_date_set() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- mixed case string -- + +Warning: date_date_set() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- heredoc -- + +Warning: date_date_set() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- instance of classWithToString -- + +Warning: date_date_set() expects parameter 2 to be long, object given in %s on line %d +bool(false) + +-- instance of classWithoutToString -- + +Warning: date_date_set() expects parameter 2 to be long, object given in %s on line %d +bool(false) + +-- undefined var -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "0000-07-02 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- unset var -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "0000-07-02 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- resource -- + +Warning: date_date_set() expects parameter 2 to be long, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/date_date_set_variation3.phpt b/ext/date/tests/date_date_set_variation3.phpt new file mode 100644 index 0000000000..dba2105c27 --- /dev/null +++ b/ext/date/tests/date_date_set_variation3.phpt @@ -0,0 +1,329 @@ +--TEST-- +Test date_date_set() function : usage variation - Passing unexpected values to third argument $month. +--FILE-- +<?php +/* Prototype : DateTime date_date_set ( DateTime $object , int $year , int $month , int $day ) + * Description: Resets the current date of the DateTime object to a different date. + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::setDate + */ + +echo "*** Testing date_date_set() : usage variation - unexpected values to third argument \$month***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -12345, + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + // resource + 'resource' => $file_handle +); + +$object = date_create("2009-02-27 08:34:10"); +$day = 2; +$year = 1963; + +foreach($inputs as $variation =>$month) { + echo "\n-- $variation --\n"; + var_dump( date_date_set($object, $year, $month, $day) ); +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing date_date_set() : usage variation - unexpected values to third argument $month*** + +-- int 0 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1962-12-02 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- int 1 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1963-01-02 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- int 12345 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2991-09-02 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- int -12345 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "0934-03-02 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- float 10.5 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1963-10-02 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- float -10.5 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1962-02-02 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- float .5 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1962-12-02 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- empty array -- + +Warning: date_date_set() expects parameter 3 to be long, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: date_date_set() expects parameter 3 to be long, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: date_date_set() expects parameter 3 to be long, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: date_date_set() expects parameter 3 to be long, array given in %s on line %d +bool(false) + +-- uppercase NULL -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1962-12-02 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- lowercase null -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1962-12-02 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- lowercase true -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1963-01-02 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- lowercase false -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1962-12-02 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- uppercase TRUE -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1963-01-02 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- uppercase FALSE -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1962-12-02 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- empty string DQ -- + +Warning: date_date_set() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- empty string SQ -- + +Warning: date_date_set() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- string DQ -- + +Warning: date_date_set() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- string SQ -- + +Warning: date_date_set() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- mixed case string -- + +Warning: date_date_set() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- heredoc -- + +Warning: date_date_set() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- instance of classWithToString -- + +Warning: date_date_set() expects parameter 3 to be long, object given in %s on line %d +bool(false) + +-- instance of classWithoutToString -- + +Warning: date_date_set() expects parameter 3 to be long, object given in %s on line %d +bool(false) + +-- undefined var -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1962-12-02 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- unset var -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1962-12-02 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- resource -- + +Warning: date_date_set() expects parameter 3 to be long, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/date_date_set_variation4.phpt b/ext/date/tests/date_date_set_variation4.phpt new file mode 100644 index 0000000000..a8a8ed7def --- /dev/null +++ b/ext/date/tests/date_date_set_variation4.phpt @@ -0,0 +1,329 @@ +--TEST-- +Test date_date_set() function : usage variation - Passing unexpected values to forth argument $day. +--FILE-- +<?php +/* Prototype : DateTime date_date_set ( DateTime $object , int $year , int $month , int $day ) + * Description: Resets the current date of the DateTime object to a different date. + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::setDate + */ + +echo "*** Testing date_date_set() : usage variation - unexpected values to forth argument \$day***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -12345, + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + // resource + 'resource' => $file_handle +); + +$object = date_create("2009-02-27 08:34:10"); +$month = 7; +$year = 1963; + +foreach($inputs as $variation =>$day) { + echo "\n-- $variation --\n"; + var_dump( date_date_set($object, $year, $month, $day) ); +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing date_date_set() : usage variation - unexpected values to forth argument $day*** + +-- int 0 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1963-06-30 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- int 1 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1963-07-01 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- int 12345 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1997-04-17 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- int -12345 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1929-09-11 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- float 10.5 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1963-07-10 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- float -10.5 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1963-06-20 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- float .5 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1963-06-30 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- empty array -- + +Warning: date_date_set() expects parameter 4 to be long, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: date_date_set() expects parameter 4 to be long, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: date_date_set() expects parameter 4 to be long, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: date_date_set() expects parameter 4 to be long, array given in %s on line %d +bool(false) + +-- uppercase NULL -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1963-06-30 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- lowercase null -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1963-06-30 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- lowercase true -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1963-07-01 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- lowercase false -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1963-06-30 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- uppercase TRUE -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1963-07-01 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- uppercase FALSE -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1963-06-30 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- empty string DQ -- + +Warning: date_date_set() expects parameter 4 to be long, Unicode string given in %s on line %d +bool(false) + +-- empty string SQ -- + +Warning: date_date_set() expects parameter 4 to be long, Unicode string given in %s on line %d +bool(false) + +-- string DQ -- + +Warning: date_date_set() expects parameter 4 to be long, Unicode string given in %s on line %d +bool(false) + +-- string SQ -- + +Warning: date_date_set() expects parameter 4 to be long, Unicode string given in %s on line %d +bool(false) + +-- mixed case string -- + +Warning: date_date_set() expects parameter 4 to be long, Unicode string given in %s on line %d +bool(false) + +-- heredoc -- + +Warning: date_date_set() expects parameter 4 to be long, Unicode string given in %s on line %d +bool(false) + +-- instance of classWithToString -- + +Warning: date_date_set() expects parameter 4 to be long, object given in %s on line %d +bool(false) + +-- instance of classWithoutToString -- + +Warning: date_date_set() expects parameter 4 to be long, object given in %s on line %d +bool(false) + +-- undefined var -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1963-06-30 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- unset var -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1963-06-30 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- resource -- + +Warning: date_date_set() expects parameter 4 to be long, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/date_error.phpt b/ext/date/tests/date_error.phpt new file mode 100644 index 0000000000..9856a35f65 --- /dev/null +++ b/ext/date/tests/date_error.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test date() function : error conditions +--FILE-- +<?php +/* Prototype : string date ( string $format [, int $timestamp ] ) + * Description: Format a local time/date. + * Source code: ext/date/php_date.c + */ + +echo "*** Testing date() : error conditions ***\n"; + +//Set the default time zone +date_default_timezone_set("America/Chicago"); + +$format = "m.d.y"; +$timestamp = mktime(10, 44, 30, 2, 27, 2009); + +echo "\n-- Testing date function with no arguments --\n"; +var_dump (date()); + +echo "\n-- Testing date function with more than expected no. of arguments --\n"; +$extra_arg = true; +var_dump (checkdate($format, $timestamp, $extra_arg)); + +?> +===DONE=== +--EXPECTF-- +*** Testing date() : error conditions *** + +-- Testing date function with no arguments -- + +Warning: date() expects at least 1 parameter, 0 given in %s on line %d +bool(false) + +-- Testing date function with more than expected no. of arguments -- + +Warning: checkdate() expects parameter 1 to be long, Unicode string given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/date_format_basic1.phpt b/ext/date/tests/date_format_basic1.phpt new file mode 100644 index 0000000000..c5bb7dcd37 --- /dev/null +++ b/ext/date/tests/date_format_basic1.phpt @@ -0,0 +1,40 @@ +--TEST-- +Test date_format() function : basic functionality +--FILE-- +<?php +/* Prototype : unicode date_format ( DateTime $object , unicode $format ) + * Description: Returns date formatted according to given format + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::format + */ + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +echo "*** Testing date_format() : basic functionality ***\n"; +$date = date_create("2005-07-14 22:30:41"); + +var_dump( date_format($date, "F j, Y, g:i a") ); +var_dump( date_format($date, "m.d.y") ); +var_dump( date_format($date, "j, n, Y") ); +var_dump( date_format($date, "Ymd") ); +var_dump( date_format($date, 'h-i-s, j-m-y, it is w Day') ); +var_dump( date_format($date, '\i\t \i\s \t\h\e jS \d\a\y.') ); +var_dump( date_format($date, "D M j G:i:s T Y") ); +var_dump( date_format($date, 'H:m:s \m \i\s\ \m\o\n\t\h') ); +var_dump( date_format($date, "H:i:s") ); + +?> +===DONE=== +--EXPECTF-- +*** Testing date_format() : basic functionality *** +unicode(23) "July 14, 2005, 10:30 pm" +unicode(8) "07.14.05" +unicode(11) "14, 7, 2005" +unicode(8) "20050714" +unicode(39) "10-30-41, 14-07-05, 3031 3041 4 Thupm05" +unicode(19) "it is the 14th day." +unicode(28) "Thu Jul 14 22:30:41 BST 2005" +unicode(19) "22:07:41 m is month" +unicode(8) "22:30:41" +===DONE=== diff --git a/ext/date/tests/date_format_error.phpt b/ext/date/tests/date_format_error.phpt new file mode 100644 index 0000000000..967695a86d --- /dev/null +++ b/ext/date/tests/date_format_error.phpt @@ -0,0 +1,67 @@ +--TEST-- +Test date_format() function : error conditions +--FILE-- +<?php +/* Prototype : string date_format ( DateTime $object , string $format ) + * Description: Returns date formatted according to given format + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::format + */ + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +echo "*** Testing date_format() : error conditions ***\n"; + +echo "\n-- Testing date_create() function with zero arguments --\n"; +var_dump( date_format() ); + +$date = date_create("2005-07-14 22:30:41"); + +echo "\n-- Testing date_create() function with less than expected no. of arguments --\n"; +var_dump( date_format($date) ); + +echo "\n-- Testing date_create() function with more than expected no. of arguments --\n"; +$format = "F j, Y, g:i a"; +$extra_arg = 10; +var_dump( date_format($date, $format, $extra_arg) ); + +echo "\n-- Testing date_create() function with an invalid values for \$object argument --\n"; +$invalid_obj = new stdClass(); +var_dump( date_format($invalid_obj, $format) ); +$invalid_obj = 10; +var_dump( date_format($invalid_obj, $format) ); +$invalid_obj = null; +var_dump( date_format($invalid_obj, $format) ); + +?> +===DONE=== +--EXPECTF-- +*** Testing date_format() : error conditions *** + +-- Testing date_create() function with zero arguments -- + +Warning: date_format() expects exactly 2 parameters, 0 given in %s on line %d +bool(false) + +-- Testing date_create() function with less than expected no. of arguments -- + +Warning: date_format() expects exactly 2 parameters, 1 given in %s on line %d +bool(false) + +-- Testing date_create() function with more than expected no. of arguments -- + +Warning: date_format() expects exactly 2 parameters, 3 given in %s on line %d +bool(false) + +-- Testing date_create() function with an invalid values for $object argument -- + +Warning: date_format() expects parameter 1 to be DateTime, object given in %sp on line %d +bool(false) + +Warning: date_format() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +Warning: date_format() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/date_format_variation1.phpt b/ext/date/tests/date_format_variation1.phpt new file mode 100644 index 0000000000..84e741a378 --- /dev/null +++ b/ext/date/tests/date_format_variation1.phpt @@ -0,0 +1,252 @@ +--TEST-- +Test date_format() function : usage variation - Passing unexpected values to first argument $object. +--FILE-- +<?php +/* Prototype : string date_format ( DateTime $object , string $format ) + * Description: Returns date formatted according to given format + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::format + */ + +echo "*** Testing date_format() : usage variation - unexpected values to first argument \$object***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -12345, + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + // resource + 'resource' => $file_handle +); + +$format = 'H:m:s \m \i\s\ \m\o\n\t\h'; + +foreach($inputs as $variation =>$object) { + echo "\n-- $variation --\n"; + var_dump( date_format($object, $format) ); +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing date_format() : usage variation - unexpected values to first argument $object*** + +-- int 0 -- + +Warning: date_format() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +-- int 1 -- + +Warning: date_format() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +-- int 12345 -- + +Warning: date_format() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +-- int -12345 -- + +Warning: date_format() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +-- float 10.5 -- + +Warning: date_format() expects parameter 1 to be DateTime, double given in %s on line %d +bool(false) + +-- float -10.5 -- + +Warning: date_format() expects parameter 1 to be DateTime, double given in %s on line %d +bool(false) + +-- float .5 -- + +Warning: date_format() expects parameter 1 to be DateTime, double given in %s on line %d +bool(false) + +-- empty array -- + +Warning: date_format() expects parameter 1 to be DateTime, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: date_format() expects parameter 1 to be DateTime, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: date_format() expects parameter 1 to be DateTime, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: date_format() expects parameter 1 to be DateTime, array given in %s on line %d +bool(false) + +-- uppercase NULL -- + +Warning: date_format() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) + +-- lowercase null -- + +Warning: date_format() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) + +-- lowercase true -- + +Warning: date_format() expects parameter 1 to be DateTime, boolean given in %s on line %d +bool(false) + +-- lowercase false -- + +Warning: date_format() expects parameter 1 to be DateTime, boolean given in %s on line %d +bool(false) + +-- uppercase TRUE -- + +Warning: date_format() expects parameter 1 to be DateTime, boolean given in %s on line %d +bool(false) + +-- uppercase FALSE -- + +Warning: date_format() expects parameter 1 to be DateTime, boolean given in %s on line %d +bool(false) + +-- empty string DQ -- + +Warning: date_format() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- empty string SQ -- + +Warning: date_format() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- string DQ -- + +Warning: date_format() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- string SQ -- + +Warning: date_format() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- mixed case string -- + +Warning: date_format() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- heredoc -- + +Warning: date_format() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- instance of classWithToString -- + +Warning: date_format() expects parameter 1 to be DateTime, object given in %s on line %d +bool(false) + +-- instance of classWithoutToString -- + +Warning: date_format() expects parameter 1 to be DateTime, object given in %s on line %d +bool(false) + +-- undefined var -- + +Warning: date_format() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) + +-- unset var -- + +Warning: date_format() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) + +-- resource -- + +Warning: date_format() expects parameter 1 to be DateTime, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/date_isodate_set_basic1.phpt b/ext/date/tests/date_isodate_set_basic1.phpt new file mode 100644 index 0000000000..dc8daba533 --- /dev/null +++ b/ext/date/tests/date_isodate_set_basic1.phpt @@ -0,0 +1,38 @@ +--TEST-- +Test date_isodate_set() function : basic functionality +--FILE-- +<?php +/* Prototype : DateTime date_isodate_set ( DateTime $object , int $year , int $week [, int $day ] ) + * Description: Set a date according to the ISO 8601 standard - using weeks and day offsets rather than specific dates. + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::setISODate + */ + +echo "*** Testing date_isodate_set() : basic functionality ***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +// Create a deate object +$datetime = date_create("2009-01-30 17:57:32"); + +// Which month is week 40 ? +date_isodate_set($datetime, 2008, 40); +echo "Week 40 of 2009 is in \"" . date_format($datetime, "F") . "\"\n"; + +// What date is week week 30 day 3 ? +date_isodate_set($datetime, 2009, 30, 3); +echo "Week 30 day 3 of 2009 is \"" . date_format($datetime, "D M j") . "\"\n"; + +// What date was is last year ? +date_isodate_set($datetime, 2008, 30, 3); +echo "..same day last year was \"" . date_format($datetime, "D M j") . "\"\n"; + +?> +===DONE=== +--EXPECTF-- +*** Testing date_isodate_set() : 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/date_isodate_set_error.phpt b/ext/date/tests/date_isodate_set_error.phpt new file mode 100644 index 0000000000..9accd92d93 --- /dev/null +++ b/ext/date/tests/date_isodate_set_error.phpt @@ -0,0 +1,68 @@ +--TEST-- +Test date_isodate_set() function : error conditions +--FILE-- +<?php + +/* Prototype : DateTime date_isodate_set ( DateTime $object , int $year , int $week [, int $day ] ) + * Description: Set a date according to the ISO 8601 standard - using weeks and day offsets rather than specific dates. + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::setISODate + */ + + //Set the default time zone +date_default_timezone_set("Europe/London"); + +echo "*** Testing date_isodate_set() : error conditions ***\n"; + +echo "\n-- Testing date_isodate_set() function with zero arguments --\n"; +var_dump( date_isodate_set() ); + +$datetime = date_create("2009-01-30 19:34:10"); +echo "\n-- Testing date_isodate_set() function with less than expected no. of arguments --\n"; +var_dump( date_isodate_set($datetime) ); + +echo "\n-- Testing date_isodate_set() function with more than expected no. of arguments --\n"; +$year = 2009; +$week = 30; +$day = 7; +$extra_arg = 30; +var_dump( date_isodate_set($datetime, $year, $week, $day, $extra_arg) ); + +echo "\n-- Testing date_isodate_set() function with an invalid values for \$object argument --\n"; +$invalid_obj = new stdClass(); +var_dump( date_isodate_set($invalid_obj, $year, $week, $day) ); +$invalid_obj = 10; +var_dump( date_isodate_set($invalid_obj, $year, $week, $day) ); +$invalid_obj = null; +var_dump( date_isodate_set($invalid_obj, $year, $week, $day) ); +?> +===DONE=== +--EXPECTF-- +*** Testing date_isodate_set() : error conditions *** + +-- Testing date_isodate_set() function with zero arguments -- + +Warning: date_isodate_set() expects at least 3 parameters, 0 given in %s on line %d +bool(false) + +-- Testing date_isodate_set() function with less than expected no. of arguments -- + +Warning: date_isodate_set() expects at least 3 parameters, 1 given in %s on line %d +bool(false) + +-- Testing date_isodate_set() function with more than expected no. of arguments -- + +Warning: date_isodate_set() expects at most 4 parameters, 5 given in %s on line %d +bool(false) + +-- Testing date_isodate_set() function with an invalid values for $object argument -- + +Warning: date_isodate_set() expects parameter 1 to be DateTime, object given in %s on line %d +bool(false) + +Warning: date_isodate_set() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +Warning: date_isodate_set() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/date_isodate_set_variation1.phpt b/ext/date/tests/date_isodate_set_variation1.phpt new file mode 100644 index 0000000000..0b1cb43be6 --- /dev/null +++ b/ext/date/tests/date_isodate_set_variation1.phpt @@ -0,0 +1,254 @@ +--TEST-- +Test date_isodate_set() function : usage variation - Passing unexpected values to first argument $object. +--FILE-- +<?php +/* Prototype : DateTime date_isodate_set ( DateTime $object , int $year , int $week [, int $day ] ) + * Description: Set a date according to the ISO 8601 standard - using weeks and day offsets rather than specific dates. + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::setISODate + */ + +echo "*** Testing date_isodate_set() : usage variation - unexpected values to first argument \$object***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -12345, + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + // resource + 'resource' => $file_handle +); + +$day = 2; +$month = 7; +$year = 1963; + +foreach($inputs as $variation =>$object) { + echo "\n-- $variation --\n"; + var_dump( date_isodate_set($object, $year, $month, $day) ); +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing date_isodate_set() : usage variation - unexpected values to first argument $object*** + +-- int 0 -- + +Warning: date_isodate_set() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +-- int 1 -- + +Warning: date_isodate_set() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +-- int 12345 -- + +Warning: date_isodate_set() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +-- int -12345 -- + +Warning: date_isodate_set() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +-- float 10.5 -- + +Warning: date_isodate_set() expects parameter 1 to be DateTime, double given in %s on line %d +bool(false) + +-- float -10.5 -- + +Warning: date_isodate_set() expects parameter 1 to be DateTime, double given in %s on line %d +bool(false) + +-- float .5 -- + +Warning: date_isodate_set() expects parameter 1 to be DateTime, double given in %s on line %d +bool(false) + +-- empty array -- + +Warning: date_isodate_set() expects parameter 1 to be DateTime, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: date_isodate_set() expects parameter 1 to be DateTime, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: date_isodate_set() expects parameter 1 to be DateTime, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: date_isodate_set() expects parameter 1 to be DateTime, array given in %s on line %d +bool(false) + +-- uppercase NULL -- + +Warning: date_isodate_set() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) + +-- lowercase null -- + +Warning: date_isodate_set() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) + +-- lowercase true -- + +Warning: date_isodate_set() expects parameter 1 to be DateTime, boolean given in %s on line %d +bool(false) + +-- lowercase false -- + +Warning: date_isodate_set() expects parameter 1 to be DateTime, boolean given in %s on line %d +bool(false) + +-- uppercase TRUE -- + +Warning: date_isodate_set() expects parameter 1 to be DateTime, boolean given in %s on line %d +bool(false) + +-- uppercase FALSE -- + +Warning: date_isodate_set() expects parameter 1 to be DateTime, boolean given in %s on line %d +bool(false) + +-- empty string DQ -- + +Warning: date_isodate_set() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- empty string SQ -- + +Warning: date_isodate_set() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- string DQ -- + +Warning: date_isodate_set() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- string SQ -- + +Warning: date_isodate_set() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- mixed case string -- + +Warning: date_isodate_set() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- heredoc -- + +Warning: date_isodate_set() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- instance of classWithToString -- + +Warning: date_isodate_set() expects parameter 1 to be DateTime, object given in %s on line %d +bool(false) + +-- instance of classWithoutToString -- + +Warning: date_isodate_set() expects parameter 1 to be DateTime, object given in %s on line %d +bool(false) + +-- undefined var -- + +Warning: date_isodate_set() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) + +-- unset var -- + +Warning: date_isodate_set() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) + +-- resource -- + +Warning: date_isodate_set() expects parameter 1 to be DateTime, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/date_isodate_set_variation2.phpt b/ext/date/tests/date_isodate_set_variation2.phpt new file mode 100644 index 0000000000..49cb3efb86 --- /dev/null +++ b/ext/date/tests/date_isodate_set_variation2.phpt @@ -0,0 +1,329 @@ +--TEST-- +Test date_isodate_set() function : usage variation - Passing unexpected values to second argument $year. +--FILE-- +<?php +/* Prototype : DateTime date_isodate_set ( DateTime $object , int $year , int $week [, int $day ] ) + * Description: Set a date according to the ISO 8601 standard - using weeks and day offsets rather than specific dates. + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::setISODate + */ + +echo "*** Testing date_isodate_set() : usage variation - unexpected values to second argument \$year***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -12345, + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + // resource + 'resource' => $file_handle +); + +$object = date_create("2009-02-27 08:34:10"); +$day = 2; +$month = 7; + +foreach($inputs as $variation =>$year) { + echo "\n-- $variation --\n"; + var_dump( date_isodate_set($object, $year, $month, $day) ); +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing date_isodate_set() : usage variation - unexpected values to second argument $year*** + +-- int 0 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "0000-02-15 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- int 1 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "0001-02-13 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- int 12345 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(20) "12345-02-13 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- int -12345 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(21) "-12345-02-15 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- float 10.5 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "0010-02-16 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- float -10.5 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(20) "-0010-02-19 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- float .5 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "0000-02-15 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- empty array -- + +Warning: date_isodate_set() expects parameter 2 to be long, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: date_isodate_set() expects parameter 2 to be long, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: date_isodate_set() expects parameter 2 to be long, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: date_isodate_set() expects parameter 2 to be long, array given in %s on line %d +bool(false) + +-- uppercase NULL -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "0000-02-15 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- lowercase null -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "0000-02-15 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- lowercase true -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "0001-02-13 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- lowercase false -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "0000-02-15 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- uppercase TRUE -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "0001-02-13 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- uppercase FALSE -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "0000-02-15 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- empty string DQ -- + +Warning: date_isodate_set() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- empty string SQ -- + +Warning: date_isodate_set() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- string DQ -- + +Warning: date_isodate_set() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- string SQ -- + +Warning: date_isodate_set() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- mixed case string -- + +Warning: date_isodate_set() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- heredoc -- + +Warning: date_isodate_set() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- instance of classWithToString -- + +Warning: date_isodate_set() expects parameter 2 to be long, object given in %s on line %d +bool(false) + +-- instance of classWithoutToString -- + +Warning: date_isodate_set() expects parameter 2 to be long, object given in %s on line %d +bool(false) + +-- undefined var -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "0000-02-15 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- unset var -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "0000-02-15 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- resource -- + +Warning: date_isodate_set() expects parameter 2 to be long, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/date_isodate_set_variation3.phpt b/ext/date/tests/date_isodate_set_variation3.phpt new file mode 100644 index 0000000000..00e89ad7ce --- /dev/null +++ b/ext/date/tests/date_isodate_set_variation3.phpt @@ -0,0 +1,329 @@ +--TEST-- +Test date_isodate_set() function : usage variation - Passing unexpected values to third argument $week. +--FILE-- +<?php +/* Prototype : DateTime date_isodate_set ( DateTime $object , int $year , int $week [, int $day ] ) + * Description: Set a date according to the ISO 8601 standard - using weeks and day offsets rather than specific dates. + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::setISODate + */ + +echo "*** Testing date_isodate_set() : usage variation - unexpected values to third argument \$week***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -12345, + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + // resource + 'resource' => $file_handle +); + +$object = date_create("2009-02-27 08:34:10"); +$day = 2; +$year = 1963; + +foreach($inputs as $variation =>$month) { + echo "\n-- $variation --\n"; + var_dump( date_isodate_set($object, $year, $month, $day) ); +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing date_isodate_set() : usage variation - unexpected values to third argument $week*** + +-- int 0 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1962-12-25 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- int 1 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1963-01-01 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- int 12345 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2199-07-30 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- int -12345 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1726-05-21 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- float 10.5 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1963-03-05 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- float -10.5 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1962-10-16 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- float .5 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1962-12-25 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- empty array -- + +Warning: date_isodate_set() expects parameter 3 to be long, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: date_isodate_set() expects parameter 3 to be long, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: date_isodate_set() expects parameter 3 to be long, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: date_isodate_set() expects parameter 3 to be long, array given in %s on line %d +bool(false) + +-- uppercase NULL -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1962-12-25 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- lowercase null -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1962-12-25 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- lowercase true -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1963-01-01 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- lowercase false -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1962-12-25 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- uppercase TRUE -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1963-01-01 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- uppercase FALSE -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1962-12-25 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- empty string DQ -- + +Warning: date_isodate_set() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- empty string SQ -- + +Warning: date_isodate_set() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- string DQ -- + +Warning: date_isodate_set() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- string SQ -- + +Warning: date_isodate_set() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- mixed case string -- + +Warning: date_isodate_set() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- heredoc -- + +Warning: date_isodate_set() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- instance of classWithToString -- + +Warning: date_isodate_set() expects parameter 3 to be long, object given in %s on line %d +bool(false) + +-- instance of classWithoutToString -- + +Warning: date_isodate_set() expects parameter 3 to be long, object given in %s on line %d +bool(false) + +-- undefined var -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1962-12-25 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- unset var -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1962-12-25 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- resource -- + +Warning: date_isodate_set() expects parameter 3 to be long, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/date_isodate_set_variation4.phpt b/ext/date/tests/date_isodate_set_variation4.phpt new file mode 100644 index 0000000000..b79efb0131 --- /dev/null +++ b/ext/date/tests/date_isodate_set_variation4.phpt @@ -0,0 +1,329 @@ +--TEST-- +Test date_isodate_set() function : usage variation - Passing unexpected values to forth argument $day. +--FILE-- +<?php +/* Prototype : DateTime date_isodate_set ( DateTime $object , int $year , int $week [, int $day ] ) + * Description: Set a date according to the ISO 8601 standard - using weeks and day offsets rather than specific dates. + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::setISODate + */ + +echo "*** Testing date_isodate_set() : usage variation - unexpected values to forth argument \$day***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -12345, + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + // resource + 'resource' => $file_handle +); + +$object = date_create("2009-02-27 08:34:10"); +$year = 1963; +$month = 7; + +foreach($inputs as $variation =>$day) { + echo "\n-- $variation --\n"; + var_dump( date_isodate_set($object, $year, $month, $day) ); +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing date_isodate_set() : usage variation - unexpected values to forth argument $day*** + +-- int 0 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1963-02-10 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- int 1 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1963-02-11 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- int 12345 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1996-11-28 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- int -12345 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1929-04-24 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- float 10.5 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1963-02-20 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- float -10.5 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1963-01-31 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- float .5 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1963-02-10 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- empty array -- + +Warning: date_isodate_set() expects parameter 4 to be long, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: date_isodate_set() expects parameter 4 to be long, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: date_isodate_set() expects parameter 4 to be long, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: date_isodate_set() expects parameter 4 to be long, array given in %s on line %d +bool(false) + +-- uppercase NULL -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1963-02-10 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- lowercase null -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1963-02-10 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- lowercase true -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1963-02-11 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- lowercase false -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1963-02-10 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- uppercase TRUE -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1963-02-11 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- uppercase FALSE -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1963-02-10 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- empty string DQ -- + +Warning: date_isodate_set() expects parameter 4 to be long, Unicode string given in %s on line %d +bool(false) + +-- empty string SQ -- + +Warning: date_isodate_set() expects parameter 4 to be long, Unicode string given in %s on line %d +bool(false) + +-- string DQ -- + +Warning: date_isodate_set() expects parameter 4 to be long, Unicode string given in %s on line %d +bool(false) + +-- string SQ -- + +Warning: date_isodate_set() expects parameter 4 to be long, Unicode string given in %s on line %d +bool(false) + +-- mixed case string -- + +Warning: date_isodate_set() expects parameter 4 to be long, Unicode string given in %s on line %d +bool(false) + +-- heredoc -- + +Warning: date_isodate_set() expects parameter 4 to be long, Unicode string given in %s on line %d +bool(false) + +-- instance of classWithToString -- + +Warning: date_isodate_set() expects parameter 4 to be long, object given in %s on line %d +bool(false) + +-- instance of classWithoutToString -- + +Warning: date_isodate_set() expects parameter 4 to be long, object given in %s on line %d +bool(false) + +-- undefined var -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1963-02-10 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- unset var -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "1963-02-10 08:34:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- resource -- + +Warning: date_isodate_set() expects parameter 4 to be long, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/date_modify_basic1.phpt b/ext/date/tests/date_modify_basic1.phpt new file mode 100644 index 0000000000..038b94ce08 --- /dev/null +++ b/ext/date/tests/date_modify_basic1.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test date_modify() function : basic functionality +--FILE-- +<?php +/* Prototype : DateTime date_modify ( DateTime $object , string $modify ) + * Description: Alter the timestamp of a DateTime object by incrementing or decrementing in a format accepted by strtotime(). + * Source code: ext/date/php_date.c + * Alias to functions: public DateTime DateTime::modify() + */ + + //Set the default time zone +date_default_timezone_set("Europe/London"); + +echo "*** Testing date_modify() : basic functionality ***\n"; + +// Create a date object to modify +$datetime = date_create("2009-01-31 14:28:41"); + +date_modify($datetime, "+1 day"); +echo "After modification 1: " . date_format($datetime, "D, d M Y") . "\n"; + +date_modify($datetime, "+1 week 2 days 4 hours 2 seconds"); +echo "After modification 2: " . date_format($datetime, "D, d M Y H:i:s") . "\n"; + +date_modify($datetime, "next Thursday"); +echo "After modification 3: " . date_format($datetime, "D, d M Y") . "\n"; + +date_modify($datetime, "last Sunday"); +echo "After modification 4: " . date_format($datetime, "D, d M Y") . "\n"; + +?> +===DONE=== +--EXPECTF-- +*** Testing date_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/date_modify_error.phpt b/ext/date/tests/date_modify_error.phpt new file mode 100644 index 0000000000..ac727f1ca1 --- /dev/null +++ b/ext/date/tests/date_modify_error.phpt @@ -0,0 +1,68 @@ +--TEST-- +Test date_modify() function : error conditions +--FILE-- +<?php +/* Prototype : DateTime date_modify ( DateTime $object , string $modify ) + * Description: Alter the timestamp of a DateTime object by incrementing or decrementing in a format accepted by strtotime(). + * Source code: ext/date/php_date.c + * Alias to functions: public DateTime DateTime::modify() + */ + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +echo "*** Testing date_modify() : error conditions ***\n"; + +echo "\n-- Testing date_modify() function with zero arguments --\n"; +var_dump( date_modify() ); + +// Create a date object +$datetime = date_create("2009-01-30 19:34:10"); + +echo "\n-- Testing date_modify() function with less than expected no. of arguments --\n"; +var_dump( date_modify($datetime) ); + +echo "\n-- Testing date_modify() function with more than expected no. of arguments --\n"; +$modify = "+1 day"; +$extra_arg = 99; +var_dump( date_modify($datetime, $modify, $extra_arg) ); + +echo "\n-- Testing date_modify() function with an invalid values for \$object argument --\n"; +$invalid_obj = new stdClass(); +var_dump( date_modify($invalid_obj, $modify) ); +$invalid_obj = 10; +var_dump( date_modify($invalid_obj, $modify) ); +$invalid_obj = null; +var_dump( date_modify($invalid_obj, $modify) ); + +?> +===DONE=== +--EXPECTF-- +*** Testing date_modify() : error conditions *** + +-- Testing date_modify() function with zero arguments -- + +Warning: date_modify() expects exactly 2 parameters, 0 given in %s on line %d +bool(false) + +-- Testing date_modify() function with less than expected no. of arguments -- + +Warning: date_modify() expects exactly 2 parameters, 1 given in %s on line %d +bool(false) + +-- Testing date_modify() function with more than expected no. of arguments -- + +Warning: date_modify() expects exactly 2 parameters, 3 given in %s on line %d +bool(false) + +-- Testing date_modify() function with an invalid values for $object argument -- + +Warning: date_modify() expects parameter 1 to be DateTime, object given in %s on line %d +bool(false) + +Warning: date_modify() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +Warning: date_modify() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/date_modify_variation1.phpt b/ext/date/tests/date_modify_variation1.phpt new file mode 100644 index 0000000000..dc17c5f4d3 --- /dev/null +++ b/ext/date/tests/date_modify_variation1.phpt @@ -0,0 +1,252 @@ +--TEST-- +Test date_modify() function : usage variation - Passing unexpected values to first argument $object. +--FILE-- +<?php +/* Prototype : DateTime date_modify ( DateTime $object , string $modify ) + * Description: Alter the timestamp of a DateTime object by incrementing or decrementing in a format accepted by strtotime(). + * Source code: ext/date/php_date.c + * Alias to functions: public DateTime DateTime::modify() + */ + +echo "*** Testing date_modify() : usage variation - unexpected values to first argument \$object***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -12345, + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + // resource + 'resource' => $file_handle +); + +$format = "D, d M Y"; + +foreach($inputs as $variation =>$object) { + echo "\n-- $variation --\n"; + var_dump( date_modify($object, $format) ); +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing date_modify() : usage variation - unexpected values to first argument $object*** + +-- int 0 -- + +Warning: date_modify() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +-- int 1 -- + +Warning: date_modify() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +-- int 12345 -- + +Warning: date_modify() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +-- int -12345 -- + +Warning: date_modify() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +-- float 10.5 -- + +Warning: date_modify() expects parameter 1 to be DateTime, double given in %s on line %d +bool(false) + +-- float -10.5 -- + +Warning: date_modify() expects parameter 1 to be DateTime, double given in %s on line %d +bool(false) + +-- float .5 -- + +Warning: date_modify() expects parameter 1 to be DateTime, double given in %s on line %d +bool(false) + +-- empty array -- + +Warning: date_modify() expects parameter 1 to be DateTime, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: date_modify() expects parameter 1 to be DateTime, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: date_modify() expects parameter 1 to be DateTime, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: date_modify() expects parameter 1 to be DateTime, array given in %s on line %d +bool(false) + +-- uppercase NULL -- + +Warning: date_modify() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) + +-- lowercase null -- + +Warning: date_modify() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) + +-- lowercase true -- + +Warning: date_modify() expects parameter 1 to be DateTime, boolean given in %s on line %d +bool(false) + +-- lowercase false -- + +Warning: date_modify() expects parameter 1 to be DateTime, boolean given in %s on line %d +bool(false) + +-- uppercase TRUE -- + +Warning: date_modify() expects parameter 1 to be DateTime, boolean given in %s on line %d +bool(false) + +-- uppercase FALSE -- + +Warning: date_modify() expects parameter 1 to be DateTime, boolean given in %s on line %d +bool(false) + +-- empty string DQ -- + +Warning: date_modify() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- empty string SQ -- + +Warning: date_modify() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- string DQ -- + +Warning: date_modify() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- string SQ -- + +Warning: date_modify() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- mixed case string -- + +Warning: date_modify() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- heredoc -- + +Warning: date_modify() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- instance of classWithToString -- + +Warning: date_modify() expects parameter 1 to be DateTime, object given in %s on line %d +bool(false) + +-- instance of classWithoutToString -- + +Warning: date_modify() expects parameter 1 to be DateTime, object given in %s on line %d +bool(false) + +-- undefined var -- + +Warning: date_modify() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) + +-- unset var -- + +Warning: date_modify() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) + +-- resource -- + +Warning: date_modify() expects parameter 1 to be DateTime, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/date_modify_variation2.phpt b/ext/date/tests/date_modify_variation2.phpt new file mode 100644 index 0000000000..9506b72607 --- /dev/null +++ b/ext/date/tests/date_modify_variation2.phpt @@ -0,0 +1,362 @@ +--TEST-- +Test date_modify() function : usage variation - Passing unexpected values to second argument $format. +--FILE-- +<?php +/* Prototype : DateTime date_modify ( DateTime $object , string $modify ) + * Description: Alter the timestamp of a DateTime object by incrementing or decrementing in a format accepted by strtotime(). + * Source code: ext/date/php_date.c + * Alias to functions: public DateTime DateTime::modify() + */ + +echo "*** Testing date_modify() : usage variation - unexpected values to second argument \$format***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -12345, + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + // resource + 'resource' => $file_handle +); + +$object = date_create("2009-01-31 14:28:41"); + +foreach($inputs as $variation =>$format) { + echo "\n-- $variation --\n"; + var_dump( date_modify($object, $format) ); +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing date_modify() : usage variation - unexpected values to second argument $format*** + +-- int 0 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 14:28:41" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- int 1 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 14:28:41" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- int 12345 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 14:28:41" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- int -12345 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 14:28:41" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- float 10.5 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 14:28:41" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- float -10.5 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 14:28:41" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- float .5 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 14:28:41" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- empty array -- + +Warning: date_modify() expects parameter 2 to be binary string, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: date_modify() expects parameter 2 to be binary string, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: date_modify() expects parameter 2 to be binary string, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: date_modify() expects parameter 2 to be binary string, array given in %s on line %d +bool(false) + +-- uppercase NULL -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 14:28:41" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- lowercase null -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 14:28:41" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- lowercase true -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 14:28:41" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- lowercase false -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 14:28:41" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- uppercase TRUE -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 14:28:41" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- uppercase FALSE -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 14:28:41" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- empty string DQ -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 14:28:41" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- empty string SQ -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 14:28:41" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- string DQ -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 14:28:41" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- string SQ -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 14:28:41" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- mixed case string -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 14:28:41" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- heredoc -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 14:28:41" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- instance of classWithToString -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 14:28:41" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- instance of classWithoutToString -- + +Warning: date_modify() expects parameter 2 to be binary string, object given in %s on line %d +bool(false) + +-- undefined var -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 14:28:41" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- unset var -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 14:28:41" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- resource -- + +Warning: date_modify() expects parameter 2 to be binary string, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/date_offset_get_basic1.phpt b/ext/date/tests/date_offset_get_basic1.phpt new file mode 100644 index 0000000000..42f38939e8 --- /dev/null +++ b/ext/date/tests/date_offset_get_basic1.phpt @@ -0,0 +1,28 @@ +--TEST-- +Test date_offset_get() function : basic functionality +--FILE-- +<?php +/* Prototype : int date_offset_get ( DateTime $object ) + * Description: Returns the daylight saving time offset + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::getOffset + */ + +//Set the default time zone +date_default_timezone_set('Europe/London'); + +echo "*** Testing date_offset_get() : basic functionality ***\n"; + +$winter = date_create('2008-12-25 14:25:41'); +$summer = date_create('2008-07-02 14:25:41'); + +echo "Winter offset: " . date_offset_get($winter) / 3600 . " hours\n"; +echo "Summer offset: " . date_offset_get($summer) / 3600 . " hours\n"; + +?> +===DONE=== +--EXPECTF-- +*** Testing date_offset_get() : basic functionality *** +Winter offset: 0 hours +Summer offset: 1 hours +===DONE=== diff --git a/ext/date/tests/date_offset_get_error.phpt b/ext/date/tests/date_offset_get_error.phpt new file mode 100644 index 0000000000..bd4e429225 --- /dev/null +++ b/ext/date/tests/date_offset_get_error.phpt @@ -0,0 +1,57 @@ +--TEST-- +Test date_offset_get() function : error conditions +--FILE-- +<?php + +/* Prototype : int date_offset_get ( DateTime $object ) + * Description: Returns the daylight saving time offset + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::getOffset + */ + + //Set the default time zone +date_default_timezone_set("Europe/London"); + +echo "*** Testing date_offset_get() : error conditions ***\n"; + +echo "\n-- Testing date_offset_get() function with zero arguments --\n"; +var_dump( date_offset_get() ); + +echo "\n-- Testing date_offset_get() function with more than expected no. of arguments --\n"; +$datetime = date_create("2009-01-30 19:34:10"); +$extra_arg = 30; +var_dump( date_offset_get($datetime, $extra_arg) ); + +echo "\n-- Testing date_offset_get() function with an invalid values for \$object argument --\n"; +$invalid_obj = new stdClass(); +var_dump( date_offset_get($invalid_obj) ); +$invalid_obj = 10; +var_dump( date_offset_get($invalid_obj) ); +$invalid_obj = null; +var_dump( date_offset_get($invalid_obj) ); +?> +===DONE=== +--EXPECTF-- +*** Testing date_offset_get() : error conditions *** + +-- Testing date_offset_get() function with zero arguments -- + +Warning: date_offset_get() expects exactly 1 parameter, 0 given in %s on line %d +bool(false) + +-- Testing date_offset_get() function with more than expected no. of arguments -- + +Warning: date_offset_get() expects exactly 1 parameter, 2 given in %s on line %d +bool(false) + +-- Testing date_offset_get() function with an invalid values for $object argument -- + +Warning: date_offset_get() expects parameter 1 to be DateTime, object given in %s on line %d +bool(false) + +Warning: date_offset_get() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +Warning: date_offset_get() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/date_offset_get_variation1.phpt b/ext/date/tests/date_offset_get_variation1.phpt new file mode 100644 index 0000000000..117d212a7d --- /dev/null +++ b/ext/date/tests/date_offset_get_variation1.phpt @@ -0,0 +1,250 @@ +--TEST-- +Test date_offset_get() function : usage variation - Passing unexpected values to first argument $object. +--FILE-- +<?php +/* Prototype : int date_offset_get ( DateTime $object ) + * Description: Returns the daylight saving time offset + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::getOffset + */ + +echo "*** Testing date_offset_get() : usage variation - unexpected values to first argument \$object***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -12345, + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + // resource + 'resource' => $file_handle +); + +foreach($inputs as $variation =>$object) { + echo "\n-- $variation --\n"; + var_dump( date_offset_get($object) ); +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing date_offset_get() : usage variation - unexpected values to first argument $object*** + +-- int 0 -- + +Warning: date_offset_get() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +-- int 1 -- + +Warning: date_offset_get() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +-- int 12345 -- + +Warning: date_offset_get() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +-- int -12345 -- + +Warning: date_offset_get() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +-- float 10.5 -- + +Warning: date_offset_get() expects parameter 1 to be DateTime, double given in %s on line %d +bool(false) + +-- float -10.5 -- + +Warning: date_offset_get() expects parameter 1 to be DateTime, double given in %s on line %d +bool(false) + +-- float .5 -- + +Warning: date_offset_get() expects parameter 1 to be DateTime, double given in %s on line %d +bool(false) + +-- empty array -- + +Warning: date_offset_get() expects parameter 1 to be DateTime, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: date_offset_get() expects parameter 1 to be DateTime, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: date_offset_get() expects parameter 1 to be DateTime, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: date_offset_get() expects parameter 1 to be DateTime, array given in %s on line %d +bool(false) + +-- uppercase NULL -- + +Warning: date_offset_get() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) + +-- lowercase null -- + +Warning: date_offset_get() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) + +-- lowercase true -- + +Warning: date_offset_get() expects parameter 1 to be DateTime, boolean given in %s on line %d +bool(false) + +-- lowercase false -- + +Warning: date_offset_get() expects parameter 1 to be DateTime, boolean given in %s on line %d +bool(false) + +-- uppercase TRUE -- + +Warning: date_offset_get() expects parameter 1 to be DateTime, boolean given in %s on line %d +bool(false) + +-- uppercase FALSE -- + +Warning: date_offset_get() expects parameter 1 to be DateTime, boolean given in %s on line %d +bool(false) + +-- empty string DQ -- + +Warning: date_offset_get() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- empty string SQ -- + +Warning: date_offset_get() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- string DQ -- + +Warning: date_offset_get() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- string SQ -- + +Warning: date_offset_get() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- mixed case string -- + +Warning: date_offset_get() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- heredoc -- + +Warning: date_offset_get() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- instance of classWithToString -- + +Warning: date_offset_get() expects parameter 1 to be DateTime, object given in %s on line %d +bool(false) + +-- instance of classWithoutToString -- + +Warning: date_offset_get() expects parameter 1 to be DateTime, object given in %s on line %d +bool(false) + +-- undefined var -- + +Warning: date_offset_get() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) + +-- unset var -- + +Warning: date_offset_get() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) + +-- resource -- + +Warning: date_offset_get() expects parameter 1 to be DateTime, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/date_parse_basic1.phpt b/ext/date/tests/date_parse_basic1.phpt new file mode 100644 index 0000000000..48e00d1b6d --- /dev/null +++ b/ext/date/tests/date_parse_basic1.phpt @@ -0,0 +1,107 @@ +--TEST-- +Test date_parse() function : basic functionality +--FILE-- +<?php +/* Prototype : array date_parse ( string $date ) + * Description: Returns associative array with detailed info about given date. + * Source code: ext/date/php_date.c + */ + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +echo "*** Testing date_parse() : basic functionality ***\n"; + +var_dump( date_parse("2009-02-27 10:00:00.5") ); +var_dump( date_parse("10:00:00.5") ); +var_dump( date_parse("2009-02-27") ); + +?> +===DONE=== +--EXPECT-- +*** Testing date_parse() : basic functionality *** +array(12) { + [u"year"]=> + int(2009) + [u"month"]=> + int(2) + [u"day"]=> + int(27) + [u"hour"]=> + int(10) + [u"minute"]=> + int(0) + [u"second"]=> + int(0) + [u"fraction"]=> + float(0.5) + [u"warning_count"]=> + int(0) + [u"warnings"]=> + array(0) { + } + [u"error_count"]=> + int(0) + [u"errors"]=> + array(0) { + } + [u"is_localtime"]=> + bool(false) +} +array(12) { + [u"year"]=> + bool(false) + [u"month"]=> + bool(false) + [u"day"]=> + bool(false) + [u"hour"]=> + int(10) + [u"minute"]=> + int(0) + [u"second"]=> + int(0) + [u"fraction"]=> + float(0.5) + [u"warning_count"]=> + int(0) + [u"warnings"]=> + array(0) { + } + [u"error_count"]=> + int(0) + [u"errors"]=> + array(0) { + } + [u"is_localtime"]=> + bool(false) +} +array(12) { + [u"year"]=> + int(2009) + [u"month"]=> + int(2) + [u"day"]=> + int(27) + [u"hour"]=> + bool(false) + [u"minute"]=> + bool(false) + [u"second"]=> + bool(false) + [u"fraction"]=> + bool(false) + [u"warning_count"]=> + int(0) + [u"warnings"]=> + array(0) { + } + [u"error_count"]=> + int(0) + [u"errors"]=> + array(0) { + } + [u"is_localtime"]=> + bool(false) +} +===DONE=== diff --git a/ext/date/tests/date_parse_error.phpt b/ext/date/tests/date_parse_error.phpt new file mode 100644 index 0000000000..0f1ae068e3 --- /dev/null +++ b/ext/date/tests/date_parse_error.phpt @@ -0,0 +1,89 @@ +--TEST-- +Test date_parse() function : error conditions +--FILE-- +<?php +/* Prototype : array date_parse ( string $date ) + * Description: Returns associative array with detailed info about given date. + * Source code: ext/date/php_date.c + */ + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +echo "*** Testing date_parse() : error conditions ***\n"; + +echo "\n-- Testing date_parse() function with zero arguments --\n"; +var_dump( date_parse() ); + +echo "\n-- Testing date_parse() function with more than expected no. of arguments --\n"; +$date = "2009-02-27 10:00:00.5"; +$extra_arg = 10; +var_dump( date_parse($date, $extra_arg) ); + +echo "\n-- Testing date_parse() function with unexpected characters in \$date argument --\n"; +$invalid_date = "2OO9-02--27 10:00?00.5"; +var_dump( date_parse($invalid_date) ); + +?> +===DONE=== +--EXPECTF-- +*** Testing date_parse() : error conditions *** + +-- Testing date_parse() function with zero arguments -- + +Warning: date_parse() expects exactly 1 parameter, 0 given in %s on line %d +bool(false) + +-- Testing date_parse() function with more than expected no. of arguments -- + +Warning: date_parse() expects exactly 1 parameter, 2 given in %s on line %d +bool(false) + +-- Testing date_parse() function with unexpected characters in $date argument -- +array(13) { + [u"year"]=> + bool(false) + [u"month"]=> + bool(false) + [u"day"]=> + bool(false) + [u"hour"]=> + int(10) + [u"minute"]=> + int(0) + [u"second"]=> + int(0) + [u"fraction"]=> + float(0) + [u"warning_count"]=> + int(1) + [u"warnings"]=> + array(1) { + [4]=> + unicode(29) "Double timezone specification" + } + [u"error_count"]=> + int(7) + [u"errors"]=> + array(7) { + [0]=> + unicode(20) "Unexpected character" + [1]=> + unicode(47) "The timezone could not be found in the database" + [3]=> + unicode(20) "Unexpected character" + [7]=> + unicode(20) "Unexpected character" + [8]=> + unicode(29) "Double timezone specification" + [17]=> + unicode(20) "Unexpected character" + [18]=> + unicode(25) "Double time specification" + } + [u"is_localtime"]=> + bool(true) + [u"zone_type"]=> + int(0) +} +===DONE=== diff --git a/ext/date/tests/date_parse_variation1.phpt b/ext/date/tests/date_parse_variation1.phpt new file mode 100644 index 0000000000..eb87162347 --- /dev/null +++ b/ext/date/tests/date_parse_variation1.phpt @@ -0,0 +1,274 @@ +--TEST-- +Test date_parse() function : usage variation - Passing unexpected values to first argument $date. +--FILE-- +<?php +/* Prototype : array date_parse ( string $date ) + * Description: Returns associative array with detailed info about given date. + * Source code: ext/date/php_date.c + */ + +echo "*** Testing date_parse() : usage variation - unexpected values to first argument \$date***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -12345, + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + // resource + 'resource' => $file_handle +); + +foreach($inputs as $variation =>$date) { + echo "\n-- $variation --\n"; + $result = date_parse($date); + if (is_array($result)) { + var_dump($result["errors"]); + } else { + var_dump($result); + } +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing date_parse() : usage variation - unexpected values to first argument $date*** + +-- int 0 -- +array(1) { + [0]=> + unicode(20) "Unexpected character" +} + +-- int 1 -- +array(1) { + [0]=> + unicode(20) "Unexpected character" +} + +-- int 12345 -- +array(1) { + [4]=> + unicode(20) "Unexpected character" +} + +-- int -12345 -- +array(1) { + [5]=> + unicode(20) "Unexpected character" +} + +-- float 10.5 -- +array(0) { +} + +-- float -10.5 -- +array(1) { + [4]=> + unicode(20) "Unexpected character" +} + +-- float .5 -- +array(0) { +} + +-- empty array -- + +Warning: date_parse() expects parameter 1 to be binary string, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: date_parse() expects parameter 1 to be binary string, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: date_parse() expects parameter 1 to be binary string, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: date_parse() expects parameter 1 to be binary string, array given in %s on line %d +bool(false) + +-- uppercase NULL -- +array(1) { + [0]=> + unicode(12) "Empty string" +} + +-- lowercase null -- +array(1) { + [0]=> + unicode(12) "Empty string" +} + +-- lowercase true -- +array(1) { + [0]=> + unicode(20) "Unexpected character" +} + +-- lowercase false -- +array(1) { + [0]=> + unicode(12) "Empty string" +} + +-- uppercase TRUE -- +array(1) { + [0]=> + unicode(20) "Unexpected character" +} + +-- uppercase FALSE -- +array(1) { + [0]=> + unicode(12) "Empty string" +} + +-- empty string DQ -- +array(1) { + [0]=> + unicode(12) "Empty string" +} + +-- empty string SQ -- +array(1) { + [0]=> + unicode(12) "Empty string" +} + +-- string DQ -- +array(1) { + [0]=> + unicode(47) "The timezone could not be found in the database" +} + +-- string SQ -- +array(1) { + [0]=> + unicode(47) "The timezone could not be found in the database" +} + +-- mixed case string -- +array(1) { + [0]=> + unicode(47) "The timezone could not be found in the database" +} + +-- heredoc -- +array(1) { + [0]=> + unicode(47) "The timezone could not be found in the database" +} + +-- instance of classWithToString -- +array(2) { + [0]=> + unicode(47) "The timezone could not be found in the database" + [8]=> + unicode(29) "Double timezone specification" +} + +-- instance of classWithoutToString -- + +Warning: date_parse() expects parameter 1 to be binary string, object given in %s on line %d +bool(false) + +-- undefined var -- +array(1) { + [0]=> + unicode(12) "Empty string" +} + +-- unset var -- +array(1) { + [0]=> + unicode(12) "Empty string" +} + +-- resource -- + +Warning: date_parse() expects parameter 1 to be binary string, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/date_time_set_basic1.phpt b/ext/date/tests/date_time_set_basic1.phpt new file mode 100644 index 0000000000..c0c9c66c56 --- /dev/null +++ b/ext/date/tests/date_time_set_basic1.phpt @@ -0,0 +1,46 @@ +--TEST-- +Test date_time_set() function : basic functionality +--FILE-- +<?php +/* Prototype : DateTime date_time_set ( DateTime $object , int $hour , int $minute [, int $second ] ) + * Description: Resets the current time of the DateTime object to a different time. + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::setTime + */ + + //Set the default time zone +date_default_timezone_set("Europe/London"); + +echo "*** Testing date_time_set() : basic functionality ***\n"; + +// Create a DateTime object +$datetime = date_create("2009-01-31 15:14:10"); + +echo "Initial date: " . date_format($datetime, DATE_RFC2822) . "\n"; + +date_time_set($datetime, 17, 20); +echo "After modification1 " . date_format($datetime, DATE_RFC2822) . "\n"; + +date_time_set($datetime, 19, 05, 59); +echo "After modification2 " . date_format($datetime, DATE_RFC2822) . "\n"; + +date_time_set($datetime, 24, 10); +echo "After modification3 " . date_format($datetime, DATE_RFC2822) . "\n"; + +date_time_set($datetime, 47, 35, 47); +echo "After modification4 " . date_format($datetime, DATE_RFC2822) . "\n"; + +date_time_set($datetime, 54, 25); +echo "After modification5 " . date_format($datetime, DATE_RFC2822) . "\n"; + +?> +===DONE=== +--EXPECTF-- +*** Testing date_time_set() : 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/date_time_set_error.phpt b/ext/date/tests/date_time_set_error.phpt new file mode 100644 index 0000000000..8e5c855bcd --- /dev/null +++ b/ext/date/tests/date_time_set_error.phpt @@ -0,0 +1,70 @@ +--TEST-- +Test date_time_set() function : error conditions +--FILE-- +<?php +/* Prototype : DateTime date_time_set ( DateTime $object , int $hour , int $minute [, int $second ] ) + * Description: Resets the current time of the DateTime object to a different time. + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::setTime + */ + +date_default_timezone_set("Europe/London"); + +echo "*** Testing date_time_set() : error conditions ***\n"; + +echo "\n-- Testing date_time_set() function with zero arguments --\n"; +var_dump( date_time_set() ); + +echo "\n-- Testing date_time_set() function with less than expected no. of arguments --\n"; +$datetime = date_create("2009-01-31 15:34:10"); +$hour = 18; +var_dump( date_time_set($datetime) ); +var_dump( date_time_set($datetime, $hour) ); + +echo "\n-- Testing date_time_set() function with more than expected no. of arguments --\n"; +$min = 15; +$sec = 30; +$extra_arg = 10; +var_dump( date_time_set($datetime, $hour, $min, $sec, $extra_arg) ); + +echo "\n-- Testing date_time_set() function with an invalid values for \$object argument --\n"; +$invalid_obj = new stdClass(); +var_dump( date_time_set($invalid_obj, $hour, $min, $sec) ); +$invalid_obj = 10; +var_dump( date_time_set($invalid_obj, $hour, $min, $sec) ); +$invalid_obj = null; +var_dump( date_time_set($invalid_obj, $hour, $min, $sec) ); +?> +===DONE=== +--EXPECTF-- +*** Testing date_time_set() : error conditions *** + +-- Testing date_time_set() function with zero arguments -- + +Warning: date_time_set() expects at least 3 parameters, 0 given in %s on line %d +bool(false) + +-- Testing date_time_set() function with less than expected no. of arguments -- + +Warning: date_time_set() expects at least 3 parameters, 1 given in %s on line %d +bool(false) + +Warning: date_time_set() expects at least 3 parameters, 2 given in %s on line %d +bool(false) + +-- Testing date_time_set() function with more than expected no. of arguments -- + +Warning: date_time_set() expects at most 4 parameters, 5 given in %s on line %d +bool(false) + +-- Testing date_time_set() function with an invalid values for $object argument -- + +Warning: date_time_set() expects parameter 1 to be DateTime, object given in %s on line %d +bool(false) + +Warning: date_time_set() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +Warning: date_time_set() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/date_time_set_variation1.phpt b/ext/date/tests/date_time_set_variation1.phpt new file mode 100644 index 0000000000..d808a1bbcf --- /dev/null +++ b/ext/date/tests/date_time_set_variation1.phpt @@ -0,0 +1,254 @@ +--TEST-- +Test date_time_set() function : usage variation - Passing unexpected values to first argument $object. +--FILE-- +<?php +/* Prototype : DateTime date_time_set ( DateTime $object , int $hour , int $minute [, int $second ] ) + * Description: Resets the current time of the DateTime object to a different time. + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::setTime + */ + +echo "*** Testing date_time_set() : usage variation - unexpected values to first argument \$object***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -12345, + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + // resource + 'resource' => $file_handle +); + +$hour = 10; +$minute = 13; +$sec = 45; + +foreach($inputs as $variation =>$object) { + echo "\n-- $variation --\n"; + var_dump( date_time_set($object, $hour, $minute, $sec) ); +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing date_time_set() : usage variation - unexpected values to first argument $object*** + +-- int 0 -- + +Warning: date_time_set() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +-- int 1 -- + +Warning: date_time_set() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +-- int 12345 -- + +Warning: date_time_set() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +-- int -12345 -- + +Warning: date_time_set() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +-- float 10.5 -- + +Warning: date_time_set() expects parameter 1 to be DateTime, double given in %s on line %d +bool(false) + +-- float -10.5 -- + +Warning: date_time_set() expects parameter 1 to be DateTime, double given in %s on line %d +bool(false) + +-- float .5 -- + +Warning: date_time_set() expects parameter 1 to be DateTime, double given in %s on line %d +bool(false) + +-- empty array -- + +Warning: date_time_set() expects parameter 1 to be DateTime, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: date_time_set() expects parameter 1 to be DateTime, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: date_time_set() expects parameter 1 to be DateTime, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: date_time_set() expects parameter 1 to be DateTime, array given in %s on line %d +bool(false) + +-- uppercase NULL -- + +Warning: date_time_set() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) + +-- lowercase null -- + +Warning: date_time_set() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) + +-- lowercase true -- + +Warning: date_time_set() expects parameter 1 to be DateTime, boolean given in %s on line %d +bool(false) + +-- lowercase false -- + +Warning: date_time_set() expects parameter 1 to be DateTime, boolean given in %s on line %d +bool(false) + +-- uppercase TRUE -- + +Warning: date_time_set() expects parameter 1 to be DateTime, boolean given in %s on line %d +bool(false) + +-- uppercase FALSE -- + +Warning: date_time_set() expects parameter 1 to be DateTime, boolean given in %s on line %d +bool(false) + +-- empty string DQ -- + +Warning: date_time_set() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- empty string SQ -- + +Warning: date_time_set() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- string DQ -- + +Warning: date_time_set() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- string SQ -- + +Warning: date_time_set() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- mixed case string -- + +Warning: date_time_set() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- heredoc -- + +Warning: date_time_set() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- instance of classWithToString -- + +Warning: date_time_set() expects parameter 1 to be DateTime, object given in %s on line %d +bool(false) + +-- instance of classWithoutToString -- + +Warning: date_time_set() expects parameter 1 to be DateTime, object given in %s on line %d +bool(false) + +-- undefined var -- + +Warning: date_time_set() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) + +-- unset var -- + +Warning: date_time_set() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) + +-- resource -- + +Warning: date_time_set() expects parameter 1 to be DateTime, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/date_time_set_variation2.phpt b/ext/date/tests/date_time_set_variation2.phpt new file mode 100644 index 0000000000..3155979774 --- /dev/null +++ b/ext/date/tests/date_time_set_variation2.phpt @@ -0,0 +1,329 @@ +--TEST-- +Test date_time_set() function : usage variation - Passing unexpected values to second argument $hour. +--FILE-- +<?php +/* Prototype : DateTime date_time_set ( DateTime $object , int $hour , int $minute [, int $second ] ) + * Description: Resets the current time of the DateTime object to a different time. + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::setTime + */ + +echo "*** Testing date_time_set() : usage variation - unexpected values to second argument \$hour***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -12345, + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + // resource + 'resource' => $file_handle +); + +$object = date_create("2009-01-31 15:14:10"); +$minute = 13; +$sec = 45; + +foreach($inputs as $variation =>$hour) { + echo "\n-- $variation --\n"; + var_dump( date_time_set($object, $hour, $minute, $sec) ); +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing date_time_set() : usage variation - unexpected values to second argument $hour*** + +-- int 0 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 00:13:45" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- int 1 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 01:13:45" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- int 12345 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2010-06-29 09:13:45" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- int -12345 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-30 15:13:45" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- float 10.5 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-30 10:13:45" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- float -10.5 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-29 14:13:45" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- float .5 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-29 00:13:45" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- empty array -- + +Warning: date_time_set() expects parameter 2 to be long, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: date_time_set() expects parameter 2 to be long, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: date_time_set() expects parameter 2 to be long, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: date_time_set() expects parameter 2 to be long, array given in %s on line %d +bool(false) + +-- uppercase NULL -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-29 00:13:45" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- lowercase null -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-29 00:13:45" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- lowercase true -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-29 01:13:45" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- lowercase false -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-29 00:13:45" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- uppercase TRUE -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-29 01:13:45" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- uppercase FALSE -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-29 00:13:45" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- empty string DQ -- + +Warning: date_time_set() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- empty string SQ -- + +Warning: date_time_set() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- string DQ -- + +Warning: date_time_set() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- string SQ -- + +Warning: date_time_set() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- mixed case string -- + +Warning: date_time_set() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- heredoc -- + +Warning: date_time_set() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- instance of classWithToString -- + +Warning: date_time_set() expects parameter 2 to be long, object given in %s on line %d +bool(false) + +-- instance of classWithoutToString -- + +Warning: date_time_set() expects parameter 2 to be long, object given in %s on line %d +bool(false) + +-- undefined var -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-29 00:13:45" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- unset var -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-29 00:13:45" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- resource -- + +Warning: date_time_set() expects parameter 2 to be long, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/date_time_set_variation3.phpt b/ext/date/tests/date_time_set_variation3.phpt new file mode 100644 index 0000000000..33511b82eb --- /dev/null +++ b/ext/date/tests/date_time_set_variation3.phpt @@ -0,0 +1,329 @@ +--TEST-- +Test date_time_set() function : usage variation - Passing unexpected values to third argument $minute. +--FILE-- +<?php +/* Prototype : DateTime date_time_set ( DateTime $object , int $hour , int $minute [, int $second ] ) + * Description: Resets the current time of the DateTime object to a different time. + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::setTime + */ + +echo "*** Testing date_time_set() : usage variation - unexpected values to third argument \$minute***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -12345, + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + // resource + 'resource' => $file_handle +); + +$object = date_create("2009-01-31 15:14:10"); +$hour = 10; +$sec = 45; + +foreach($inputs as $variation =>$minute) { + echo "\n-- $variation --\n"; + var_dump( date_time_set($object, $hour, $minute, $sec) ); +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing date_time_set() : usage variation - unexpected values to third argument $minute*** + +-- int 0 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 10:00:45" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- int 1 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 10:01:45" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- int 12345 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-02-08 23:45:45" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- int -12345 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-30 20:15:45" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- float 10.5 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-30 10:10:45" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- float -10.5 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-30 09:50:45" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- float .5 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-30 10:00:45" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- empty array -- + +Warning: date_time_set() expects parameter 3 to be long, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: date_time_set() expects parameter 3 to be long, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: date_time_set() expects parameter 3 to be long, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: date_time_set() expects parameter 3 to be long, array given in %s on line %d +bool(false) + +-- uppercase NULL -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-30 10:00:45" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- lowercase null -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-30 10:00:45" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- lowercase true -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-30 10:01:45" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- lowercase false -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-30 10:00:45" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- uppercase TRUE -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-30 10:01:45" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- uppercase FALSE -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-30 10:00:45" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- empty string DQ -- + +Warning: date_time_set() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- empty string SQ -- + +Warning: date_time_set() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- string DQ -- + +Warning: date_time_set() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- string SQ -- + +Warning: date_time_set() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- mixed case string -- + +Warning: date_time_set() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- heredoc -- + +Warning: date_time_set() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- instance of classWithToString -- + +Warning: date_time_set() expects parameter 3 to be long, object given in %s on line %d +bool(false) + +-- instance of classWithoutToString -- + +Warning: date_time_set() expects parameter 3 to be long, object given in %s on line %d +bool(false) + +-- undefined var -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-30 10:00:45" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- unset var -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-30 10:00:45" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- resource -- + +Warning: date_time_set() expects parameter 3 to be long, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/date_time_set_variation4.phpt b/ext/date/tests/date_time_set_variation4.phpt new file mode 100644 index 0000000000..d767343177 --- /dev/null +++ b/ext/date/tests/date_time_set_variation4.phpt @@ -0,0 +1,329 @@ +--TEST-- +Test date_time_set() function : usage variation - Passing unexpected values to forth argument $sec. +--FILE-- +<?php +/* Prototype : DateTime date_time_set ( DateTime $object , int $hour , int $minute [, int $second ] ) + * Description: Resets the current time of the DateTime object to a different time. + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::setTime + */ + +echo "*** Testing date_time_set() : usage variation - unexpected values to forth argument \$sec***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -12345, + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + // resource + 'resource' => $file_handle +); + +$object = date_create("2009-01-31 15:14:10"); +$hour = 10; +$minute = 13; + +foreach($inputs as $variation =>$sec) { + echo "\n-- $variation --\n"; + var_dump( date_time_set($object, $hour, $minute, $sec) ); +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing date_time_set() : usage variation - unexpected values to forth argument $sec*** + +-- int 0 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 10:13:00" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- int 1 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 10:13:01" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- int 12345 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 13:38:45" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- int -12345 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 06:47:15" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- float 10.5 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 10:13:10" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- float -10.5 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 10:12:50" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- float .5 -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 10:13:00" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- empty array -- + +Warning: date_time_set() expects parameter 4 to be long, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: date_time_set() expects parameter 4 to be long, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: date_time_set() expects parameter 4 to be long, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: date_time_set() expects parameter 4 to be long, array given in %s on line %d +bool(false) + +-- uppercase NULL -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 10:13:00" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- lowercase null -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 10:13:00" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- lowercase true -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 10:13:01" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- lowercase false -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 10:13:00" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- uppercase TRUE -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 10:13:01" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- uppercase FALSE -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 10:13:00" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- empty string DQ -- + +Warning: date_time_set() expects parameter 4 to be long, Unicode string given in %s on line %d +bool(false) + +-- empty string SQ -- + +Warning: date_time_set() expects parameter 4 to be long, Unicode string given in %s on line %d +bool(false) + +-- string DQ -- + +Warning: date_time_set() expects parameter 4 to be long, Unicode string given in %s on line %d +bool(false) + +-- string SQ -- + +Warning: date_time_set() expects parameter 4 to be long, Unicode string given in %s on line %d +bool(false) + +-- mixed case string -- + +Warning: date_time_set() expects parameter 4 to be long, Unicode string given in %s on line %d +bool(false) + +-- heredoc -- + +Warning: date_time_set() expects parameter 4 to be long, Unicode string given in %s on line %d +bool(false) + +-- instance of classWithToString -- + +Warning: date_time_set() expects parameter 4 to be long, object given in %s on line %d +bool(false) + +-- instance of classWithoutToString -- + +Warning: date_time_set() expects parameter 4 to be long, object given in %s on line %d +bool(false) + +-- undefined var -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 10:13:00" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- unset var -- +object(DateTime)#%d (3) { + [u"date"]=> + unicode(19) "2009-01-31 10:13:00" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(13) "Europe/London" +} + +-- resource -- + +Warning: date_time_set() expects parameter 4 to be long, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/date_timezone_get_basic1.phpt b/ext/date/tests/date_timezone_get_basic1.phpt new file mode 100644 index 0000000000..91a0b33e7d --- /dev/null +++ b/ext/date/tests/date_timezone_get_basic1.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test date_timezone_get() function : basic functionality +--FILE-- +<?php +/* Prototype : DateTimeZone date_timezone_get ( DateTime $object ) + * Description: Return time zone relative to given DateTime + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::setTimezone + */ + +echo "*** Testing date_timezone_get() : basic functionality ***\n"; + +date_default_timezone_set("Europe/London"); +$object = date_create("2009-01-30 17:57:32"); +$tz = date_timezone_get($object); +var_dump( timezone_name_get($tz) ); + +date_default_timezone_set("America/New_York"); +$object = date_create("2009-01-30 17:57:32"); +$tz = date_timezone_get($object); +var_dump( timezone_name_get($tz) ); + +$la_time = timezone_open("America/Los_Angeles"); +date_timezone_set($object, $la_time); +$tz = date_timezone_get($object); +var_dump( timezone_name_get($tz) ); + +?> +===DONE=== +--EXPECTF-- +*** Testing date_timezone_get() : basic functionality *** +unicode(13) "Europe/London" +unicode(16) "America/New_York" +unicode(19) "America/Los_Angeles" +===DONE===
\ No newline at end of file diff --git a/ext/date/tests/date_timezone_get_error.phpt b/ext/date/tests/date_timezone_get_error.phpt new file mode 100644 index 0000000000..1310cbe9d6 --- /dev/null +++ b/ext/date/tests/date_timezone_get_error.phpt @@ -0,0 +1,56 @@ +--TEST-- +Test date_timezone_get() function : error conditions +--FILE-- +<?php +/* Prototype : DateTimeZone date_timezone_get ( DateTime $object ) + * Description: Return time zone relative to given DateTime + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::getTimezone + */ + +// Set timezone +date_default_timezone_set("Europe/London"); + +echo "*** Testing date_timezone_get() : error conditions ***\n"; + +echo "\n-- Testing date_timezone_get() function with zero arguments --\n"; +var_dump( date_timezone_get() ); + +echo "\n-- Testing date_timezone_get() function with more than expected no. of arguments --\n"; +$datetime = date_create("2009-01-30 17:57:32"); +$extra_arg = 99; +var_dump( date_timezone_get($datetime, $extra_arg) ); + +echo "\n-- Testing date_timezone_get() function with an invalid values for \$object argument --\n"; +$invalid_obj = new stdClass(); +var_dump( date_timezone_get($invalid_obj) ); +$invalid_obj = 10; +var_dump( date_timezone_get($invalid_obj) ); +$invalid_obj = null; +var_dump( date_timezone_get($invalid_obj) ); +?> +===DONE=== +--EXPECTF-- +*** Testing date_timezone_get() : error conditions *** + +-- Testing date_timezone_get() function with zero arguments -- + +Warning: date_timezone_get() expects exactly 1 parameter, 0 given in %s on line %d +bool(false) + +-- Testing date_timezone_get() function with more than expected no. of arguments -- + +Warning: date_timezone_get() expects exactly 1 parameter, 2 given in %s on line %d +bool(false) + +-- Testing date_timezone_get() function with an invalid values for $object argument -- + +Warning: date_timezone_get() expects parameter 1 to be DateTime, object given in %s on line %d +bool(false) + +Warning: date_timezone_get() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +Warning: date_timezone_get() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/date_timezone_get_variation1.phpt b/ext/date/tests/date_timezone_get_variation1.phpt new file mode 100644 index 0000000000..fcc6d65d07 --- /dev/null +++ b/ext/date/tests/date_timezone_get_variation1.phpt @@ -0,0 +1,250 @@ +--TEST-- +Test date_timezone_get() function : usage variation - Passing unexpected values to first argument $object. +--FILE-- +<?php +/* Prototype : DateTimeZone date_timezone_get ( DateTime $object ) + * Description: Return time zone relative to given DateTime + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::getTimezone + */ + +echo "*** Testing date_timezone_get() : usage variation - unexpected values to first argument \$object***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -12345, + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + // resource + 'resource' => $file_handle +); + +foreach($inputs as $variation =>$object) { + echo "\n-- $variation --\n"; + var_dump( date_timezone_get($object) ); +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing date_timezone_get() : usage variation - unexpected values to first argument $object*** + +-- int 0 -- + +Warning: date_timezone_get() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +-- int 1 -- + +Warning: date_timezone_get() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +-- int 12345 -- + +Warning: date_timezone_get() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +-- int -12345 -- + +Warning: date_timezone_get() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +-- float 10.5 -- + +Warning: date_timezone_get() expects parameter 1 to be DateTime, double given in %s on line %d +bool(false) + +-- float -10.5 -- + +Warning: date_timezone_get() expects parameter 1 to be DateTime, double given in %s on line %d +bool(false) + +-- float .5 -- + +Warning: date_timezone_get() expects parameter 1 to be DateTime, double given in %s on line %d +bool(false) + +-- empty array -- + +Warning: date_timezone_get() expects parameter 1 to be DateTime, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: date_timezone_get() expects parameter 1 to be DateTime, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: date_timezone_get() expects parameter 1 to be DateTime, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: date_timezone_get() expects parameter 1 to be DateTime, array given in %s on line %d +bool(false) + +-- uppercase NULL -- + +Warning: date_timezone_get() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) + +-- lowercase null -- + +Warning: date_timezone_get() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) + +-- lowercase true -- + +Warning: date_timezone_get() expects parameter 1 to be DateTime, boolean given in %s on line %d +bool(false) + +-- lowercase false -- + +Warning: date_timezone_get() expects parameter 1 to be DateTime, boolean given in %s on line %d +bool(false) + +-- uppercase TRUE -- + +Warning: date_timezone_get() expects parameter 1 to be DateTime, boolean given in %s on line %d +bool(false) + +-- uppercase FALSE -- + +Warning: date_timezone_get() expects parameter 1 to be DateTime, boolean given in %s on line %d +bool(false) + +-- empty string DQ -- + +Warning: date_timezone_get() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- empty string SQ -- + +Warning: date_timezone_get() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- string DQ -- + +Warning: date_timezone_get() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- string SQ -- + +Warning: date_timezone_get() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- mixed case string -- + +Warning: date_timezone_get() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- heredoc -- + +Warning: date_timezone_get() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- instance of classWithToString -- + +Warning: date_timezone_get() expects parameter 1 to be DateTime, object given in %s on line %d +bool(false) + +-- instance of classWithoutToString -- + +Warning: date_timezone_get() expects parameter 1 to be DateTime, object given in %s on line %d +bool(false) + +-- undefined var -- + +Warning: date_timezone_get() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) + +-- unset var -- + +Warning: date_timezone_get() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) + +-- resource -- + +Warning: date_timezone_get() expects parameter 1 to be DateTime, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/date_timezone_set_basic1.phpt b/ext/date/tests/date_timezone_set_basic1.phpt new file mode 100644 index 0000000000..2e9154cebe --- /dev/null +++ b/ext/date/tests/date_timezone_set_basic1.phpt @@ -0,0 +1,34 @@ +--TEST-- +Test date_timezone_set() function : basic functionality +--FILE-- +<?php +/* Prototype : DateTime date_timezone_set ( DateTime $object , DateTimeZone $timezone ) + * Description: Sets the time zone for the DateTime object + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::setTimezone + */ + +echo "*** Testing date_timezone_set() : basic functionality ***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +$datetime = date_create("2009-01-30 17:57:32"); +$tz = date_timezone_get($datetime); +echo "Default timezone: " . timezone_name_get($tz) . "\n"; + +$datetime = date_create("2009-01-30 22:57:32"); +$la_time = timezone_open("America/Los_Angeles"); + +date_timezone_set($datetime, $la_time); +$tz = date_timezone_get($datetime); +echo "New timezone: " . timezone_name_get($tz) . "\n"; + +?> +===DONE=== +--EXPECTF-- +*** Testing date_timezone_set() : basic functionality *** +Default timezone: Europe/London +New timezone: America/Los_Angeles +===DONE=== + diff --git a/ext/date/tests/date_timezone_set_error.phpt b/ext/date/tests/date_timezone_set_error.phpt new file mode 100644 index 0000000000..8c9c00d638 --- /dev/null +++ b/ext/date/tests/date_timezone_set_error.phpt @@ -0,0 +1,64 @@ +--TEST-- +Test date_timezone_set() function : error conditions +--FILE-- +<?php +/* Prototype : DateTime date_timezone_set ( DateTime $object , DateTimeZone $timezone ) + * Description: Sets the time zone for the DateTime object + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::setTimezone + */ + +date_default_timezone_set("UTC"); + +echo "*** Testing date_timezone_set() : error conditions ***\n"; + +echo "\n-- Testing date_timezone_set() function with zero arguments --\n"; +var_dump( date_timezone_set() ); + +echo "\n-- Testing date_timezone_set() function with less than expected no. of arguments --\n"; +$datetime = date_create("2009-01-30 17:57:32"); +var_dump( date_timezone_set($datetime) ); + +echo "\n-- Testing date_timezone_set() function with more than expected no. of arguments --\n"; +$timezone = timezone_open("GMT"); +$extra_arg = 99; +var_dump( date_timezone_set($datetime, $timezone, $extra_arg) ); + +echo "\n-- Testing date_timezone_set() function with an invalid values for \$object argument --\n"; +$invalid_obj = new stdClass(); +var_dump( date_timezone_set($invalid_obj, $timezone) ); +$invalid_obj = 10; +var_dump( date_timezone_set($invalid_obj, $timezone) ); +$invalid_obj = null; +var_dump( date_timezone_set($invalid_obj, $timezone) ); +?> +===DONE=== +--EXPECTF-- +*** Testing date_timezone_set() : error conditions *** + +-- Testing date_timezone_set() function with zero arguments -- + +Warning: date_timezone_set() expects exactly 2 parameters, 0 given in %s on line %d +bool(false) + +-- Testing date_timezone_set() function with less than expected no. of arguments -- + +Warning: date_timezone_set() expects exactly 2 parameters, 1 given in %s on line %d +bool(false) + +-- Testing date_timezone_set() function with more than expected no. of arguments -- + +Warning: date_timezone_set() expects exactly 2 parameters, 3 given in %s on line %d +bool(false) + +-- Testing date_timezone_set() function with an invalid values for $object argument -- + +Warning: date_timezone_set() expects parameter 1 to be DateTime, object given in %s on line %d +bool(false) + +Warning: date_timezone_set() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +Warning: date_timezone_set() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/date_timezone_set_variation1.phpt b/ext/date/tests/date_timezone_set_variation1.phpt new file mode 100644 index 0000000000..43bbb3aa53 --- /dev/null +++ b/ext/date/tests/date_timezone_set_variation1.phpt @@ -0,0 +1,254 @@ +--TEST-- +Test date_timezone_set() function : usage variation - Passing unexpected values to first argument $object. +--FILE-- +<?php +/* Prototype : DateTime date_timezone_set ( DateTime $object , DateTimeZone $timezone ) + * Description: Sets the time zone for the DateTime object + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::setTimezone + */ + +echo "*** Testing date_timezone_set() : usage variation - unexpected values to first argument \$object***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -12345, + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + // resource + 'resource' => $file_handle +); + +$timezone = timezone_open("America/Los_Angeles"); + +foreach($inputs as $variation =>$object) { + echo "\n-- $variation --\n"; + var_dump( date_timezone_set($object, $timezone) ); +}; + + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing date_timezone_set() : usage variation - unexpected values to first argument $object*** + +-- int 0 -- + +Warning: date_timezone_set() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +-- int 1 -- + +Warning: date_timezone_set() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +-- int 12345 -- + +Warning: date_timezone_set() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +-- int -12345 -- + +Warning: date_timezone_set() expects parameter 1 to be DateTime, integer given in %s on line %d +bool(false) + +-- float 10.5 -- + +Warning: date_timezone_set() expects parameter 1 to be DateTime, double given in %s on line %d +bool(false) + +-- float -10.5 -- + +Warning: date_timezone_set() expects parameter 1 to be DateTime, double given in %s on line %d +bool(false) + +-- float .5 -- + +Warning: date_timezone_set() expects parameter 1 to be DateTime, double given in %s on line %d +bool(false) + +-- empty array -- + +Warning: date_timezone_set() expects parameter 1 to be DateTime, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: date_timezone_set() expects parameter 1 to be DateTime, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: date_timezone_set() expects parameter 1 to be DateTime, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: date_timezone_set() expects parameter 1 to be DateTime, array given in %s on line %d +bool(false) + +-- uppercase NULL -- + +Warning: date_timezone_set() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) + +-- lowercase null -- + +Warning: date_timezone_set() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) + +-- lowercase true -- + +Warning: date_timezone_set() expects parameter 1 to be DateTime, boolean given in %s on line %d +bool(false) + +-- lowercase false -- + +Warning: date_timezone_set() expects parameter 1 to be DateTime, boolean given in %s on line %d +bool(false) + +-- uppercase TRUE -- + +Warning: date_timezone_set() expects parameter 1 to be DateTime, boolean given in %s on line %d +bool(false) + +-- uppercase FALSE -- + +Warning: date_timezone_set() expects parameter 1 to be DateTime, boolean given in %s on line %d +bool(false) + +-- empty string DQ -- + +Warning: date_timezone_set() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- empty string SQ -- + +Warning: date_timezone_set() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- string DQ -- + +Warning: date_timezone_set() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- string SQ -- + +Warning: date_timezone_set() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- mixed case string -- + +Warning: date_timezone_set() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- heredoc -- + +Warning: date_timezone_set() expects parameter 1 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- instance of classWithToString -- + +Warning: date_timezone_set() expects parameter 1 to be DateTime, object given in %s on line %d +bool(false) + +-- instance of classWithoutToString -- + +Warning: date_timezone_set() expects parameter 1 to be DateTime, object given in %s on line %d +bool(false) + +-- undefined var -- + +Warning: date_timezone_set() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) + +-- unset var -- + +Warning: date_timezone_set() expects parameter 1 to be DateTime, null given in %s on line %d +bool(false) + +-- resource -- + +Warning: date_timezone_set() expects parameter 1 to be DateTime, resource given in %s on line %d +bool(false) +===DONE=== + diff --git a/ext/date/tests/date_timezone_set_variation2.phpt b/ext/date/tests/date_timezone_set_variation2.phpt new file mode 100644 index 0000000000..31f6766818 --- /dev/null +++ b/ext/date/tests/date_timezone_set_variation2.phpt @@ -0,0 +1,252 @@ +--TEST-- +Test date_timezone_set() function : usage variation - Passing unexpected values to second argument $timezone. +--FILE-- +<?php +/* Prototype : DateTime date_timezone_set ( DateTime $object , DateTimeZone $timezone ) + * Description: Sets the time zone for the DateTime object + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::setTimezone + */ + +echo "*** Testing date_timezone_set() : usage variation - unexpected values to second argument \$timezone***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -12345, + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + // resource + 'resource' => $file_handle +); + +$object = date_create("2009-01-30 17:57:32"); + +foreach($inputs as $variation =>$timezone) { + echo "\n-- $variation --\n"; + var_dump( date_timezone_set($object, $timezone) ); +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing date_timezone_set() : usage variation - unexpected values to second argument $timezone*** + +-- int 0 -- + +Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, integer given in %s on line %d +bool(false) + +-- int 1 -- + +Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, integer given in %s on line %d +bool(false) + +-- int 12345 -- + +Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, integer given in %s on line %d +bool(false) + +-- int -12345 -- + +Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, integer given in %s on line %d +bool(false) + +-- float 10.5 -- + +Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, double given in %s on line %d +bool(false) + +-- float -10.5 -- + +Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, double given in %s on line %d +bool(false) + +-- float .5 -- + +Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, double given in %s on line %d +bool(false) + +-- empty array -- + +Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, array given in %s on line %d +bool(false) + +-- uppercase NULL -- + +Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, null given in %s on line %d +bool(false) + +-- lowercase null -- + +Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, null given in %s on line %d +bool(false) + +-- lowercase true -- + +Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, boolean given in %s on line %d +bool(false) + +-- lowercase false -- + +Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, boolean given in %s on line %d +bool(false) + +-- uppercase TRUE -- + +Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, boolean given in %s on line %d +bool(false) + +-- uppercase FALSE -- + +Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, boolean given in %s on line %d +bool(false) + +-- empty string DQ -- + +Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, Unicode string given in %s on line %d +bool(false) + +-- empty string SQ -- + +Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, Unicode string given in %s on line %d +bool(false) + +-- string DQ -- + +Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, Unicode string given in %s on line %d +bool(false) + +-- string SQ -- + +Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, Unicode string given in %s on line %d +bool(false) + +-- mixed case string -- + +Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, Unicode string given in %s on line %d +bool(false) + +-- heredoc -- + +Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, Unicode string given in %s on line %d +bool(false) + +-- instance of classWithToString -- + +Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, object given in %s on line %d +bool(false) + +-- instance of classWithoutToString -- + +Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, object given in %s on line %d +bool(false) + +-- undefined var -- + +Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, null given in %s on line %d +bool(false) + +-- unset var -- + +Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, null given in %s on line %d +bool(false) + +-- resource -- + +Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/date_variation1.phpt b/ext/date/tests/date_variation1.phpt new file mode 100644 index 0000000000..8df692ace5 --- /dev/null +++ b/ext/date/tests/date_variation1.phpt @@ -0,0 +1,207 @@ +--TEST-- +Test date() function : usage variation - Passing unexpected values to first argument $format. +--FILE-- +<?php +/* Prototype : string date ( string $format [, int $timestamp ] ) + * Description: Format a local time/date. + * Source code: ext/date/php_date.c + */ + +echo "*** Testing date() : usage variation - unexpected values to first argument \$format***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -12345, + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + // resource + 'resource' => $file_handle +); + +$timestamp = mktime(10, 44, 30, 2, 27, 2009); + +foreach($inputs as $variation =>$format) { + echo "\n-- $variation --\n"; + var_dump( date($format, $timestamp) ); +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing date() : usage variation - unexpected values to first argument $format*** + +-- int 0 -- +unicode(1) "0" + +-- int 1 -- +unicode(1) "1" + +-- int 12345 -- +unicode(5) "12345" + +-- int -12345 -- +unicode(6) "-12345" + +-- float 10.5 -- +unicode(4) "10.5" + +-- float -10.5 -- +unicode(5) "-10.5" + +-- float .5 -- +unicode(3) "0.5" + +-- empty array -- + +Warning: date() expects parameter 1 to be binary string, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: date() expects parameter 1 to be binary string, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: date() expects parameter 1 to be binary string, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: date() expects parameter 1 to be binary string, array given in %s on line %d +bool(false) + +-- uppercase NULL -- +unicode(0) "" + +-- lowercase null -- +unicode(0) "" + +-- lowercase true -- +unicode(1) "1" + +-- lowercase false -- +unicode(0) "" + +-- uppercase TRUE -- +unicode(1) "1" + +-- uppercase FALSE -- +unicode(0) "" + +-- empty string DQ -- +unicode(0) "" + +-- empty string SQ -- +unicode(0) "" + +-- string DQ -- +unicode(40) "3028Fri, 27 Feb 2009 10:44:30 +000044210" + +-- string SQ -- +unicode(40) "3028Fri, 27 Feb 2009 10:44:30 +000044210" + +-- mixed case string -- +unicode(40) "30GMTFri, 27 Feb 2009 10:44:30 +00000210" + +-- heredoc -- +unicode(76) "10Europe/LondonFridayFriday2009 52009Fri, 27 Feb 2009 10:44:30 +0000Friday27" + +-- instance of classWithToString -- +unicode(64) "CFridayam3030 AM 2009b27Europe/London2009-02-27T10:44:30+00:0028" + +-- instance of classWithoutToString -- + +Warning: date() expects parameter 1 to be binary string, object given in %s on line %d +bool(false) + +-- undefined var -- +unicode(0) "" + +-- unset var -- +unicode(0) "" + +-- resource -- + +Warning: date() expects parameter 1 to be binary string, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/date_variation2.phpt b/ext/date/tests/date_variation2.phpt new file mode 100644 index 0000000000..bc55be9017 --- /dev/null +++ b/ext/date/tests/date_variation2.phpt @@ -0,0 +1,222 @@ +--TEST-- +Test date() function : usage variation - Passing unexpected values to second argument $timestamp. +--FILE-- +<?php +/* Prototype : string date ( string $format [, int $timestamp ] ) + * Description: Format a local time/date. + * Source code: ext/date/php_date.c + */ + +echo "*** Testing date() : usage variation - unexpected values to second argument \$timestamp***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithTounicode +{ + public function __tounicode() { + return "Class A object"; + } +} + +class classWithoutTounicode +{ +} + +// heredoc unicode +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -12345, + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty unicode DQ' => "", + 'empty unicode SQ' => '', + + // unicode data + 'unicode DQ' => "unicode", + 'unicode SQ' => 'unicode', + 'mixed case unicode' => "unicode", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithTounicode' => new classWithTounicode(), + 'instance of classWithoutTounicode' => new classWithoutTounicode(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + // resource + 'resource' => $file_handle +); + +$format = "F j, Y, g:i a"; + +foreach($inputs as $variation =>$timestamp) { + echo "\n-- $variation --\n"; + var_dump( date($format, $timestamp) ); +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing date() : usage variation - unexpected values to second argument $timestamp*** + +-- int 0 -- +unicode(24) "January 1, 1970, 1:00 am" + +-- int 1 -- +unicode(24) "January 1, 1970, 1:00 am" + +-- int 12345 -- +unicode(24) "January 1, 1970, 4:25 am" + +-- int -12345 -- +unicode(26) "December 31, 1969, 9:34 pm" + +-- float 10.5 -- +unicode(24) "January 1, 1970, 1:00 am" + +-- float -10.5 -- +unicode(25) "January 1, 1970, 12:59 am" + +-- float .5 -- +unicode(24) "January 1, 1970, 1:00 am" + +-- empty array -- + +Warning: date() expects parameter 2 to be long, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: date() expects parameter 2 to be long, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: date() expects parameter 2 to be long, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: date() expects parameter 2 to be long, array given in %s on line %d +bool(false) + +-- uppercase NULL -- +unicode(24) "January 1, 1970, 1:00 am" + +-- lowercase null -- +unicode(24) "January 1, 1970, 1:00 am" + +-- lowercase true -- +unicode(24) "January 1, 1970, 1:00 am" + +-- lowercase false -- +unicode(24) "January 1, 1970, 1:00 am" + +-- uppercase TRUE -- +unicode(24) "January 1, 1970, 1:00 am" + +-- uppercase FALSE -- +unicode(24) "January 1, 1970, 1:00 am" + +-- empty unicode DQ -- + +Warning: date() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- empty unicode SQ -- + +Warning: date() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- unicode DQ -- + +Warning: date() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- unicode SQ -- + +Warning: date() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- mixed case unicode -- + +Warning: date() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- heredoc -- + +Warning: date() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- instance of classWithTounicode -- + +Warning: date() expects parameter 2 to be long, object given in %s on line %d +bool(false) + +-- instance of classWithoutTounicode -- + +Warning: date() expects parameter 2 to be long, object given in %s on line %d +bool(false) + +-- undefined var -- +unicode(24) "January 1, 1970, 1:00 am" + +-- unset var -- +unicode(24) "January 1, 1970, 1:00 am" + +-- resource -- + +Warning: date() expects parameter 2 to be long, resource given in %s on line %d +bool(false) +===DONE=== + diff --git a/ext/date/tests/idate_error.phpt b/ext/date/tests/idate_error.phpt new file mode 100644 index 0000000000..7dad4606d7 --- /dev/null +++ b/ext/date/tests/idate_error.phpt @@ -0,0 +1,37 @@ +--TEST-- +Test idate() function : error conditions +--FILE-- +<?php +/* Prototype : int idate(string format [, int timestamp]) + * Description: Format a local time/date as integer + * Source code: ext/date/php_date.c + * Alias to functions: + */ + +echo "*** Testing idate() : error conditions ***\n"; + +echo "\n-- Testing idate() function with Zero arguments --\n"; +var_dump( idate() ); + +echo "\n-- Testing idate() function with more than expected no. of arguments --\n"; +$format = '%b %d %Y %H:%M:%S'; +$timestamp = gmmktime(8, 8, 8, 8, 8, 2008); +$extra_arg = 10; +var_dump( idate($format, $timestamp, $extra_arg) ); + +?> +===DONE=== +--EXPECTF-- +*** Testing idate() : error conditions *** + +-- Testing idate() function with Zero arguments -- + +Warning: idate() expects at least 1 parameter, 0 given in %s on line %d +bool(false) + +-- Testing idate() function with more than expected no. of arguments -- + +Warning: idate() expects at most 2 parameters, 3 given in %s on line %d +bool(false) +===DONE=== + diff --git a/ext/date/tests/localtime_error.phpt b/ext/date/tests/localtime_error.phpt new file mode 100644 index 0000000000..b231ed0749 --- /dev/null +++ b/ext/date/tests/localtime_error.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test localtime() function : error conditions +--FILE-- +<?php +/* Prototype : array localtime([int timestamp [, bool associative_array]]) + * Description: Returns the results of the C system call localtime as an associative array + * if the associative_array argument is set to 1 other wise it is a regular array + * Source code: ext/date/php_date.c + * Alias to functions: + */ + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +echo "*** Testing localtime() : error conditions ***\n"; + +echo "\n-- Testing localtime() function with more than expected no. of arguments --\n"; +$timestamp = gmmktime(8, 8, 8, 8, 8, 2008); +$assoc = true; +$extra_arg = 10; +var_dump( localtime($timestamp, $assoc, $extra_arg) ); + +?> +===DONE=== +--EXPECTF-- +*** Testing localtime() : error conditions *** + +-- Testing localtime() function with more than expected no. of arguments -- + +Warning: localtime() expects at most 2 parameters, 3 given in %s on line %d +bool(false) +===DONE=== + diff --git a/ext/date/tests/mktime_basic1.phpt b/ext/date/tests/mktime_basic1.phpt new file mode 100644 index 0000000000..dc17c29b78 --- /dev/null +++ b/ext/date/tests/mktime_basic1.phpt @@ -0,0 +1,47 @@ +--TEST-- +Test mktime() function : basic functionality +--FILE-- +<?php +/* Prototype : int mktime ([ int $hour= date("H") [, int $minute= date("i") [, int $second= date("s") [, int $month= date("n") [, int $day= date("j") [, int $year= date("Y") [, int $is_dst= -1 ]]]]]]] ) + * Description: Get Unix timestamp for a date + * Source code: ext/date/php_date.c + * Alias to functions: + */ +error_reporting(E_ALL | E_STRICT); + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +echo "*** Testing DateTime::modify() : basic functionality ***\n"; + +$hour = 10; +$minute = 30; +$sec = 45; +$month = 7; +$day = 2; +$year = 1963; +$is_dst = 0; + +var_dump( mktime($hour) ); +var_dump( mktime($hour, $minute) ); +var_dump( mktime($hour, $minute, $sec) ); +var_dump( mktime($hour, $minute, $sec, $month) ); +var_dump( mktime($hour, $minute, $sec, $month, $day) ); +var_dump( mktime($hour, $minute, $sec, $month, $day, $year) ); +var_dump( mktime($hour, $minute, $sec, $month, $day, $year, $is_dst) ); + +?> +===DONE=== +--EXPECTF-- +*** Testing DateTime::modify() : basic functionality *** +int(%i) +int(%i) +int(%i) +int(%i) +int(%i) +int(%i) + +Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d +int(%i) +===DONE=== + diff --git a/ext/date/tests/mktime_error.phpt b/ext/date/tests/mktime_error.phpt new file mode 100644 index 0000000000..f517dc8aa3 --- /dev/null +++ b/ext/date/tests/mktime_error.phpt @@ -0,0 +1,45 @@ +--TEST-- +Test mktime() function : error conditions +--FILE-- +<?php +/* Prototype : int mktime ([ int $hour= date("H") [, int $minute= date("i") [, int $second= date("s") [, int $month= date("n") [, int $day= date("j") [, int $year= date("Y") [, int $is_dst= -1 ]]]]]]] ) + * Description: Get Unix timestamp for a date + * Source code: ext/date/php_date.c + * Alias to functions: + */ +error_reporting(E_ALL | E_STRICT); + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +echo "*** Testing mktime() : error conditions ***\n"; + +echo "\n-- Testing mktime() function with Zero arguments --\n"; +var_dump( mktime() ); + +echo "\n-- Testing mktime() function with more than expected no. of arguments --\n"; +$hour = 10; +$minute = 30; +$sec = 45; +$month = 7; +$day = 2; +$year = 1963; +$is_dst = 0; +$extra_arg = 10; +var_dump( mktime($hour, $minute, $sec, $month, $day, $year, $is_dst, $extra_arg) ); + +?> +===DONE=== +--EXPECTF-- +*** Testing mktime() : error conditions *** + +-- Testing mktime() function with Zero arguments -- + +Strict Standards: mktime(): You should be using the time() function instead in %s on line %d +int(%d) + +-- Testing mktime() function with more than expected no. of arguments -- + +Warning: mktime() expects at most 7 parameters, 8 given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/mktime_variation1.phpt b/ext/date/tests/mktime_variation1.phpt new file mode 100644 index 0000000000..cc1d50e916 --- /dev/null +++ b/ext/date/tests/mktime_variation1.phpt @@ -0,0 +1,224 @@ +--TEST-- +Test mktime() function : usage variation - Passing unexpected values to first argument $hour. +--FILE-- +<?php +/* Prototype : int mktime ([ int $hour= date("H") [, int $minute= date("i") [, int $second= date("s") [, int $month= date("n") [, int $day= date("j") [, int $year= date("Y") [, int $is_dst= -1 ]]]]]]] ) + * Description: Get Unix timestamp for a date + * Source code: ext/date/php_date.c + * Alias to functions: + */ + +echo "*** Testing mktime() : usage variation - unexpected values to first argument \$hour***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 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 +); + +$hour = 10; +$minute = 30; +$sec = 45; +$month = 7; +$day = 2; +$year = 1963; +$is_dst = 0; + +foreach($inputs as $variation =>$hour) { + echo "\n-- $variation --\n"; + var_dump( mktime($hour) ); +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing mktime() : usage variation - unexpected values to first argument $hour*** + +-- int 0 -- +int(%i) + +-- int 12345 -- +int(%i) + +-- int -12345 -- +int(%i) + +-- float 10.5 -- +int(%i) + +-- float -10.5 -- +int(%i) + +-- float .5 -- +int(%i) + +-- empty array -- + +Warning: mktime() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: mktime() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: mktime() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: mktime() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +-- uppercase NULL -- +int(%i) + +-- lowercase null -- +int(%i) + +-- lowercase true -- +int(%i) + +-- lowercase false -- +int(%i) + +-- uppercase TRUE -- +int(%i) + +-- uppercase FALSE -- +int(%i) + +-- empty string DQ -- + +Warning: mktime() expects parameter 1 to be long, Unicode string given in %s on line %d +bool(false) + +-- empty string SQ -- + +Warning: mktime() expects parameter 1 to be long, Unicode string given in %s on line %d +bool(false) + +-- string DQ -- + +Warning: mktime() expects parameter 1 to be long, Unicode string given in %s on line %d +bool(false) + +-- string SQ -- + +Warning: mktime() expects parameter 1 to be long, Unicode string given in %s on line %d +bool(false) + +-- mixed case string -- + +Warning: mktime() expects parameter 1 to be long, Unicode string given in %s on line %d +bool(false) + +-- heredoc -- + +Warning: mktime() expects parameter 1 to be long, Unicode string given in %s on line %d +bool(false) + +-- instance of classWithToString -- + +Warning: mktime() expects parameter 1 to be long, object given in %s on line %d +bool(false) + +-- instance of classWithoutToString -- + +Warning: mktime() expects parameter 1 to be long, object given in %s on line %d +bool(false) + +-- undefined var -- +int(%i) + +-- unset var -- +int(%i) + +-- resource -- + +Warning: mktime() expects parameter 1 to be long, resource given in %s on line %d +bool(false) +===DONE===
\ No newline at end of file diff --git a/ext/date/tests/mktime_variation2.phpt b/ext/date/tests/mktime_variation2.phpt new file mode 100644 index 0000000000..66467ffb39 --- /dev/null +++ b/ext/date/tests/mktime_variation2.phpt @@ -0,0 +1,218 @@ +--TEST-- +Test mktime() function : usage variation - Passing unexpected values to second argument $minute. +--FILE-- +<?php +/* Prototype : int mktime ([ int $hour= date("H") [, int $minute= date("i") [, int $second= date("s") [, int $month= date("n") [, int $day= date("j") [, int $year= date("Y") [, int $is_dst= -1 ]]]]]]] ) + * Description: Get Unix timestamp for a date + * Source code: ext/date/php_date.c + * Alias to functions: + */ + +echo "*** Testing mktime() : usage variation - unexpected values to second argument \$minute***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 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 +); + +$hour = 10; + +foreach($inputs as $variation =>$minute) { + echo "\n-- $variation --\n"; + var_dump( mktime($hour, $minute) ); +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing mktime() : usage variation - unexpected values to second argument $minute*** + +-- int 0 -- +int(%i) + +-- int 12345 -- +int(%i) + +-- int -12345 -- +int(%i) + +-- float 10.5 -- +int(%i) + +-- float -10.5 -- +int(%i) + +-- float .5 -- +int(%i) + +-- empty array -- + +Warning: mktime() expects parameter 2 to be long, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: mktime() expects parameter 2 to be long, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: mktime() expects parameter 2 to be long, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: mktime() expects parameter 2 to be long, array given in %s on line %d +bool(false) + +-- uppercase NULL -- +int(%i) + +-- lowercase null -- +int(%i) + +-- lowercase true -- +int(%i) + +-- lowercase false -- +int(%i) + +-- uppercase TRUE -- +int(%i) + +-- uppercase FALSE -- +int(%i) + +-- empty string DQ -- + +Warning: mktime() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- empty string SQ -- + +Warning: mktime() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- string DQ -- + +Warning: mktime() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- string SQ -- + +Warning: mktime() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- mixed case string -- + +Warning: mktime() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- heredoc -- + +Warning: mktime() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- instance of classWithToString -- + +Warning: mktime() expects parameter 2 to be long, object given in %s on line %d +bool(false) + +-- instance of classWithoutToString -- + +Warning: mktime() expects parameter 2 to be long, object given in %s on line %d +bool(false) + +-- undefined var -- +int(%i) + +-- unset var -- +int(%i) + +-- resource -- + +Warning: mktime() expects parameter 2 to be long, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/mktime_variation3.phpt b/ext/date/tests/mktime_variation3.phpt new file mode 100644 index 0000000000..0de2c9b568 --- /dev/null +++ b/ext/date/tests/mktime_variation3.phpt @@ -0,0 +1,219 @@ +--TEST-- +Test mktime() function : usage variation - Passing unexpected values to third argument $second. +--FILE-- +<?php +/* Prototype : int mktime ([ int $hour= date("H") [, int $minute= date("i") [, int $second= date("s") [, int $month= date("n") [, int $day= date("j") [, int $year= date("Y") [, int $is_dst= -1 ]]]]]]] ) + * Description: Get Unix timestamp for a date + * Source code: ext/date/php_date.c + * Alias to functions: + */ + +echo "*** Testing mktime() : usage variation - unexpected values to third argument \$second***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 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 +); + +$hour = 10; +$minute = 30; + +foreach($inputs as $variation =>$second) { + echo "\n-- $variation --\n"; + var_dump( mktime($hour, $minute, $second) ); +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing mktime() : usage variation - unexpected values to third argument $second*** + +-- int 0 -- +int(%i) + +-- int 12345 -- +int(%i) + +-- int -12345 -- +int(%i) + +-- float 10.5 -- +int(%i) + +-- float -10.5 -- +int(%i) + +-- float .5 -- +int(%i) + +-- empty array -- + +Warning: mktime() expects parameter 3 to be long, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: mktime() expects parameter 3 to be long, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: mktime() expects parameter 3 to be long, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: mktime() expects parameter 3 to be long, array given in %s on line %d +bool(false) + +-- uppercase NULL -- +int(%i) + +-- lowercase null -- +int(%i) + +-- lowercase true -- +int(%i) + +-- lowercase false -- +int(%i) + +-- uppercase TRUE -- +int(%i) + +-- uppercase FALSE -- +int(%i) + +-- empty string DQ -- + +Warning: mktime() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- empty string SQ -- + +Warning: mktime() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- string DQ -- + +Warning: mktime() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- string SQ -- + +Warning: mktime() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- mixed case string -- + +Warning: mktime() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- heredoc -- + +Warning: mktime() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- instance of classWithToString -- + +Warning: mktime() expects parameter 3 to be long, object given in %s on line %d +bool(false) + +-- instance of classWithoutToString -- + +Warning: mktime() expects parameter 3 to be long, object given in %s on line %d +bool(false) + +-- undefined var -- +int(%i) + +-- unset var -- +int(%i) + +-- resource -- + +Warning: mktime() expects parameter 3 to be long, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/mktime_variation4.phpt b/ext/date/tests/mktime_variation4.phpt new file mode 100644 index 0000000000..1e21329fdb --- /dev/null +++ b/ext/date/tests/mktime_variation4.phpt @@ -0,0 +1,220 @@ +--TEST-- +Test mktime() function : usage variation - Passing unexpected values to forth argument $month. +--FILE-- +<?php +/* Prototype : int mktime ([ int $hour= date("H") [, int $minute= date("i") [, int $second= date("s") [, int $month= date("n") [, int $day= date("j") [, int $year= date("Y") [, int $is_dst= -1 ]]]]]]] ) + * Description: Get Unix timestamp for a date + * Source code: ext/date/php_date.c + * Alias to functions: + */ + +echo "*** Testing mktime() : usage variation - unexpected values to forth argument \$month***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 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 +); + +$hour = 10; +$minute = 30; +$second = 45; + +foreach($inputs as $variation =>$month) { + echo "\n-- $variation --\n"; + var_dump( mktime($hour, $minute, $second, $month) ); +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing mktime() : usage variation - unexpected values to forth argument $month*** + +-- int 0 -- +int(%i) + +-- int 12345 -- +%rint\(-?[1-9][0-9]*\)|bool\(false\)%r + +-- int -12345 -- +%rint\(-?[1-9][0-9]*\)|bool\(false\)%r + +-- float 10.5 -- +int(%i) + +-- float -10.5 -- +int(%i) + +-- float .5 -- +int(%i) + +-- empty array -- + +Warning: mktime() expects parameter 4 to be long, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: mktime() expects parameter 4 to be long, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: mktime() expects parameter 4 to be long, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: mktime() expects parameter 4 to be long, array given in %s on line %d +bool(false) + +-- uppercase NULL -- +int(%i) + +-- lowercase null -- +int(%i) + +-- lowercase true -- +int(%i) + +-- lowercase false -- +int(%i) + +-- uppercase TRUE -- +int(%i) + +-- uppercase FALSE -- +int(%i) + +-- empty string DQ -- + +Warning: mktime() expects parameter 4 to be long, Unicode string given in %s on line %d +bool(false) + +-- empty string SQ -- + +Warning: mktime() expects parameter 4 to be long, Unicode string given in %s on line %d +bool(false) + +-- string DQ -- + +Warning: mktime() expects parameter 4 to be long, Unicode string given in %s on line %d +bool(false) + +-- string SQ -- + +Warning: mktime() expects parameter 4 to be long, Unicode string given in %s on line %d +bool(false) + +-- mixed case string -- + +Warning: mktime() expects parameter 4 to be long, Unicode string given in %s on line %d +bool(false) + +-- heredoc -- + +Warning: mktime() expects parameter 4 to be long, Unicode string given in %s on line %d +bool(false) + +-- instance of classWithToString -- + +Warning: mktime() expects parameter 4 to be long, object given in %s on line %d +bool(false) + +-- instance of classWithoutToString -- + +Warning: mktime() expects parameter 4 to be long, object given in %s on line %d +bool(false) + +-- undefined var -- +int(%i) + +-- unset var -- +int(%i) + +-- resource -- + +Warning: mktime() expects parameter 4 to be long, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/mktime_variation5.phpt b/ext/date/tests/mktime_variation5.phpt new file mode 100644 index 0000000000..01846e868d --- /dev/null +++ b/ext/date/tests/mktime_variation5.phpt @@ -0,0 +1,221 @@ +--TEST-- +Test mktime() function : usage variation - Passing unexpected values to fifth argument $day. +--FILE-- +<?php +/* Prototype : int mktime ([ int $hour= date("H") [, int $minute= date("i") [, int $second= date("s") [, int $month= date("n") [, int $day= date("j") [, int $year= date("Y") [, int $is_dst= -1 ]]]]]]] ) + * Description: Get Unix timestamp for a date + * Source code: ext/date/php_date.c + * Alias to functions: + */ + +echo "*** Testing mktime() : usage variation - unexpected values to fifth argument \$day***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 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 +); + +$hour = 10; +$minute = 30; +$second = 45; +$month = 7; + +foreach($inputs as $variation =>$day) { + echo "\n-- $variation --\n"; + var_dump( mktime($hour, $minute, $second, $month, $day) ); +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing mktime() : usage variation - unexpected values to fifth argument $day*** + +-- int 0 -- +int(%i) + +-- int 12345 -- +%rint\(-?[1-9][0-9]*\)|bool\(false\)%r + +-- int -12345 -- +int(%i) + +-- float 10.5 -- +int(%i) + +-- float -10.5 -- +int(%i) + +-- float .5 -- +int(%i) + +-- empty array -- + +Warning: mktime() expects parameter 5 to be long, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: mktime() expects parameter 5 to be long, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: mktime() expects parameter 5 to be long, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: mktime() expects parameter 5 to be long, array given in %s on line %d +bool(false) + +-- uppercase NULL -- +int(%i) + +-- lowercase null -- +int(%i) + +-- lowercase true -- +int(%i) + +-- lowercase false -- +int(%i) + +-- uppercase TRUE -- +int(%i) + +-- uppercase FALSE -- +int(%i) + +-- empty string DQ -- + +Warning: mktime() expects parameter 5 to be long, Unicode string given in %s on line %d +bool(false) + +-- empty string SQ -- + +Warning: mktime() expects parameter 5 to be long, Unicode string given in %s on line %d +bool(false) + +-- string DQ -- + +Warning: mktime() expects parameter 5 to be long, Unicode string given in %s on line %d +bool(false) + +-- string SQ -- + +Warning: mktime() expects parameter 5 to be long, Unicode string given in %s on line %d +bool(false) + +-- mixed case string -- + +Warning: mktime() expects parameter 5 to be long, Unicode string given in %s on line %d +bool(false) + +-- heredoc -- + +Warning: mktime() expects parameter 5 to be long, Unicode string given in %s on line %d +bool(false) + +-- instance of classWithToString -- + +Warning: mktime() expects parameter 5 to be long, object given in %s on line %d +bool(false) + +-- instance of classWithoutToString -- + +Warning: mktime() expects parameter 5 to be long, object given in %s on line %d +bool(false) + +-- undefined var -- +int(%i) + +-- unset var -- +int(%i) + +-- resource -- + +Warning: mktime() expects parameter 5 to be long, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/mktime_variation6.phpt b/ext/date/tests/mktime_variation6.phpt new file mode 100644 index 0000000000..213791647b --- /dev/null +++ b/ext/date/tests/mktime_variation6.phpt @@ -0,0 +1,223 @@ +--TEST-- +Test mktime() function : usage variation - Passing unexpected values to sixth argument $year. +--FILE-- +<?php +/* Prototype : int mktime ([ int $hour= date("H") [, int $minute= date("i") [, int $second= date("s") [, int $month= date("n") [, int $day= date("j") [, int $year= date("Y") [, int $is_dst= -1 ]]]]]]] ) + * Description: Get Unix timestamp for a date + * Source code: ext/date/php_date.c + * Alias to functions: + */ + +echo "*** Testing mktime() : usage variation - unexpected values to sixth argument \$year***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 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 +); + +$hour = 10; +$minute = 30; +$second = 45; +$month = 7; +$day = 2; + +foreach($inputs as $variation =>$year) { + echo "\n-- $variation --\n"; + var_dump( mktime($hour, $minute, $second, $month, $day, $year) ); +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing mktime() : usage variation - unexpected values to sixth argument $year*** + +-- int 0 -- +int(%i) + +-- int 12345 -- +%rint\(-?[1-9][0-9]*\)|bool\(false\)%r + +-- int -12345 -- +%rint\(-?[1-9][0-9]*\)|bool\(false\)%r + +-- float 10.5 -- +int(%i) + +-- float -10.5 -- +%rint\(-?[1-9][0-9]*\)|bool\(false\)%r + +-- float .5 -- +int(%i) + +-- empty array -- + +Warning: mktime() expects parameter 6 to be long, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: mktime() expects parameter 6 to be long, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: mktime() expects parameter 6 to be long, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: mktime() expects parameter 6 to be long, array given in %s on line %d +bool(false) + +-- uppercase NULL -- +int(%i) + +-- lowercase null -- +int(%i) + +-- lowercase true -- +int(%i) + +-- lowercase false -- +int(%i) + +-- uppercase TRUE -- +int(%i) + +-- uppercase FALSE -- +int(%i) + +-- empty string DQ -- + +Warning: mktime() expects parameter 6 to be long, Unicode string given in %s on line %d +bool(false) + +-- empty string SQ -- + +Warning: mktime() expects parameter 6 to be long, Unicode string given in %s on line %d +bool(false) + +-- string DQ -- + +Warning: mktime() expects parameter 6 to be long, Unicode string given in %s on line %d +bool(false) + +-- string SQ -- + +Warning: mktime() expects parameter 6 to be long, Unicode string given in %s on line %d +bool(false) + +-- mixed case string -- + +Warning: mktime() expects parameter 6 to be long, Unicode string given in %s on line %d +bool(false) + +-- heredoc -- + +Warning: mktime() expects parameter 6 to be long, Unicode string given in %s on line %d +bool(false) + +-- instance of classWithToString -- + +Warning: mktime() expects parameter 6 to be long, object given in %s on line %d +bool(false) + +-- instance of classWithoutToString -- + +Warning: mktime() expects parameter 6 to be long, object given in %s on line %d +bool(false) + +-- undefined var -- +int(%i) + +-- unset var -- +int(%i) + +-- resource -- + +Warning: mktime() expects parameter 6 to be long, resource given in %s on line %d +bool(false) +===DONE=== + diff --git a/ext/date/tests/mktime_variation7.phpt b/ext/date/tests/mktime_variation7.phpt new file mode 100644 index 0000000000..fc6deca181 --- /dev/null +++ b/ext/date/tests/mktime_variation7.phpt @@ -0,0 +1,251 @@ +--TEST-- +Test mktime() function : usage variation - Passing unexpected values to seventh argument $is_dst. +--FILE-- +<?php +/* Prototype : int mktime ([ int $hour= date("H") [, int $minute= date("i") [, int $second= date("s") [, int $month= date("n") [, int $day= date("j") [, int $year= date("Y") [, int $is_dst= -1 ]]]]]]] ) + * Description: Get Unix timestamp for a date + * Source code: ext/date/php_date.c + * Alias to functions: + */ + +echo "*** Testing mktime() : usage variation - unexpected values to seventh argument \$is_dst***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 0' => 1, + 'int 0' => -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 +); + +$hour = 10; +$minute = 30; +$second = 45; +$month = 7; +$day = 2; +$year = 1963; + +foreach($inputs as $variation =>$is_dst) { + echo "\n-- $variation --\n"; + var_dump( mktime($hour, $minute, $second, $month, $day, $year, $is_dst) ); +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing mktime() : usage variation - unexpected values to seventh argument $is_dst*** + +-- int 0 -- +int(-205165755) + +-- int 12345 -- + +Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d +int(-205165755) + +-- int -12345 -- + +Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d +int(-205165755) + +-- float 10.5 -- + +Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d +int(-205165755) + +-- float -10.5 -- + +Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d +int(-205165755) + +-- float .5 -- + +Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d +int(-205162155) + +-- empty array -- + +Warning: mktime() expects parameter 7 to be long, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: mktime() expects parameter 7 to be long, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: mktime() expects parameter 7 to be long, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: mktime() expects parameter 7 to be long, array given in %s on line %d +bool(false) + +-- uppercase NULL -- + +Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d +int(-205162155) + +-- lowercase null -- + +Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d +int(-205162155) + +-- lowercase true -- + +Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d +int(-205165755) + +-- lowercase false -- + +Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d +int(-205162155) + +-- uppercase TRUE -- + +Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d +int(-205165755) + +-- uppercase FALSE -- + +Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d +int(-205162155) + +-- empty string DQ -- + +Warning: mktime() expects parameter 7 to be long, Unicode string given in %s on line %d +bool(false) + +-- empty string SQ -- + +Warning: mktime() expects parameter 7 to be long, Unicode string given in %s on line %d +bool(false) + +-- string DQ -- + +Warning: mktime() expects parameter 7 to be long, Unicode string given in %s on line %d +bool(false) + +-- string SQ -- + +Warning: mktime() expects parameter 7 to be long, Unicode string given in %s on line %d +bool(false) + +-- mixed case string -- + +Warning: mktime() expects parameter 7 to be long, Unicode string given in %s on line %d +bool(false) + +-- heredoc -- + +Warning: mktime() expects parameter 7 to be long, Unicode string given in %s on line %d +bool(false) + +-- instance of classWithToString -- + +Warning: mktime() expects parameter 7 to be long, object given in %s on line %d +bool(false) + +-- instance of classWithoutToString -- + +Warning: mktime() expects parameter 7 to be long, object given in %s on line %d +bool(false) + +-- undefined var -- + +Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d +int(-205162155) + +-- unset var -- + +Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d +int(-205162155) + +-- resource -- + +Warning: mktime() expects parameter 7 to be long, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/timezone_abbreviations_list_basic1.phpt b/ext/date/tests/timezone_abbreviations_list_basic1.phpt new file mode 100644 index 0000000000..c808c33ef2 --- /dev/null +++ b/ext/date/tests/timezone_abbreviations_list_basic1.phpt @@ -0,0 +1,70 @@ +--TEST-- +Test timezone_abbreviations_list() function : basic functionality +--FILE-- +<?php +/* Prototype : array timezone_abbreviations_list ( void ) + * Description: Returns associative array containing dst, offset and the timezone name + * Source code: ext/date/php_date.c + * Alias to functions: DateTimeZone::listAbbreviations + */ + +echo "*** Testing timezone_abbreviations_list() : basic functionality ***\n"; + +//Set the default time zone +date_default_timezone_set("GMT"); + +$abbr = timezone_abbreviations_list(); + +var_dump( gettype($abbr) ); +var_dump( count($abbr) ); + +echo "\n-- Format a sample entry --\n"; +var_dump( $abbr["acst"] ); + +?> +===DONE=== +--EXPECT-- +*** Testing timezone_abbreviations_list() : basic functionality *** +unicode(5) "array" +int(338) + +-- Format a sample entry -- +array(4) { + [0]=> + array(3) { + [u"dst"]=> + bool(true) + [u"offset"]=> + int(-14400) + [u"timezone_id"]=> + unicode(18) "America/Porto_Acre" + } + [1]=> + array(3) { + [u"dst"]=> + bool(true) + [u"offset"]=> + int(-14400) + [u"timezone_id"]=> + unicode(16) "America/Eirunepe" + } + [2]=> + array(3) { + [u"dst"]=> + bool(true) + [u"offset"]=> + int(-14400) + [u"timezone_id"]=> + unicode(18) "America/Rio_Branco" + } + [3]=> + array(3) { + [u"dst"]=> + bool(true) + [u"offset"]=> + int(-14400) + [u"timezone_id"]=> + unicode(11) "Brazil/Acre" + } +} +===DONE===
\ No newline at end of file diff --git a/ext/date/tests/timezone_identifiers_list_basic1.phpt b/ext/date/tests/timezone_identifiers_list_basic1.phpt new file mode 100644 index 0000000000..5a273744e3 --- /dev/null +++ b/ext/date/tests/timezone_identifiers_list_basic1.phpt @@ -0,0 +1,828 @@ +--TEST-- +Test timezone_identifiers_list() function : basic functionality +--FILE-- +<?php +/* Prototype : array timezone_identifiers_list ( void ) + * Description: Returns numerically index array with all timezone identifiers + * Source code: ext/date/php_date.c + * Alias to functions: + */ + +echo "*** Testing timezone_identifiers_list() : basic functionality ***\n"; + +//Set the default time zone +date_default_timezone_set("GMT"); + +var_dump (timezone_identifiers_list() ); + +?> +===DONE=== +--EXPECTF-- +*** Testing timezone_identifiers_list() : basic functionality *** +array(402) { + [0]=> + unicode(14) "Africa/Abidjan" + [1]=> + unicode(12) "Africa/Accra" + [2]=> + unicode(18) "Africa/Addis_Ababa" + [3]=> + unicode(14) "Africa/Algiers" + [4]=> + unicode(13) "Africa/Asmara" + [5]=> + unicode(13) "Africa/Bamako" + [6]=> + unicode(13) "Africa/Bangui" + [7]=> + unicode(13) "Africa/Banjul" + [8]=> + unicode(13) "Africa/Bissau" + [9]=> + unicode(15) "Africa/Blantyre" + [10]=> + unicode(18) "Africa/Brazzaville" + [11]=> + unicode(16) "Africa/Bujumbura" + [12]=> + unicode(12) "Africa/Cairo" + [13]=> + unicode(17) "Africa/Casablanca" + [14]=> + unicode(12) "Africa/Ceuta" + [15]=> + unicode(14) "Africa/Conakry" + [16]=> + unicode(12) "Africa/Dakar" + [17]=> + unicode(20) "Africa/Dar_es_Salaam" + [18]=> + unicode(15) "Africa/Djibouti" + [19]=> + unicode(13) "Africa/Douala" + [20]=> + unicode(15) "Africa/El_Aaiun" + [21]=> + unicode(15) "Africa/Freetown" + [22]=> + unicode(15) "Africa/Gaborone" + [23]=> + unicode(13) "Africa/Harare" + [24]=> + unicode(19) "Africa/Johannesburg" + [25]=> + unicode(14) "Africa/Kampala" + [26]=> + unicode(15) "Africa/Khartoum" + [27]=> + unicode(13) "Africa/Kigali" + [28]=> + unicode(15) "Africa/Kinshasa" + [29]=> + unicode(12) "Africa/Lagos" + [30]=> + unicode(17) "Africa/Libreville" + [31]=> + unicode(11) "Africa/Lome" + [32]=> + unicode(13) "Africa/Luanda" + [33]=> + unicode(17) "Africa/Lubumbashi" + [34]=> + unicode(13) "Africa/Lusaka" + [35]=> + unicode(13) "Africa/Malabo" + [36]=> + unicode(13) "Africa/Maputo" + [37]=> + unicode(13) "Africa/Maseru" + [38]=> + unicode(14) "Africa/Mbabane" + [39]=> + unicode(16) "Africa/Mogadishu" + [40]=> + unicode(15) "Africa/Monrovia" + [41]=> + unicode(14) "Africa/Nairobi" + [42]=> + unicode(15) "Africa/Ndjamena" + [43]=> + unicode(13) "Africa/Niamey" + [44]=> + unicode(17) "Africa/Nouakchott" + [45]=> + unicode(18) "Africa/Ouagadougou" + [46]=> + unicode(17) "Africa/Porto-Novo" + [47]=> + unicode(15) "Africa/Sao_Tome" + [48]=> + unicode(14) "Africa/Tripoli" + [49]=> + unicode(12) "Africa/Tunis" + [50]=> + unicode(15) "Africa/Windhoek" + [51]=> + unicode(12) "America/Adak" + [52]=> + unicode(17) "America/Anchorage" + [53]=> + unicode(16) "America/Anguilla" + [54]=> + unicode(15) "America/Antigua" + [55]=> + unicode(17) "America/Araguaina" + [56]=> + unicode(30) "America/Argentina/Buenos_Aires" + [57]=> + unicode(27) "America/Argentina/Catamarca" + [58]=> + unicode(25) "America/Argentina/Cordoba" + [59]=> + unicode(23) "America/Argentina/Jujuy" + [60]=> + unicode(26) "America/Argentina/La_Rioja" + [61]=> + unicode(25) "America/Argentina/Mendoza" + [62]=> + unicode(30) "America/Argentina/Rio_Gallegos" + [63]=> + unicode(23) "America/Argentina/Salta" + [64]=> + unicode(26) "America/Argentina/San_Juan" + [65]=> + unicode(26) "America/Argentina/San_Luis" + [66]=> + unicode(25) "America/Argentina/Tucuman" + [67]=> + unicode(25) "America/Argentina/Ushuaia" + [68]=> + unicode(13) "America/Aruba" + [69]=> + unicode(16) "America/Asuncion" + [70]=> + unicode(16) "America/Atikokan" + [71]=> + unicode(13) "America/Bahia" + [72]=> + unicode(16) "America/Barbados" + [73]=> + unicode(13) "America/Belem" + [74]=> + unicode(14) "America/Belize" + [75]=> + unicode(20) "America/Blanc-Sablon" + [76]=> + unicode(17) "America/Boa_Vista" + [77]=> + unicode(14) "America/Bogota" + [78]=> + unicode(13) "America/Boise" + [79]=> + unicode(21) "America/Cambridge_Bay" + [80]=> + unicode(20) "America/Campo_Grande" + [81]=> + unicode(14) "America/Cancun" + [82]=> + unicode(15) "America/Caracas" + [83]=> + unicode(15) "America/Cayenne" + [84]=> + unicode(14) "America/Cayman" + [85]=> + unicode(15) "America/Chicago" + [86]=> + unicode(17) "America/Chihuahua" + [87]=> + unicode(18) "America/Costa_Rica" + [88]=> + unicode(14) "America/Cuiaba" + [89]=> + unicode(15) "America/Curacao" + [90]=> + unicode(20) "America/Danmarkshavn" + [91]=> + unicode(14) "America/Dawson" + [92]=> + unicode(20) "America/Dawson_Creek" + [93]=> + unicode(14) "America/Denver" + [94]=> + unicode(15) "America/Detroit" + [95]=> + unicode(16) "America/Dominica" + [96]=> + unicode(16) "America/Edmonton" + [97]=> + unicode(16) "America/Eirunepe" + [98]=> + unicode(19) "America/El_Salvador" + [99]=> + unicode(17) "America/Fortaleza" + [100]=> + unicode(17) "America/Glace_Bay" + [101]=> + unicode(15) "America/Godthab" + [102]=> + unicode(17) "America/Goose_Bay" + [103]=> + unicode(18) "America/Grand_Turk" + [104]=> + unicode(15) "America/Grenada" + [105]=> + unicode(18) "America/Guadeloupe" + [106]=> + unicode(17) "America/Guatemala" + [107]=> + unicode(17) "America/Guayaquil" + [108]=> + unicode(14) "America/Guyana" + [109]=> + unicode(15) "America/Halifax" + [110]=> + unicode(14) "America/Havana" + [111]=> + unicode(18) "America/Hermosillo" + [112]=> + unicode(28) "America/Indiana/Indianapolis" + [113]=> + unicode(20) "America/Indiana/Knox" + [114]=> + unicode(23) "America/Indiana/Marengo" + [115]=> + unicode(26) "America/Indiana/Petersburg" + [116]=> + unicode(25) "America/Indiana/Tell_City" + [117]=> + unicode(21) "America/Indiana/Vevay" + [118]=> + unicode(25) "America/Indiana/Vincennes" + [119]=> + unicode(23) "America/Indiana/Winamac" + [120]=> + unicode(14) "America/Inuvik" + [121]=> + unicode(15) "America/Iqaluit" + [122]=> + unicode(15) "America/Jamaica" + [123]=> + unicode(14) "America/Juneau" + [124]=> + unicode(27) "America/Kentucky/Louisville" + [125]=> + unicode(27) "America/Kentucky/Monticello" + [126]=> + unicode(14) "America/La_Paz" + [127]=> + unicode(12) "America/Lima" + [128]=> + unicode(19) "America/Los_Angeles" + [129]=> + unicode(14) "America/Maceio" + [130]=> + unicode(15) "America/Managua" + [131]=> + unicode(14) "America/Manaus" + [132]=> + unicode(15) "America/Marigot" + [133]=> + unicode(18) "America/Martinique" + [134]=> + unicode(16) "America/Mazatlan" + [135]=> + unicode(17) "America/Menominee" + [136]=> + unicode(14) "America/Merida" + [137]=> + unicode(19) "America/Mexico_City" + [138]=> + unicode(16) "America/Miquelon" + [139]=> + unicode(15) "America/Moncton" + [140]=> + unicode(17) "America/Monterrey" + [141]=> + unicode(18) "America/Montevideo" + [142]=> + unicode(16) "America/Montreal" + [143]=> + unicode(18) "America/Montserrat" + [144]=> + unicode(14) "America/Nassau" + [145]=> + unicode(16) "America/New_York" + [146]=> + unicode(15) "America/Nipigon" + [147]=> + unicode(12) "America/Nome" + [148]=> + unicode(15) "America/Noronha" + [149]=> + unicode(27) "America/North_Dakota/Center" + [150]=> + unicode(30) "America/North_Dakota/New_Salem" + [151]=> + unicode(14) "America/Panama" + [152]=> + unicode(19) "America/Pangnirtung" + [153]=> + unicode(18) "America/Paramaribo" + [154]=> + unicode(15) "America/Phoenix" + [155]=> + unicode(22) "America/Port-au-Prince" + [156]=> + unicode(21) "America/Port_of_Spain" + [157]=> + unicode(19) "America/Porto_Velho" + [158]=> + unicode(19) "America/Puerto_Rico" + [159]=> + unicode(19) "America/Rainy_River" + [160]=> + unicode(20) "America/Rankin_Inlet" + [161]=> + unicode(14) "America/Recife" + [162]=> + unicode(14) "America/Regina" + [163]=> + unicode(16) "America/Resolute" + [164]=> + unicode(18) "America/Rio_Branco" + [165]=> + unicode(16) "America/Santarem" + [166]=> + unicode(16) "America/Santiago" + [167]=> + unicode(21) "America/Santo_Domingo" + [168]=> + unicode(17) "America/Sao_Paulo" + [169]=> + unicode(20) "America/Scoresbysund" + [170]=> + unicode(16) "America/Shiprock" + [171]=> + unicode(21) "America/St_Barthelemy" + [172]=> + unicode(16) "America/St_Johns" + [173]=> + unicode(16) "America/St_Kitts" + [174]=> + unicode(16) "America/St_Lucia" + [175]=> + unicode(17) "America/St_Thomas" + [176]=> + unicode(18) "America/St_Vincent" + [177]=> + unicode(21) "America/Swift_Current" + [178]=> + unicode(19) "America/Tegucigalpa" + [179]=> + unicode(13) "America/Thule" + [180]=> + unicode(19) "America/Thunder_Bay" + [181]=> + unicode(15) "America/Tijuana" + [182]=> + unicode(15) "America/Toronto" + [183]=> + unicode(15) "America/Tortola" + [184]=> + unicode(17) "America/Vancouver" + [185]=> + unicode(18) "America/Whitehorse" + [186]=> + unicode(16) "America/Winnipeg" + [187]=> + unicode(15) "America/Yakutat" + [188]=> + unicode(19) "America/Yellowknife" + [189]=> + unicode(16) "Antarctica/Casey" + [190]=> + unicode(16) "Antarctica/Davis" + [191]=> + unicode(25) "Antarctica/DumontDUrville" + [192]=> + unicode(17) "Antarctica/Mawson" + [193]=> + unicode(18) "Antarctica/McMurdo" + [194]=> + unicode(17) "Antarctica/Palmer" + [195]=> + unicode(18) "Antarctica/Rothera" + [196]=> + unicode(21) "Antarctica/South_Pole" + [197]=> + unicode(16) "Antarctica/Syowa" + [198]=> + unicode(17) "Antarctica/Vostok" + [199]=> + unicode(19) "Arctic/Longyearbyen" + [200]=> + unicode(9) "Asia/Aden" + [201]=> + unicode(11) "Asia/Almaty" + [202]=> + unicode(10) "Asia/Amman" + [203]=> + unicode(11) "Asia/Anadyr" + [204]=> + unicode(10) "Asia/Aqtau" + [205]=> + unicode(11) "Asia/Aqtobe" + [206]=> + unicode(13) "Asia/Ashgabat" + [207]=> + unicode(12) "Asia/Baghdad" + [208]=> + unicode(12) "Asia/Bahrain" + [209]=> + unicode(9) "Asia/Baku" + [210]=> + unicode(12) "Asia/Bangkok" + [211]=> + unicode(11) "Asia/Beirut" + [212]=> + unicode(12) "Asia/Bishkek" + [213]=> + unicode(11) "Asia/Brunei" + [214]=> + unicode(15) "Asia/Choibalsan" + [215]=> + unicode(14) "Asia/Chongqing" + [216]=> + unicode(12) "Asia/Colombo" + [217]=> + unicode(13) "Asia/Damascus" + [218]=> + unicode(10) "Asia/Dhaka" + [219]=> + unicode(9) "Asia/Dili" + [220]=> + unicode(10) "Asia/Dubai" + [221]=> + unicode(13) "Asia/Dushanbe" + [222]=> + unicode(9) "Asia/Gaza" + [223]=> + unicode(11) "Asia/Harbin" + [224]=> + unicode(16) "Asia/Ho_Chi_Minh" + [225]=> + unicode(14) "Asia/Hong_Kong" + [226]=> + unicode(9) "Asia/Hovd" + [227]=> + unicode(12) "Asia/Irkutsk" + [228]=> + unicode(12) "Asia/Jakarta" + [229]=> + unicode(13) "Asia/Jayapura" + [230]=> + unicode(14) "Asia/Jerusalem" + [231]=> + unicode(10) "Asia/Kabul" + [232]=> + unicode(14) "Asia/Kamchatka" + [233]=> + unicode(12) "Asia/Karachi" + [234]=> + unicode(12) "Asia/Kashgar" + [235]=> + unicode(14) "Asia/Kathmandu" + [236]=> + unicode(12) "Asia/Kolkata" + [237]=> + unicode(16) "Asia/Krasnoyarsk" + [238]=> + unicode(17) "Asia/Kuala_Lumpur" + [239]=> + unicode(12) "Asia/Kuching" + [240]=> + unicode(11) "Asia/Kuwait" + [241]=> + unicode(10) "Asia/Macau" + [242]=> + unicode(12) "Asia/Magadan" + [243]=> + unicode(13) "Asia/Makassar" + [244]=> + unicode(11) "Asia/Manila" + [245]=> + unicode(11) "Asia/Muscat" + [246]=> + unicode(12) "Asia/Nicosia" + [247]=> + unicode(16) "Asia/Novosibirsk" + [248]=> + unicode(9) "Asia/Omsk" + [249]=> + unicode(9) "Asia/Oral" + [250]=> + unicode(15) "Asia/Phnom_Penh" + [251]=> + unicode(14) "Asia/Pontianak" + [252]=> + unicode(14) "Asia/Pyongyang" + [253]=> + unicode(10) "Asia/Qatar" + [254]=> + unicode(14) "Asia/Qyzylorda" + [255]=> + unicode(12) "Asia/Rangoon" + [256]=> + unicode(11) "Asia/Riyadh" + [257]=> + unicode(13) "Asia/Sakhalin" + [258]=> + unicode(14) "Asia/Samarkand" + [259]=> + unicode(10) "Asia/Seoul" + [260]=> + unicode(13) "Asia/Shanghai" + [261]=> + unicode(14) "Asia/Singapore" + [262]=> + unicode(11) "Asia/Taipei" + [263]=> + unicode(13) "Asia/Tashkent" + [264]=> + unicode(12) "Asia/Tbilisi" + [265]=> + unicode(11) "Asia/Tehran" + [266]=> + unicode(12) "Asia/Thimphu" + [267]=> + unicode(10) "Asia/Tokyo" + [268]=> + unicode(16) "Asia/Ulaanbaatar" + [269]=> + unicode(11) "Asia/Urumqi" + [270]=> + unicode(14) "Asia/Vientiane" + [271]=> + unicode(16) "Asia/Vladivostok" + [272]=> + unicode(12) "Asia/Yakutsk" + [273]=> + unicode(18) "Asia/Yekaterinburg" + [274]=> + unicode(12) "Asia/Yerevan" + [275]=> + unicode(15) "Atlantic/Azores" + [276]=> + unicode(16) "Atlantic/Bermuda" + [277]=> + unicode(15) "Atlantic/Canary" + [278]=> + unicode(19) "Atlantic/Cape_Verde" + [279]=> + unicode(14) "Atlantic/Faroe" + [280]=> + unicode(16) "Atlantic/Madeira" + [281]=> + unicode(18) "Atlantic/Reykjavik" + [282]=> + unicode(22) "Atlantic/South_Georgia" + [283]=> + unicode(18) "Atlantic/St_Helena" + [284]=> + unicode(16) "Atlantic/Stanley" + [285]=> + unicode(18) "Australia/Adelaide" + [286]=> + unicode(18) "Australia/Brisbane" + [287]=> + unicode(21) "Australia/Broken_Hill" + [288]=> + unicode(16) "Australia/Currie" + [289]=> + unicode(16) "Australia/Darwin" + [290]=> + unicode(15) "Australia/Eucla" + [291]=> + unicode(16) "Australia/Hobart" + [292]=> + unicode(18) "Australia/Lindeman" + [293]=> + unicode(19) "Australia/Lord_Howe" + [294]=> + unicode(19) "Australia/Melbourne" + [295]=> + unicode(15) "Australia/Perth" + [296]=> + unicode(16) "Australia/Sydney" + [297]=> + unicode(16) "Europe/Amsterdam" + [298]=> + unicode(14) "Europe/Andorra" + [299]=> + unicode(13) "Europe/Athens" + [300]=> + unicode(15) "Europe/Belgrade" + [301]=> + unicode(13) "Europe/Berlin" + [302]=> + unicode(17) "Europe/Bratislava" + [303]=> + unicode(15) "Europe/Brussels" + [304]=> + unicode(16) "Europe/Bucharest" + [305]=> + unicode(15) "Europe/Budapest" + [306]=> + unicode(15) "Europe/Chisinau" + [307]=> + unicode(17) "Europe/Copenhagen" + [308]=> + unicode(13) "Europe/Dublin" + [309]=> + unicode(16) "Europe/Gibraltar" + [310]=> + unicode(15) "Europe/Guernsey" + [311]=> + unicode(15) "Europe/Helsinki" + [312]=> + unicode(18) "Europe/Isle_of_Man" + [313]=> + unicode(15) "Europe/Istanbul" + [314]=> + unicode(13) "Europe/Jersey" + [315]=> + unicode(18) "Europe/Kaliningrad" + [316]=> + unicode(11) "Europe/Kiev" + [317]=> + unicode(13) "Europe/Lisbon" + [318]=> + unicode(16) "Europe/Ljubljana" + [319]=> + unicode(13) "Europe/London" + [320]=> + unicode(17) "Europe/Luxembourg" + [321]=> + unicode(13) "Europe/Madrid" + [322]=> + unicode(12) "Europe/Malta" + [323]=> + unicode(16) "Europe/Mariehamn" + [324]=> + unicode(12) "Europe/Minsk" + [325]=> + unicode(13) "Europe/Monaco" + [326]=> + unicode(13) "Europe/Moscow" + [327]=> + unicode(11) "Europe/Oslo" + [328]=> + unicode(12) "Europe/Paris" + [329]=> + unicode(16) "Europe/Podgorica" + [330]=> + unicode(13) "Europe/Prague" + [331]=> + unicode(11) "Europe/Riga" + [332]=> + unicode(11) "Europe/Rome" + [333]=> + unicode(13) "Europe/Samara" + [334]=> + unicode(17) "Europe/San_Marino" + [335]=> + unicode(15) "Europe/Sarajevo" + [336]=> + unicode(17) "Europe/Simferopol" + [337]=> + unicode(13) "Europe/Skopje" + [338]=> + unicode(12) "Europe/Sofia" + [339]=> + unicode(16) "Europe/Stockholm" + [340]=> + unicode(14) "Europe/Tallinn" + [341]=> + unicode(13) "Europe/Tirane" + [342]=> + unicode(15) "Europe/Uzhgorod" + [343]=> + unicode(12) "Europe/Vaduz" + [344]=> + unicode(14) "Europe/Vatican" + [345]=> + unicode(13) "Europe/Vienna" + [346]=> + unicode(14) "Europe/Vilnius" + [347]=> + unicode(16) "Europe/Volgograd" + [348]=> + unicode(13) "Europe/Warsaw" + [349]=> + unicode(13) "Europe/Zagreb" + [350]=> + unicode(17) "Europe/Zaporozhye" + [351]=> + unicode(13) "Europe/Zurich" + [352]=> + unicode(19) "Indian/Antananarivo" + [353]=> + unicode(13) "Indian/Chagos" + [354]=> + unicode(16) "Indian/Christmas" + [355]=> + unicode(12) "Indian/Cocos" + [356]=> + unicode(13) "Indian/Comoro" + [357]=> + unicode(16) "Indian/Kerguelen" + [358]=> + unicode(11) "Indian/Mahe" + [359]=> + unicode(15) "Indian/Maldives" + [360]=> + unicode(16) "Indian/Mauritius" + [361]=> + unicode(14) "Indian/Mayotte" + [362]=> + unicode(14) "Indian/Reunion" + [363]=> + unicode(12) "Pacific/Apia" + [364]=> + unicode(16) "Pacific/Auckland" + [365]=> + unicode(15) "Pacific/Chatham" + [366]=> + unicode(14) "Pacific/Easter" + [367]=> + unicode(13) "Pacific/Efate" + [368]=> + unicode(17) "Pacific/Enderbury" + [369]=> + unicode(15) "Pacific/Fakaofo" + [370]=> + unicode(12) "Pacific/Fiji" + [371]=> + unicode(16) "Pacific/Funafuti" + [372]=> + unicode(17) "Pacific/Galapagos" + [373]=> + unicode(15) "Pacific/Gambier" + [374]=> + unicode(19) "Pacific/Guadalcanal" + [375]=> + unicode(12) "Pacific/Guam" + [376]=> + unicode(16) "Pacific/Honolulu" + [377]=> + unicode(16) "Pacific/Johnston" + [378]=> + unicode(18) "Pacific/Kiritimati" + [379]=> + unicode(14) "Pacific/Kosrae" + [380]=> + unicode(17) "Pacific/Kwajalein" + [381]=> + unicode(14) "Pacific/Majuro" + [382]=> + unicode(17) "Pacific/Marquesas" + [383]=> + unicode(14) "Pacific/Midway" + [384]=> + unicode(13) "Pacific/Nauru" + [385]=> + unicode(12) "Pacific/Niue" + [386]=> + unicode(15) "Pacific/Norfolk" + [387]=> + unicode(14) "Pacific/Noumea" + [388]=> + unicode(17) "Pacific/Pago_Pago" + [389]=> + unicode(13) "Pacific/Palau" + [390]=> + unicode(16) "Pacific/Pitcairn" + [391]=> + unicode(14) "Pacific/Ponape" + [392]=> + unicode(20) "Pacific/Port_Moresby" + [393]=> + unicode(17) "Pacific/Rarotonga" + [394]=> + unicode(14) "Pacific/Saipan" + [395]=> + unicode(14) "Pacific/Tahiti" + [396]=> + unicode(14) "Pacific/Tarawa" + [397]=> + unicode(17) "Pacific/Tongatapu" + [398]=> + unicode(12) "Pacific/Truk" + [399]=> + unicode(12) "Pacific/Wake" + [400]=> + unicode(14) "Pacific/Wallis" + [401]=> + unicode(3) "UTC" +} +===DONE=== diff --git a/ext/date/tests/timezone_name_from_abbr_basic1.phpt b/ext/date/tests/timezone_name_from_abbr_basic1.phpt new file mode 100644 index 0000000000..75caf00a65 --- /dev/null +++ b/ext/date/tests/timezone_name_from_abbr_basic1.phpt @@ -0,0 +1,68 @@ +--TEST-- +Test timezone_name_from_abbr() function : basic functionality +--FILE-- +<?php +/* Prototype : string timezone_name_from_abbr ( string $abbr [, int $gmtOffset= -1 [, int $isdst= -1 ]] ) + * Description: Returns the timezone name from abbrevation + * Source code: ext/date/php_date.c + * Alias to functions: + */ + +echo "*** Testing timezone_name_from_abbr() : basic functionality ***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +echo "-- Tests with special cases first - no lookup needed --\n"; +var_dump( timezone_name_from_abbr("GMT") ); +var_dump( timezone_name_from_abbr("UTC") ); + +echo "-- Lookup with just name --\n"; +var_dump( timezone_name_from_abbr("CET") ); +var_dump( timezone_name_from_abbr("EDT") ); + +echo "-- Lookup with name and offset--\n"; +var_dump( timezone_name_from_abbr("ADT", -10800) ); +var_dump( timezone_name_from_abbr("ADT", 14400) ); +var_dump( timezone_name_from_abbr("AKTT", 14400) ); +var_dump( timezone_name_from_abbr("aktt", 18000) ); +var_dump( timezone_name_from_abbr("Aktt", 21600) ); +var_dump( timezone_name_from_abbr("AMST", -10800) ); +var_dump( timezone_name_from_abbr("amst", 180000) ); + +echo "-- Tests without valid name - uses gmtOffset and isdst to find match --\n"; +var_dump( timezone_name_from_abbr("", 3600, 1) ); +var_dump( timezone_name_from_abbr("FOO", -7200, 1) ); +var_dump( timezone_name_from_abbr("", -14400, 1) ); +var_dump( timezone_name_from_abbr("", -14400, 0) ); + +echo "-- Tests with invalid offsets --\n"; +var_dump( timezone_name_from_abbr("", 5400) ); // offset = 1.5 hrs +var_dump( timezone_name_from_abbr("", 62400) ); // offset = 24 hrs +?> +===DONE=== +--EXPECTF-- +*** Testing timezone_name_from_abbr() : basic functionality *** +-- Tests with special cases first - no lookup needed -- +unicode(3) "UTC" +unicode(3) "UTC" +-- Lookup with just name -- +unicode(13) "Europe/Berlin" +unicode(16) "America/New_York" +-- Lookup with name and offset-- +unicode(15) "America/Halifax" +unicode(12) "Asia/Baghdad" +unicode(11) "Asia/Aqtobe" +unicode(11) "Asia/Aqtobe" +unicode(11) "Asia/Aqtobe" +unicode(17) "America/Boa_Vista" +unicode(12) "Asia/Yerevan" +-- Tests without valid name - uses gmtOffset and isdst to find match -- +unicode(13) "Europe/London" +unicode(17) "America/Sao_Paulo" +unicode(16) "America/New_York" +unicode(15) "America/Halifax" +-- Tests with invalid offsets -- +bool(false) +bool(false) +===DONE===
\ No newline at end of file diff --git a/ext/date/tests/timezone_name_from_abbr_error.phpt b/ext/date/tests/timezone_name_from_abbr_error.phpt new file mode 100644 index 0000000000..640caaec54 --- /dev/null +++ b/ext/date/tests/timezone_name_from_abbr_error.phpt @@ -0,0 +1,42 @@ +--TEST-- +Test timezone_name_from_abbr() function : error conditions +--FILE-- +<?php +/* Prototype : string timezone_name_from_abbr ( string $abbr [, int $gmtOffset= -1 [, int $isdst= -1 ]] ) + * Description: Returns the timezone name from abbrevation + * Source code: ext/date/php_date.c + * Alias to functions: + */ + +error_reporting(E_ALL | E_STRICT); + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +echo "*** Testing timezone_name_from_abbr() : error conditions ***\n"; + +echo "\n-- Testing timezone_name_from_abbr() function with Zero arguments --\n"; +var_dump( timezone_name_from_abbr() ); + +echo "\n-- Testing timezone_name_from_abbr() function with more than expected no. of arguments --\n"; +$abbr = 10; +$gmtOffset = 30; +$isdst = 45; +$extra_arg = 10; +var_dump( timezone_name_from_abbr($abbr, $gmtOffset, $isdst, $extra_arg) ); + +?> +===DONE=== +--EXPECTF-- +*** Testing timezone_name_from_abbr() : error conditions *** + +-- Testing timezone_name_from_abbr() function with Zero arguments -- + +Warning: timezone_name_from_abbr() expects at least 1 parameter, 0 given in %s on line %d +bool(false) + +-- Testing timezone_name_from_abbr() function with more than expected no. of arguments -- + +Warning: timezone_name_from_abbr() expects at most 3 parameters, 4 given in %s on line %d +bool(false) +===DONE===
\ No newline at end of file diff --git a/ext/date/tests/timezone_name_from_abbr_variation1.phpt b/ext/date/tests/timezone_name_from_abbr_variation1.phpt new file mode 100644 index 0000000000..09a10fa4ca --- /dev/null +++ b/ext/date/tests/timezone_name_from_abbr_variation1.phpt @@ -0,0 +1,205 @@ +--TEST-- +Test timezone_name_from_abbr() function : usage variation - Passing unexpected values to first argument $abbr. +--FILE-- +<?php +/* Prototype : string timezone_name_from_abbr ( string $abbr [, int $gmtOffset= -1 [, int $isdst= -1 ]] ) + * Description: Returns the timezone name from abbrevation + * Source code: ext/date/php_date.c + * Alias to functions: + */ + +echo "*** Testing timezone_name_from_abbr() : usage variation - unexpected values to first argument \$abbr***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 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 +); + +$gmtOffset= 3600; +$isdst = 1; + +foreach($inputs as $variation =>$abbr) { + echo "\n-- $variation --\n"; + var_dump( timezone_name_from_abbr($abbr, $gmtOffset, $isdst) ); +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing timezone_name_from_abbr() : usage variation - unexpected values to first argument $abbr*** + +-- int 0 -- +unicode(13) "Europe/London" + +-- int 12345 -- +unicode(13) "Europe/London" + +-- int -12345 -- +unicode(13) "Europe/London" + +-- float 10.5 -- +unicode(13) "Europe/London" + +-- float -10.5 -- +unicode(13) "Europe/London" + +-- float .5 -- +unicode(13) "Europe/London" + +-- empty array -- + +Warning: timezone_name_from_abbr() expects parameter 1 to be binary string, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: timezone_name_from_abbr() expects parameter 1 to be binary string, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: timezone_name_from_abbr() expects parameter 1 to be binary string, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: timezone_name_from_abbr() expects parameter 1 to be binary string, array given in %s on line %d +bool(false) + +-- uppercase NULL -- +unicode(13) "Europe/London" + +-- lowercase null -- +unicode(13) "Europe/London" + +-- lowercase true -- +unicode(13) "Europe/London" + +-- lowercase false -- +unicode(13) "Europe/London" + +-- uppercase TRUE -- +unicode(13) "Europe/London" + +-- uppercase FALSE -- +unicode(13) "Europe/London" + +-- empty string DQ -- +unicode(13) "Europe/London" + +-- empty string SQ -- +unicode(13) "Europe/London" + +-- string DQ -- +unicode(13) "Europe/London" + +-- string SQ -- +unicode(13) "Europe/London" + +-- mixed case string -- +unicode(13) "Europe/London" + +-- heredoc -- +unicode(13) "Europe/London" + +-- instance of classWithToString -- +unicode(13) "Europe/London" + +-- instance of classWithoutToString -- + +Warning: timezone_name_from_abbr() expects parameter 1 to be binary string, object given in %s on line %d +bool(false) + +-- undefined var -- +unicode(13) "Europe/London" + +-- unset var -- +unicode(13) "Europe/London" + +-- resource -- + +Warning: timezone_name_from_abbr() expects parameter 1 to be binary string, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/timezone_name_from_abbr_variation2.phpt b/ext/date/tests/timezone_name_from_abbr_variation2.phpt new file mode 100644 index 0000000000..b038d79a72 --- /dev/null +++ b/ext/date/tests/timezone_name_from_abbr_variation2.phpt @@ -0,0 +1,219 @@ +--TEST-- +Test timezone_name_from_abbr() function : usage variation - Passing unexpected values to second argument $gmtOffset. +--FILE-- +<?php +/* Prototype : string timezone_name_from_abbr ( string $abbr [, int $gmtOffset= -1 [, int $isdst= -1 ]] ) + * Description: Returns the timezone name from abbrevation + * Source code: ext/date/php_date.c + * Alias to functions: + */ + +echo "*** Testing timezone_name_from_abbr() : usage variation - unexpected values to second argument \$gmtOffset***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 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 +); + +$abbr= "GMT"; +$isdst = 1; + +foreach($inputs as $variation =>$gmtOffset) { + echo "\n-- $variation --\n"; + var_dump( timezone_name_from_abbr($abbr, $gmtOffset, $isdst) ); +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing timezone_name_from_abbr() : usage variation - unexpected values to second argument $gmtOffset*** + +-- int 0 -- +unicode(3) "UTC" + +-- int 12345 -- +unicode(3) "UTC" + +-- int -12345 -- +unicode(3) "UTC" + +-- float 10.5 -- +unicode(3) "UTC" + +-- float -10.5 -- +unicode(3) "UTC" + +-- float .5 -- +unicode(3) "UTC" + +-- empty array -- + +Warning: timezone_name_from_abbr() expects parameter 2 to be long, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: timezone_name_from_abbr() expects parameter 2 to be long, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: timezone_name_from_abbr() expects parameter 2 to be long, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: timezone_name_from_abbr() expects parameter 2 to be long, array given in %s on line %d +bool(false) + +-- uppercase NULL -- +unicode(3) "UTC" + +-- lowercase null -- +unicode(3) "UTC" + +-- lowercase true -- +unicode(3) "UTC" + +-- lowercase false -- +unicode(3) "UTC" + +-- uppercase TRUE -- +unicode(3) "UTC" + +-- uppercase FALSE -- +unicode(3) "UTC" + +-- empty string DQ -- + +Warning: timezone_name_from_abbr() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- empty string SQ -- + +Warning: timezone_name_from_abbr() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- string DQ -- + +Warning: timezone_name_from_abbr() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- string SQ -- + +Warning: timezone_name_from_abbr() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- mixed case string -- + +Warning: timezone_name_from_abbr() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- heredoc -- + +Warning: timezone_name_from_abbr() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- instance of classWithToString -- + +Warning: timezone_name_from_abbr() expects parameter 2 to be long, object given in %s on line %d +bool(false) + +-- instance of classWithoutToString -- + +Warning: timezone_name_from_abbr() expects parameter 2 to be long, object given in %s on line %d +bool(false) + +-- undefined var -- +unicode(3) "UTC" + +-- unset var -- +unicode(3) "UTC" + +-- resource -- + +Warning: timezone_name_from_abbr() expects parameter 2 to be long, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/timezone_name_from_abbr_variation3.phpt b/ext/date/tests/timezone_name_from_abbr_variation3.phpt new file mode 100644 index 0000000000..23a5671900 --- /dev/null +++ b/ext/date/tests/timezone_name_from_abbr_variation3.phpt @@ -0,0 +1,219 @@ +--TEST-- +Test timezone_name_from_abbr() function : usage variation - Passing unexpected values to third argument $isdst. +--FILE-- +<?php +/* Prototype : string timezone_name_from_abbr ( string $abbr [, int $gmtOffset= -1 [, int $isdst= -1 ]] ) + * Description: Returns the timezone name from abbrevation + * Source code: ext/date/php_date.c + * Alias to functions: + */ + +echo "*** Testing timezone_name_from_abbr() : usage variation - unexpected values to third argument \$isdst***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 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 +); + +$abbr= "GMT"; +$gmtOffset = 3600; + +foreach($inputs as $variation =>$isdst) { + echo "\n-- $variation --\n"; + var_dump( timezone_name_from_abbr($abbr, $gmtOffset, $isdst) ); +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing timezone_name_from_abbr() : usage variation - unexpected values to third argument $isdst*** + +-- int 0 -- +unicode(3) "UTC" + +-- int 12345 -- +unicode(3) "UTC" + +-- int -12345 -- +unicode(3) "UTC" + +-- float 10.5 -- +unicode(3) "UTC" + +-- float -10.5 -- +unicode(3) "UTC" + +-- float .5 -- +unicode(3) "UTC" + +-- empty array -- + +Warning: timezone_name_from_abbr() expects parameter 3 to be long, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: timezone_name_from_abbr() expects parameter 3 to be long, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: timezone_name_from_abbr() expects parameter 3 to be long, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: timezone_name_from_abbr() expects parameter 3 to be long, array given in %s on line %d +bool(false) + +-- uppercase NULL -- +unicode(3) "UTC" + +-- lowercase null -- +unicode(3) "UTC" + +-- lowercase true -- +unicode(3) "UTC" + +-- lowercase false -- +unicode(3) "UTC" + +-- uppercase TRUE -- +unicode(3) "UTC" + +-- uppercase FALSE -- +unicode(3) "UTC" + +-- empty string DQ -- + +Warning: timezone_name_from_abbr() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- empty string SQ -- + +Warning: timezone_name_from_abbr() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- string DQ -- + +Warning: timezone_name_from_abbr() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- string SQ -- + +Warning: timezone_name_from_abbr() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- mixed case string -- + +Warning: timezone_name_from_abbr() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- heredoc -- + +Warning: timezone_name_from_abbr() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- instance of classWithToString -- + +Warning: timezone_name_from_abbr() expects parameter 3 to be long, object given in %s on line %d +bool(false) + +-- instance of classWithoutToString -- + +Warning: timezone_name_from_abbr() expects parameter 3 to be long, object given in %s on line %d +bool(false) + +-- undefined var -- +unicode(3) "UTC" + +-- unset var -- +unicode(3) "UTC" + +-- resource -- + +Warning: timezone_name_from_abbr() expects parameter 3 to be long, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/timezone_name_get_error.phpt b/ext/date/tests/timezone_name_get_error.phpt new file mode 100644 index 0000000000..3c33e33f4d --- /dev/null +++ b/ext/date/tests/timezone_name_get_error.phpt @@ -0,0 +1,56 @@ +--TEST-- +Test timezone_name_get() function : error conditions +--FILE-- +<?php +/* Prototype : string timezone_name_get ( DateTime $object ) + * Description: Returns the name of the timezone + * Source code: ext/date/php_date.c + * Alias to functions: DateTimeZone::getName() + */ + +// Set timezone +date_default_timezone_set("Europe/London"); + +echo "*** Testing timezone_name_get() : error conditions ***\n"; + +echo "\n-- Testing timezone_name_get() function with zero arguments --\n"; +var_dump( timezone_name_get() ); + +echo "\n-- Testing date_timezone_set() function with more than expected no. of arguments --\n"; +$datetime = date_create("2009-01-30 17:57:32"); +$extra_arg = 99; +var_dump( timezone_name_get($datetime, $extra_arg) ); + +echo "\n-- Testing timezone_name_get() function with an invalid values for \$object argument --\n"; +$invalid_obj = new stdClass(); +var_dump( timezone_name_get($invalid_obj) ); +$invalid_obj = 10; +var_dump( timezone_name_get($invalid_obj) ); +$invalid_obj = null; +var_dump( timezone_name_get($invalid_obj) ); +?> +===DONE=== +--EXPECTF-- +*** Testing timezone_name_get() : error conditions *** + +-- Testing timezone_name_get() function with zero arguments -- + +Warning: timezone_name_get() expects exactly 1 parameter, 0 given in %s on line %d +bool(false) + +-- Testing date_timezone_set() function with more than expected no. of arguments -- + +Warning: timezone_name_get() expects exactly 1 parameter, 2 given in %s on line %d +bool(false) + +-- Testing timezone_name_get() function with an invalid values for $object argument -- + +Warning: timezone_name_get() expects parameter 1 to be DateTimeZone, object given in %s on line %d +bool(false) + +Warning: timezone_name_get() expects parameter 1 to be DateTimeZone, integer given in %s on line %d +bool(false) + +Warning: timezone_name_get() expects parameter 1 to be DateTimeZone, null given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/timezone_offset_get_basic1.phpt b/ext/date/tests/timezone_offset_get_basic1.phpt new file mode 100644 index 0000000000..bf241788da --- /dev/null +++ b/ext/date/tests/timezone_offset_get_basic1.phpt @@ -0,0 +1,34 @@ +--TEST-- +Test timezone_offset_get() function : basic functionality +--FILE-- +<?php +/* Prototype : int timezone_offset_get ( DateTimeZone $object , DateTime $datetime ) + * Description: Returns the timezone offset from GMT + * Source code: ext/date/php_date.c + * Alias to functions: DateTimeZone::getOffset + */ + +echo "*** Testing timezone_offset_get() : basic functionality ***\n"; + +//Set the default time zone +date_default_timezone_set("GMT"); + +$tz = timezone_open("Europe/London"); +$date = date_create("GMT"); + +var_dump(timezone_offset_get($tz, $date)); + +$tz = timezone_open("America/New_York"); +var_dump(timezone_offset_get($tz, $date)); + +$tz = timezone_open("America/Los_Angeles"); +var_dump(timezone_offset_get($tz, $date)); + +?> +===DONE=== +--EXPECTF-- +*** Testing timezone_offset_get() : basic functionality *** +int(0) +%rint\(-18000\)|int\(-14400\)%r +%rint\(-28800\)|int\(-25200\)%r +===DONE===
\ No newline at end of file diff --git a/ext/date/tests/timezone_offset_get_error.phpt b/ext/date/tests/timezone_offset_get_error.phpt new file mode 100644 index 0000000000..b8ca2c1c15 --- /dev/null +++ b/ext/date/tests/timezone_offset_get_error.phpt @@ -0,0 +1,84 @@ +--TEST-- +Test timezone_offset_get() function : error conditions +--FILE-- +<?php +/* Prototype : int timezone_offset_get ( DateTimeZone $object , DateTime $datetime ) + * Description: Returns the timezone offset from GMT + * Source code: ext/date/php_date.c + * Alias to functions: DateTimeZone::getOffset + */ + +//Set the default time zone +date_default_timezone_set("GMT"); +$tz = timezone_open("Europe/London"); +$date = date_create("GMT"); + +echo "*** Testing timezone_offset_get() : error conditions ***\n"; + +echo "\n-- Testing timezone_offset_get() function with zero arguments --\n"; +var_dump( timezone_offset_get() ); + +echo "\n-- Testing timezone_offset_get() function with less than expected no. of arguments --\n"; +var_dump( timezone_offset_get($tz) ); + +echo "\n-- Testing timezone_offset_get() function with more than expected no. of arguments --\n"; +$extra_arg = 99; +var_dump( timezone_offset_get($tz, $date, $extra_arg) ); + +echo "\n-- Testing timezone_offset_get() function with an invalid values for \$object argument --\n"; +$invalid_obj = new stdClass(); +var_dump( timezone_offset_get($invalid_obj, $date) ); +$invalid_obj = 10; +var_dump( timezone_offset_get($invalid_obj, $date) ); +$invalid_obj = null; +var_dump( timezone_offset_get($invalid_obj, $date) ); + +echo "\n-- Testing timezone_offset_get() function with an invalid values for \$datetime argument --\n"; +$invalid_obj = new stdClass(); +var_dump( timezone_offset_get($tz, $invalid_obj) ); +$invalid_obj = 10; +var_dump( timezone_offset_get($tz, $invalid_obj) ); +$invalid_obj = null; +var_dump( timezone_offset_get($tz, $invalid_obj) ); +?> +===DONE=== +--EXPECTF-- +*** Testing timezone_offset_get() : error conditions *** + +-- Testing timezone_offset_get() function with zero arguments -- + +Warning: timezone_offset_get() expects exactly 2 parameters, 0 given in %s on line %d +bool(false) + +-- Testing timezone_offset_get() function with less than expected no. of arguments -- + +Warning: timezone_offset_get() expects exactly 2 parameters, 1 given in %s on line %d +bool(false) + +-- Testing timezone_offset_get() function with more than expected no. of arguments -- + +Warning: timezone_offset_get() expects exactly 2 parameters, 3 given in %s on line %d +bool(false) + +-- Testing timezone_offset_get() function with an invalid values for $object argument -- + +Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, object given in %s on line %d +bool(false) + +Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, integer given in %s on line %d +bool(false) + +Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, null given in %s on line %d +bool(false) + +-- Testing timezone_offset_get() function with an invalid values for $datetime argument -- + +Warning: timezone_offset_get() expects parameter 2 to be DateTime, object given in %s on line %d +bool(false) + +Warning: timezone_offset_get() expects parameter 2 to be DateTime, integer given in %s on line %d +bool(false) + +Warning: timezone_offset_get() expects parameter 2 to be DateTime, null given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/timezone_offset_get_variation1.phpt b/ext/date/tests/timezone_offset_get_variation1.phpt new file mode 100644 index 0000000000..e90c38b19b --- /dev/null +++ b/ext/date/tests/timezone_offset_get_variation1.phpt @@ -0,0 +1,252 @@ +--TEST-- +Test timezone_offset_get() function : usage variation - Passing unexpected values to first argument $object. +--FILE-- +<?php +/* Prototype : int timezone_offset_get ( DateTimeZone $object , DateTime $datetime ) + * Description: Returns the timezone offset from GMT + * Source code: ext/date/php_date.c + * Alias to functions: DateTimeZone::getOffset() + */ + +echo "*** Testing timezone_offset_get() : usage variation - unexpected values to first argument \$object***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -12345, + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + // resource + 'resource' => $file_handle +); + +$datetime = new DateTime("2009-01-31 15:14:10"); + +foreach($inputs as $variation =>$object) { + echo "\n-- $variation --\n"; + var_dump( timezone_offset_get($object, $datetime) ); +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing timezone_offset_get() : usage variation - unexpected values to first argument $object*** + +-- int 0 -- + +Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, integer given in %s on line %d +bool(false) + +-- int 1 -- + +Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, integer given in %s on line %d +bool(false) + +-- int 12345 -- + +Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, integer given in %s on line %d +bool(false) + +-- int -12345 -- + +Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, integer given in %s on line %d +bool(false) + +-- float 10.5 -- + +Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, double given in %s on line %d +bool(false) + +-- float -10.5 -- + +Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, double given in %s on line %d +bool(false) + +-- float .5 -- + +Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, double given in %s on line %d +bool(false) + +-- empty array -- + +Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, array given in %s on line %d +bool(false) + +-- uppercase NULL -- + +Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, null given in %s on line %d +bool(false) + +-- lowercase null -- + +Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, null given in %s on line %d +bool(false) + +-- lowercase true -- + +Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, boolean given in %s on line %d +bool(false) + +-- lowercase false -- + +Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, boolean given in %s on line %d +bool(false) + +-- uppercase TRUE -- + +Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, boolean given in %s on line %d +bool(false) + +-- uppercase FALSE -- + +Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, boolean given in %s on line %d +bool(false) + +-- empty string DQ -- + +Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, Unicode string given in %s on line %d +bool(false) + +-- empty string SQ -- + +Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, Unicode string given in %s on line %d +bool(false) + +-- string DQ -- + +Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, Unicode string given in %s on line %d +bool(false) + +-- string SQ -- + +Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, Unicode string given in %s on line %d +bool(false) + +-- mixed case string -- + +Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, Unicode string given in %s on line %d +bool(false) + +-- heredoc -- + +Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, Unicode string given in %s on line %d +bool(false) + +-- instance of classWithToString -- + +Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, object given in %s on line %d +bool(false) + +-- instance of classWithoutToString -- + +Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, object given in %s on line %d +bool(false) + +-- undefined var -- + +Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, null given in %s on line %d +bool(false) + +-- unset var -- + +Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, null given in %s on line %d +bool(false) + +-- resource -- + +Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/timezone_offset_get_variation2.phpt b/ext/date/tests/timezone_offset_get_variation2.phpt new file mode 100644 index 0000000000..fbcbec8431 --- /dev/null +++ b/ext/date/tests/timezone_offset_get_variation2.phpt @@ -0,0 +1,252 @@ +--TEST-- +Test timezone_offset_get() function : usage variation - Passing unexpected values to second argument $datetime. +--FILE-- +<?php +/* Prototype : int timezone_offset_get ( DateTimeZone $object , DateTime $datetime ) + * Description: Returns the timezone offset from GMT + * Source code: ext/date/php_date.c + * Alias to functions: DateTimeZone::getOffset() + */ + +echo "*** Testing timezone_offset_get() : usage variation - unexpected values to second argument \$datetime***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -12345, + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + // resource + 'resource' => $file_handle +); + +$object = new DateTimezone("Europe/London"); + +foreach($inputs as $variation =>$datetime) { + echo "\n-- $variation --\n"; + var_dump( timezone_offset_get($object, $datetime) ); +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing timezone_offset_get() : usage variation - unexpected values to second argument $datetime*** + +-- int 0 -- + +Warning: timezone_offset_get() expects parameter 2 to be DateTime, integer given in %s on line %d +bool(false) + +-- int 1 -- + +Warning: timezone_offset_get() expects parameter 2 to be DateTime, integer given in %s on line %d +bool(false) + +-- int 12345 -- + +Warning: timezone_offset_get() expects parameter 2 to be DateTime, integer given in %s on line %d +bool(false) + +-- int -12345 -- + +Warning: timezone_offset_get() expects parameter 2 to be DateTime, integer given in %s on line %d +bool(false) + +-- float 10.5 -- + +Warning: timezone_offset_get() expects parameter 2 to be DateTime, double given in %s on line %d +bool(false) + +-- float -10.5 -- + +Warning: timezone_offset_get() expects parameter 2 to be DateTime, double given in %s on line %d +bool(false) + +-- float .5 -- + +Warning: timezone_offset_get() expects parameter 2 to be DateTime, double given in %s on line %d +bool(false) + +-- empty array -- + +Warning: timezone_offset_get() expects parameter 2 to be DateTime, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: timezone_offset_get() expects parameter 2 to be DateTime, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: timezone_offset_get() expects parameter 2 to be DateTime, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: timezone_offset_get() expects parameter 2 to be DateTime, array given in %s on line %d +bool(false) + +-- uppercase NULL -- + +Warning: timezone_offset_get() expects parameter 2 to be DateTime, null given in %s on line %d +bool(false) + +-- lowercase null -- + +Warning: timezone_offset_get() expects parameter 2 to be DateTime, null given in %s on line %d +bool(false) + +-- lowercase true -- + +Warning: timezone_offset_get() expects parameter 2 to be DateTime, boolean given in %s on line %d +bool(false) + +-- lowercase false -- + +Warning: timezone_offset_get() expects parameter 2 to be DateTime, boolean given in %s on line %d +bool(false) + +-- uppercase TRUE -- + +Warning: timezone_offset_get() expects parameter 2 to be DateTime, boolean given in %s on line %d +bool(false) + +-- uppercase FALSE -- + +Warning: timezone_offset_get() expects parameter 2 to be DateTime, boolean given in %s on line %d +bool(false) + +-- empty string DQ -- + +Warning: timezone_offset_get() expects parameter 2 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- empty string SQ -- + +Warning: timezone_offset_get() expects parameter 2 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- string DQ -- + +Warning: timezone_offset_get() expects parameter 2 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- string SQ -- + +Warning: timezone_offset_get() expects parameter 2 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- mixed case string -- + +Warning: timezone_offset_get() expects parameter 2 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- heredoc -- + +Warning: timezone_offset_get() expects parameter 2 to be DateTime, Unicode string given in %s on line %d +bool(false) + +-- instance of classWithToString -- + +Warning: timezone_offset_get() expects parameter 2 to be DateTime, object given in %s on line %d +bool(false) + +-- instance of classWithoutToString -- + +Warning: timezone_offset_get() expects parameter 2 to be DateTime, object given in %s on line %d +bool(false) + +-- undefined var -- + +Warning: timezone_offset_get() expects parameter 2 to be DateTime, null given in %s on line %d +bool(false) + +-- unset var -- + +Warning: timezone_offset_get() expects parameter 2 to be DateTime, null given in %s on line %d +bool(false) + +-- resource -- + +Warning: timezone_offset_get() expects parameter 2 to be DateTime, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/timezone_open_basic1.phpt b/ext/date/tests/timezone_open_basic1.phpt new file mode 100644 index 0000000000..7a989362b0 --- /dev/null +++ b/ext/date/tests/timezone_open_basic1.phpt @@ -0,0 +1,27 @@ +--TEST-- +Test timezone_open() function : basic functionality +--FILE-- +<?php +/* Prototype : DateTimeZone timezone_open ( string $timezone ) + * Description: Returns new DateTimeZone object + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::__construct() + */ + +echo "*** Testing timezone_open() : basic functionality ***\n"; + +var_dump( timezone_open("GMT") ); +var_dump( timezone_open("Europe/London") ); +var_dump( timezone_open("America/Los_Angeles") ); + +?> +===DONE=== +--EXPECTF-- +*** Testing timezone_open() : basic functionality *** +object(DateTimeZone)#%d (0) { +} +object(DateTimeZone)#%d (0) { +} +object(DateTimeZone)#%d (0) { +} +===DONE===
\ No newline at end of file diff --git a/ext/date/tests/timezone_open_error.phpt b/ext/date/tests/timezone_open_error.phpt new file mode 100644 index 0000000000..16c5f0b09f --- /dev/null +++ b/ext/date/tests/timezone_open_error.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test timezone_open() function : error conditions +--FILE-- +<?php +/* Prototype : DateTimeZone timezone_open ( string $timezone ) + * Description: Returns new DateTimeZone object + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::__construct() + */ + +echo "*** Testing timezone_open() : error conditions ***\n"; + +echo "\n-- Testing timezone_open() function with zero arguments --\n"; +var_dump( timezone_open() ); + +echo "\n-- Testing timezone_open() function with more than expected no. of arguments --\n"; +$time = "GMT"; +$extra_arg = 99; +var_dump( timezone_open($time, $extra_arg) ); + +?> +===DONE=== +--EXPECTF-- +*** Testing timezone_open() : error conditions *** + +-- Testing timezone_open() function with zero arguments -- + +Warning: timezone_open() expects exactly 1 parameter, 0 given in %s on line %d +bool(false) + +-- Testing timezone_open() function with more than expected no. of arguments -- + +Warning: timezone_open() expects exactly 1 parameter, 2 given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/timezone_open_variation1.phpt b/ext/date/tests/timezone_open_variation1.phpt new file mode 100644 index 0000000000..650892218b --- /dev/null +++ b/ext/date/tests/timezone_open_variation1.phpt @@ -0,0 +1,251 @@ +--TEST-- +Test timezone_open function : usage variation - Passing unexpected values to first argument $timezone. +--FILE-- +<?php +/* Prototype : DateTimeZone timezone_open ( string $timezone ) + * Description: Returns new DateTimeZone object + * Source code: ext/date/php_date.c + * Alias to functions: DateTime::__construct() + */ + +echo "*** Testing timezone_open() : usage variation - unexpected values to first argument \$timezone***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -12345, + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + // resource + 'resource' => $file_handle +); + +foreach($inputs as $variation =>$timezone) { + echo "\n-- $variation --\n"; + var_dump( timezone_open($timezone) ); + +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing timezone_open() : usage variation - unexpected values to first argument $timezone*** + +-- int 0 -- + +Warning: timezone_open(): Unknown or bad timezone (0) in %s on line %d +bool(false) + +-- int 1 -- + +Warning: timezone_open(): Unknown or bad timezone (1) in %s on line %d +bool(false) + +-- int 12345 -- + +Warning: timezone_open(): Unknown or bad timezone (12345) in %s on line %d +bool(false) + +-- int -12345 -- + +Warning: timezone_open(): Unknown or bad timezone (-12345) in %s on line %d +bool(false) + +-- float 10.5 -- + +Warning: timezone_open(): Unknown or bad timezone (10.5) in %s on line %d +bool(false) + +-- float -10.5 -- + +Warning: timezone_open(): Unknown or bad timezone (-10.5) in %s on line %d +bool(false) + +-- float .5 -- + +Warning: timezone_open(): Unknown or bad timezone (0.5) in %s on line %d +bool(false) + +-- empty array -- + +Warning: timezone_open() expects parameter 1 to be binary string, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: timezone_open() expects parameter 1 to be binary string, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: timezone_open() expects parameter 1 to be binary string, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: timezone_open() expects parameter 1 to be binary string, array given in %s on line %d +bool(false) + +-- uppercase NULL -- + +Warning: timezone_open(): Unknown or bad timezone () in %s on line %d +bool(false) + +-- lowercase null -- + +Warning: timezone_open(): Unknown or bad timezone () in %s on line %d +bool(false) + +-- lowercase true -- + +Warning: timezone_open(): Unknown or bad timezone (1) in %s on line %d +bool(false) + +-- lowercase false -- + +Warning: timezone_open(): Unknown or bad timezone () in %s on line %d +bool(false) + +-- uppercase TRUE -- + +Warning: timezone_open(): Unknown or bad timezone (1) in %s on line %d +bool(false) + +-- uppercase FALSE -- + +Warning: timezone_open(): Unknown or bad timezone () in %s on line %d +bool(false) + +-- empty string DQ -- + +Warning: timezone_open(): Unknown or bad timezone () in %s on line %d +bool(false) + +-- empty string SQ -- + +Warning: timezone_open(): Unknown or bad timezone () in %s on line %d +bool(false) + +-- string DQ -- + +Warning: timezone_open(): Unknown or bad timezone (string) in %s on line %d +bool(false) + +-- string SQ -- + +Warning: timezone_open(): Unknown or bad timezone (string) in %s on line %d +bool(false) + +-- mixed case string -- + +Warning: timezone_open(): Unknown or bad timezone (sTrInG) in %s on line %d +bool(false) + +-- heredoc -- + +Warning: timezone_open(): Unknown or bad timezone (hello world) in %s on line %d +bool(false) + +-- instance of classWithToString -- + +Warning: timezone_open(): Unknown or bad timezone (Class A object) in %s on line %d +bool(false) + +-- instance of classWithoutToString -- + +Warning: timezone_open() expects parameter 1 to be binary string, object given in %s on line %d +bool(false) + +-- undefined var -- + +Warning: timezone_open(): Unknown or bad timezone () in %s on line %d +bool(false) + +-- unset var -- + +Warning: timezone_open(): Unknown or bad timezone () in %s on line %d +bool(false) + +-- resource -- + +Warning: timezone_open() expects parameter 1 to be binary string, resource given in %s on line %d +bool(false) +===DONE===
\ No newline at end of file diff --git a/ext/date/tests/timezone_transitions_get_basic1.phpt b/ext/date/tests/timezone_transitions_get_basic1.phpt new file mode 100644 index 0000000000..aaf348010e --- /dev/null +++ b/ext/date/tests/timezone_transitions_get_basic1.phpt @@ -0,0 +1,53 @@ +--TEST-- +Test timezone_transitions_get() function : basic functionality +--FILE-- +<?php +/* Prototype : array timezone_transitions_get ( DateTimeZone $object, [ int $timestamp_begin [, int $timestamp_end ]] ) + * Description: Returns all transitions for the timezone + * Source code: ext/date/php_date.c + * Alias to functions: DateTimeZone::getTransitions() + */ + +echo "*** Testing timezone_transitions_get() : basic functionality ***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +// Create a DateTimeZone object +$tz = timezone_open("Europe/London"); + +$tran = timezone_transitions_get($tz); + +echo "\n-- Get all transitions --\n"; +$tran = timezone_transitions_get($tz); +var_dump( gettype($tran) ); + +echo "\n-- Total number of transitions: " . count($tran). " --\n"; + +echo "\n-- Format a sample entry pfor Spring 1963 --\n"; +var_dump( $tran[97] ); + +?> +===DONE=== +--EXPECT-- +*** Testing timezone_transitions_get() : basic functionality *** + +-- Get all transitions -- +unicode(5) "array" + +-- Total number of transitions: 243 -- + +-- Format a sample entry pfor Spring 1963 -- +array(5) { + [u"ts"]=> + int(-213228000) + [u"time"]=> + unicode(24) "1963-03-31T02:00:00+0000" + [u"offset"]=> + int(3600) + [u"isdst"]=> + bool(true) + [u"abbr"]=> + unicode(3) "BST" +} +===DONE===
\ No newline at end of file diff --git a/ext/date/tests/timezone_transitions_get_error.phpt b/ext/date/tests/timezone_transitions_get_error.phpt new file mode 100644 index 0000000000..142cfda2ff --- /dev/null +++ b/ext/date/tests/timezone_transitions_get_error.phpt @@ -0,0 +1,58 @@ +--TEST-- +Test timezone_transitions_get() function : error conditions +--FILE-- +<?php +/* Prototype : array timezone_transitions_get ( DateTimeZone $object, [ int $timestamp_begin [, int $timestamp_end ]] ) + * Description: Returns all transitions for the timezone + * Source code: ext/date/php_date.c + * Alias to functions: DateTimeZone::getTransitions() + */ + +//Set the default time zone +date_default_timezone_set("GMT"); +$tz = timezone_open("Europe/London"); + +echo "*** Testing timezone_transitions_get() : error conditions ***\n"; + +echo "\n-- Testing timezone_transitions_get() function with zero arguments --\n"; +var_dump( timezone_transitions_get() ); + +echo "\n-- Testing timezone_transitions_get() function with more than expected no. of arguments --\n"; +$timestamp_begin = mktime(0, 0, 0, 1, 1, 1972); +$timestamp_end = mktime(0, 0, 0, 1, 1, 1975); +$extra_arg = 99; +var_dump( timezone_transitions_get($tz, $timestamp_begin, $timestamp_end, $extra_arg) ); + +echo "\n-- Testing timezone_transitions_get() function with an invalid values for \$object argument --\n"; +$invalid_obj = new stdClass(); +var_dump( timezone_transitions_get($invalid_obj) ); +$invalid_obj = 10; +var_dump( timezone_transitions_get($invalid_obj) ); +$invalid_obj = null; +var_dump( timezone_transitions_get($invalid_obj) ); +?> +===DONE=== +--EXPECTF-- +*** Testing timezone_transitions_get() : error conditions *** + +-- Testing timezone_transitions_get() function with zero arguments -- + +Warning: timezone_transitions_get() expects at least 1 parameter, 0 given in %s on line %d +bool(false) + +-- Testing timezone_transitions_get() function with more than expected no. of arguments -- + +Warning: timezone_transitions_get() expects at most 3 parameters, 4 given in %s on line %d +bool(false) + +-- Testing timezone_transitions_get() function with an invalid values for $object argument -- + +Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, object given in %s on line %d +bool(false) + +Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, integer given in %s on line %d +bool(false) + +Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, null given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/timezone_transitions_get_variation1.phpt b/ext/date/tests/timezone_transitions_get_variation1.phpt new file mode 100644 index 0000000000..724292f9bd --- /dev/null +++ b/ext/date/tests/timezone_transitions_get_variation1.phpt @@ -0,0 +1,250 @@ +--TEST-- +Test timezone_transitions_get() function : usage variation - Passing unexpected values to first argument $object. +--FILE-- +<?php +/* Prototype : array timezone_transitions_get ( DateTimeZone $object, [ int $timestamp_begin [, int $timestamp_end ]] ) + * Description: Returns all transitions for the timezone + * Source code: ext/date/php_date.c + * Alias to functions: DateTimeZone::getTransitions() + */ + +echo "*** Testing timezone_transitions_get() : usage variation - unexpected values to first argument \$object***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -12345, + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + // resource + 'resource' => $file_handle +); + +foreach($inputs as $variation =>$object) { + echo "\n-- $variation --\n"; + var_dump( timezone_transitions_get($object) ); +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing timezone_transitions_get() : usage variation - unexpected values to first argument $object*** + +-- int 0 -- + +Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, integer given in %s on line %d +bool(false) + +-- int 1 -- + +Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, integer given in %s on line %d +bool(false) + +-- int 12345 -- + +Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, integer given in %s on line %d +bool(false) + +-- int -12345 -- + +Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, integer given in %s on line %d +bool(false) + +-- float 10.5 -- + +Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, double given in %s on line %d +bool(false) + +-- float -10.5 -- + +Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, double given in %s on line %d +bool(false) + +-- float .5 -- + +Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, double given in %s on line %d +bool(false) + +-- empty array -- + +Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, array given in %s on line %d +bool(false) + +-- int indexed array -- + +Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, array given in %s on line %d +bool(false) + +-- associative array -- + +Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, array given in %s on line %d +bool(false) + +-- nested arrays -- + +Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, array given in %s on line %d +bool(false) + +-- uppercase NULL -- + +Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, null given in %s on line %d +bool(false) + +-- lowercase null -- + +Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, null given in %s on line %d +bool(false) + +-- lowercase true -- + +Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, boolean given in %s on line %d +bool(false) + +-- lowercase false -- + +Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, boolean given in %s on line %d +bool(false) + +-- uppercase TRUE -- + +Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, boolean given in %s on line %d +bool(false) + +-- uppercase FALSE -- + +Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, boolean given in %s on line %d +bool(false) + +-- empty string DQ -- + +Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, Unicode string given in %s on line %d +bool(false) + +-- empty string SQ -- + +Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, Unicode string given in %s on line %d +bool(false) + +-- string DQ -- + +Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, Unicode string given in %s on line %d +bool(false) + +-- string SQ -- + +Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, Unicode string given in %s on line %d +bool(false) + +-- mixed case string -- + +Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, Unicode string given in %s on line %d +bool(false) + +-- heredoc -- + +Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, Unicode string given in %s on line %d +bool(false) + +-- instance of classWithToString -- + +Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, object given in %s on line %d +bool(false) + +-- instance of classWithoutToString -- + +Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, object given in %s on line %d +bool(false) + +-- undefined var -- + +Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, null given in %s on line %d +bool(false) + +-- unset var -- + +Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, null given in %s on line %d +bool(false) + +-- resource -- + +Warning: timezone_transitions_get() expects parameter 1 to be DateTimeZone, resource given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/date/tests/timezone_transitions_get_variation2.phpt b/ext/date/tests/timezone_transitions_get_variation2.phpt new file mode 100644 index 0000000000..1cb296aa12 --- /dev/null +++ b/ext/date/tests/timezone_transitions_get_variation2.phpt @@ -0,0 +1,253 @@ +--TEST-- +Test timezone_transitions_get() function : usage variation - Passing unexpected values to first argument $object. +--FILE-- +<?php +/* Prototype : array timezone_transitions_get ( DateTimeZone $object, [ int $timestamp_begin [, int $timestamp_end ]] ) + * Description: Returns all transitions for the timezone + * Source code: ext/date/php_date.c + * Alias to functions: DateTimeZone::getTransitions() + */ + +echo "*** Testing timezone_transitions_get() : usage variation - unexpected values to first argument \$object***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __tounicode() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -12345, + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + // resource + 'resource' => $file_handle +); + +$tz = timezone_open("Europe/London"); +$timestamp_end = mktime(0, 0, 0, 1, 1, 1975); + +foreach($inputs as $variation =>$timestamp_begin) { + echo "\n-- $variation --\n"; + $tran = timezone_transitions_get($tz, $timestamp_begin, $timestamp_end); + var_dump( gettype($tran) ); + var_dump( count($tran) ); +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing timezone_transitions_get() : usage variation - unexpected values to first argument $object*** + +-- int 0 -- +unicode(5) "array" +int(8) + +-- int 1 -- +unicode(5) "array" +int(8) + +-- int 12345 -- +unicode(5) "array" +int(8) + +-- int -12345 -- +unicode(5) "array" +int(8) + +-- float 10.5 -- +unicode(5) "array" +int(8) + +-- float -10.5 -- +unicode(5) "array" +int(8) + +-- float .5 -- +unicode(5) "array" +int(8) + +-- empty array -- + +Warning: timezone_transitions_get() expects parameter 2 to be long, array given in %s on line %d +unicode(7) "boolean" +int(1) + +-- int indexed array -- + +Warning: timezone_transitions_get() expects parameter 2 to be long, array given in %s on line %d +unicode(7) "boolean" +int(1) + +-- associative array -- + +Warning: timezone_transitions_get() expects parameter 2 to be long, array given in %s on line %d +unicode(7) "boolean" +int(1) + +-- nested arrays -- + +Warning: timezone_transitions_get() expects parameter 2 to be long, array given in %s on line %d +unicode(7) "boolean" +int(1) + +-- uppercase NULL -- +unicode(5) "array" +int(8) + +-- lowercase null -- +unicode(5) "array" +int(8) + +-- lowercase true -- +unicode(5) "array" +int(8) + +-- lowercase false -- +unicode(5) "array" +int(8) + +-- uppercase TRUE -- +unicode(5) "array" +int(8) + +-- uppercase FALSE -- +unicode(5) "array" +int(8) + +-- empty string DQ -- + +Warning: timezone_transitions_get() expects parameter 2 to be long, Unicode string given in %s on line %d +unicode(7) "boolean" +int(1) + +-- empty string SQ -- + +Warning: timezone_transitions_get() expects parameter 2 to be long, Unicode string given in %s on line %d +unicode(7) "boolean" +int(1) + +-- string DQ -- + +Warning: timezone_transitions_get() expects parameter 2 to be long, Unicode string given in %s on line %d +unicode(7) "boolean" +int(1) + +-- string SQ -- + +Warning: timezone_transitions_get() expects parameter 2 to be long, Unicode string given in %s on line %d +unicode(7) "boolean" +int(1) + +-- mixed case string -- + +Warning: timezone_transitions_get() expects parameter 2 to be long, Unicode string given in %s on line %d +unicode(7) "boolean" +int(1) + +-- heredoc -- + +Warning: timezone_transitions_get() expects parameter 2 to be long, Unicode string given in %s on line %d +unicode(7) "boolean" +int(1) + +-- instance of classWithToString -- + +Warning: timezone_transitions_get() expects parameter 2 to be long, object given in %s on line %d +unicode(7) "boolean" +int(1) + +-- instance of classWithoutToString -- + +Warning: timezone_transitions_get() expects parameter 2 to be long, object given in %s on line %d +unicode(7) "boolean" +int(1) + +-- undefined var -- +unicode(5) "array" +int(8) + +-- unset var -- +unicode(5) "array" +int(8) + +-- resource -- + +Warning: timezone_transitions_get() expects parameter 2 to be long, resource given in %s on line %d +unicode(7) "boolean" +int(1) +===DONE=== diff --git a/ext/date/tests/timezone_transitions_get_variation3.phpt b/ext/date/tests/timezone_transitions_get_variation3.phpt new file mode 100644 index 0000000000..29ee26a824 --- /dev/null +++ b/ext/date/tests/timezone_transitions_get_variation3.phpt @@ -0,0 +1,253 @@ +--TEST-- +Test timezone_transitions_get() function : usage variation - Passing unexpected values to first argument $object. +--FILE-- +<?php +/* Prototype : array timezone_transitions_get ( DateTimeZone $object, [ int $timestamp_begin [, int $timestamp_end ]] ) + * Description: Returns all transitions for the timezone + * Source code: ext/date/php_date.c + * Alias to functions: DateTimeZone::getTransitions() + */ + +echo "*** Testing timezone_transitions_get() : usage variation - unexpected values to first argument \$object***\n"; + +//Set the default time zone +date_default_timezone_set("Europe/London"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +// resource +$file_handle = fopen(__FILE__, 'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -12345, + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + // resource + 'resource' => $file_handle +); + +$tz = timezone_open("Europe/London"); +$timestamp_begin = mktime(0, 0, 0, 1, 1, 1975); + +foreach($inputs as $variation =>$timestamp_end) { + echo "\n-- $variation --\n"; + $tran = timezone_transitions_get($tz, $timestamp_begin, $timestamp_end); + var_dump( gettype($tran) ); + var_dump( count($tran) ); +}; + +// closing the resource +fclose( $file_handle ); + +?> +===DONE=== +--EXPECTF-- +*** Testing timezone_transitions_get() : usage variation - unexpected values to first argument $object*** + +-- int 0 -- +unicode(5) "array" +int(1) + +-- int 1 -- +unicode(5) "array" +int(1) + +-- int 12345 -- +unicode(5) "array" +int(1) + +-- int -12345 -- +unicode(5) "array" +int(1) + +-- float 10.5 -- +unicode(5) "array" +int(1) + +-- float -10.5 -- +unicode(5) "array" +int(1) + +-- float .5 -- +unicode(5) "array" +int(1) + +-- empty array -- + +Warning: timezone_transitions_get() expects parameter 3 to be long, array given in %s on line %d +unicode(7) "boolean" +int(1) + +-- int indexed array -- + +Warning: timezone_transitions_get() expects parameter 3 to be long, array given in %s on line %d +unicode(7) "boolean" +int(1) + +-- associative array -- + +Warning: timezone_transitions_get() expects parameter 3 to be long, array given in %s on line %d +unicode(7) "boolean" +int(1) + +-- nested arrays -- + +Warning: timezone_transitions_get() expects parameter 3 to be long, array given in %s on line %d +unicode(7) "boolean" +int(1) + +-- uppercase NULL -- +unicode(5) "array" +int(1) + +-- lowercase null -- +unicode(5) "array" +int(1) + +-- lowercase true -- +unicode(5) "array" +int(1) + +-- lowercase false -- +unicode(5) "array" +int(1) + +-- uppercase TRUE -- +unicode(5) "array" +int(1) + +-- uppercase FALSE -- +unicode(5) "array" +int(1) + +-- empty string DQ -- + +Warning: timezone_transitions_get() expects parameter 3 to be long, Unicode string given in %s on line %d +unicode(7) "boolean" +int(1) + +-- empty string SQ -- + +Warning: timezone_transitions_get() expects parameter 3 to be long, Unicode string given in %s on line %d +unicode(7) "boolean" +int(1) + +-- string DQ -- + +Warning: timezone_transitions_get() expects parameter 3 to be long, Unicode string given in %s on line %d +unicode(7) "boolean" +int(1) + +-- string SQ -- + +Warning: timezone_transitions_get() expects parameter 3 to be long, Unicode string given in %s on line %d +unicode(7) "boolean" +int(1) + +-- mixed case string -- + +Warning: timezone_transitions_get() expects parameter 3 to be long, Unicode string given in %s on line %d +unicode(7) "boolean" +int(1) + +-- heredoc -- + +Warning: timezone_transitions_get() expects parameter 3 to be long, Unicode string given in %s on line %d +unicode(7) "boolean" +int(1) + +-- instance of classWithToString -- + +Warning: timezone_transitions_get() expects parameter 3 to be long, object given in %s on line %d +unicode(7) "boolean" +int(1) + +-- instance of classWithoutToString -- + +Warning: timezone_transitions_get() expects parameter 3 to be long, object given in %s on line %d +unicode(7) "boolean" +int(1) + +-- undefined var -- +unicode(5) "array" +int(1) + +-- unset var -- +unicode(5) "array" +int(1) + +-- resource -- + +Warning: timezone_transitions_get() expects parameter 3 to be long, resource given in %s on line %d +unicode(7) "boolean" +int(1) +===DONE=== |