MediaWiki
REL1_24
|
00001 <?php 00006 class BadTitleErrorTest extends MediaWikiTestCase { 00007 00008 protected $wgOut; 00009 00010 protected function setUp() { 00011 parent::setUp(); 00012 global $wgOut; 00013 $this->wgOut = clone $wgOut; 00014 } 00015 00016 protected function tearDown() { 00017 parent::tearDown(); 00018 global $wgOut; 00019 $wgOut = $this->wgOut; 00020 } 00021 00022 public function testExceptionSetsStatusCode() { 00023 global $wgOut; 00024 $wgOut = $this->getMockWgOut(); 00025 try { 00026 throw new BadTitleError(); 00027 } catch ( BadTitleError $e ) { 00028 $e->report(); 00029 $this->assertTrue( true ); 00030 } 00031 } 00032 00033 private function getMockWgOut() { 00034 $mock = $this->getMockBuilder( 'OutputPage' ) 00035 ->disableOriginalConstructor() 00036 ->getMock(); 00037 $mock->expects( $this->once() ) 00038 ->method( 'setStatusCode' ) 00039 ->with( 400 ); 00040 return $mock; 00041 } 00042 00043 }