You are here

function FieldTokensPropertyTestCase::testPropertyTokens in Field tokens 7

Test that Field property tokens render correctly.

File

tests/field_tokens.test, line 156
Tests for the Field tokens module.

Class

FieldTokensPropertyTestCase
Class FieldTokensPropertyTestCase

Code

function testPropertyTokens() {

  // 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);
  $items = field_get_items('node', $node, $this->field_name);

  // Image field URI property token.
  $token = "[node:{$this->field_name}-property:0:uri]";
  $value = token_replace($token, array(
    'node' => $node,
  ));

  // Check the token is rendered correctly.
  $this
    ->assertEqual($value, $items[0]['uri'], $token . ' matches provided Image field URI property.');
}