You are here

function SelectOrOtherTextTestCase::testSpecialCharHandling in Select (or other) 7.3

Tests if Other value with special characters are properly selected on edit.

File

tests/select_or_other_text.test, line 85

Class

SelectOrOtherTextTestCase
Tests the select or other text field based functionality

Code

function testSpecialCharHandling() {
  foreach ($this->fields as $field_name => $field) {
    $parts = array(
      $this
        ->randomName(),
      $this
        ->randomName(),
    );
    $other_value = implode('&', $parts);
    $this
      ->setFieldValue($field_name, 'select_or_other', $other_value);
    $this
      ->assertText(filter_xss($other_value));
    $this
      ->assertNoRaw('select_or_other');
    $this
      ->clickLink(t('Edit'));
    $option = strtolower(implode($parts));
    if ($field['widget'] === 'select_or_other') {

      // Select widgets have options which get selected.
      $this
        ->assertOptionSelected("edit-{$field_name}-und-select", $other_value);
    }
    else {

      // Checkboxes and radios have options that get checked.
      $this
        ->assertFieldChecked("edit-{$field_name}-und-select-{$option}");
    }
  }
}