comparison core/modules/statistics/tests/src/Functional/StatisticsAdminTest.php @ 18:af1871eacc83

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:33:08 +0100
parents 129ea1e6d783
children
comparison
equal deleted inserted replaced
17:129ea1e6d783 18:af1871eacc83
1 <?php 1 <?php
2 2
3 namespace Drupal\Tests\statistics\Functional; 3 namespace Drupal\Tests\statistics\Functional;
4 4
5 use Drupal\Core\Database\Database;
5 use Drupal\Tests\BrowserTestBase; 6 use Drupal\Tests\BrowserTestBase;
6 use Drupal\Tests\Traits\Core\CronRunTrait; 7 use Drupal\Tests\Traits\Core\CronRunTrait;
7 8
8 /** 9 /**
9 * Tests the statistics admin. 10 * Tests the statistics admin.
113 $post = ['nid' => $nid]; 114 $post = ['nid' => $nid];
114 global $base_url; 115 global $base_url;
115 $stats_path = $base_url . '/' . drupal_get_path('module', 'statistics') . '/statistics.php'; 116 $stats_path = $base_url . '/' . drupal_get_path('module', 'statistics') . '/statistics.php';
116 $this->client->post($stats_path, ['form_params' => $post]); 117 $this->client->post($stats_path, ['form_params' => $post]);
117 118
118 $result = db_select('node_counter', 'n') 119 $connection = Database::getConnection();
120 $result = $connection->select('node_counter', 'n')
119 ->fields('n', ['nid']) 121 ->fields('n', ['nid'])
120 ->condition('n.nid', $this->testNode->id()) 122 ->condition('n.nid', $this->testNode->id())
121 ->execute() 123 ->execute()
122 ->fetchAssoc(); 124 ->fetchAssoc();
123 $this->assertEqual($result['nid'], $this->testNode->id(), 'Verifying that the node counter is incremented.'); 125 $this->assertEqual($result['nid'], $this->testNode->id(), 'Verifying that the node counter is incremented.');
124 126
125 $this->testNode->delete(); 127 $this->testNode->delete();
126 128
127 $result = db_select('node_counter', 'n') 129 $result = $connection->select('node_counter', 'n')
128 ->fields('n', ['nid']) 130 ->fields('n', ['nid'])
129 ->condition('n.nid', $this->testNode->id()) 131 ->condition('n.nid', $this->testNode->id())
130 ->execute() 132 ->execute()
131 ->fetchAssoc(); 133 ->fetchAssoc();
132 $this->assertFalse($result, 'Verifying that the node counter is deleted.'); 134 $this->assertFalse($result, 'Verifying that the node counter is deleted.');
160 $this->cronRun(); 162 $this->cronRun();
161 163
162 $this->drupalGet('admin/reports/pages'); 164 $this->drupalGet('admin/reports/pages');
163 $this->assertNoText('node/' . $this->testNode->id(), 'No hit URL found.'); 165 $this->assertNoText('node/' . $this->testNode->id(), 'No hit URL found.');
164 166
165 $result = db_select('node_counter', 'nc') 167 $result = Database::getConnection()->select('node_counter', 'nc')
166 ->fields('nc', ['daycount']) 168 ->fields('nc', ['daycount'])
167 ->condition('nid', $this->testNode->id(), '=') 169 ->condition('nid', $this->testNode->id(), '=')
168 ->execute() 170 ->execute()
169 ->fetchField(); 171 ->fetchField();
170 $this->assertFalse($result, 'Daycounter is zero.'); 172 $this->assertFalse($result, 'Daycounter is zero.');