Merge "Fix "UTPage" creation in tests"
[lhc/web/wiklou.git] / tests / phpunit / includes / exception / ErrorPageErrorTest.php
1 <?php
2
3 /**
4 * @covers ErrorPageError
5 * @author Adam Shorland
6 */
7 class ErrorPageErrorTest extends MediaWikiTestCase {
8
9 private $wgOut;
10
11 protected function setUp() {
12 parent::setUp();
13 global $wgOut;
14 $this->wgOut = clone $wgOut;
15 }
16
17 protected function tearDown() {
18 global $wgOut;
19 $wgOut = $this->wgOut;
20 parent::tearDown();
21 }
22
23 private function getMockMessage() {
24 $mockMessage = $this->getMockBuilder( 'Message' )
25 ->disableOriginalConstructor()
26 ->getMock();
27 $mockMessage->expects( $this->once() )
28 ->method( 'inLanguage' )
29 ->will( $this->returnValue( $mockMessage ) );
30 $mockMessage->expects( $this->once() )
31 ->method( 'useDatabase' )
32 ->will( $this->returnValue( $mockMessage ) );
33 return $mockMessage;
34 }
35
36 public function testConstruction() {
37 $mockMessage = $this->getMockMessage();
38 $title = 'Foo';
39 $params = array( 'Baz' );
40 $e = new ErrorPageError( $title, $mockMessage, $params );
41 $this->assertEquals( $title, $e->title );
42 $this->assertEquals( $mockMessage, $e->msg );
43 $this->assertEquals( $params, $e->params );
44 }
45
46 public function testReport() {
47 $mockMessage = $this->getMockMessage();
48 $title = 'Foo';
49 $params = array( 'Baz' );
50
51 global $wgOut;
52 $wgOut = $this->getMockBuilder( 'OutputPage' )
53 ->disableOriginalConstructor()
54 ->getMock();
55 $wgOut->expects( $this->once() )
56 ->method( 'showErrorPage' )
57 ->with( $title, $mockMessage, $params );
58 $wgOut->expects( $this->once() )
59 ->method( 'output' );
60
61 $e = new ErrorPageError( $title, $mockMessage, $params );
62 $e->report();
63 }
64
65
66
67 }