comparison core/modules/search/tests/src/Functional/SearchMultilingualEntityTest.php @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents a9cd425dd02b
children
comparison
equal deleted inserted replaced
4:a9cd425dd02b 5:12f9dff5fda9
1 <?php 1 <?php
2 2
3 namespace Drupal\Tests\search\Functional; 3 namespace Drupal\Tests\search\Functional;
4 4
5 use Drupal\Core\Database\Database;
5 use Drupal\field\Entity\FieldStorageConfig; 6 use Drupal\field\Entity\FieldStorageConfig;
6 use Drupal\language\Entity\ConfigurableLanguage; 7 use Drupal\language\Entity\ConfigurableLanguage;
7 use Drupal\Tests\BrowserTestBase; 8 use Drupal\Tests\BrowserTestBase;
8 9
9 /** 10 /**
205 // The request time is always the same throughout test runs. Update the 206 // The request time is always the same throughout test runs. Update the
206 // request time to a previous time, to simulate it having been marked 207 // request time to a previous time, to simulate it having been marked
207 // previously. 208 // previously.
208 $current = REQUEST_TIME; 209 $current = REQUEST_TIME;
209 $old = $current - 10; 210 $old = $current - 10;
210 db_update('search_dataset') 211 $connection = Database::getConnection();
212 $connection->update('search_dataset')
211 ->fields(['reindex' => $old]) 213 ->fields(['reindex' => $old])
212 ->condition('reindex', $current, '>=') 214 ->condition('reindex', $current, '>=')
213 ->execute(); 215 ->execute();
214 216
215 // Save the node again. Verify that the request time on it is not updated. 217 // Save the node again. Verify that the request time on it is not updated.
216 $this->searchableNodes[1]->save(); 218 $this->searchableNodes[1]->save();
217 $result = db_select('search_dataset', 'd') 219 $result = $connection->select('search_dataset', 'd')
218 ->fields('d', ['reindex']) 220 ->fields('d', ['reindex'])
219 ->condition('type', 'node_search') 221 ->condition('type', 'node_search')
220 ->condition('sid', $this->searchableNodes[1]->id()) 222 ->condition('sid', $this->searchableNodes[1]->id())
221 ->execute() 223 ->execute()
222 ->fetchField(); 224 ->fetchField();
300 * @param string $message 302 * @param string $message
301 * Message suffix to use. 303 * Message suffix to use.
302 */ 304 */
303 protected function assertDatabaseCounts($count_node, $count_foo, $message) { 305 protected function assertDatabaseCounts($count_node, $count_foo, $message) {
304 // Count number of distinct nodes by ID. 306 // Count number of distinct nodes by ID.
305 $results = db_select('search_dataset', 'i') 307 $connection = Database::getConnection();
308 $results = $connection->select('search_dataset', 'i')
306 ->fields('i', ['sid']) 309 ->fields('i', ['sid'])
307 ->condition('type', 'node_search') 310 ->condition('type', 'node_search')
308 ->groupBy('sid') 311 ->groupBy('sid')
309 ->execute() 312 ->execute()
310 ->fetchCol(); 313 ->fetchCol();
311 $this->assertEqual($count_node, count($results), 'Node count was ' . $count_node . ' for ' . $message); 314 $this->assertEqual($count_node, count($results), 'Node count was ' . $count_node . ' for ' . $message);
312 315
313 // Count number of "foo" records. 316 // Count number of "foo" records.
314 $results = db_select('search_dataset', 'i') 317 $results = $connection->select('search_dataset', 'i')
315 ->fields('i', ['sid']) 318 ->fields('i', ['sid'])
316 ->condition('type', 'foo') 319 ->condition('type', 'foo')
317 ->execute() 320 ->execute()
318 ->fetchCol(); 321 ->fetchCol();
319 $this->assertEqual($count_foo, count($results), 'Foo count was ' . $count_foo . ' for ' . $message); 322 $this->assertEqual($count_foo, count($results), 'Foo count was ' . $count_foo . ' for ' . $message);