public function NodePageCacheTest::testNodeDelete in Drupal 7
Tests deleting nodes clears page cache.
File
- modules/
node/ node.test, line 2991 - Tests for node.module.
Class
- NodePageCacheTest
- Tests the cache invalidation of node operations.
Code
public function testNodeDelete() {
$node_path = 'node/' . $this
->drupalCreateNode()->nid;
// Populate page cache.
$this
->drupalGet($node_path);
// Login and delete the node.
$this
->drupalLogin($this->admin_user);
$this
->drupalPost($node_path . '/delete', array(), t('Delete'));
// Logout and check the node is not available.
$this
->drupalLogout();
$this
->drupalGet($node_path);
$this
->assertResponse(404);
// Create two new nodes.
$nodes[0] = $this
->drupalCreateNode();
$nodes[1] = $this
->drupalCreateNode();
$node_path = 'node/' . $nodes[0]->nid;
// Populate page cache.
$this
->drupalGet($node_path);
// Login and delete the nodes.
$this
->drupalLogin($this->admin_user);
$this
->drupalGet('admin/content');
$edit = array(
'operation' => 'delete',
'nodes[' . $nodes[0]->nid . ']' => TRUE,
'nodes[' . $nodes[1]->nid . ']' => TRUE,
);
$this
->drupalPost(NULL, $edit, t('Update'));
$this
->drupalPost(NULL, array(), t('Delete'));
// Logout and check the node is not available.
$this
->drupalLogout();
$this
->drupalGet($node_path);
$this
->assertResponse(404);
}