MediaWiki  REL1_24
ErrorPageErrorTest.php
Go to the documentation of this file.
00001 <?php
00002 
00007 class ErrorPageErrorTest extends MediaWikiTestCase {
00008 
00009     private $wgOut;
00010 
00011     protected function setUp() {
00012         parent::setUp();
00013         global $wgOut;
00014         $this->wgOut = clone $wgOut;
00015     }
00016 
00017     protected function tearDown() {
00018         global $wgOut;
00019         $wgOut = $this->wgOut;
00020         parent::tearDown();
00021     }
00022 
00023     private function getMockMessage() {
00024         $mockMessage = $this->getMockBuilder( 'Message' )
00025             ->disableOriginalConstructor()
00026             ->getMock();
00027         $mockMessage->expects( $this->once() )
00028             ->method( 'inLanguage' )
00029             ->will( $this->returnValue( $mockMessage ) );
00030         $mockMessage->expects( $this->once() )
00031             ->method( 'useDatabase' )
00032             ->will( $this->returnValue( $mockMessage ) );
00033         return $mockMessage;
00034     }
00035 
00036     public function testConstruction() {
00037         $mockMessage = $this->getMockMessage();
00038         $title = 'Foo';
00039         $params = array( 'Baz' );
00040         $e = new ErrorPageError( $title, $mockMessage, $params );
00041         $this->assertEquals( $title, $e->title );
00042         $this->assertEquals( $mockMessage, $e->msg );
00043         $this->assertEquals( $params, $e->params );
00044     }
00045 
00046     public function testReport() {
00047         $mockMessage = $this->getMockMessage();
00048         $title = 'Foo';
00049         $params = array( 'Baz' );
00050 
00051         global $wgOut;
00052         $wgOut = $this->getMockBuilder( 'OutputPage' )
00053             ->disableOriginalConstructor()
00054             ->getMock();
00055         $wgOut->expects( $this->once() )
00056             ->method( 'showErrorPage' )
00057             ->with( $title, $mockMessage, $params );
00058         $wgOut->expects( $this->once() )
00059             ->method( 'output' );
00060 
00061         $e = new ErrorPageError( $title, $mockMessage, $params );
00062         $e->report();
00063     }
00064 
00065 
00066 
00067 }