You are here

public function RangeUnitTestCase::testRangeFormatterViewPrefixSuffix in Range 7

Tests range prefixer/suffixer.

File

tests/range.unit.test, line 133
Unit tests for Range module.

Class

RangeUnitTestCase
Unit tests for Range.

Code

public function testRangeFormatterViewPrefixSuffix() {
  $value = 1234;

  // Test disabled prefix/suffix.
  $result = _range_field_formatter_view_prefix_suffix($value, FALSE, array(
    'prefix' => 'prefix-',
    'suffix' => '-suffix',
  ));
  $this
    ->assertEqual($result, '1234', format_string('No prefix or suffix has been added: <strong>@output<strong>', array(
    '@output' => var_export($result, TRUE),
  )));

  // Test enabled prefix and suffix.
  $result = _range_field_formatter_view_prefix_suffix($value, TRUE, array(
    'prefix' => 'prefix-',
    'suffix' => '-suffix',
  ));
  $this
    ->assertEqual($result, 'prefix-1234-suffix', format_string('Prefix and suffix have been added correctly: <strong>@output<strong>', array(
    '@output' => var_export($result, TRUE),
  )));
}