MediaWiki
REL1_31
ThrottledErrorTest.php
Go to the documentation of this file.
1
<?php
2
7
class
ThrottledErrorTest
extends
MediaWikiTestCase
{
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
}
MediaWikiTestCase
Definition
MediaWikiTestCase.php:17
MediaWikiTestCase\setMwGlobals
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
Definition
MediaWikiTestCase.php:678
ThrottledErrorTest
ThrottledError.
Definition
ThrottledErrorTest.php:7
ThrottledErrorTest\testExceptionSetsStatusCode
testExceptionSetsStatusCode()
Definition
ThrottledErrorTest.php:9
ThrottledErrorTest\getMockWgOut
getMockWgOut()
Definition
ThrottledErrorTest.php:21
ThrottledError
Show an error when the user hits a rate limit.
Definition
ThrottledError.php:27
$e
returning false will NOT prevent logging $e
Definition
hooks.txt:2176
tests
phpunit
includes
exception
ThrottledErrorTest.php
Generated on Mon Nov 25 2024 15:36:21 for MediaWiki by
1.10.0