2015-07-02 22:38:06 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace MediaWiki\Logger;
|
|
|
|
|
|
2017-04-19 19:37:35 +00:00
|
|
|
use Wikimedia\TestingAccessWrapper;
|
2015-07-02 22:38:06 +00:00
|
|
|
|
2019-06-30 13:23:53 +00:00
|
|
|
class MonologSpiTest extends \MediaWikiUnitTestCase {
|
2015-07-02 22:38:06 +00:00
|
|
|
|
|
|
|
|
/**
|
2016-02-23 03:18:31 +00:00
|
|
|
* @covers MediaWiki\Logger\MonologSpi::mergeConfig
|
2015-07-02 22:38:06 +00:00
|
|
|
*/
|
|
|
|
|
public function testMergeConfig() {
|
2016-02-17 09:09:32 +00:00
|
|
|
$base = [
|
|
|
|
|
'loggers' => [
|
|
|
|
|
'@default' => [
|
|
|
|
|
'processors' => [ 'constructor' ],
|
|
|
|
|
'handlers' => [ 'constructor' ],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
'processors' => [
|
|
|
|
|
'constructor' => [
|
2015-07-02 22:38:06 +00:00
|
|
|
'class' => 'constructor',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
'handlers' => [
|
|
|
|
|
'constructor' => [
|
2015-07-02 22:38:06 +00:00
|
|
|
'class' => 'constructor',
|
|
|
|
|
'formatter' => 'constructor',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
'formatters' => [
|
|
|
|
|
'constructor' => [
|
2015-07-02 22:38:06 +00:00
|
|
|
'class' => 'constructor',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
];
|
2015-07-02 22:38:06 +00:00
|
|
|
|
|
|
|
|
$fixture = new MonologSpi( $base );
|
|
|
|
|
$this->assertSame(
|
|
|
|
|
$base,
|
|
|
|
|
TestingAccessWrapper::newFromObject( $fixture )->config
|
|
|
|
|
);
|
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$fixture->mergeConfig( [
|
|
|
|
|
'loggers' => [
|
|
|
|
|
'merged' => [
|
|
|
|
|
'processors' => [ 'merged' ],
|
|
|
|
|
'handlers' => [ 'merged' ],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
'processors' => [
|
|
|
|
|
'merged' => [
|
2015-07-02 22:38:06 +00:00
|
|
|
'class' => 'merged',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
'magic' => [
|
|
|
|
|
'idkfa' => [ 'xyzzy' ],
|
|
|
|
|
],
|
|
|
|
|
'handlers' => [
|
|
|
|
|
'merged' => [
|
2015-07-02 22:38:06 +00:00
|
|
|
'class' => 'merged',
|
|
|
|
|
'formatter' => 'merged',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
'formatters' => [
|
|
|
|
|
'merged' => [
|
2015-07-02 22:38:06 +00:00
|
|
|
'class' => 'merged',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
] );
|
2015-07-02 22:38:06 +00:00
|
|
|
$this->assertSame(
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
|
|
|
|
'loggers' => [
|
|
|
|
|
'@default' => [
|
|
|
|
|
'processors' => [ 'constructor' ],
|
|
|
|
|
'handlers' => [ 'constructor' ],
|
|
|
|
|
],
|
|
|
|
|
'merged' => [
|
|
|
|
|
'processors' => [ 'merged' ],
|
|
|
|
|
'handlers' => [ 'merged' ],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
'processors' => [
|
|
|
|
|
'constructor' => [
|
2015-07-02 22:38:06 +00:00
|
|
|
'class' => 'constructor',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
'merged' => [
|
2015-07-02 22:38:06 +00:00
|
|
|
'class' => 'merged',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
'handlers' => [
|
|
|
|
|
'constructor' => [
|
2015-07-02 22:38:06 +00:00
|
|
|
'class' => 'constructor',
|
|
|
|
|
'formatter' => 'constructor',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
'merged' => [
|
2015-07-02 22:38:06 +00:00
|
|
|
'class' => 'merged',
|
|
|
|
|
'formatter' => 'merged',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
'formatters' => [
|
|
|
|
|
'constructor' => [
|
2015-07-02 22:38:06 +00:00
|
|
|
'class' => 'constructor',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
'merged' => [
|
2015-07-02 22:38:06 +00:00
|
|
|
'class' => 'merged',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
'magic' => [
|
|
|
|
|
'idkfa' => [ 'xyzzy' ],
|
|
|
|
|
],
|
|
|
|
|
],
|
2015-07-02 22:38:06 +00:00
|
|
|
TestingAccessWrapper::newFromObject( $fixture )->config
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|