function SelectOrOtherNumberTestCase::testOtherSelected in Select (or other) 7.2
Same name and namespace in other branches
- 7.3 tests/select_or_other_number.test \SelectOrOtherNumberTestCase::testOtherSelected()
File
- tests/
select_or_other_number.test, line 136
Class
- SelectOrOtherNumberTestCase
- Tests the select or other text field based functionality
Code
function testOtherSelected() {
$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);
if ($cardinality === 'single') {
// Test single select.
$edit["{$field_name}[{$langcode}][select]"] = 'select_or_other';
}
else {
// Test multiple select.
$edit["{$field_name}[{$langcode}][select][]"] = array(
'select_or_other',
);
}
$other = rand(50, 100);
switch ($type) {
case 'number_float':
$other = rand($other, $other * 2) / 1000;
break;
case 'number_decimal':
$other = rand($other, $other * 2) / 100;
break;
}
$edit["{$field_name}[{$langcode}][other]"] = $other;
// Create the node.
$this
->drupalPost('node/add/page', $edit, t('Save'));
// Check if the value has been created.
// Add the </div> because assertRaw fails for integer values.
$this
->assertRaw("{$other}</div>");
// Check if the 'select_or_other' option is not displayed.
$this
->assertNoRaw('select_or_other');
}
}
}
}