You are here

function NodeSaveTest::testNodeSaveOnInsert in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/node/src/Tests/NodeSaveTest.php \Drupal\node\Tests\NodeSaveTest::testNodeSaveOnInsert()

Tests saving a node on node insert.

This test ensures that a node has been fully saved when hook_ENTITY_TYPE_insert() is invoked, so that the node can be saved again in a hook implementation without errors.

See also

node_test_node_insert()

File

core/modules/node/src/Tests/NodeSaveTest.php, line 180
Contains \Drupal\node\Tests\NodeSaveTest.

Class

NodeSaveTest
Tests $node->save() for saving content.

Namespace

Drupal\node\Tests

Code

function testNodeSaveOnInsert() {

  // node_test_node_insert() triggers a save on insert if the title equals
  // 'new'.
  $node = $this
    ->drupalCreateNode(array(
    'title' => 'new',
  ));
  $this
    ->assertEqual($node
    ->getTitle(), 'Node ' . $node
    ->id(), 'Node saved on node insert.');
}