Merge "Title: Refactor JS/CSS page handling to be more sane"
[lhc/web/wiklou.git] / tests / phpunit / includes / exception / BadTitleErrorTest.php
1 <?php
2 /**
3 * @covers BadTitleError
4 * @author Addshore
5 */
6 class BadTitleErrorTest extends MediaWikiTestCase {
7
8 public function testExceptionSetsStatusCode() {
9 $this->setMwGlobals( 'wgOut', $this->getMockWgOut() );
10 try {
11 throw new BadTitleError();
12 } catch ( BadTitleError $e ) {
13 ob_start();
14 $e->report();
15 $text = ob_get_clean();
16 $this->assertContains( $e->getText(), $text );
17 }
18 }
19
20 private function getMockWgOut() {
21 $mock = $this->getMockBuilder( OutputPage::class )
22 ->disableOriginalConstructor()
23 ->getMock();
24 $mock->expects( $this->once() )
25 ->method( 'setStatusCode' )
26 ->with( 400 );
27 return $mock;
28 }
29
30 }