wiki.techinc.nl/tests/phpunit/includes/exception/ThrottledErrorTest.php
DannyS712 fcecd9c5e4 Remove sepate getMockWgOut() method in exception tests
Single use method in both BadTitleErrorTest and ThrottledErrorTest,
merge into only place that needs it

Change-Id: I1a5c2ed2ac76ae821758d50b7d6378acb98af861
2021-03-08 03:54:14 +00:00

28 lines
616 B
PHP

<?php
/**
* @covers ThrottledError
* @author Addshore
*/
class ThrottledErrorTest extends MediaWikiIntegrationTestCase {
public function testExceptionSetsStatusCode() {
$mockOut = $this->getMockBuilder( OutputPage::class )
->disableOriginalConstructor()
->getMock();
$mockOut->expects( $this->once() )
->method( 'setStatusCode' )
->with( 429 );
$this->setMwGlobals( 'wgOut', $mockOut );
try {
throw new ThrottledError();
} catch ( ThrottledError $e ) {
ob_start();
$e->report();
$text = ob_get_clean();
$this->assertStringContainsString( $e->getText(), $text );
}
}
}