summaryrefslogtreecommitdiff
path: root/modules/statistics/statistics.test
diff options
context:
space:
mode:
Diffstat (limited to 'modules/statistics/statistics.test')
-rw-r--r--modules/statistics/statistics.test17
1 files changed, 16 insertions, 1 deletions
diff --git a/modules/statistics/statistics.test b/modules/statistics/statistics.test
index d2155da6c..0498bb76b 100644
--- a/modules/statistics/statistics.test
+++ b/modules/statistics/statistics.test
@@ -118,6 +118,22 @@ class StatisticsLoggingTestCase extends DrupalWebTestCase {
$node_counter = statistics_get($this->node->nid);
$this->assertIdentical($node_counter['totalcount'], '3');
+ // Test that Ajax logging doesn't occur when disabled.
+ $post = http_build_query(array('nid' => $this->node->nid));
+ $headers = array('Content-Type' => 'application/x-www-form-urlencoded');
+ global $base_url;
+ $stats_path = $base_url . '/' . drupal_get_path('module', 'statistics'). '/statistics.php';
+ drupal_http_request($stats_path, array('method' => 'POST', 'data' => $post, 'headers' => $headers, 'timeout' => 10000));
+ $node_counter = statistics_get($this->node->nid);
+ $this->assertIdentical($node_counter['totalcount'], '3', 'Page request was not counted via Ajax.');
+
+ // Test that Ajax logging occurs when enabled.
+ variable_set('statistics_count_content_views_ajax', 1);
+ drupal_http_request($stats_path, array('method' => 'POST', 'data' => $post, 'headers' => $headers, 'timeout' => 10000));
+ $node_counter = statistics_get($this->node->nid);
+ $this->assertIdentical($node_counter['totalcount'], '4', 'Page request was counted via Ajax.');
+ variable_set('statistics_count_content_views_ajax', 0);
+
// Visit edit page to generate a title greater than 255.
$path = 'node/' . $this->node->nid . '/edit';
$expected = array(
@@ -142,7 +158,6 @@ class StatisticsLoggingTestCase extends DrupalWebTestCase {
$log = db_query('SELECT * FROM {accesslog}')->fetchAll(PDO::FETCH_ASSOC);
$this->assertTrue(is_array($log) && count($log) == 8, 'Page request was logged for a path over 255 characters.');
$this->assertEqual($log[7]['path'], truncate_utf8($long_path, 255));
-
}
}