date_parse_error.phpt 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. --TEST--
  2. Test date_parse() function : error conditions
  3. --FILE--
  4. <?php
  5. /* Prototype : array date_parse ( string $date )
  6. * Description: Returns associative array with detailed info about given date.
  7. * Source code: ext/date/php_date.c
  8. */
  9. //Set the default time zone
  10. date_default_timezone_set("Europe/London");
  11. echo "*** Testing date_parse() : error conditions ***\n";
  12. echo "\n-- Testing date_parse() function with zero arguments --\n";
  13. var_dump( date_parse() );
  14. echo "\n-- Testing date_parse() function with more than expected no. of arguments --\n";
  15. $date = "2009-02-27 10:00:00.5";
  16. $extra_arg = 10;
  17. var_dump( date_parse($date, $extra_arg) );
  18. echo "\n-- Testing date_parse() function with unexpected characters in \$date argument --\n";
  19. $invalid_date = "2OO9-02--27 10:00?00.5";
  20. var_dump( date_parse($invalid_date) );
  21. ?>
  22. ===DONE===
  23. --EXPECTF--
  24. *** Testing date_parse() : error conditions ***
  25. -- Testing date_parse() function with zero arguments --
  26. Warning: date_parse() expects exactly 1 parameter, 0 given in %s on line %d
  27. bool(false)
  28. -- Testing date_parse() function with more than expected no. of arguments --
  29. Warning: date_parse() expects exactly 1 parameter, 2 given in %s on line %d
  30. bool(false)
  31. -- Testing date_parse() function with unexpected characters in $date argument --
  32. array(13) {
  33. ["year"]=>
  34. bool(false)
  35. ["month"]=>
  36. bool(false)
  37. ["day"]=>
  38. bool(false)
  39. ["hour"]=>
  40. int(10)
  41. ["minute"]=>
  42. int(0)
  43. ["second"]=>
  44. int(0)
  45. ["fraction"]=>
  46. float(0)
  47. ["warning_count"]=>
  48. int(1)
  49. ["warnings"]=>
  50. array(1) {
  51. [4]=>
  52. string(29) "Double timezone specification"
  53. }
  54. ["error_count"]=>
  55. int(7)
  56. ["errors"]=>
  57. array(7) {
  58. [0]=>
  59. string(20) "Unexpected character"
  60. [1]=>
  61. string(47) "The timezone could not be found in the database"
  62. [3]=>
  63. string(20) "Unexpected character"
  64. [7]=>
  65. string(20) "Unexpected character"
  66. [8]=>
  67. string(29) "Double timezone specification"
  68. [17]=>
  69. string(20) "Unexpected character"
  70. [18]=>
  71. string(25) "Double time specification"
  72. }
  73. ["is_localtime"]=>
  74. bool(true)
  75. ["zone_type"]=>
  76. int(0)
  77. }
  78. ===DONE===