Commit cf66ac6b authored by hass's avatar hass
Browse files

#1797988: Added some DNT tests.

parent d78fde74
......@@ -87,6 +87,20 @@ class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
// Test whether 404 not found tracking code is shown on non-existent pages.
$this->drupalGet($this->randomName(64));
$this->assertRaw('/404.html', '[testGoogleAnalyticsPageVisibility]: 404 Not Found tracking code shown on non-existent page.');
// DNT Tests:
// Enable caching of pages for anonymous users.
variable_set('cache', 1);
// Test whether DNT headers will fail to disable embedding of tracking code.
$this->drupalGet('', array(), array('DNT: 1'));
$this->assertRaw('_gaq.push(["_trackPageview"]);', '[testGoogleAnalyticsDNTVisibility]: DNT header send from client, but page caching is enabled and tracker cannot removed.');
// DNT works only with caching of pages for anonymous users disabled.
variable_set('cache', 0);
$this->drupalGet('');
$this->assertRaw('_gaq.push(["_trackPageview"]);', '[testGoogleAnalyticsDNTVisibility]: Tracking is enabled without DNT header.');
// Test whether DNT header is able to remove the tracking code.
$this->drupalGet('', array(), array('DNT: 1'));
$this->assertNoRaw('_gaq.push(["_trackPageview"]);', '[testGoogleAnalyticsDNTVisibility]: DNT header received from client. Tracking has been disabled by browser.');
}
function testGoogleAnalyticsTrackingCode() {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment