3 namespace Drupal\Tests\statistics\Kernel\Migrate\d7;
5 use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
8 * Tests the migration of node counter data to Drupal 8.
12 class MigrateNodeCounterTest extends MigrateDrupal7TestBase {
17 public static $modules = [
27 protected function setUp() {
30 $this->installEntitySchema('node');
31 $this->installConfig('node');
32 $this->installSchema('statistics', ['node_counter']);
34 $this->executeMigrations([
39 'statistics_node_counter'
44 * Tests migration of node counter.
46 public function testStatisticsSettings() {
47 $this->assertNodeCounter(1, 2, 0, 1421727536);
48 $this->assertNodeCounter(2, 1, 0, 1471428059);
49 $this->assertNodeCounter(4, 1, 1, 1478755275);
53 * Asserts various aspects of a node counter.
57 * @param int $total_count
58 * The expected total count.
59 * @param int $day_count
60 * The expected day count.
61 * @param int $timestamp
62 * The expected timestamp.
64 protected function assertNodeCounter($nid, $total_count, $day_count, $timestamp) {
65 /** @var \Drupal\statistics\StatisticsViewsResult $statistics */
66 $statistics = $this->container->get('statistics.storage.node')->fetchView($nid);
67 // @todo Remove casting after https://www.drupal.org/node/2926069 lands.
68 $this->assertSame($total_count, (int) $statistics->getTotalCount());
69 $this->assertSame($day_count, (int) $statistics->getDayCount());
70 $this->assertSame($timestamp, (int) $statistics->getTimestamp());