From: addshore Date: Tue, 25 Feb 2014 19:09:17 +0000 (+0100) Subject: Add test for BadTitleError exception X-Git-Tag: 1.31.0-rc.0~16817^2 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations/gestion/rappel_supprimer.php?a=commitdiff_plain;h=ceabf35c402c8f62381d2bf2f81338290003a5cf;p=lhc%2Fweb%2Fwiklou.git Add test for BadTitleError exception Change-Id: Ib7c5b9f385aa3fc3e68c55927b0cd5adc82ac1d1 --- diff --git a/tests/phpunit/includes/exception/BadTitleErrorTest.php b/tests/phpunit/includes/exception/BadTitleErrorTest.php new file mode 100644 index 0000000000..6f9804dab4 --- /dev/null +++ b/tests/phpunit/includes/exception/BadTitleErrorTest.php @@ -0,0 +1,44 @@ +wgOut = clone $wgOut; + } + + protected function tearDown() { + parent::tearDown(); + global $wgOut; + $wgOut = $this->wgOut; + } + + public function testExceptionSetsStatusCode() { + global $wgOut; + $wgOut = $this->getMockWgOut(); + try{ + throw new BadTitleError(); + } + catch( BadTitleError $e ) { + $e->report(); + $this->assertTrue( true ); + } + } + + private function getMockWgOut() { + $mock = $this->getMockBuilder( 'OutputPage' ) + ->disableOriginalConstructor() + ->getMock(); + $mock->expects( $this->once() ) + ->method( 'setStatusCode' ) + ->with( 400 ); + return $mock; + } + +}