Merge "Add tests for API's assert={user|bot}"
[lhc/web/wiklou.git] / tests / phpunit / includes / exception / ThrottledErrorTest.php
1 <?php
2
3 /**
4 * @covers ThrottledError
5 * @author Adam Shorland
6 */
7 class ThrottledErrorTest extends MediaWikiTestCase {
8
9 protected $wgOut;
10
11 protected function setUp() {
12 parent::setUp();
13 global $wgOut;
14 $this->wgOut = clone $wgOut;
15 }
16
17 protected function tearDown() {
18 parent::tearDown();
19 global $wgOut;
20 $wgOut = $this->wgOut;
21 }
22
23 public function testExceptionSetsStatusCode() {
24 global $wgOut;
25 $wgOut = $this->getMockWgOut();
26 try {
27 throw new ThrottledError();
28 } catch ( ThrottledError $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( 429 );
41 return $mock;
42 }
43
44 }