Implements hook_node_insert().
This tests saving a node on node insert.
\Drupal\node\Tests\NodeSaveTest::testNodeSaveOnInsert()
function node_test_node_insert(Node $node) {
// Set the node title to the node ID and save.
if ($node->title == 'new') {
$node->title = 'Node ' . $node->nid;
node_save($node);
}
}