| 1 |
<?php |
| 2 |
|
| 3 |
use MediaWiki\Output\OutputPage; |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
class ThrottledErrorTest extends MediaWikiIntegrationTestCase { |
| 10 |
|
| 11 |
public function testExceptionSetsStatusCode() { |
| 12 |
$mockOut = $this->createMock( OutputPage::class ); |
| 13 |
$mockOut->expects( $this->once() ) |
| 14 |
->method( 'setStatusCode' ) |
| 15 |
->with( 429 ); |
| 16 |
$this->setMwGlobals( 'wgOut', $mockOut ); |
| 17 |
|
| 18 |
try { |
| 19 |
throw new ThrottledError(); |
| 20 |
} catch ( ThrottledError $e ) { |
| 21 |
ob_start(); |
| 22 |
$e->report(); |
| 23 |
$text = ob_get_clean(); |
| 24 |
$this->assertStringContainsString( $e->getMessage(), $text ); |
| 25 |
} |
| 26 |
} |
| 27 |
|
| 28 |
} |