You are here

function CurrencyFilterWebTestCase::testCurrencyExchange in Currency 7.2

Test the currency_exchange input filter.

File

currency/tests/CurrencyFilterWebTestCase.test, line 35
Contains class CurrencyFilterWebTestCase.

Class

CurrencyFilterWebTestCase
Tests the currency exchange input filter.

Code

function testCurrencyExchange() {
  $tokens_valid = array(
    '[currency:EUR:NLG]' => '2.20371',
    '[currency:EUR:NLG:1]' => '2.20371',
    '[currency:EUR:NLG:2]' => '4.40742',
  );
  $tokens_invalid = array(
    // Missing arguments.
    '[currency]',
    '[currency:]',
    '[currency::]',
    '[currency:EUR]',
    // Invalid currency code.
    '[currency:EUR:123]',
    '[currency:123:EUR]',
    // Invalid currency code and missing argument.
    '[currency:123]',
  );
  $format = new stdClass();
  $format->format = 'currency_localize';
  $format->name = 'Currency format';
  $format->filters = array(
    'currency_exchange' => array(
      'status' => TRUE,
    ),
  );
  filter_format_save($format);
  foreach ($tokens_valid as $token => $replacement) {
    $this
      ->assertIdentical(check_markup($token, $format->format), $replacement);
  }
  foreach ($tokens_invalid as $token) {
    $this
      ->assertIdentical(check_markup($token, $format->format), $token);
  }
}