This helps to find renamed or misspelled classes earlier. Phan will check the class names Change-Id: Ie541a7baae10ab6f5c13f95ac2ff6598b8f8950c
52 lines
1.4 KiB
PHP
52 lines
1.4 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @covers ErrorPageError
|
|
* @author Addshore
|
|
*/
|
|
class ErrorPageErrorTest extends MediaWikiTestCase {
|
|
|
|
private function getMockMessage() {
|
|
$mockMessage = $this->getMockBuilder( Message::class )
|
|
->disableOriginalConstructor()
|
|
->getMock();
|
|
$mockMessage->expects( $this->once() )
|
|
->method( 'inLanguage' )
|
|
->will( $this->returnValue( $mockMessage ) );
|
|
$mockMessage->expects( $this->once() )
|
|
->method( 'useDatabase' )
|
|
->will( $this->returnValue( $mockMessage ) );
|
|
return $mockMessage;
|
|
}
|
|
|
|
public function testConstruction() {
|
|
$mockMessage = $this->getMockMessage();
|
|
$title = 'Foo';
|
|
$params = [ 'Baz' ];
|
|
$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';
|
|
$params = [ 'Baz' ];
|
|
|
|
$mock = $this->getMockBuilder( OutputPage::class )
|
|
->disableOriginalConstructor()
|
|
->getMock();
|
|
$mock->expects( $this->once() )
|
|
->method( 'showErrorPage' )
|
|
->with( $title, $mockMessage, $params );
|
|
$mock->expects( $this->once() )
|
|
->method( 'output' );
|
|
$this->setMwGlobals( 'wgOut', $mock );
|
|
$this->setMwGlobals( 'wgCommandLineMode', false );
|
|
|
|
$e = new ErrorPageError( $title, $mockMessage, $params );
|
|
$e->report();
|
|
}
|
|
|
|
}
|