Commit b3e8f84b authored by catch's avatar catch

Issue #3046393 by claudiu.cristea, dawehner: Convert ConnectionFailureTest into a Kernel test

parent d938b0a8
<?php
namespace Drupal\Tests\dblog\Functional;
namespace Drupal\Tests\dblog\Kernel;
use Drupal\Core\Database\Database;
use Drupal\Tests\BrowserTestBase;
use Drupal\KernelTests\KernelTestBase;
/**
* Tests logging of connection failures.
*
* @group dblog
*/
class ConnectionFailureTest extends BrowserTestBase {
class ConnectionFailureTest extends KernelTestBase {
public static $modules = ['dblog'];
/**
* {@inheritdoc}
*/
protected static $modules = ['dblog'];
/**
* Tests logging of connection failures.
*/
public function testConnectionFailureLogging() {
$logger = \Drupal::service('logger.factory');
$this->installSchema('dblog', ['watchdog']);
// MySQL errors like "1153 - Got a packet bigger than 'max_allowed_packet'
// bytes" or "1100 - Table 'xyz' was not locked with LOCK TABLES" lead to a
......@@ -31,13 +34,13 @@ public function testConnectionFailureLogging() {
Database::closeConnection();
// Create a log entry.
$logger->get('php')->error('testConnectionFailureLogging');
$this->container->get('logger.factory')->get('php')->error('testConnectionFailureLogging');
// Re-establish the default database connection.
Database::getConnection();
$database = Database::getConnection();
$wid = db_query("SELECT MAX(wid) FROM {watchdog} WHERE message = 'testConnectionFailureLogging'")->fetchField();
$this->assertTrue($wid, 'Watchdog entry has been stored in database.');
$wid = $database->query("SELECT MAX(wid) FROM {watchdog} WHERE message = 'testConnectionFailureLogging'")->fetchField();
$this->assertTrue($wid);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment