You are here

function node_test_node_insert in Drupal 7

Same name and namespace in other branches
  1. 8 core/modules/node/tests/modules/node_test/node_test.module \node_test_node_insert()
  2. 9 core/modules/node/tests/modules/node_test/node_test.module \node_test_node_insert()

Implements hook_node_insert().

This tests saving a node on node insert.

See also

NodeSaveTest::testNodeSaveOnInsert()

File

modules/node/tests/node_test.module, line 172
A dummy module for testing node related hooks.

Code

function node_test_node_insert($node) {

  // Set the node title to the node ID and save.
  if ($node->title == 'new') {
    $node->title = 'Node ' . $node->nid;

    // Remove the is_new flag, so that the node is updated and not inserted
    // again.
    unset($node->is_new);
    node_save($node);
  }
}