MediaWiki REL1_32
ThrottledErrorTest.php
Go to the documentation of this file.
1<?php
2
8
9 public function testExceptionSetsStatusCode() {
10 $this->setMwGlobals( 'wgOut', $this->getMockWgOut() );
11 try {
12 throw new ThrottledError();
13 } catch ( ThrottledError $e ) {
14 ob_start();
15 $e->report();
16 $text = ob_get_clean();
17 $this->assertContains( $e->getText(), $text );
18 }
19 }
20
21 private function getMockWgOut() {
22 $mock = $this->getMockBuilder( OutputPage::class )
23 ->disableOriginalConstructor()
24 ->getMock();
25 $mock->expects( $this->once() )
26 ->method( 'setStatusCode' )
27 ->with( 429 );
28 return $mock;
29 }
30
31}
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
Show an error when the user hits a rate limit.
returning false will NOT prevent logging $e
Definition hooks.txt:2226