You are here

protected function StatisticsLoggingTest::getStatisticsCounter in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/statistics/tests/src/FunctionalJavascript/StatisticsLoggingTest.php \Drupal\Tests\statistics\FunctionalJavascript\StatisticsLoggingTest::getStatisticsCounter()

Gets counter of views by path.

Parameters

string $path: A path to node.

Return value

int|null A counter of views. Returns NULL if the page does not contain statistics.

1 call to StatisticsLoggingTest::getStatisticsCounter()
StatisticsLoggingTest::testLoggingPage in core/modules/statistics/tests/src/FunctionalJavascript/StatisticsLoggingTest.php
Tests that statistics works with different addressing variants.

File

core/modules/statistics/tests/src/FunctionalJavascript/StatisticsLoggingTest.php, line 80

Class

StatisticsLoggingTest
Tests that statistics works.

Namespace

Drupal\Tests\statistics\FunctionalJavascript

Code

protected function getStatisticsCounter($path) {
  $this
    ->drupalGet($path);

  // Wait while statistics module send ajax request.
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();

  // Resaving the node to call the hook_node_links_alter(), which is used to
  // update information on the page. See statistics_node_links_alter().
  $this->node
    ->save();
  $field_counter = $this
    ->getSession()
    ->getPage()
    ->find('css', '.statistics-counter');
  return $field_counter ? (int) explode(' ', $field_counter
    ->getText())[0] : NULL;
}