You are here

public function StatisticsDeprecationsTest::testStatisticsGetDeprecation in Drupal 8

@expectedDeprecation statistics_get() is deprecated in drupal:8.2.0 and is removed from drupal:9.0.0. Use Drupal::service('statistics.storage.node')->fetchView() instead. See https://www.drupal.org/node/2778245

File

core/modules/statistics/tests/src/Kernel/StatisticsDeprecationsTest.php, line 25

Class

StatisticsDeprecationsTest
Tests deprecations in the Statistics module.

Namespace

Drupal\Tests\statistics\Kernel

Code

public function testStatisticsGetDeprecation() {
  $this
    ->installSchema('statistics', 'node_counter');
  $this->container
    ->get('statistics.storage.node')
    ->recordView(1);
  $expected_timestamp = $this->container
    ->get('datetime.time')
    ->getRequestTime();
  $this
    ->assertSame([
    'totalcount' => 1,
    'daycount' => 1,
    'timestamp' => $expected_timestamp,
  ], statistics_get(1));
}