Mwalker has submitted this change and it was merged.

Change subject: Add test for ThrottledError exception
......................................................................


Add test for ThrottledError exception

Change-Id: Ia98d6c24ce56c6707a67498e26107250d427a3bf
---
A tests/phpunit/includes/exception/ThrottledErrorTest.php
1 file changed, 45 insertions(+), 0 deletions(-)

Approvals:
  Mwalker: Looks good to me, approved



diff --git a/tests/phpunit/includes/exception/ThrottledErrorTest.php 
b/tests/phpunit/includes/exception/ThrottledErrorTest.php
new file mode 100644
index 0000000..ca67241
--- /dev/null
+++ b/tests/phpunit/includes/exception/ThrottledErrorTest.php
@@ -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;
+       }
+
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/115421
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia98d6c24ce56c6707a67498e26107250d427a3bf
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: Hashar <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Mwalker <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to