MediaWiki REL1_32
LineFormatterTest.php
Go to the documentation of this file.
1<?php
22
23use InvalidArgumentException;
24use LengthException;
25use LogicException;
27use Wikimedia\TestingAccessWrapper;
28
30
31 protected function setUp() {
32 if ( !class_exists( 'Monolog\Formatter\LineFormatter' ) ) {
33 $this->markTestSkipped( 'This test requires monolog to be installed' );
34 }
35 parent::setUp();
36 }
37
42 $fixture = new LineFormatter();
43 $fixture->includeStacktraces( false );
44 $fixture = TestingAccessWrapper::newFromObject( $fixture );
45 $boom = new InvalidArgumentException( 'boom', 0,
46 new LengthException( 'too long', 0,
47 new LogicException( 'Spock wuz here' )
48 )
49 );
50 $out = $fixture->normalizeException( $boom );
51 $this->assertContains( "\n[Exception InvalidArgumentException]", $out );
52 $this->assertContains( "\nCaused by: [Exception LengthException]", $out );
53 $this->assertContains( "\nCaused by: [Exception LogicException]", $out );
54 $this->assertNotContains( "\n #0", $out );
55 }
56
60 public function testNormalizeExceptionTrace() {
61 $fixture = new LineFormatter();
62 $fixture->includeStacktraces( true );
63 $fixture = TestingAccessWrapper::newFromObject( $fixture );
64 $boom = new InvalidArgumentException( 'boom', 0,
65 new LengthException( 'too long', 0,
66 new LogicException( 'Spock wuz here' )
67 )
68 );
69 $out = $fixture->normalizeException( $boom );
70 $this->assertContains( "\n[Exception InvalidArgumentException]", $out );
71 $this->assertContains( "\nCaused by: [Exception LengthException]", $out );
72 $this->assertContains( "\nCaused by: [Exception LogicException]", $out );
73 $this->assertContains( "\n #0", $out );
74 }
75}
testNormalizeExceptionTrace()
MediaWiki\Logger\Monolog\LineFormatter::normalizeException.
testNormalizeExceptionNoTrace()
MediaWiki\Logger\Monolog\LineFormatter::normalizeException.
Formats incoming records into a one-line string.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Definition hooks.txt:894