2014-02-25 19:07:06 +00:00
|
|
|
<?php
|
|
|
|
|
|
2023-09-05 17:31:53 +00:00
|
|
|
use MediaWiki\Output\OutputPage;
|
|
|
|
|
|
2014-02-25 19:07:06 +00:00
|
|
|
/**
|
|
|
|
|
* @covers ThrottledError
|
2016-01-27 09:59:31 +00:00
|
|
|
* @author Addshore
|
2014-02-25 19:07:06 +00:00
|
|
|
*/
|
2020-06-30 15:09:24 +00:00
|
|
|
class ThrottledErrorTest extends MediaWikiIntegrationTestCase {
|
2014-02-25 19:07:06 +00:00
|
|
|
|
|
|
|
|
public function testExceptionSetsStatusCode() {
|
2022-07-14 12:42:07 +00:00
|
|
|
$mockOut = $this->createMock( OutputPage::class );
|
2021-03-08 03:51:21 +00:00
|
|
|
$mockOut->expects( $this->once() )
|
|
|
|
|
->method( 'setStatusCode' )
|
|
|
|
|
->with( 429 );
|
|
|
|
|
$this->setMwGlobals( 'wgOut', $mockOut );
|
|
|
|
|
|
2014-03-20 18:59:20 +00:00
|
|
|
try {
|
2014-02-25 19:07:06 +00:00
|
|
|
throw new ThrottledError();
|
2014-03-20 18:59:20 +00:00
|
|
|
} catch ( ThrottledError $e ) {
|
2018-02-14 18:01:19 +00:00
|
|
|
ob_start();
|
2014-02-25 19:07:06 +00:00
|
|
|
$e->report();
|
2018-02-14 18:01:19 +00:00
|
|
|
$text = ob_get_clean();
|
2023-12-14 16:28:48 +00:00
|
|
|
$this->expectDeprecationAndContinue( '/MWException::getText was deprecated/' );
|
2019-12-14 12:22:50 +00:00
|
|
|
$this->assertStringContainsString( $e->getText(), $text );
|
2014-02-25 19:07:06 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|