function ImageFieldDisplayTestCase::testNodeDisplay in ImageField 6.3
Test normal formatter display on node display.
File
- tests/
imagefield.test, line 54
Class
- ImageFieldDisplayTestCase
- Test class to check that formatters are working properly.
Code
function testNodeDisplay() {
$field_name = 'field_' . strtolower($this
->randomName());
$type = $this
->drupalCreateContentType();
$field = $this
->createImageField($field_name, $type->name, array(), array(
'custom_alt' => '1',
'custom_title' => '1',
));
$test_file = $this
->getTestFile('image');
// Create a new node with the uploaded file.
$nid = $this
->uploadNodeFile($test_file, $field, $type->name);
// Add an alt and title value.
$edit = array(
$field['field_name'] . '[0][data][alt]' => 'foo',
$field['field_name'] . '[0][data][title]' => 'bar',
);
$this
->drupalPost('node/' . $nid . '/edit', $edit, t('Save'));
// Check that the image formatter is displaying.
$node = node_load($nid, NULL, TRUE);
$node_file = $node->{$field['field_name']}[0];
$class = 'imagefield imagefield-' . $field['field_name'];
$default_output = theme('imagefield_image', $node_file, $node_file['data']['alt'], $node_file['data']['title'], array(
'class' => $class,
));
$this
->assertRaw($default_output, t('Image formatter displaying correctly on full node view.'));
}