Use User::equals() where applicable in the class
[lhc/web/wiklou.git] / tests / phpunit / includes / debug / logger / monolog / LineFormatterTest.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\Monolog;
22
23 use InvalidArgumentException;
24 use LengthException;
25 use LogicException;
26 use MediaWikiTestCase;
27 use TestingAccessWrapper;
28
29 class LineFormatterTest extends MediaWikiTestCase {
30
31 /**
32 * @covers LineFormatter::normalizeException
33 */
34 public function testNormalizeExceptionNoTrace() {
35 $fixture = new LineFormatter();
36 $fixture->includeStacktraces( false );
37 $fixture = TestingAccessWrapper::newFromObject( $fixture );
38 $boom = new InvalidArgumentException( 'boom', 0,
39 new LengthException( 'too long', 0,
40 new LogicException( 'Spock wuz here' )
41 )
42 );
43 $out = $fixture->normalizeException( $boom );
44 $this->assertContains( '[Exception InvalidArgumentException]', $out );
45 $this->assertContains( ', [Exception LengthException]', $out );
46 $this->assertContains( ', [Exception LogicException]', $out );
47 $this->assertNotContains( '[stacktrace]', $out );
48 }
49
50 /**
51 * @covers LineFormatter::normalizeException
52 */
53 public function testNormalizeExceptionTrace() {
54 $fixture = new LineFormatter();
55 $fixture->includeStacktraces( true );
56 $fixture = TestingAccessWrapper::newFromObject( $fixture );
57 $boom = new InvalidArgumentException( 'boom', 0,
58 new LengthException( 'too long', 0,
59 new LogicException( 'Spock wuz here' )
60 )
61 );
62 $out = $fixture->normalizeException( $boom );
63 $this->assertContains( '[Exception InvalidArgumentException', $out );
64 $this->assertContains( ', [Exception LengthException]', $out );
65 $this->assertContains( ', [Exception LogicException]', $out );
66 $this->assertContains( '[stacktrace]', $out );
67 }
68 }