You are here

function CCKSelectOtherAllowedValuesTest::testAllowedValues in CCK Select Other 6

Same name and namespace in other branches
  1. 7.2 tests/cck_select_other.test \CCKSelectOtherAllowedValuesTest::testAllowedValues()
  2. 7 tests/cck_select_other.test \CCKSelectOtherAllowedValuesTest::testAllowedValues()

Fail validation or test allowed values for other option

File

tests/cck_select_other.test, line 235
test file for cck_select_other Testing file

Class

CCKSelectOtherAllowedValuesTest
@class CCK Select Other Allowed Values Test Case

Code

function testAllowedValues() {

  //Setup some allowed values to equal our select list options + another known value
  $this->test_field['allowed_values'] = $this->test_field['widget']['select_list_options'] . "\nAllowedValue";
  _content_field_write($this->test_field, 'update');
  _content_field_instance_write($this->test_field, 'update');
  content_alter_schema(array(), $this->test_field);
  _content_type_info(TRUE);
  $this->test_field = content_fields('field_blah', 'page');
  $this
    ->assertEqual($this->new_field['field_name'], $this->test_field['field_name'], t('Field name @first is equal to @second. Field updated successfully.', array(
    '@first' => $this->new_field['field_name'],
    '@second' => $this->test_field['field_name'],
  )));
  $edit = array(
    'field_blah[select_other_list]' => 'other',
    'field_blah[select_other_text_input]' => 'DisallowedValue',
  );

  // try to save a disallowed value
  $this
    ->drupalPost('node/' . $this->test_node->nid . '/edit', $edit, t('Save'));
  $this
    ->assertRaw(t('illegal value'), t('Successfully blocked submission of DisallowedValue.'));

  // try to save an allowed value
  $edit['field_blah[select_other_text_input]'] = 'AllowedValue';
  $this
    ->drupalPost('node/' . $this->test_node->nid . '/edit', $edit, t('Save'));
  $this
    ->assertNoRaw(t('illegal value'), t('Successfully saved form with allowed value, AllowedValue.'));
}