/** * Verify that initial currencies have been loaded */ public function test_default_currencies() { APP_Currencies::init(); $this->assertNotEmpty(APP_Currencies::get_currencies()); $this->assertNotEmpty(APP_Currencies::get_currency('USD')); $this->assertEquals('US Dollars ($)', APP_Currencies::get_currency_string('USD')); }
<?php APP_Currencies::init(); /** * Helps define currencies, their display preferences, and * presenting price and currency information */ class APP_Currencies { /** * Holds a list of all currently registered currencies * @var array */ private static $currencies; /** * Initializes the registered currency list. * Allows for localization of currency names. */ public static function init() { self::$currencies = array('USD' => array('symbol' => '$', 'name' => __('US Dollars', APP_TD)), 'EUR' => array('symbol' => '€', 'name' => __('Euros', APP_TD)), 'GBP' => array('symbol' => '£', 'name' => __('Pounds Sterling', APP_TD)), 'AUD' => array('symbol' => '$', 'name' => __('Australian Dollars', APP_TD)), 'BRL' => array('symbol' => 'R$', 'name' => __('Brazilian Real', APP_TD)), 'CAD' => array('symbol' => '$', 'name' => __('Canadian Dollars', APP_TD)), 'CZK' => array('symbol' => 'Kč', 'name' => __('Czech Koruna', APP_TD)), 'DKK' => array('symbol' => 'kr', 'name' => __('Danish Krone', APP_TD)), 'HKD' => array('symbol' => '$', 'name' => __('Hong Kong Dollar', APP_TD)), 'HUF' => array('symbol' => 'Ft', 'name' => __('Hungarian Forint', APP_TD)), 'ILS' => array('symbol' => '₪', 'name' => __('Israeli Shekel', APP_TD)), 'JPY' => array('symbol' => '¥', 'name' => __('Japanese Yen', APP_TD)), 'MYR' => array('symbol' => 'RM', 'name' => __('Malaysian Ringgits', APP_TD)), 'MXN' => array('symbol' => '$', 'name' => __('Mexican Peso', APP_TD)), 'NZD' => array('symbol' => '$', 'name' => __('New Zealand Dollar', APP_TD)), 'NOK' => array('symbol' => 'kr', 'name' => __('Norwegian Krone', APP_TD)), 'PHP' => array('symbol' => 'P', 'name' => __('Philippine Pesos', APP_TD)), 'PLN' => array('symbol' => 'zł', 'name' => __('Polish Zloty', APP_TD)), 'SGD' => array('symbol' => '$', 'name' => __('Singapore Dollar', APP_TD)), 'SEK' => array('symbol' => 'kr', 'name' => __('Swedish Krona', APP_TD)), 'CHF' => array('symbol' => 'Fr', 'name' => __('Swiss Franc', APP_TD)), 'TWD' => array('symbol' => '$', 'name' => __('Taiwan New Dollar', APP_TD)), 'THB' => array('symbol' => '฿', 'name' => __('Thai Baht', APP_TD)), 'TRY' => array('symbol' => '₤', 'name' => __('Turkish Lira', APP_TD))); } /** * Adds a currency to the list of registered currencies if the currency does not * already exist. * Allows plugins and themes to define their own custom currencies. * * @param string $currency_code Currency code used to identify currency. * @param array $args Array of options related to this currency * 'symbol' => The symbol denoting the type of currency. IE: $ for USD * 'name' => The formal name of the currency