Separate MediaWiki unit and integration tests
[lhc/web/wiklou.git] / tests / phpunit / unit / includes / debug / logger / MonologSpiTest.php
1 <?php
2 /**
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.
7 *
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.
12 *
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
17 *
18 * @file
19 */
20
21 namespace MediaWiki\Logger;
22
23 use Wikimedia\TestingAccessWrapper;
24
25 class MonologSpiTest extends \MediaWikiUnitTestCase {
26
27 /**
28 * @covers MediaWiki\Logger\MonologSpi::mergeConfig
29 */
30 public function testMergeConfig() {
31 $base = [
32 'loggers' => [
33 '@default' => [
34 'processors' => [ 'constructor' ],
35 'handlers' => [ 'constructor' ],
36 ],
37 ],
38 'processors' => [
39 'constructor' => [
40 'class' => 'constructor',
41 ],
42 ],
43 'handlers' => [
44 'constructor' => [
45 'class' => 'constructor',
46 'formatter' => 'constructor',
47 ],
48 ],
49 'formatters' => [
50 'constructor' => [
51 'class' => 'constructor',
52 ],
53 ],
54 ];
55
56 $fixture = new MonologSpi( $base );
57 $this->assertSame(
58 $base,
59 TestingAccessWrapper::newFromObject( $fixture )->config
60 );
61
62 $fixture->mergeConfig( [
63 'loggers' => [
64 'merged' => [
65 'processors' => [ 'merged' ],
66 'handlers' => [ 'merged' ],
67 ],
68 ],
69 'processors' => [
70 'merged' => [
71 'class' => 'merged',
72 ],
73 ],
74 'magic' => [
75 'idkfa' => [ 'xyzzy' ],
76 ],
77 'handlers' => [
78 'merged' => [
79 'class' => 'merged',
80 'formatter' => 'merged',
81 ],
82 ],
83 'formatters' => [
84 'merged' => [
85 'class' => 'merged',
86 ],
87 ],
88 ] );
89 $this->assertSame(
90 [
91 'loggers' => [
92 '@default' => [
93 'processors' => [ 'constructor' ],
94 'handlers' => [ 'constructor' ],
95 ],
96 'merged' => [
97 'processors' => [ 'merged' ],
98 'handlers' => [ 'merged' ],
99 ],
100 ],
101 'processors' => [
102 'constructor' => [
103 'class' => 'constructor',
104 ],
105 'merged' => [
106 'class' => 'merged',
107 ],
108 ],
109 'handlers' => [
110 'constructor' => [
111 'class' => 'constructor',
112 'formatter' => 'constructor',
113 ],
114 'merged' => [
115 'class' => 'merged',
116 'formatter' => 'merged',
117 ],
118 ],
119 'formatters' => [
120 'constructor' => [
121 'class' => 'constructor',
122 ],
123 'merged' => [
124 'class' => 'merged',
125 ],
126 ],
127 'magic' => [
128 'idkfa' => [ 'xyzzy' ],
129 ],
130 ],
131 TestingAccessWrapper::newFromObject( $fixture )->config
132 );
133 }
134
135 }