protected function SelectOrOtherTestBase::setFieldValue in Select (or other) 7.3
Submit the add node form with the selected values.
Parameters
$field_name:
$select:
$other:
12 calls to SelectOrOtherTestBase::setFieldValue()
- SelectOrOtherNumberTestCase::testNoOtherSelected in tests/
select_or_other_number.test - Tests Select or Other without other selected.
- SelectOrOtherNumberTestCase::testOtherSelected in tests/
select_or_other_number.test - SelectOrOtherNumberTestCase::testOtherSelectedWithPreExistingKey in tests/
select_or_other_number.test - SelectOrOtherTaxonomyTestCase::testMultipleOther in modules/
select_or_other_taxonomy/ tests/ select_or_other_taxonomy.test - Test Select or Other with "other" selected.
- SelectOrOtherTaxonomyTestCase::testNoOtherSelected in modules/
select_or_other_taxonomy/ tests/ select_or_other_taxonomy.test - Tests Select or Other without "other" selected.
File
- tests/
SelectOrOtherTestBase.test, line 201 - Contains SelectOrOtherTestBase.
Class
- SelectOrOtherTestBase
- Class SelectOrOtherTestBase Base class for select_or_other testing.
Code
protected function setFieldValue($field_name, $select, $other = '') {
$edit = array();
// A node requires a title.
$edit["title"] = $this
->randomName(8);
$this
->drupalGet('node/add/' . $this
->getFieldContentType($field_name));
// Set the select value.
if ($this->fields[$field_name]['cardinality'] == 1) {
$edit["{$field_name}[und][select]"] = $select;
}
else {
// We have to treat multiple selection elements differently.
if ($this
->getWidgetType($field_name) === 'select') {
// We're dealing with a multiple select.
$edit["{$field_name}[und][select][]"] = $select;
}
else {
// We're dealing with checkboxes.
$edit["{$field_name}[und][select][{$select}]"] = $select;
}
}
// Set the other value.
$edit["{$field_name}[und][other]"] = $other;
// Create the node.
$this
->drupalPost(NULL, $edit, t('Save'));
}