function StatisticsLoggingTest::getStatisticsCounter
Same name in other branches
- 9 core/modules/statistics/tests/src/FunctionalJavascript/StatisticsLoggingTest.php \Drupal\Tests\statistics\FunctionalJavascript\StatisticsLoggingTest::getStatisticsCounter()
- 10 core/modules/statistics/tests/src/FunctionalJavascript/StatisticsLoggingTest.php \Drupal\Tests\statistics\FunctionalJavascript\StatisticsLoggingTest::getStatisticsCounter()
- 11.x 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\FunctionalJavascriptCode
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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.