createMock() does the same, but is much easier to read. A small difference is that some of the replacements made in this patch didn't use disableOriginalConstructor() before. In case this was relevant we should see the respective test fail. If not we can save some CPU cycles and skip these constructors. Change-Id: Ib98fb06e0fe753b7a53cb087a47e1159515a8ad5
37 lines
960 B
PHP
37 lines
960 B
PHP
<?php
|
|
|
|
/**
|
|
* @covers ErrorPageError
|
|
* @author Addshore
|
|
*/
|
|
class ErrorPageErrorTest extends MediaWikiIntegrationTestCase {
|
|
|
|
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->createMock( OutputPage::class );
|
|
$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();
|
|
}
|
|
|
|
}
|