Mercurial > hg > isophonics-drupal-site
diff core/modules/statistics/tests/src/Functional/StatisticsTestBase.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/modules/statistics/tests/src/Functional/StatisticsTestBase.php Wed Nov 29 16:09:58 2017 +0000 @@ -0,0 +1,51 @@ +<?php + +namespace Drupal\Tests\statistics\Functional; + +use Drupal\Tests\BrowserTestBase; + +/** + * Defines a base class for testing the Statistics module. + */ +abstract class StatisticsTestBase extends BrowserTestBase { + + /** + * Modules to enable. + * + * @var array + */ + public static $modules = ['node', 'block', 'ban', 'statistics']; + + /** + * User with permissions to ban IP's. + * + * @var \Drupal\user\UserInterface + */ + protected $blockingUser; + + protected function setUp() { + parent::setUp(); + + // Create Basic page node type. + if ($this->profile != 'standard') { + $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']); + } + + // Create user. + $this->blockingUser = $this->drupalCreateUser([ + 'access administration pages', + 'access site reports', + 'ban IP addresses', + 'administer blocks', + 'administer statistics', + 'administer users', + ]); + $this->drupalLogin($this->blockingUser); + + // Enable logging. + $this->config('statistics.settings') + ->set('count_content_views', 1) + ->save(); + } + +}