Tests normal and key formatter display on node display.
function testNodeDisplay() {
$this->field_name = strtolower($this
->randomName());
$this
->createOptionsField('list_boolean');
$node = $this
->drupalCreateNode(array(
'type' => $this->type,
));
$on = $this
->randomName();
$off = $this
->randomName();
$allowed_values = array(
1 => $on,
0 => $off,
);
$edit = array(
'on' => $on,
'off' => $off,
);
$this
->drupalPost($this->admin_path, $edit, t('Save field settings'));
$this
->assertText(format_string('Updated field !field_name field settings.', array(
'!field_name' => $this->field_name,
)), "The 'On' and 'Off' form fields work for boolean fields.");
// Select a default value.
$edit = array(
$this->field_name . '[und]' => '1',
);
$this
->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save and keep published'));
// Check the node page and see if the values are correct.
$file_formatters = array(
'list_default',
'list_key',
);
foreach ($file_formatters as $formatter) {
$edit = array(
"fields[{$this->field_name}][type]" => $formatter,
);
$this
->drupalPost('admin/structure/types/manage/' . $this->type_name . '/display', $edit, t('Save'));
$this
->drupalGet('node/' . $node->nid);
if ($formatter == 'list_default') {
$output = $on;
}
else {
$output = '1';
}
$elements = $this
->xpath('//div[text()="' . $output . '"]');
$this
->assertEqual(count($elements), 1, 'Correct options found.');
}
}