Merge "Revert "Log the reason why revision->getContent() returns null""
[lhc/web/wiklou.git] / tests / phpunit / includes / exception / ThrottledErrorTest.php
1 <?php
2
3 /**
4 * @covers ThrottledError
5 * @author Addshore
6 */
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 }