From 87aee66672377f4031bbaab2a71bc24adc857109 Mon Sep 17 00:00:00 2001 From: addshore Date: Tue, 25 Feb 2014 20:07:06 +0100 Subject: [PATCH] Add test for ThrottledError exception Change-Id: Ia98d6c24ce56c6707a67498e26107250d427a3bf --- .../includes/exception/ThrottledErrorTest.php | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 tests/phpunit/includes/exception/ThrottledErrorTest.php 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; + } + +} -- 2.20.1