From 69a38c2970ac13c5d524703bc0e6732f10ad19f3 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Wed, 3 Nov 2021 18:01:48 -0700 Subject: [PATCH] Temporarily enable Monolog in the test suite --- composer.json | 1 + tests/TestUtil.php | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 040b46c7016..a5e2f399677 100644 --- a/composer.json +++ b/composer.json @@ -42,6 +42,7 @@ "require-dev": { "doctrine/coding-standard": "9.0.0", "jetbrains/phpstorm-stubs": "2021.1", + "monolog/monolog": "^2.3", "phpstan/phpstan": "1.1.1", "phpstan/phpstan-strict-rules": "^1", "phpunit/phpunit": "9.5.10", diff --git a/tests/TestUtil.php b/tests/TestUtil.php index 346a70c950e..321336670c2 100644 --- a/tests/TestUtil.php +++ b/tests/TestUtil.php @@ -3,11 +3,16 @@ namespace Doctrine\DBAL\Tests; use Doctrine\Common\EventSubscriber; +use Doctrine\DBAL\Configuration; use Doctrine\DBAL\Connection; use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\Exception\DatabaseObjectNotFoundException; +use Doctrine\DBAL\Logging; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\OraclePlatform; +use Monolog\Handler\StreamHandler; +use Monolog\Logger; +use Monolog\Processor\PsrLogMessageProcessor; use PHPUnit\Framework\Assert; use function array_keys; @@ -58,7 +63,12 @@ public static function getConnection(): Connection self::$initialized = true; } - $conn = DriverManager::getConnection(self::getConnectionParams()); + $logger = new Logger('PHPUnit'); + $logger->pushHandler(new StreamHandler('/tmp/dbal.log', Logger::DEBUG)); + $logger->pushProcessor(new PsrLogMessageProcessor(null, true)); + + $configuration = (new Configuration())->setMiddlewares([new Logging\Middleware($logger)]); + $conn = DriverManager::getConnection(self::getConnectionParams(), $configuration); self::addDbEventSubscribers($conn);