Jelajahi Sumber

[ZF-9941] Zend_Currency:

- allow to give value as option

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@22368 44c647ce-9c0f-0410-b52a-842ac1e357ba
thomas 16 tahun lalu
induk
melakukan
600237ccaf
2 mengubah file dengan 10 tambahan dan 1 penghapusan
  1. 1 1
      library/Zend/Currency.php
  2. 9 0
      tests/Zend/CurrencyTest.php

+ 1 - 1
library/Zend/Currency.php

@@ -137,7 +137,7 @@ class Zend_Currency
     public function toCurrency($value = null, array $options = array())
     {
         if ($value === null) {
-            if (is_array($value) && isset($options['value'])) {
+            if (is_array($options) && isset($options['value'])) {
                 $value = $options['value'];
             } else {
                 $value = $this->_options['value'];

+ 9 - 0
tests/Zend/CurrencyTest.php

@@ -816,4 +816,13 @@ class Zend_CurrencyTest extends PHPUnit_Framework_TestCase
         $this->assertEquals(50, $currency->getValue());
         $this->assertEquals('RUB', $currency->getShortName());
     }
+
+    /**
+     * @ZF-9941
+     */
+    public function testSetValueByOutput()
+    {
+        $currency = new Zend_Currency(array('value' => 1000, 'locale' => 'de_AT'));
+        $this->assertEquals('€ 2.000,00', $currency->toCurrency(null, array('value' => 2000)));
+    }
 }