/** * Sets the currency to be used in this order. * Changing this does not affect any of the prices used in the order * @param string $currency_code Currency code used to identify the * currency. Must be registered with APP_Currencies * @return boolean True if currency was changed, false on error */ public function set_currency($currency_code) { if (!is_string($currency_code)) { trigger_error('Currency code must be string', E_USER_WARNING); } if (APP_Currencies::is_valid($currency_code)) { $this->payment['currency'] = $currency_code; } else { return false; } $this->update_meta('currency', $this->payment['currency']); return true; }
/** * Verify that is_valid works correctly */ public function test_is_valid() { $this->assertTrue(APP_Currencies::is_valid('USD')); $this->assertFalse(APP_Currencies::is_valid('not-a-currency')); }