You are here

function CCKSelectOtherNotRequiredTest::testValueToNone in CCK Select Other 7.2

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

Save a value to the field and then set it to -none-

File

tests/cck_select_other.test, line 568
CCK Select Other Functional Tests

Class

CCKSelectOtherNotRequiredTest
Assert that select other list is not saving any values if -none- is selected

Code

function testValueToNone() {
  $this
    ->drupalLogin($this->web_user);

  // Save a value into the node and assert that it was saved.
  $edit = array(
    $this->test_instance['field_name'] . '[und][0][select_other_list]' => 'other',
    $this->test_instance['field_name'] . '[und][0][select_other_text_input]' => $this
      ->randomName(15),
  );
  $this
    ->drupalPost('node/' . $this->test_node->nid . '/edit', $edit, t('Save'));
  $this
    ->assertRaw($this->test_instance['label']);
  $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();
}