MediaWiki REL1_31
BadTitleErrorTest.php
Go to the documentation of this file.
1<?php
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}
Show an error page on a badtitle.
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
returning false will NOT prevent logging $e
Definition hooks.txt:2176