diff options
author | diosmosis <diosmosis@users.noreply.github.com> | 2018-09-06 01:33:03 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-06 01:33:03 +0300 |
commit | d679c5571ece625b9863c63ad9b99d09f28ce63f (patch) | |
tree | 92c8d40c945c21d9aaf13837eac24f91c7de4e97 /plugins/Monolog | |
parent | 04c8456861787b50b22444617bef114eb00be7e1 (diff) |
Add [tests] config option to enable logging in tests. (#13335)
* Add [tests] config option to enable logging in tests.
* Allow tests:run/tests:run-ui commands to enable logging for individual runs + during tests only log to file.
* Remove Fixture field
* fix failing test
* fixing build
* Fix another failure.
* Fix an other test.
Diffstat (limited to 'plugins/Monolog')
-rw-r--r-- | plugins/Monolog/config/tracker.php | 6 | ||||
-rw-r--r-- | plugins/Monolog/tests/Integration/LogTest.php | 3 | ||||
-rw-r--r-- | plugins/Monolog/tests/System/TrackerLoggingTest.php | 10 |
3 files changed, 14 insertions, 5 deletions
diff --git a/plugins/Monolog/config/tracker.php b/plugins/Monolog/config/tracker.php index c9d0044b35..620101ff7a 100644 --- a/plugins/Monolog/config/tracker.php +++ b/plugins/Monolog/config/tracker.php @@ -10,13 +10,13 @@ function isTrackerDebugEnabled(ContainerInterface $c) return array( - 'Psr\Log\LoggerInterface' => function (ContainerInterface $c) { + 'Psr\Log\LoggerInterface' => \DI\decorate(function ($previous, ContainerInterface $c) { if (isTrackerDebugEnabled($c)) { - return $c->get('Monolog\Logger'); + return $previous; } else { return new \Psr\Log\NullLogger(); } - }, + }), 'log.handler.classes' => DI\decorate(function ($previous) { if (isset($previous['screen'])) { diff --git a/plugins/Monolog/tests/Integration/LogTest.php b/plugins/Monolog/tests/Integration/LogTest.php index 0389b504f0..744b59b41c 100644 --- a/plugins/Monolog/tests/Integration/LogTest.php +++ b/plugins/Monolog/tests/Integration/LogTest.php @@ -258,7 +258,8 @@ class LogTest extends IntegrationTestCase 'ini.log.log_level' => $level, 'ini.log.string_message_format' => self::STRING_MESSAGE_FORMAT, 'ini.log.logger_file_path' => self::getLogFileLocation(), - 'Psr\Log\LoggerInterface' => \DI\get('Monolog\Logger') + 'Psr\Log\LoggerInterface' => \DI\get('Monolog\Logger'), + 'Tests.log.allowAllHandlers' => true, )); $newEnv->init(); diff --git a/plugins/Monolog/tests/System/TrackerLoggingTest.php b/plugins/Monolog/tests/System/TrackerLoggingTest.php index 0c85338850..661c69e710 100644 --- a/plugins/Monolog/tests/System/TrackerLoggingTest.php +++ b/plugins/Monolog/tests/System/TrackerLoggingTest.php @@ -10,6 +10,7 @@ namespace Piwik\Plugins\Monolog\tests\System; use Piwik\Config; use Piwik\Date; +use Piwik\Plugins\Monolog\Handler\EchoHandler; use Piwik\Tests\Framework\Fixture; use Piwik\Tests\Framework\TestCase\SystemTestCase; use Piwik\Tests\Framework\TestingEnvironmentVariables; @@ -92,7 +93,14 @@ DEBUG: 'apiv' => '1',", $response); public static function provideContainerConfigBeforeClass() { return array( - 'Psr\Log\LoggerInterface' => \DI\get('Monolog\Logger') + 'Psr\Log\LoggerInterface' => \DI\get('Monolog\Logger'), + Config::class => \DI\decorate(function (Config $config) { + $config->tests['enable_logging'] = 1; + return $config; + }), + 'log.handlers' => [ + \DI\get(EchoHandler::class), + ], ); } |