DateTimeZone_getLocation.phpt 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. --TEST--
  2. Test DateTimeZone::getLocation()
  3. --CREDITS--
  4. marcosptf - <marcosptf@yahoo.com.br> - #phparty7 - @phpsp - novatec/2015 - sao paulo - br
  5. --FILE--
  6. <?php
  7. $countryCode = array("??");
  8. $countryCodeTest = array("AU", "CA", "ET", "AF", "US", "KZ", "AM");
  9. foreach (DateTimeZone::listAbbreviations() as $value) {
  10. if (NULL != $value[0]['timezone_id']) {
  11. $timeZone = new DateTimeZone($value[0]['timezone_id']);
  12. $timeZoneArray = $timeZone->getLocation();
  13. if (false === $timeZoneArray) {
  14. continue;
  15. }
  16. if (!in_array($timeZoneArray['country_code'], $countryCode) && NULL != $timeZoneArray['country_code']) {
  17. array_push($countryCode, $timeZoneArray['country_code']);
  18. if(in_array($timeZoneArray['country_code'], $countryCodeTest)){
  19. print_r($timeZoneArray);
  20. }
  21. }
  22. }
  23. }
  24. ?>
  25. --EXPECTF--
  26. Array
  27. (
  28. [country_code] => %s
  29. [latitude] => %f
  30. [longitude] => %f
  31. [comments] => %s
  32. )
  33. Array
  34. (
  35. [country_code] => %s
  36. [latitude] => %f
  37. [longitude] => %f
  38. [comments] => %s
  39. )
  40. Array
  41. (
  42. [country_code] => %s
  43. [latitude] => %f
  44. [longitude] => %f
  45. [comments] => %s
  46. )
  47. Array
  48. (
  49. [country_code] => %s
  50. [latitude] => %f
  51. [longitude] => %f
  52. [comments] => %S
  53. )