Add test for ThrottledError exception

Change-Id: Ia98d6c24ce56c6707a67498e26107250d427a3bf
This commit is contained in:
addshore 2014-02-25 20:07:06 +01:00
parent 6c5b246ab7
commit 87aee66672

View 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;
}
}