function FieldTokensFormattedTestCase::testFormattedTokens in Field tokens 7
Test that Formatted tokens render correctly.
File
- tests/
field_tokens.test, line 113 - Tests for the Field tokens module.
Class
- FieldTokensFormattedTestCase
- Class FieldTokensFormattedTestCase
Code
function testFormattedTokens() {
// Create a new node with an image attached.
$test_image = current($this
->drupalGetTestFiles('image'));
$nid = $this
->uploadNodeImage($test_image, $this->field_name, $this->content_type);
$node = node_load($nid, NULL, TRUE);
$display = array(
'type' => 'image',
'settings' => array(
'image_style' => '',
'image_link' => '',
),
'module' => 'image',
);
$element = field_view_field('node', $node, $this->field_name, $display);
$output = render($element['0']);
// Image field with Image formatter.
$token = "[node:{$this->field_name}-formatted:0:image]";
$value = token_replace($token, array(
'node' => $node,
));
// Check the token is rendered correctly.
$this
->assertEqual($value, $output, $token . ' matches rendered Image formatter for provided Image field.');
}