You are here

protected function NodeViewCountTestBase::setUp in Node view count 8

Overrides BrowserTestBase::setUp

File

src/Tests/NodeViewCountTestBase.php, line 82

Class

NodeViewCountTestBase
Defines a base class for testing the nodeviewcount module.

Namespace

Drupal\nodeviewcount\Tests

Code

protected function setUp() {
  parent::setUp();
  $this
    ->createRole([
    'access administration pages',
    'administer modules',
    'administer users',
    'access content',
  ], 'administrator', 'administrator');
  $this->adminUser = $this
    ->createUserWithRole('administrator');
  $this->firstTestTrackedNode = $this
    ->drupalCreateNode([
    'type' => 'tracked_page',
    'uid' => $this->adminUser
      ->id(),
    'promoted' => TRUE,
  ]);
  $this->secondTestTrackedNode = $this
    ->drupalCreateNode([
    'type' => 'tracked_page',
    'uid' => $this->adminUser
      ->id(),
    'promoted' => TRUE,
  ]);
  $this->testNotTrackedNode = $this
    ->drupalCreateNode([
    'type' => 'not_tracked_page',
    'uid' => $this->adminUser
      ->id(),
    'promoted' => TRUE,
  ]);
  $this->connection = $this->container
    ->get('database');
  $this->httpClientFactory = $this->container
    ->get('http_client_factory');
  $this->client = $this->httpClientFactory
    ->fromOptions([
    'config/curl' => [
      CURLOPT_TIMEOUT => 20,
    ],
  ]);
  $this
    ->drupalCreateContentType([
    'type' => 'tracked_page',
    'name' => 'Basic page with tracking',
  ]);

  // Create one more content type.
  $this
    ->drupalCreateContentType([
    'type' => 'not_tracked_page',
    'name' => 'Basic page with no tracking',
  ]);

  // Create role for authenticated user.
  $this
    ->createRole([
    'access content',
    'change own username',
  ], 'logged', 'logged');
  $this
    ->setNodeviewcountSettings();
}