function CCKSelectOtherBasicTest::testSelectFieldValue in CCK Select Other 7
Same name and namespace in other branches
- 6 tests/cck_select_other.test \CCKSelectOtherBasicTest::testSelectFieldValue()
- 7.2 tests/cck_select_other.test \CCKSelectOtherBasicTest::testSelectFieldValue()
Modify node with a new value from select list options
File
- tests/
cck_select_other.test, line 133 - test file for cck_select_other Testing file
Class
- CCKSelectOtherBasicTest
- @class CCK Select Other Basic Test Case
Code
function testSelectFieldValue() {
$options_arr = cck_select_other_options($this->test_instance);
$this
->assertEqual(6, count($options_arr), t('There are 6 = %count options set on the field.', array(
'%count' => count($options_arr),
)));
do {
$my_option = array_rand(cck_select_other_options($this->test_instance));
} while (in_array($my_option, array(
'other',
'_none',
'',
)));
$this
->drupalLogin($this->web_user);
// @todo sometimes 'und' is undefined...
$select_field = $this->test_field['field_name'] . '[und][0][select_other_list]';
$text_field = $this->test_field['field_name'] . '[und][0][select_other_text_input]';
$edit = array(
$select_field => $my_option,
);
if ($my_option == 'other') {
$edit[$text_field] = $this
->randomName(16);
}
$my_option_value = $my_option == 'other' ? $edit[$text_field] : $edit[$select_field];
$this
->drupalGet('node/' . $this->test_node->nid);
$this
->drupalPost('node/' . $this->test_node->nid . '/edit', $edit, t('Save'));
$this->test_node = node_load($this->test_node->nid, NULL, TRUE);
$this
->assertRaw($this->test_node->{$this->test_field['field_name']}['und'][0]['value'], t('Select other field data %field matches %match on node.', array(
'%field' => $this->test_node->{$this->test_field['field_name']}['und'][0]['value'],
'%match' => $my_option_value,
)));
$this
->drupalLogout();
}