1 node.test public NodePageCacheTest::testNodeDelete()

Tests deleting nodes clears page cache.

File

core/modules/node/tests/node.test, line 3775
Tests for node.module.

Class

NodePageCacheTest
Tests the cache invalidation of node operations.

Code

public function testNodeDelete() {
  $node_path = 'node/' . $this->backdropCreateNode()->nid;

  // Populate page cache.
  $this->backdropGet($node_path);

  // Login and delete the node.
  $this->backdropLogin($this->admin_user);
  $this->backdropPost($node_path . '/delete', array(), t('Delete'));

  // Logout. The node will still be accessible due to the page cache.
  $this->backdropLogout();
  $this->backdropGet($node_path);
  $this->assertResponse(200);

  // Create two new nodes.
  $nodes[0] = $this->backdropCreateNode();
  $nodes[1] = $this->backdropCreateNode();
  $node_path = 'node/' . $nodes[0]->nid;

  // Populate page cache.
  $this->backdropGet($node_path);

  // Login and delete the nodes.
  $this->backdropLogin($this->admin_user);
  $this->backdropGet('admin/content');
  $edit = array(
    'action' => 'node_delete_action',
    'bulk_form[0]' => TRUE,
    'bulk_form[1]' => TRUE,
  );
  $this->backdropPost(NULL, $edit, t('Execute'));
  $this->backdropPost(NULL, array(), t('Delete'));

  // Logout and check the node is not available.
  $this->backdropLogout();
  $this->backdropGet($node_path);
  $this->assertResponse(404);
}