You are here

function CurrencyExchangerFixedRatesUIWebTestCase::testCurrencyExchangerFixedRatesUI in Currency 7.2

Test CurrencyExchanger's UI.

File

currency/tests/CurrencyConverterFixedRatesUIWebTestCase.test, line 35
Contains class CurrencyExchangerFixedRatesUIWebTestCase.

Class

CurrencyExchangerFixedRatesUIWebTestCase
Tests the UI for CurrencyExchangerFixedRates.

Code

function testCurrencyExchangerFixedRatesUI() {
  $user = $this
    ->drupalCreateUser(array(
    'currency.currency_exchanger.administer',
  ));
  $this
    ->drupalLogin($user);
  $path = 'admin/config/regional/currency-exchange/fixed';

  // Test the overview.
  $this
    ->drupalGet($path);
  $this
    ->assertText(t('Add an exchange rate'));
  $currency_code_from = 'EUR';
  $currency_code_to = 'NLG';

  // Test adding a exchange rate.
  $rate = '3';
  $values = array(
    'currency_code_from' => $currency_code_from,
    'currency_code_to' => $currency_code_to,
    'rate[amount]' => $rate,
  );
  $this
    ->drupalPost($path . '/add', $values, t('Save'));
  $this
    ->assertIdentical(CurrencyExchangerFixedRates::load($currency_code_from, $currency_code_to), $rate);

  // Test editing a exchange rate.
  $rate = '6';
  $values = array(
    'rate[amount]' => $rate,
  );
  $this
    ->drupalPost($path . '/' . $currency_code_from . '/' . $currency_code_to, $values, t('Save'));
  drupal_static_reset('CurrencyExchangerFixedRates');
  $this
    ->assertIdentical(CurrencyExchangerFixedRates::load($currency_code_from, $currency_code_to), $rate);

  // Test deleting a exchange rate.
  $this
    ->drupalPost($path . '/' . $currency_code_from . '/' . $currency_code_to, $values, t('Delete'));
  drupal_static_reset('CurrencyExchangerFixedRates');
  $this
    ->assertFalse(CurrencyExchangerFixedRates::load($currency_code_from, $currency_code_to));
}