You are here

function CCKSelectOtherNotRequiredTest::testNoRequired in CCK Select Other 7

Same name and namespace in other branches
  1. 7.2 tests/cck_select_other.test \CCKSelectOtherNotRequiredTest::testNoRequired()

Test that there is a -none- option in a non-required field and that it does not save a field value.

File

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

Class

CCKSelectOtherNotRequiredTest
@class CCKSelectOtherNotRequiredTest

Code

function testNoRequired() {
  $this
    ->drupalLogin($this->web_user);
  $name = substr($this->test_field['field_name'], 6);

  // Assert that we have -none- as the option in our select list.
  $this
    ->drupalGet('node/' . $this->test_node->nid . '/edit');
  $this
    ->assertOptionSelected('edit-field-' . $name . '-und-0-select-other-list', '_none', t('- None - option selected in select list.'));

  // Post to the node, and make sure that -none- is the value and that value ends up as empty.
  $edit = array(
    $this->test_instance['field_name'] . '[und][0][select_other_list]' => '_none',
  );
  $this
    ->drupalPost('node/' . $this->test_node->nid . '/edit', $edit, t('Save'));
  $this
    ->assertNoRaw($this->test_instance['label']);

  // Assert the node object as well.
  $node = node_load($this->test_node->nid);
  $this
    ->assertTrue(empty($node->{$this->test_instance['field_name']}), t('Select other did not save any value for non-required field.'));
  $this
    ->drupalLogout();
}