Merge "Provide direction hinting in the personal toolbar"
[lhc/web/wiklou.git] / tests / phpunit / includes / exception / BadTitleErrorTest.php
1 <?php
2 /**
3 * @covers BadTitleError
4 * @author Adam Shorland
5 */
6 class BadTitleErrorTest extends MediaWikiTestCase {
7
8 protected $wgOut;
9
10 protected function setUp() {
11 parent::setUp();
12 global $wgOut;
13 $this->wgOut = clone $wgOut;
14 }
15
16 protected function tearDown() {
17 parent::tearDown();
18 global $wgOut;
19 $wgOut = $this->wgOut;
20 }
21
22 public function testExceptionSetsStatusCode() {
23 global $wgOut;
24 $wgOut = $this->getMockWgOut();
25 try{
26 throw new BadTitleError();
27 }
28 catch( BadTitleError $e ) {
29 $e->report();
30 $this->assertTrue( true );
31 }
32 }
33
34 private function getMockWgOut() {
35 $mock = $this->getMockBuilder( 'OutputPage' )
36 ->disableOriginalConstructor()
37 ->getMock();
38 $mock->expects( $this->once() )
39 ->method( 'setStatusCode' )
40 ->with( 400 );
41 return $mock;
42 }
43
44 }