public function YandexMetricsCounterTestCase::testCounterCodeRolesSettings in Yandex.Metrics 7.3
Same name and namespace in other branches
- 7.2 yandex_metrics.test \YandexMetricsCounterTestCase::testCounterCodeRolesSettings()
Test Yandex.Metrics role specific settings.
File
- ./
yandex_metrics.test, line 153 - Tests for Yandex.Metrics Counter module.
Class
- YandexMetricsCounterTestCase
- Tests of functionality and settings of Yandex.Metrics Counter module.
Code
public function testCounterCodeRolesSettings() {
// Login as administrator.
$this
->drupalLogin($this->admin_user);
// Add Yandex.Metrica counter code only for anonymous users.
$edit = array();
$edit['yandex_metrics_roles[' . DRUPAL_ANONYMOUS_RID . ']'] = DRUPAL_ANONYMOUS_RID;
$this
->drupalPost('admin/config/system/yandex_metrics', $edit, t('Save'));
// Check if counter doesn't exist for admin.
$this
->drupalGet('');
$this
->checkNoCounter();
// Check if counter exists for anonymous user.
$this
->drupalLogout();
$this
->drupalGet('');
$this
->checkCounter();
// Check if counter doesn't exist for normal user.
$this
->drupalLogin($this->regular_user);
$this
->drupalGet('');
$this
->checkNoCounter();
// Add Yandex.Metrica counter code for all roles except administrators.
$this
->drupalLogin($this->admin_user);
$admin_role_id = key(array_diff_key($this->admin_user->roles, array(
DRUPAL_AUTHENTICATED_RID => 0,
)));
$edit = array();
$edit['yandex_metrics_visibility_roles'] = 1;
$edit['yandex_metrics_roles[' . $admin_role_id . ']'] = $admin_role_id;
// Unset previous setting for anonymous role.
$edit['yandex_metrics_roles[' . DRUPAL_ANONYMOUS_RID . ']'] = FALSE;
$this
->drupalPost('admin/config/system/yandex_metrics', $edit, t('Save'));
// Check if counter doesn't exist for admin.
$this
->drupalGet('');
$this
->checkNoCounter();
// Check if counter exists for anonymous user.
$this
->drupalLogout();
$this
->drupalGet('');
$this
->checkCounter();
// Check if counter exists for normal user.
$this
->drupalLogin($this->regular_user);
$this
->drupalGet('');
$this
->checkCounter();
}