Merge "Add test to validate special page aliases"
[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 }
29 catch( ThrottledError $e ) {
30 $e->report();
31 $this->assertTrue( true );
32 }
33 }
34
35 private function getMockWgOut() {
36 $mock = $this->getMockBuilder( 'OutputPage' )
37 ->disableOriginalConstructor()
38 ->getMock();
39 $mock->expects( $this->once() )
40 ->method( 'setStatusCode' )
41 ->with( 503 );
42 return $mock;
43 }
44
45 }