function node_test_node_insert

Same name in other branches
  1. 9 core/modules/node/tests/modules/node_test/node_test.module \node_test_node_insert()
  2. 8.9.x core/modules/node/tests/modules/node_test/node_test.module \node_test_node_insert()
  3. 10 core/modules/node/tests/modules/node_test/node_test.module \node_test_node_insert()
  4. 11.x 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

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);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.