You are here

public function CommerceMulticurrencyTestCase::testSetCurrency in Commerce Multicurrency 7

Test that the currency switching works as expected.

File

tests/commerce_multicurrency.test, line 87
Tests for the commerce currency module.

Class

CommerceMulticurrencyTestCase
Tests for the commerce currency module.

Code

public function testSetCurrency() {

  // Reset currency to default.
  $currency_code =& drupal_static('commerce_multicurrency_get_user_currency_code', FALSE);
  $currency_code = commerce_default_currency();

  // Ensure no cookie is set.
  unset($_COOKIE[$this->cookieName]);
  commerce_multicurrency_set_user_currency_code('CHF');
  $this
    ->assertEqual('CHF', commerce_multicurrency_get_user_currency_code(), 'Currency set to CHF.');
  $this
    ->assertEqual('CHF', $currency_code, 'Static cache reference contains CHF.');

  // We can't check if cookie is set in unit tests.
  // Ensure only valid currency can be set.
  commerce_multicurrency_set_user_currency_code('NOP');
  $this
    ->assertEqual('CHF', commerce_multicurrency_get_user_currency_code(), 'Invalid currency was not set.');
}