Kaynağa Gözat

[ZF-9519] Zend_Currency:

- allow setting values without giving locale

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@21615 44c647ce-9c0f-0410-b52a-842ac1e357ba
thomas 16 yıl önce
ebeveyn
işleme
e67bf379d5
2 değiştirilmiş dosya ile 18 ekleme ve 1 silme
  1. 1 1
      library/Zend/Currency.php
  2. 17 0
      tests/Zend/CurrencyTest.php

+ 1 - 1
library/Zend/Currency.php

@@ -749,7 +749,7 @@ class Zend_Currency
             $currency = $value->getShortName();
             $value    = $value->getValue();
         } else {
-            $currency = $this->getShortName($currency);
+            $currency = $this->getShortName($currency, $this->getLocale());
         }
 
         $rate = 1;

+ 17 - 0
tests/Zend/CurrencyTest.php

@@ -799,4 +799,21 @@ class Zend_CurrencyTest extends PHPUnit_Framework_TestCase
         $currency  = new Zend_Currency(array('value' => 10000, 'format' => '#,#0', 'locale' => 'de_DE'));
         $this->assertEquals('1.00.00', $currency->toString());
     }
+
+    /**
+     * @ZF-9519
+     */
+    public function testSetValueWithoutLocale()
+    {
+        $currency = new Zend_Currency('RUB', 'ru_RU');
+        require_once 'Currency/ExchangeTest.php';
+
+        $this->assertEquals(null, $currency->getService());
+        $currency->setService(new ExchangeTest());
+        $this->assertTrue($currency->getService() instanceof Zend_Currency_CurrencyInterface);
+
+        $currency->setValue(100, 'USD');
+        $this->assertEquals(200, $currency->getValue());
+        $this->assertEquals('USD', $currency->getShortName());
+    }
 }