This patch adds two more commonly used methods for params/rawParams to getMockMessage and relocates the functionality to the MediaWikiTestCaseTrait. Follows-Up: Ia94521b786 Change-Id: If9a6ccf1885ba11fbf3fb1b586006118462c1410
39 lines
1,002 B
PHP
39 lines
1,002 B
PHP
<?php
|
|
|
|
/**
|
|
* @covers ErrorPageError
|
|
* @author Addshore
|
|
*/
|
|
class ErrorPageErrorTest extends MediaWikiTestCase {
|
|
|
|
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();
|
|
}
|
|
|
|
}
|