MediaWiki  REL1_24
ThrottledErrorTest.php
Go to the documentation of this file.
00001 <?php
00002 
00007 class ThrottledErrorTest extends MediaWikiTestCase {
00008 
00009     protected $wgOut;
00010 
00011     protected function setUp() {
00012         parent::setUp();
00013         global $wgOut;
00014         $this->wgOut = clone $wgOut;
00015     }
00016 
00017     protected function tearDown() {
00018         parent::tearDown();
00019         global $wgOut;
00020         $wgOut = $this->wgOut;
00021     }
00022 
00023     public function testExceptionSetsStatusCode() {
00024         global $wgOut;
00025         $wgOut = $this->getMockWgOut();
00026         try {
00027             throw new ThrottledError();
00028         } catch ( ThrottledError $e ) {
00029             $e->report();
00030             $this->assertTrue( true );
00031         }
00032     }
00033 
00034     private function getMockWgOut() {
00035         $mock = $this->getMockBuilder( 'OutputPage' )
00036             ->disableOriginalConstructor()
00037             ->getMock();
00038         $mock->expects( $this->once() )
00039             ->method( 'setStatusCode' )
00040             ->with( 429 );
00041         return $mock;
00042     }
00043 
00044 }