1 node.test NodeSaveTestCase::testDeterminingChanges()

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


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


Tests node save related functionality, including import-save.


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

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

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

  // 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.');