You are here

function StatisticsAdminTestCase::testDeleteNode in Drupal 7

Tests that when a node is deleted, the node counter is deleted too.

File

modules/statistics/statistics.test, line 375
Tests for the Statistics module.

Class

StatisticsAdminTestCase
Tests the statistics administration screen.

Code

function testDeleteNode() {
  variable_set('statistics_count_content_views', 1);
  $this
    ->drupalGet('node/' . $this->test_node->nid);
  $result = db_select('node_counter', 'n')
    ->fields('n', array(
    'nid',
  ))
    ->condition('n.nid', $this->test_node->nid)
    ->execute()
    ->fetchAssoc();
  $this
    ->assertEqual($result['nid'], $this->test_node->nid, 'Verifying that the node counter is incremented.');
  node_delete($this->test_node->nid);
  $result = db_select('node_counter', 'n')
    ->fields('n', array(
    'nid',
  ))
    ->condition('n.nid', $this->test_node->nid)
    ->execute()
    ->fetchAssoc();
  $this
    ->assertFalse($result, 'Verifying that the node counter is deleted.');
}