comparison core/modules/system/src/Tests/Module/ModuleTestBase.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\system\Tests\Module; 3 namespace Drupal\system\Tests\Module;
4
5 @trigger_error(__NAMESPACE__ . '\ModuleTestBase is deprecated for removal before Drupal 9.0.0. Use \Drupal\Tests\system\Functional\Module\ModuleTestBase instead. See https://www.drupal.org/node/2999939', E_USER_DEPRECATED);
4 6
5 use Drupal\Core\Config\InstallStorage; 7 use Drupal\Core\Config\InstallStorage;
6 use Drupal\Core\Database\Database; 8 use Drupal\Core\Database\Database;
7 use Drupal\Core\Config\FileStorage; 9 use Drupal\Core\Config\FileStorage;
8 use Drupal\Core\Logger\RfcLogLevel; 10 use Drupal\Core\Logger\RfcLogLevel;
11 /** 13 /**
12 * Helper class for module test cases. 14 * Helper class for module test cases.
13 * 15 *
14 * @deprecated Scheduled for removal in Drupal 9.0.0. 16 * @deprecated Scheduled for removal in Drupal 9.0.0.
15 * Use \Drupal\Tests\system\Functional\Module\ModuleTestBase instead. 17 * Use \Drupal\Tests\system\Functional\Module\ModuleTestBase instead.
18 *
19 * @see https://www.drupal.org/node/2999939
16 */ 20 */
17 abstract class ModuleTestBase extends WebTestBase { 21 abstract class ModuleTestBase extends WebTestBase {
18 22
19 /** 23 /**
20 * Modules to enable. 24 * Modules to enable.
40 * @param $count 44 * @param $count
41 * (optional) Whether or not to assert that there are tables that match the 45 * (optional) Whether or not to assert that there are tables that match the
42 * specified base table. Defaults to TRUE. 46 * specified base table. Defaults to TRUE.
43 */ 47 */
44 public function assertTableCount($base_table, $count = TRUE) { 48 public function assertTableCount($base_table, $count = TRUE) {
45 $tables = db_find_tables(Database::getConnection()->prefixTables('{' . $base_table . '}') . '%'); 49 $connection = Database::getConnection();
50 $tables = $connection->schema()->findTables($connection->prefixTables('{' . $base_table . '}') . '%');
46 51
47 if ($count) { 52 if ($count) {
48 return $this->assertTrue($tables, format_string('Tables matching "@base_table" found.', ['@base_table' => $base_table])); 53 return $this->assertTrue($tables, format_string('Tables matching "@base_table" found.', ['@base_table' => $base_table]));
49 } 54 }
50 return $this->assertFalse($tables, format_string('Tables matching "@base_table" not found.', ['@base_table' => $base_table])); 55 return $this->assertFalse($tables, format_string('Tables matching "@base_table" not found.', ['@base_table' => $base_table]));
184 * The severity of the message, as per RFC 3164. 189 * The severity of the message, as per RFC 3164.
185 * @param $link 190 * @param $link
186 * A link to associate with the message. 191 * A link to associate with the message.
187 */ 192 */
188 public function assertLogMessage($type, $message, $variables = [], $severity = RfcLogLevel::NOTICE, $link = '') { 193 public function assertLogMessage($type, $message, $variables = [], $severity = RfcLogLevel::NOTICE, $link = '') {
189 $count = db_select('watchdog', 'w') 194 $count = Database::getConnection()->select('watchdog', 'w')
190 ->condition('type', $type) 195 ->condition('type', $type)
191 ->condition('message', $message) 196 ->condition('message', $message)
192 ->condition('variables', serialize($variables)) 197 ->condition('variables', serialize($variables))
193 ->condition('severity', $severity) 198 ->condition('severity', $severity)
194 ->condition('link', $link) 199 ->condition('link', $link)