function StatisticsAdminTestCase::testDeleteNode

7.x statistics.test StatisticsAdminTestCase::testDeleteNode()

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

File

drupal-7.x/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.');
}