You are here

function SelectOrOtherTextTestCase::testOtherSelected in Select (or other) 7.2

Same name and namespace in other branches
  1. 7.3 tests/select_or_other_text.test \SelectOrOtherTextTestCase::testOtherSelected()

File

tests/select_or_other_text.test, line 123

Class

SelectOrOtherTextTestCase
Tests the select or other text field based functionality

Code

function testOtherSelected() {
  $edit = array();
  $langcode = LANGUAGE_NONE;

  // A node requires a title
  $edit["title"] = $this
    ->randomName(8);

  // Test single select other.
  $single_other = $this
    ->randomName(8);
  $edit["{$this->single_field_name}[{$langcode}][select]"] = 'select_or_other';
  $edit["{$this->single_field_name}[{$langcode}][other]"] = $single_other;

  // Test multi select other.
  $multi_other = $this
    ->randomName(8);
  $edit["{$this->multi_field_name}[{$langcode}][select][]"] = array(
    'multi_keyed',
    'select_or_other',
  );
  $edit["{$this->multi_field_name}[{$langcode}][other]"] = $multi_other;

  // Create the node.
  $this
    ->drupalPost('node/add/page', $edit, t('Save'));

  // Check if the values have been created.
  $this
    ->assertRaw($single_other);
  $this
    ->assertRaw($multi_other);

  // Check if the 'select_or_other' option is not displayed.
  $this
    ->assertNoRaw('select_or_other');
}