You are here

public function NodeViewCountViewsTest::testTopViewedNodes in Node view count 8

Tests Top viewed nodes view.

File

src/Tests/NodeViewCountViewsTest.php, line 37

Class

NodeViewCountViewsTest
Tests views of nodeviewcount module.

Namespace

Drupal\nodeviewcount\Tests

Code

public function testTopViewedNodes() {
  $this
    ->drupalPlaceBlock('views_block:top_viewed_nodes-block');
  $this
    ->sendAjaxStatistics($this->firstTestTrackedNode
    ->id(), 0);
  $this
    ->sendAjaxStatistics($this->firstTestTrackedNode
    ->id(), 1);
  $this
    ->sendAjaxStatistics($this->secondTestTrackedNode
    ->id(), 0);
  $this
    ->drupalGet('<front>');
  $this
    ->assertFieldByXpath("(//div[@class='views-field views-field-title']/span/a)[1]", $this->firstTestTrackedNode
    ->getTitle());
  $this
    ->assertFieldByXpath("(//div[@class='views-field views-field-title']/span/a)[2]", $this->secondTestTrackedNode
    ->getTitle());
}