2014-02-25 19:09:17 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* @covers BadTitleError
|
2016-01-27 09:59:31 +00:00
|
|
|
* @author Addshore
|
2014-02-25 19:09:17 +00:00
|
|
|
*/
|
2020-06-30 15:09:24 +00:00
|
|
|
class BadTitleErrorTest extends MediaWikiIntegrationTestCase {
|
2014-02-25 19:09:17 +00:00
|
|
|
|
|
|
|
|
public function testExceptionSetsStatusCode() {
|
2021-03-08 03:51:21 +00:00
|
|
|
$mockOut = $this->getMockBuilder( OutputPage::class )
|
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
|
->getMock();
|
|
|
|
|
$mockOut->expects( $this->once() )
|
|
|
|
|
->method( 'setStatusCode' )
|
|
|
|
|
->with( 400 );
|
|
|
|
|
$this->setMwGlobals( 'wgOut', $mockOut );
|
|
|
|
|
|
2014-03-20 18:59:20 +00:00
|
|
|
try {
|
2014-02-25 19:09:17 +00:00
|
|
|
throw new BadTitleError();
|
2014-03-20 18:59:20 +00:00
|
|
|
} catch ( BadTitleError $e ) {
|
2018-02-14 18:01:19 +00:00
|
|
|
ob_start();
|
2014-02-25 19:09:17 +00:00
|
|
|
$e->report();
|
2018-02-14 18:01:19 +00:00
|
|
|
$text = ob_get_clean();
|
2019-12-14 12:22:50 +00:00
|
|
|
$this->assertStringContainsString( $e->getText(), $text );
|
2014-02-25 19:09:17 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|