diff options
Diffstat (limited to 'www/wiki/tests/phpunit/includes/exception/BadTitleErrorTest.php')
-rw-r--r-- | www/wiki/tests/phpunit/includes/exception/BadTitleErrorTest.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/www/wiki/tests/phpunit/includes/exception/BadTitleErrorTest.php b/www/wiki/tests/phpunit/includes/exception/BadTitleErrorTest.php new file mode 100644 index 00000000..b706face --- /dev/null +++ b/www/wiki/tests/phpunit/includes/exception/BadTitleErrorTest.php @@ -0,0 +1,30 @@ +<?php +/** + * @covers BadTitleError + * @author Addshore + */ +class BadTitleErrorTest extends MediaWikiTestCase { + + public function testExceptionSetsStatusCode() { + $this->setMwGlobals( 'wgOut', $this->getMockWgOut() ); + try { + throw new BadTitleError(); + } catch ( BadTitleError $e ) { + ob_start(); + $e->report(); + $text = ob_get_clean(); + $this->assertContains( $e->getText(), $text ); + } + } + + private function getMockWgOut() { + $mock = $this->getMockBuilder( OutputPage::class ) + ->disableOriginalConstructor() + ->getMock(); + $mock->expects( $this->once() ) + ->method( 'setStatusCode' ) + ->with( 400 ); + return $mock; + } + +} |