| 7 statistics.test | StatisticsAdminTestCase::testExpiredLogs() |
| 8 statistics.test | StatisticsAdminTestCase::testExpiredLogs() |
Tests that cron clears day counts and expired access logs.
File
- modules/
statistics/ statistics.test, line 393 - Tests for statistics.module.
Code
function testExpiredLogs() {
variable_set('statistics_enable_access_log', 1);
variable_set('statistics_count_content_views', 1);
variable_set('statistics_day_timestamp', 8640000);
variable_set('statistics_flush_accesslog_timer', 1);
$this->drupalGet('node/' . $this->test_node->nid);
$this->drupalGet('node/' . $this->test_node->nid);
$this->assertText('1 read', t('Node is read once.'));
$this->drupalGet('admin/reports/pages');
$this->assertText('node/' . $this->test_node->nid, t('Hit URL found.'));
// statistics_cron will subtract the statistics_flush_accesslog_timer
// variable from REQUEST_TIME in the delete query, so wait two secs here to
// make sure the access log will be flushed for the node just hit.
sleep(2);
$this->cronRun();
$this->drupalGet('admin/reports/pages');
$this->assertNoText('node/' . $this->test_node->nid, t('No hit URL found.'));
$result = db_select('node_counter', 'nc')
->fields('nc', array('daycount'))
->condition('nid', $this->test_node->nid, '=')
->execute()
->fetchField();
$this->assertFalse($result, t('Daycounter is zero.'));
}
Login or register to post comments