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
25 lines
558 B
PHP
25 lines
558 B
PHP
<?php
|
|
/**
|
|
* @covers BadTitleError
|
|
* @author Addshore
|
|
*/
|
|
class BadTitleErrorTest extends MediaWikiIntegrationTestCase {
|
|
|
|
public function testExceptionSetsStatusCode() {
|
|
$mockOut = $this->createMock( OutputPage::class );
|
|
$mockOut->expects( $this->once() )
|
|
->method( 'setStatusCode' )
|
|
->with( 404 );
|
|
$this->setMwGlobals( 'wgOut', $mockOut );
|
|
|
|
try {
|
|
throw new BadTitleError();
|
|
} catch ( BadTitleError $e ) {
|
|
ob_start();
|
|
$e->report();
|
|
$text = ob_get_clean();
|
|
$this->assertStringContainsString( $e->getText(), $text );
|
|
}
|
|
}
|
|
|
|
}
|