wiki.techinc.nl/tests/phpunit/includes/exception/ErrorPageErrorTest.php
Kosta Harlan 82cf3a3cfd Add getMockMessage to MediaWikiTestCaseTrait
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
2020-05-20 21:52:11 +02:00

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();
}
}