summaryrefslogtreecommitdiff
path: root/tests/phpunit/includes/exception/ThrottledErrorTest.php
blob: a1cf84bc553aa4e3ad8ffa6030556b28e5e6fccc (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
29
<?php

/**
 * @covers ThrottledError
 * @author Adam Shorland
 */
class ThrottledErrorTest extends MediaWikiTestCase {

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

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

}