Merge "Revert "selenium: add new message banner test to user spec""
[lhc/web/wiklou.git] / tests / phpunit / includes / exception / ErrorPageErrorTest.php
1 <?php
2
3 /**
4 * @covers ErrorPageError
5 * @author Addshore
6 */
7 class ErrorPageErrorTest extends MediaWikiTestCase {
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 }