3be95e2ab6eec54d19601d2bc39fa7a42bfbcea9
[yaffs-website] / web / core / modules / statistics / tests / src / Functional / StatisticsTestBase.php
1 <?php
2
3 namespace Drupal\Tests\statistics\Functional;
4
5 use Drupal\Tests\BrowserTestBase;
6
7 /**
8  * Defines a base class for testing the Statistics module.
9  */
10 abstract class StatisticsTestBase extends BrowserTestBase {
11
12   /**
13    * Modules to enable.
14    *
15    * @var array
16    */
17   public static $modules = ['node', 'block', 'ban', 'statistics'];
18
19   /**
20    * User with permissions to ban IP's.
21    *
22    * @var \Drupal\user\UserInterface
23    */
24   protected $blockingUser;
25
26   protected function setUp() {
27     parent::setUp();
28
29     // Create Basic page node type.
30     if ($this->profile != 'standard') {
31       $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
32     }
33
34     // Create user.
35     $this->blockingUser = $this->drupalCreateUser([
36       'access administration pages',
37       'access site reports',
38       'ban IP addresses',
39       'administer blocks',
40       'administer statistics',
41       'administer users',
42     ]);
43     $this->drupalLogin($this->blockingUser);
44
45     // Enable logging.
46     $this->config('statistics.settings')
47       ->set('count_content_views', 1)
48       ->save();
49   }
50
51 }