1 node.test NodeSaveTestCase::testDeterminingChanges()

Tests determining changes in hook_node_presave() and verifies the static node load cache is cleared upon save.

File

core/modules/node/tests/node.test, line 1940
Tests for node.module.

Class

NodeSaveTestCase
Tests node save related functionality, including import-save.

Code

function testDeterminingChanges() {
  // Initial creation.
  $node = entity_create('node', array(
    'uid' => $this->web_user->uid,
    'type' => 'post',
    'title' => 'test_changes',
  ));
  $node->save();

  // Update the node without applying changes.
  $node->save();
  $this->assertEqual($node->title, 'test_changes', 'No changes have been determined.');

  // Apply changes.
  $node->title = 'updated';
  $node->save();

  // The hook implementations node_test_node_presave() and
  // node_test_node_update() determine changes and change the title.
  $this->assertEqual($node->title, 'updated_presave_update', 'Changes have been determined.');

  // Test the static node load cache to be cleared.
  $node = node_load($node->nid);
  $this->assertEqual($node->title, 'updated_presave', 'Static cache has been cleared.');
}