ZF-9498: Zend_Currency service ignored

Description

The Zend_Currency service seems to be ignored. When exactly following the documentation 1.10 code examples, this are the results: Expected result: '$ 3.000' Actual result: '$2,000.00' According to the documentation: "The above example will return '$ 3.000' because the 1.000 EUR will be converted by a rate of 2 to 2.000 USD."

Comments

Affected component

Please describe what exactly you mean.

There are about 500 different code examples through the complete documentation.

What did you do, which code did you use and what did you expect? Which ZF release and which PHP release were you using?

We need some more informations to be able to reproduce your failure.

I used the 2 code examples on the English reference guide of the framework version 1.10 (http://framework.zend.com/manual/en/…) I am using php 5.3.0

This is the code I used:

 
class ZFCustom_CurrencyExchange implements Zend_Currency_CurrencyInterface
{
    public function getRate($from, $to)
    {
        if ($from !== "USD") {
            throw new Exception('We can only exchange USD');
        }
        
        switch ($to) {
            case 'EUR':
                return 0.5;
            case 'JPE':
                return 0.7;
       }
 
       throw new Exception('Unable to exchange $to');
    }
}

and

 
$currency = new Zend_Currency(
    array(
        'value'    => 1000,
        'currency' => 'USD',
    )
);
 
$service  = new ZFCustom_CurrencyExchange();
 
// attachons le service de change
$currency->setService($service);

 
$currency_2 = new Zend_Currency(
    array(
        'value'    => 1000,
        'currency' => 'EUR',
    )
);
 
print $currency->add($currency_2);

The locale is registered with:

 
Zend_Registry::set('Zend_Locale',new Zend_Locale('en_US'));

And as I said: Expected result: '$ 3.000' Actual result: '$2,000.00'

Fixed with r21602