wiki.techinc.nl/tests/phpunit/includes/exception/BadTitleErrorTest.php
addshore ceabf35c40 Add test for BadTitleError exception
Change-Id: Ib7c5b9f385aa3fc3e68c55927b0cd5adc82ac1d1
2014-02-25 22:35:48 +01:00

44 lines
803 B
PHP

<?php
/**
* @covers BadTitleError
* @author Adam Shorland
*/
class BadTitleErrorTest extends MediaWikiTestCase {
protected $wgOut;
protected function setUp() {
parent::setUp();
global $wgOut;
$this->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;
}
}