blob: bdb143faaf2e7f3087fa23fb437e8af0a8fe57a1 (
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
<?php
/**
* @covers ThrottledError
* @author Adam Shorland
*/
class ThrottledErrorTest extends MediaWikiTestCase {
protected $wgOut;
protected function setUp() {
parent::setUp();
global $wgOut;
$this->wgOut = clone $wgOut;
}
protected function tearDown() {
parent::tearDown();
global $wgOut;
$wgOut = $this->wgOut;
}
public function testExceptionSetsStatusCode() {
global $wgOut;
$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;
}
}
|