summaryrefslogtreecommitdiff
path: root/modules/node/node.test
diff options
context:
space:
mode:
Diffstat (limited to 'modules/node/node.test')
-rw-r--r--modules/node/node.test36
1 files changed, 33 insertions, 3 deletions
diff --git a/modules/node/node.test b/modules/node/node.test
index 27abb4f4a..c0b6096c2 100644
--- a/modules/node/node.test
+++ b/modules/node/node.test
@@ -1041,14 +1041,14 @@ class NodeSaveTestCase extends DrupalWebTestCase {
$changed = $node->changed;
node_save($node);
- $node = $this->drupalGetNodeByTitle($edit['title']);
+ $node = $this->drupalGetNodeByTitle($edit['title'], TRUE);
$this->assertEqual($node->created, $created, t('Updating a node preserves "created" timestamp.'));
// Programmatically set the timestamps using hook_node_presave.
$node->title = 'testing_node_presave';
node_save($node);
- $node = $this->drupalGetNodeByTitle('testing_node_presave');
+ $node = $this->drupalGetNodeByTitle('testing_node_presave', TRUE);
$this->assertEqual($node->created, 280299600, t('Saving a node uses "created" timestamp set in presave hook.'));
$this->assertEqual($node->changed, 979534800, t('Saving a node uses "changed" timestamp set in presave hook.'));
@@ -1071,10 +1071,40 @@ class NodeSaveTestCase extends DrupalWebTestCase {
$node->changed = 280299600;
node_save($node);
- $node = $this->drupalGetNodeByTitle($edit['title']);
+ $node = $this->drupalGetNodeByTitle($edit['title'], TRUE);
$this->assertEqual($node->created, 979534800, t('Updating a node uses user-set "created" timestamp.'));
$this->assertNotEqual($node->changed, 280299600, t('Updating a node doesn\'t use user-set "changed" timestamp.'));
}
+
+ /**
+ * Tests determing changes in hook_node_presave() and verifies the static node
+ * load cache is cleared upon save.
+ */
+ function testDeterminingChanges() {
+ // Initial creation.
+ $node = (object) array(
+ 'uid' => $this->web_user->uid,
+ 'type' => 'article',
+ 'title' => 'test_changes',
+ );
+ node_save($node);
+
+ // Update the node without applying changes.
+ node_save($node);
+ $this->assertEqual($node->title, 'test_changes', 'No changes have been determined.');
+
+ // Apply changes.
+ $node->title = 'updated';
+ node_save($node);
+
+ // 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.');
+ }
}
/**