MediaWiki REL1_32
ErrorPageErrorTest.php
Go to the documentation of this file.
1<?php
2
8
9 private function getMockMessage() {
10 $mockMessage = $this->getMockBuilder( Message::class )
11 ->disableOriginalConstructor()
12 ->getMock();
13 $mockMessage->expects( $this->once() )
14 ->method( 'inLanguage' )
15 ->will( $this->returnValue( $mockMessage ) );
16 $mockMessage->expects( $this->once() )
17 ->method( 'useDatabase' )
18 ->will( $this->returnValue( $mockMessage ) );
19 return $mockMessage;
20 }
21
22 public function testConstruction() {
23 $mockMessage = $this->getMockMessage();
24 $title = 'Foo';
25 $params = [ 'Baz' ];
26 $e = new ErrorPageError( $title, $mockMessage, $params );
27 $this->assertEquals( $title, $e->title );
28 $this->assertEquals( $mockMessage, $e->msg );
29 $this->assertEquals( $params, $e->params );
30 }
31
32 public function testReport() {
33 $mockMessage = $this->getMockMessage();
34 $title = 'Foo';
35 $params = [ 'Baz' ];
36
37 $mock = $this->getMockBuilder( OutputPage::class )
38 ->disableOriginalConstructor()
39 ->getMock();
40 $mock->expects( $this->once() )
41 ->method( 'showErrorPage' )
42 ->with( $title, $mockMessage, $params );
43 $mock->expects( $this->once() )
44 ->method( 'output' );
45 $this->setMwGlobals( 'wgOut', $mock );
46 $this->setMwGlobals( 'wgCommandLineMode', false );
47
48 $e = new ErrorPageError( $title, $mockMessage, $params );
49 $e->report();
50 }
51
52}
An error page which can definitely be safely rendered using the OutputPage.
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
returning false will NOT prevent logging $e
Definition hooks.txt:2226
$params