Add test for ThrottledError exception
Change-Id: Ia98d6c24ce56c6707a67498e26107250d427a3bf
This commit is contained in:
parent
6c5b246ab7
commit
87aee66672
1 changed files with 45 additions and 0 deletions
45
tests/phpunit/includes/exception/ThrottledErrorTest.php
Normal file
45
tests/phpunit/includes/exception/ThrottledErrorTest.php
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<?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( 503 );
|
||||
return $mock;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in a new issue