Просмотр исходного кода

[ZF-10169] Zend_Currency:

- fixed and unified currencylist and regionlist

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@22708 44c647ce-9c0f-0410-b52a-842ac1e357ba
thomas 15 лет назад
Родитель
Сommit
fdb3edae77
2 измененных файлов с 14 добавлено и 10 удалено
  1. 11 7
      library/Zend/Currency.php
  2. 3 3
      tests/Zend/CurrencyTest.php

+ 11 - 7
library/Zend/Currency.php

@@ -77,7 +77,8 @@ class Zend_Currency
         'symbol'    => null,
         'locale'    => null,
         'value'     => 0,
-        'service'   => null
+        'service'   => null,
+        'tag'       => 'Zend_Locale'
     );
 
     /**
@@ -431,7 +432,7 @@ class Zend_Currency
             throw new Zend_Currency_Exception('No currency defined');
         }
 
-        $data = Zend_Locale_Data::getContent('', 'regiontocurrency', $currency);
+        $data = Zend_Locale_Data::getContent($this->_options['locale'], 'regiontocurrency', $currency);
 
         $result = explode(' ', $data);
         return $result;
@@ -453,7 +454,10 @@ class Zend_Currency
             }
         }
 
-        return Zend_Locale_Data::getList('', 'regiontocurrency', $region);
+        $data = Zend_Locale_Data::getContent($this->_options['locale'], 'currencytoregion', $region);
+
+        $result = explode(' ', $data);
+        return $result;
     }
 
     /**
@@ -483,8 +487,7 @@ class Zend_Currency
      */
     public static function getCache()
     {
-        $cache = Zend_Locale_Data::getCache();
-        return $cache;
+        return Zend_Locale_Data::getCache();
     }
 
     /**
@@ -521,11 +524,12 @@ class Zend_Currency
     /**
      * Clears all set cache data
      *
+     * @param string $tag Tag to clear when the default tag name is not used
      * @return void
      */
-    public static function clearCache()
+    public static function clearCache($tag = null)
     {
-        Zend_Locale_Data::clearCache();
+        Zend_Locale_Data::clearCache($tag);
     }
 
     /**

+ 3 - 3
tests/Zend/CurrencyTest.php

@@ -497,7 +497,7 @@ class Zend_CurrencyTest extends PHPUnit_Framework_TestCase
 
         try {
             $currency = new Zend_Currency(array('currency' => 'USD'));
-            $this->assertTrue(is_array($currency->getRegionList()));
+            $this->assertTrue(in_array('US', $currency->getRegionList()));
         } catch (Zend_Currency_Exception $e) {
             $this->assertContains('No region found within the locale', $e->getMessage());
         }
@@ -505,7 +505,7 @@ class Zend_CurrencyTest extends PHPUnit_Framework_TestCase
         $currency = new Zend_Currency(array('currency' => 'USD'), 'en_US');
         $currency->setFormat(array('currency' => null));
         try {
-            $this->assertEquals('US', $currency->getRegionList());
+            $this->assertTrue(in_array('US', $currency->getRegionList()));
             $this->fail("Exception expected");
         } catch (Zend_Currency_Exception $e) {
             $this->assertContains("No currency defined", $e->getMessage());
@@ -530,7 +530,7 @@ class Zend_CurrencyTest extends PHPUnit_Framework_TestCase
         }
 
         $currency = new Zend_Currency('ar_EG');
-        $this->assertTrue(array_key_exists('EGP', $currency->getCurrencyList()));
+        $this->assertTrue(in_array('EGP', $currency->getCurrencyList()));
     }
 
     /**