From: addshore Date: Tue, 25 Feb 2014 19:07:06 +0000 (+0100) Subject: Add test for ThrottledError exception X-Git-Tag: 1.31.0-rc.0~16818^2 X-Git-Url: http://git.cyclocoop.org/clavettes/images/siteon3.jpg?a=commitdiff_plain;h=87aee66672377f4031bbaab2a71bc24adc857109;p=lhc%2Fweb%2Fwiklou.git Add test for ThrottledError exception Change-Id: Ia98d6c24ce56c6707a67498e26107250d427a3bf --- diff --git a/tests/phpunit/includes/exception/ThrottledErrorTest.php b/tests/phpunit/includes/exception/ThrottledErrorTest.php new file mode 100644 index 0000000000..ca6724192e --- /dev/null +++ b/tests/phpunit/includes/exception/ThrottledErrorTest.php @@ -0,0 +1,45 @@ +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; + } + +}