1 token.test TokenEntityTestCase::testEntityOriginal()

Test the [entity:original:*] tokens.

File

core/modules/simpletest/tests/token.test, line 831
Test integration for the token module.

Class

TokenEntityTestCase

Code

function testEntityOriginal() {
  $node = $this->backdropCreateNode(array('title' => 'Original title'));

  $tokens = array(
    'nid' => $node->nid,
    'title' => 'Original title',
    'original' => NULL,
    'original:nid' => NULL,
  );
  $this->assertTokens('node', array('node' => $node), $tokens);

  // Emulate the original entity property that would be available from
  // node_save() and change the title for the node.
  $node->original = entity_load_unchanged('node', $node->nid);
  $node->title = 'New title';

  $tokens = array(
    'nid' => $node->nid,
    'title' => 'New title',
    'original' => 'Original title',
    'original:nid' => $node->nid,
  );
  $this->assertTokens('node', array('node' => $node), $tokens);
}