2014-02-27 00:00:17 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @covers ErrorPageError
|
2016-01-27 09:59:31 +00:00
|
|
|
* @author Addshore
|
2014-02-27 00:00:17 +00:00
|
|
|
*/
|
|
|
|
|
class ErrorPageErrorTest extends MediaWikiTestCase {
|
|
|
|
|
|
|
|
|
|
private function getMockMessage() {
|
2018-01-13 00:02:09 +00:00
|
|
|
$mockMessage = $this->getMockBuilder( Message::class )
|
2014-02-27 00:00:17 +00:00
|
|
|
->disableOriginalConstructor()
|
|
|
|
|
->getMock();
|
|
|
|
|
$mockMessage->expects( $this->once() )
|
|
|
|
|
->method( 'inLanguage' )
|
|
|
|
|
->will( $this->returnValue( $mockMessage ) );
|
2014-03-20 18:59:20 +00:00
|
|
|
$mockMessage->expects( $this->once() )
|
2014-02-27 00:00:17 +00:00
|
|
|
->method( 'useDatabase' )
|
|
|
|
|
->will( $this->returnValue( $mockMessage ) );
|
|
|
|
|
return $mockMessage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testConstruction() {
|
|
|
|
|
$mockMessage = $this->getMockMessage();
|
|
|
|
|
$title = 'Foo';
|
2016-02-17 09:09:32 +00:00
|
|
|
$params = [ 'Baz' ];
|
2014-02-27 00:00:17 +00:00
|
|
|
$e = new ErrorPageError( $title, $mockMessage, $params );
|
|
|
|
|
$this->assertEquals( $title, $e->title );
|
|
|
|
|
$this->assertEquals( $mockMessage, $e->msg );
|
|
|
|
|
$this->assertEquals( $params, $e->params );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testReport() {
|
|
|
|
|
$mockMessage = $this->getMockMessage();
|
|
|
|
|
$title = 'Foo';
|
2016-02-17 09:09:32 +00:00
|
|
|
$params = [ 'Baz' ];
|
2014-02-27 00:00:17 +00:00
|
|
|
|
2018-01-13 00:02:09 +00:00
|
|
|
$mock = $this->getMockBuilder( OutputPage::class )
|
2014-02-27 00:00:17 +00:00
|
|
|
->disableOriginalConstructor()
|
|
|
|
|
->getMock();
|
2014-11-06 20:17:20 +00:00
|
|
|
$mock->expects( $this->once() )
|
2014-02-27 00:00:17 +00:00
|
|
|
->method( 'showErrorPage' )
|
|
|
|
|
->with( $title, $mockMessage, $params );
|
2014-11-06 20:17:20 +00:00
|
|
|
$mock->expects( $this->once() )
|
2014-02-27 00:00:17 +00:00
|
|
|
->method( 'output' );
|
2014-11-06 20:17:20 +00:00
|
|
|
$this->setMwGlobals( 'wgOut', $mock );
|
2017-07-06 19:42:11 +00:00
|
|
|
$this->setMwGlobals( 'wgCommandLineMode', false );
|
2014-02-27 00:00:17 +00:00
|
|
|
|
|
|
|
|
$e = new ErrorPageError( $title, $mockMessage, $params );
|
|
|
|
|
$e->report();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|