You are here

public function CurrencyAmountViewsHandlerFieldWebTestCase::testCurrencyAmountViewsHandlerField in Currency 7.2

Tests CurrencyAmountViewsHandlerField.

File

currency/tests/CurrencyAmountViewsHandlerFieldWebTestCase.test, line 195
Contains class CurrencyAmountViewsHandlerFieldWebTestCase.

Class

CurrencyAmountViewsHandlerFieldWebTestCase
Tests CurrencyAmountViewsHandlerField.

Code

public function testCurrencyAmountViewsHandlerField() {
  $view = $this
    ->getBasicView();
  $view
    ->save();

  // Test view creation/editing.
  $account = $this
    ->drupalCreateUser(array(
    'administer views',
  ));
  $this
    ->drupalLogin($account);
  $this
    ->drupalPost('admin/structure/views/nojs/config-item/test_view/default/field/amount_currency_code_definition', array(
    'options[currency_round]' => TRUE,
  ), t('Apply'));
  $this
    ->drupalPost('admin/structure/views/view/' . $view->name, array(), t('Save'));

  // Test view display.
  $view = views_get_view($view->name);
  $this
    ->executeView($view);
  $values = array(
    array(
      // The amount_currency_code_definition field is rounded.
      'amount_currency_code_definition' => '€123.46',
      'amount_currency_code_field_definition' => '€123.456',
      'amount_currency_code_field_table_definition' => '€123.456',
      'amount_currency_undefined' => '¤123.456',
    ),
    array(
      // The amount_currency_code_definition field is rounded.
      'amount_currency_code_definition' => '€123.46',
      'amount_currency_code_field_definition' => '$123.456',
      'amount_currency_code_field_table_definition' => '$123.456',
      'amount_currency_undefined' => '¤123.456',
    ),
    array(
      // The amount_currency_code_definition field is rounded.
      'amount_currency_code_definition' => '€123.46',
      'amount_currency_code_field_definition' => '₴123.456',
      'amount_currency_code_field_table_definition' => '₴123.456',
      'amount_currency_undefined' => '¤123.456',
    ),
  );
  foreach ($values as $row => $row_values) {
    foreach ($row_values as $field => $value) {
      $this
        ->assertEqual($view->field[$field]
        ->advanced_render($view->result[$row]), $value);
    }
  }
}