From d679c5571ece625b9863c63ad9b99d09f28ce63f Mon Sep 17 00:00:00 2001 From: diosmosis Date: Wed, 5 Sep 2018 15:33:03 -0700 Subject: 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. --- config/environment/test.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'config/environment') diff --git a/config/environment/test.php b/config/environment/test.php index 2ac39275b8..785eb15ce4 100644 --- a/config/environment/test.php +++ b/config/environment/test.php @@ -8,7 +8,26 @@ use Piwik\Tests\Framework\Mock\TestConfig; return array( // Disable logging - 'Psr\Log\LoggerInterface' => DI\object('Psr\Log\NullLogger'), + 'Psr\Log\LoggerInterface' => \DI\decorate(function ($previous, ContainerInterface $c) { + $enableLogging = $c->get('ini.tests.enable_logging') == 1 || !empty(getenv('MATOMO_TESTS_ENABLE_LOGGING')); + if ($enableLogging) { + return $previous; + } else { + return $c->get(\Psr\Log\NullLogger::class); + } + }), + + 'Tests.log.allowAllHandlers' => false, + + 'log.handlers' => \DI\decorate(function ($previous, ContainerInterface $c) { + if ($c->get('Tests.log.allowAllHandlers')) { + return $previous; + } + + return [ + $c->get('Piwik\Plugins\Monolog\Handler\FileHandler'), + ]; + }), 'Piwik\Cache\Backend' => function () { return \Piwik\Cache::buildBackend('file'); -- cgit v1.2.3