You are here

public function CurrentCurrencyTest::testLanguage in Commerce Currency Resolver 8

Tests language based current currency.

@covers ::getCurrency

File

tests/src/Kernel/CurrentCurrencyTest.php, line 136

Class

CurrentCurrencyTest
Tests current currency class.

Namespace

Drupal\Tests\commerce_currency_resolver\Kernel

Code

public function testLanguage() {
  $this
    ->assertEqual('USD', $this->currentCurrency
    ->getCurrency());

  // Change mapping from store to language.
  $this
    ->config('commerce_currency_resolver.settings')
    ->set('currency_mapping', 'lang')
    ->save();

  // Validate default language.
  $this
    ->assertEqual('hr', $this->languageManager
    ->getCurrentLanguage()
    ->getId());

  // Rebuild container and recheck currency.
  $this
    ->resetCurrencyContainer();
  $this
    ->assertEqual('HRK', $this->currentCurrency
    ->getCurrency());

  // Change language back to english.
  $this
    ->config('system.site')
    ->set('default_langcode', 'en')
    ->save();
  $this
    ->resetCurrencyContainer();
  $this
    ->assertEqual('USD', $this->currentCurrency
    ->getCurrency());
}