Skip to content

Commit

Permalink
Temporarily enable Monolog in the test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
morozov committed Nov 16, 2021
1 parent f9d3051 commit 69a38c2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 11 additions & 1 deletion tests/TestUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 69a38c2

Please sign in to comment.