function SelectOrOtherNumberTestCase::testNoOtherSelected in Select (or other) 7.2
Same name and namespace in other branches
- 7.3 tests/select_or_other_number.test \SelectOrOtherNumberTestCase::testNoOtherSelected()
Tests Select or Other without other selected.
File
- tests/
select_or_other_number.test, line 96
Class
- SelectOrOtherNumberTestCase
- Tests the select or other text field based functionality
Code
function testNoOtherSelected() {
$langcode = LANGUAGE_NONE;
foreach ($this->field_options as $cardinality => $field_types) {
foreach ($field_types as $type => $field_names) {
foreach ($field_names as $field_name => $options) {
$edit = array();
// A node requires a title
$edit["title"] = $this
->randomName(8);
$keys = array_keys($options);
if ($cardinality === 'single') {
// Test single select.
$edit["{$field_name}[{$langcode}][select]"] = $keys[0];
}
else {
// Test multiple select.
$edit["{$field_name}[{$langcode}][select][]"] = $keys;
}
// Create the node.
$this
->drupalPost('node/add/page', $edit, t('Save'));
// Check if the values have been created.
if ($cardinality === 'single') {
// Add the </div> because assertRaw fails for integer values.
$this
->assertRaw("{$keys[0]}</div>");
}
else {
foreach ($keys as $key) {
// Add the </div> because assertRaw fails for integer values.
$this
->assertRaw("{$key}</div>");
}
}
// Check if the 'select_or_other' option is not displayed.
$this
->assertNoRaw('select_or_other');
}
}
}
}