summaryrefslogtreecommitdiff
path: root/tests/phpunit/includes/exception/BadTitleErrorTest.php
blob: 500b7e48da88730e2649fa1133a85c2df85b3770 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
/**
 * @covers BadTitleError
 * @author Adam Shorland
 */
class BadTitleErrorTest extends MediaWikiTestCase {

	public function testExceptionSetsStatusCode() {
		$this->setMwGlobals( 'wgOut', $this->getMockWgOut() );
		try {
			throw new BadTitleError();
		} catch ( BadTitleError $e ) {
			$e->report();
			$this->assertTrue( true );
		}
	}

	private function getMockWgOut() {
		$mock = $this->getMockBuilder( 'OutputPage' )
			->disableOriginalConstructor()
			->getMock();
		$mock->expects( $this->once() )
			->method( 'setStatusCode' )
			->with( 400 );
		return $mock;
	}

}