comparison core/modules/field/tests/src/Kernel/FieldDataCountTest.php @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents c75dbcec494b
children
comparison
equal deleted inserted replaced
4:a9cd425dd02b 5:12f9dff5fda9
1 <?php 1 <?php
2 2
3 namespace Drupal\Tests\field\Kernel; 3 namespace Drupal\Tests\field\Kernel;
4 4
5 use Drupal\Core\Database\Database;
5 use Drupal\Core\Entity\Sql\SqlContentEntityStorage; 6 use Drupal\Core\Entity\Sql\SqlContentEntityStorage;
6 use Drupal\entity_test\Entity\EntityTest; 7 use Drupal\entity_test\Entity\EntityTest;
7 use Drupal\field\Entity\FieldConfig; 8 use Drupal\field\Entity\FieldConfig;
8 use Drupal\field\Entity\FieldStorageConfig; 9 use Drupal\field\Entity\FieldStorageConfig;
9 10
85 $storage = \Drupal::entityManager()->getStorage('entity_test'); 86 $storage = \Drupal::entityManager()->getStorage('entity_test');
86 if ($storage instanceof SqlContentEntityStorage) { 87 if ($storage instanceof SqlContentEntityStorage) {
87 // Count the actual number of rows in the field table. 88 // Count the actual number of rows in the field table.
88 $table_mapping = $storage->getTableMapping(); 89 $table_mapping = $storage->getTableMapping();
89 $field_table_name = $table_mapping->getDedicatedDataTableName($field_storage); 90 $field_table_name = $table_mapping->getDedicatedDataTableName($field_storage);
90 $result = db_select($field_table_name, 't') 91 $result = Database::getConnection()->select($field_table_name, 't')
91 ->fields('t') 92 ->fields('t')
92 ->countQuery() 93 ->countQuery()
93 ->execute() 94 ->execute()
94 ->fetchField(); 95 ->fetchField();
95 $this->assertEqual($result, 24, 'The field table has 24 rows.'); 96 $this->assertEqual($result, 24, 'The field table has 24 rows.');