com php-src: test to function DateTimeZone::getLocation();: ext/date/tests/DateTimeZone_getLocation.phpt
| From: | JulienPauli | Date: | Thu, 24 Dec 2015 09:56:23 +0000 |
| Subject: | com php-src: test to function DateTimeZone::getLocation();: ext/date/tests/DateTimeZone_getLocation.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-90453@lists.php.net to get a copy of this message | ||
Commit: 891ac5930561b717619e34b31b59baf140e675e0
Author: marcosptf <marcosptf@yahoo.com.br> Sun, 6 Dec 2015 12:19:10 -0200
Committer: Julien Pauli <jpauli@php.net> Thu, 24 Dec 2015 10:56:23 +0100
Parents: ca0b82fe9327af8175f5e1cbce514c0f09cafe17
Branches: PHP-5.6 PHP-7.0 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=891ac5930561b717619e34b31b59baf140e675e0
Log:
test to function DateTimeZone::getLocation();
Changed paths:
A ext/date/tests/DateTimeZone_getLocation.phpt
Diff:
diff --git a/ext/date/tests/DateTimeZone_getLocation.phpt
b/ext/date/tests/DateTimeZone_getLocation.phpt
new file mode 100644
index 0000000..8e6e33b
--- /dev/null
+++ b/ext/date/tests/DateTimeZone_getLocation.phpt
@@ -0,0 +1,82 @@
+--TEST--
+DateTimeZone::getLocation -- timezone_location_get — Returns location information for a timezone
+public array DateTimeZone::getLocation ( void ) ;
+--CREDITS--
+marcosptf - <marcosptf@yahoo.com.br> - #phparty7 - @phpsp - novatec/2015 - sao paulo - br
+--SKIPIF--
+<?php
+if (phpversion() < "5.3.0") {
+ die('SKIP php version so lower.');
+}
+?>
+--FILE--
+<?php
+$arrayDate = DateTimeZone::listAbbreviations();
+$countryCode = array("??");
+$countryCodeTest = array("AU", "CA", "ET", "AF",
"US", "KZ", "AM");
+
+foreach($arrayDate as $value){
+
+ if(NULL != $value[0]['timezone_id']){
+ $timeZone = new DateTimeZone($value[0]['timezone_id']);
+ $timeZoneArray = $timeZone->getLocation();
+
+ if((!in_array($timeZoneArray['country_code'], $countryCode)) && (NULL !=
$timeZoneArray['country_code']) && ("" !=
$timeZoneArray['country_code'])) {
+ array_push($countryCode, $timeZoneArray['country_code']);
+
+ if(in_array($timeZoneArray['country_code'], $countryCodeTest)){
+ print_r($timeZoneArray);
+ }
+ }
+ }
+}
+?>
+--CLEAN--
+<?php
+unset($arrayDate);
+unset($countryCode);
+unset($countryCodeTest);
+?>
+--EXPECTF--
+Array
+(
+ [country_code] => %s
+ [latitude] => %f
+ [longitude] => %f
+ [comments] => %s
+)
+Array
+(
+ [country_code] => %s
+ [latitude] => %f
+ [longitude] => %f
+ [comments] => %s
+)
+Array
+(
+ [country_code] => %s
+ [latitude] => %f
+ [longitude] => %f
+ [comments] =>
+)
+Array
+(
+ [country_code] => %s
+ [latitude] => %f
+ [longitude] => %f
+ [comments] => %s
+)
+Array
+(
+ [country_code] => %s
+ [latitude] => %f
+ [longitude] => %f
+ [comments] => %s
+)
+Array
+(
+ [country_code] => %s
+ [latitude] => %f
+ [longitude] => %f
+ [comments] =>
+)