3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
21 namespace MediaWiki\Logger
;
23 use MediaWikiTestCase
;
26 class LegacyLoggerTest
extends MediaWikiTestCase
{
29 * @covers LegacyLogger::interpolate
30 * @dataProvider provideInterpolate
32 public function testInterpolate( $message, $context, $expect ) {
34 $expect, LegacyLogger
::interpolate( $message, $context ) );
37 public function provideInterpolate() {
38 $e = new \
Exception( 'boom!' );
56 'greeting' => 'Goodnight',
67 '{ not interpolated }',
69 'not interpolated' => 'This should NOT show up in the message',
71 '{ not interpolated }',
90 'array' => array( 1, 2, 3 ),
99 '[Exception ' . get_class( $e ) . '( ' .
100 $e->getFile() . ':' . $e->getLine() . ') ' .
101 $e->getMessage() . ']',
113 'object' => new \stdClass
,
121 * @covers LegacyLogger::shouldEmit
122 * @dataProvider provideShouldEmit
124 public function testShouldEmit( $level, $config, $expected ) {
125 $this->setMwGlobals( 'wgDebugLogGroups', array( 'fakechannel' => $config ) );
128 LegacyLogger
::shouldEmit( 'fakechannel', 'some message', $level, array() )
132 public static function provideShouldEmit() {
133 $dest = array( 'destination' => 'foobar' );
142 $dest +
array( 'level' => LogLevel
::INFO
),
147 $dest +
array( 'level' => LogLevel
::CRITICAL
),
152 if ( class_exists( '\Monolog\Logger' ) ) {
154 \Monolog\Logger
::INFO
,
155 $dest +
array( 'level' => LogLevel
::INFO
),
159 \Monolog\Logger
::WARNING
,
160 $dest +
array( 'level' => LogLevel
::EMERGENCY
),