You are here

public function NodeViewCountViewsTest::testLastViewsPerUserView in Node view count 8

Tests Last views per user view.

File

src/Tests/NodeViewCountViewsTest.php, line 50

Class

NodeViewCountViewsTest
Tests views of nodeviewcount module.

Namespace

Drupal\nodeviewcount\Tests

Code

public function testLastViewsPerUserView() {
  $this
    ->drupalPlaceBlock('views_block:last_views_per_user-block');
  $user = $this
    ->createUserWithRole('logged');
  $this
    ->drupalLogin($user);
  $this
    ->sendAjaxStatistics($this->secondTestTrackedNode
    ->id(), 0);
  $this
    ->sendAjaxStatistics($this->firstTestTrackedNode
    ->id(), $user
    ->id());
  sleep(5);
  $this
    ->sendAjaxStatistics($this->secondTestTrackedNode
    ->id(), $user
    ->id());
  $this
    ->drupalGet('<front>');
  $this
    ->assertFieldByXpath("(//div[@class='views-field views-field-title']/span/a)[1]", $this->secondTestTrackedNode
    ->getTitle());
  $this
    ->assertFieldByXpath("(//div[@class='views-field views-field-title']/span/a)[2]", $this->firstTestTrackedNode
    ->getTitle());
  $this
    ->drupalLogout();
}