public function CounterTest::testCounterCodePagesSettings in Yandex.Metrics 8.2
Test Yandex.Metrics page specific settings.
File
- src/
Tests/ CounterTest.php, line 145 - Contains \Drupal\yandex_metrics\Tests\CounterTest.
Class
- CounterTest
- Tests of functionality and settings of Yandex.Metrics Counter module.
Namespace
Drupal\yandex_metrics\TestsCode
public function testCounterCodePagesSettings() {
// Login as administrator.
$this
->drupalLogin($this->admin_user);
$edit = array();
$edit["counter_code"] = $this->yandex_metrics_code;
$this
->drupalPostForm('admin/config/system/yandex_metrics', $edit, t('Save configuration'));
// Create test node.
$node = $this
->drupalCreateNode();
// Check if counter exists.
$this
->drupalGet('node');
$this
->checkCounter();
$this
->drupalGet('node/' . $node
->id());
$this
->checkCounter();
// Disable counter on node overview and node full pages.
$edit = array();
$edit["pages"] = \Drupal::config('yandex_metrics.settings')
->get('visibility.path.pages') . "\n" . 'node' . "\n" . 'node/*';
$this
->drupalPostForm('admin/config/system/yandex_metrics', $edit, t('Save configuration'));
// Check if counter doesn't exist.
$this
->drupalGet('node');
$this
->checkNoCounter();
$this
->drupalGet('node/' . $node
->id());
$this
->checkNoCounter();
// Enable counter only on node pages.
$edit = array();
$edit['visibility'] = 1;
$edit['pages'] = 'node/*';
$this
->drupalPostForm('admin/config/system/yandex_metrics', $edit, t('Save configuration'));
// Check if counter exists.
$this
->drupalGet('node/' . $node
->id());
$this
->checkCounter();
// Check if counter doesn't exist.
$this
->drupalGet('');
$this
->checkNoCounter();
$this
->drupalGet('user');
$this
->checkNoCounter();
}