function PiwikBasicTest::testPiwikPageVisibility in Piwik Web Analytics 6.2
Same name and namespace in other branches
- 7.2 piwik.test \PiwikBasicTest::testPiwikPageVisibility()
File
- ./piwik.test, line 66
- Test file for Piwik module.
Class
- PiwikBasicTest
- @file
Test file for Piwik module.
Code
function testPiwikPageVisibility() {
$ua_code = '1';
variable_set('piwik_site_id', $ua_code);
variable_get('piwik_url_http', 'http://example.com/piwik/');
variable_get('piwik_url_https', 'https://example.com/piwik/');
variable_set('piwik_visibility_pages', 0);
variable_set('piwik_pages', "admin\nadmin/*");
variable_set('piwik_roles', array(
DRUPAL_AUTHENTICATED_RID => DRUPAL_AUTHENTICATED_RID,
));
$this
->drupalGet('');
$this
->assertRaw('u+"piwik.php"', '[testPiwikPageVisibility]: Tracking code is displayed for authenticated users.');
$this
->drupalGet('admin');
$this
->assertNoRaw('u+"piwik.php"', '[testPiwikPageVisibility]: Tracking code is not displayed on admin page.');
$this
->drupalGet('admin/settings/piwik');
$this
->assertNoRaw('u+"piwik.php"', '[testPiwikPageVisibility]: Tracking code is not displayed on admin subpage.');
variable_set('piwik_visibility_pages', 1);
$this
->drupalGet('admin');
$this
->assertRaw('u+"piwik.php"', '[testPiwikPageVisibility]: Tracking code is displayed on admin page.');
$this
->drupalGet('admin/settings/piwik');
$this
->assertRaw('u+"piwik.php"', '[testPiwikPageVisibility]: Tracking code is displayed on admin subpage.');
$this
->drupalGet('');
$this
->assertNoRaw('u+"piwik.php"', '[testPiwikPageVisibility]: Tracking code is NOT displayed on front page.');
$this
->drupalLogout();
$this
->drupalGet('');
$this
->assertNoRaw('u+"piwik.php"', '[testPiwikPageVisibility]: Tracking code is NOT displayed for anonymous.');
variable_set('piwik_visibility_pages', 0);
variable_set('piwik_roles', array());
$this
->drupalGet($this
->randomName(64));
$this
->assertRaw('"404/URL = "', '[testPiwikPageVisibility]: 404 Not Found tracking code shown on non-existent page.');
}