smantoor Mon Dec 8 10:48:22 2008 UTC Added files: (Branch: PHP_5_3) /php-src/ext/date/tests idate_variation4.phpt idate_variation5.phpt idate_variation6.phpt idate_basic.phpt idate_variation1.phpt idate_variation2.phpt idate_variation3.phpt Log: New testcases for idate function
http://cvs.php.net/viewvc.cgi/php-src/ext/date/tests/idate_variation4.phpt?view=markup&rev=1.1 Index: php-src/ext/date/tests/idate_variation4.phpt +++ php-src/ext/date/tests/idate_variation4.phpt --TEST-- Test idate() function : usage variation - Passing supported Date format characters to format argument. --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() : usage variation ***\n"; // Initialise function arguments not being substituted (if any) date_default_timezone_set("Asia/Calcutta"); //array of values to iterate over $inputs = array( 'Day of the month' => 'd', 'Leap Year' =>'L', 'Month number' => 'm', 'Days in the month' => 't', 'Day of the week' => 'w', 'ISO-8601 week number' => 'W', 'Year (1 or 2 digits)' => 'y', 'Year 4 digits' => 'Y', 'Day of the year' => 'z', ); // loop through each element of the array for timestamp foreach($inputs as $key =>$value) { echo "\n--$key--\n"; var_dump( idate($value) ); }; ?> ===DONE=== --EXPECTF-- *** Testing idate() : usage variation *** --Day of the month-- int(%d) --Leap Year-- int(%d) --Month number-- int(%d) --Days in the month-- int(%d) --Day of the week-- int(%d) --ISO-8601 week number-- int(%d) --Year (1 or 2 digits)-- int(%d) --Year 4 digits-- int(%d) --Day of the year-- int(%d) ===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/date/tests/idate_variation5.phpt?view=markup&rev=1.1 Index: php-src/ext/date/tests/idate_variation5.phpt +++ php-src/ext/date/tests/idate_variation5.phpt --TEST-- Test idate() function : usage variation - Passing supported Time format characters to format argument. --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() : usage variation ***\n"; // Initialise function arguments not being substituted (if any) date_default_timezone_set("Asia/Calcutta"); //array of values to iterate over $inputs = array( 'Internet Time' => 'B', '12 hour format' => 'h', '24 hour format' => 'H', 'Minutes' => 'i', 'DST Activated' => 'I', 'Seconds' => 's', 'Seconds since Unix Epoch' => 'U', 'Time zone offset' => 'Z' ); // loop through each element of the array for timestamp foreach($inputs as $key =>$value) { echo "\n--$key--\n"; var_dump( idate($value) ); }; ?> ===DONE=== --EXPECTF-- *** Testing idate() : usage variation *** --Internet Time-- int(%d) --12 hour format-- int(%d) --24 hour format-- int(%d) --Minutes-- int(%d) --DST Activated-- int(%d) --Seconds-- int(%d) --Seconds since Unix Epoch-- int(%d) --Time zone offset-- int(%d) ===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/date/tests/idate_variation6.phpt?view=markup&rev=1.1 Index: php-src/ext/date/tests/idate_variation6.phpt +++ php-src/ext/date/tests/idate_variation6.phpt --TEST-- Test idate() function : usage variation - Checking return of year(1 or 2 digits) format starting with zero and nonzero. --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() : usage variation ***\n"; // Initialise function arguments not being substituted (if any) date_default_timezone_set("Asia/Calcutta"); $format = 'y'; echo "\n-- Testing idate() function for 2 digit year having no zero as starting number --\n"; $timestamp = mktime(8, 8, 8, 8, 8, 1970); var_dump( idate($format, $timestamp) ); echo "\n-- Testing idate() function for 2 digit year having zero as starting number --\n"; $timestamp = mktime(8, 8, 8, 8, 8, 2001); var_dump( idate($format, $timestamp) ); ?> ===DONE=== --EXPECTF-- *** Testing idate() : usage variation *** -- Testing idate() function for 2 digit year having no zero as starting number -- int(70) -- Testing idate() function for 2 digit year having zero as starting number -- int(1) ===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/date/tests/idate_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/date/tests/idate_basic.phpt +++ php-src/ext/date/tests/idate_basic.phpt --TEST-- Test idate() function : basic functionality --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() : basic functionality ***\n"; // Initialise all required variables $format = 'Y'; // Calling idate() with mandatory arguments date_default_timezone_set("Asia/Calcutta"); var_dump( idate($format) ); ?> ===DONE=== --EXPECTF-- *** Testing idate() : basic functionality *** int(%d) ===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/date/tests/idate_variation1.phpt?view=markup&rev=1.1 Index: php-src/ext/date/tests/idate_variation1.phpt +++ php-src/ext/date/tests/idate_variation1.phpt --TEST-- Test idate() function : usage variation - Passing unexpected values to first argument 'format'. --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() : usage variation ***\n"; // Initialise function arguments not being substituted (if any) date_default_timezone_set("Asia/Calcutta"); $timestamp = mktime(8, 8, 8, 8, 8, 2008); //get an unset variable $unset_var = 10; unset ($unset_var); // define some classes class classWithToString { public function __toString() { return "Class A object"; } } class classWithoutToString { } // heredoc string $heredoc = <<<EOT hello world EOT; // add arrays $index_array = array (1, 2, 3); $assoc_array = array ('one' => 1, 'two' => 2); //array of values to iterate over $inputs = array( // int data 'int 0' => 0, 'int 1' => 1, 'int 12345' => 12345, 'int -12345' => -12345, // float data 'float 10.5' => 10.5, 'float -10.5' => -10.5, 'float 12.3456789000e10' => 12.3456789000e10, 'float -12.3456789000e10' => -12.3456789000e10, 'float .5' => .5, // array data 'empty array' => array(), 'int indexed array' => $index_array, 'associative array' => $assoc_array, 'nested arrays' => array('foo', $index_array, $assoc_array), // null data 'uppercase NULL' => NULL, 'lowercase null' => null, // boolean data 'lowercase true' => true, 'lowercase false' =>false, 'uppercase TRUE' =>TRUE, 'uppercase FALSE' =>FALSE, // empty data 'empty string DQ' => "", 'empty string SQ' => '', // object data 'instance of classWithToString' => new classWithToString(), 'instance of classWithoutToString' => new classWithoutToString(), // undefined data 'undefined var' => @$undefined_var, // unset data 'unset var' => @$unset_var, ); // loop through each element of the array for format foreach($inputs as $key =>$value) { echo "\n--$key--\n"; var_dump( idate($value) ); var_dump( idate($value, $timestamp) ); }; ?> ===DONE=== --EXPECTF-- *** Testing idate() : usage variation *** --int 0-- Warning: idate(): Unrecognized date format token in %s on line %d bool(false) Warning: idate(): Unrecognized date format token in %s on line %d bool(false) --int 1-- Warning: idate(): Unrecognized date format token in %s on line %d bool(false) Warning: idate(): Unrecognized date format token in %s on line %d bool(false) --int 12345-- Warning: idate(): idate format is one char in %s on line %d bool(false) Warning: idate(): idate format is one char in %s on line %d bool(false) --int -12345-- Warning: idate(): idate format is one char in %s on line %d bool(false) Warning: idate(): idate format is one char in %s on line %d bool(false) --float 10.5-- Warning: idate(): idate format is one char in %s on line %d bool(false) Warning: idate(): idate format is one char in %s on line %d bool(false) --float -10.5-- Warning: idate(): idate format is one char in %s on line %d bool(false) Warning: idate(): idate format is one char in %s on line %d bool(false) --float 12.3456789000e10-- Warning: idate(): idate format is one char in %s on line %d bool(false) Warning: idate(): idate format is one char in %s on line %d bool(false) --float -12.3456789000e10-- Warning: idate(): idate format is one char in %s on line %d bool(false) Warning: idate(): idate format is one char in %s on line %d bool(false) --float .5-- Warning: idate(): idate format is one char in %s on line %d bool(false) Warning: idate(): idate format is one char in %s on line %d bool(false) --empty array-- Warning: idate() expects parameter 1 to be binary string, array given in %s on line %d bool(false) Warning: idate() expects parameter 1 to be binary string, array given in %s on line %d bool(false) --int indexed array-- Warning: idate() expects parameter 1 to be binary string, array given in %s on line %d bool(false) Warning: idate() expects parameter 1 to be binary string, array given in %s on line %d bool(false) --associative array-- Warning: idate() expects parameter 1 to be binary string, array given in %s on line %d bool(false) Warning: idate() expects parameter 1 to be binary string, array given in %s on line %d bool(false) --nested arrays-- Warning: idate() expects parameter 1 to be binary string, array given in %s on line %d bool(false) Warning: idate() expects parameter 1 to be binary string, array given in %s on line %d bool(false) --uppercase NULL-- Warning: idate(): idate format is one char in %s on line %d bool(false) Warning: idate(): idate format is one char in %s on line %d bool(false) --lowercase null-- Warning: idate(): idate format is one char in %s on line %d bool(false) Warning: idate(): idate format is one char in %s on line %d bool(false) --lowercase true-- Warning: idate(): Unrecognized date format token in %s on line %d bool(false) Warning: idate(): Unrecognized date format token in %s on line %d bool(false) --lowercase false-- Warning: idate(): idate format is one char in %s on line %d bool(false) Warning: idate(): idate format is one char in %s on line %d bool(false) --uppercase TRUE-- Warning: idate(): Unrecognized date format token in %s on line %d bool(false) Warning: idate(): Unrecognized date format token in %s on line %d bool(false) --uppercase FALSE-- Warning: idate(): idate format is one char in %s on line %d bool(false) Warning: idate(): idate format is one char in %s on line %d bool(false) --empty string DQ-- Warning: idate(): idate format is one char in %s on line %d bool(false) Warning: idate(): idate format is one char in %s on line %d bool(false) --empty string SQ-- Warning: idate(): idate format is one char in %s on line %d bool(false) Warning: idate(): idate format is one char in %s on line %d bool(false) --instance of classWithToString-- Warning: idate(): idate format is one char in %s on line %d bool(false) Warning: idate(): idate format is one char in %s on line %d bool(false) --instance of classWithoutToString-- Warning: idate() expects parameter 1 to be binary string, object given in %s on line %d bool(false) Warning: idate() expects parameter 1 to be binary string, object given in %s on line %d bool(false) --undefined var-- Warning: idate(): idate format is one char in %s on line %d bool(false) Warning: idate(): idate format is one char in %s on line %d bool(false) --unset var-- Warning: idate(): idate format is one char in %s on line %d bool(false) Warning: idate(): idate format is one char in %s on line %d bool(false) ===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/date/tests/idate_variation2.phpt?view=markup&rev=1.1 Index: php-src/ext/date/tests/idate_variation2.phpt +++ php-src/ext/date/tests/idate_variation2.phpt --TEST-- Test idate() function : usage variation - Passing unexpected values to second optional argument 'timestamp'. --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() : usage variation ***\n"; // Initialise function arguments not being substituted (if any) $format = 'Y'; date_default_timezone_set("Asia/Calcutta"); //get an unset variable $unset_var = 10; unset ($unset_var); // define some classes class classWithToString { public function __toString() { return "Class A object"; } } class classWithoutToString { } // heredoc string $heredoc = <<<EOT hello world EOT; // add arrays $index_array = array (1, 2, 3); $assoc_array = array ('one' => 1, 'two' => 2); //array of values to iterate over $inputs = array( // float data 'float 10.5' => 10.5, 'float -10.5' => -10.5, 'float .5' => .5, // array data 'empty array' => array(), 'int indexed array' => $index_array, 'associative array' => $assoc_array, 'nested arrays' => array('foo', $index_array, $assoc_array), // null data 'uppercase NULL' => NULL, 'lowercase null' => null, // boolean data 'lowercase true' => true, 'lowercase false' =>false, 'uppercase TRUE' =>TRUE, 'uppercase FALSE' =>FALSE, // empty data 'empty string DQ' => "", 'empty string SQ' => '', // string data 'string DQ' => "string", 'string SQ' => 'string', 'mixed case string' => "sTrInG", 'heredoc' => $heredoc, // object data 'instance of classWithToString' => new classWithToString(), 'instance of classWithoutToString' => new classWithoutToString(), // undefined data 'undefined var' => @$undefined_var, // unset data 'unset var' => @$unset_var, ); // loop through each element of the array for timestamp foreach($inputs as $key =>$value) { echo "\n--$key--\n"; var_dump( idate($format, $value) ); }; ?> ===DONE=== --EXPECTF-- *** Testing idate() : usage variation *** --float 10.5-- int(1970) --float -10.5-- int(1970) --float .5-- int(1970) --empty array-- Warning: idate() expects parameter 2 to be long, array given in %s on line %d bool(false) --int indexed array-- Warning: idate() expects parameter 2 to be long, array given in %s on line %d bool(false) --associative array-- Warning: idate() expects parameter 2 to be long, array given in %s on line %d bool(false) --nested arrays-- Warning: idate() expects parameter 2 to be long, array given in %s on line %d bool(false) --uppercase NULL-- int(1970) --lowercase null-- int(1970) --lowercase true-- int(1970) --lowercase false-- int(1970) --uppercase TRUE-- int(1970) --uppercase FALSE-- int(1970) --empty string DQ-- Warning: idate() expects parameter 2 to be long, Unicode string given in %s on line %d bool(false) --empty string SQ-- Warning: idate() expects parameter 2 to be long, Unicode string given in %s on line %d bool(false) --string DQ-- Warning: idate() expects parameter 2 to be long, Unicode string given in %s on line %d bool(false) --string SQ-- Warning: idate() expects parameter 2 to be long, Unicode string given in %s on line %d bool(false) --mixed case string-- Warning: idate() expects parameter 2 to be long, Unicode string given in %s on line %d bool(false) --heredoc-- Warning: idate() expects parameter 2 to be long, Unicode string given in %s on line %d bool(false) --instance of classWithToString-- Warning: idate() expects parameter 2 to be long, object given in %s on line %d bool(false) --instance of classWithoutToString-- Warning: idate() expects parameter 2 to be long, object given in %s on line %d bool(false) --undefined var-- int(1970) --unset var-- int(1970) ===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/date/tests/idate_variation3.phpt?view=markup&rev=1.1 Index: php-src/ext/date/tests/idate_variation3.phpt +++ php-src/ext/date/tests/idate_variation3.phpt --TEST-- Test idate() function : usage variation - Passing higher positive and negetive float values to timestamp. --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() : usage variation ***\n"; // Initialise function arguments not being substituted (if any) $format = 'Y'; date_default_timezone_set("Asia/Calcutta"); echo "\n-- Testing idate() function with float 12.3456789000e10 to timestamp --\n"; $timestamp = 12.3456789000e10; var_dump( idate($format, $timestamp) ); echo "\n-- Testing idate() function with float -12.3456789000e10 to timestamp --\n"; $timestamp = -12.3456789000e10; var_dump( idate($format, $timestamp) ); ?> ===DONE=== --EXPECTREGEX-- \*\*\* Testing idate\(\) : usage variation \*\*\* -- Testing idate\(\) function with float 12.3456789000e10 to timestamp -- int\((2038|5882)\) -- Testing idate\(\) function with float -12.3456789000e10 to timestamp -- int\((1901|-1943)\) ===DONE===
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php