MediaWiki
REL1_31
ErrorPageErrorTest.php
Go to the documentation of this file.
1
<?php
2
7
class
ErrorPageErrorTest
extends
MediaWikiTestCase
{
8
9
private
function
getMockMessage
() {
10
$mockMessage = $this->getMockBuilder( Message::class )
11
->disableOriginalConstructor()
12
->getMock();
13
$mockMessage->expects( $this->once() )
14
->method(
'inLanguage'
)
15
->will( $this->returnValue( $mockMessage ) );
16
$mockMessage->expects( $this->once() )
17
->method(
'useDatabase'
)
18
->will( $this->returnValue( $mockMessage ) );
19
return
$mockMessage;
20
}
21
22
public
function
testConstruction
() {
23
$mockMessage = $this->
getMockMessage
();
24
$title =
'Foo'
;
25
$params
= [
'Baz'
];
26
$e
=
new
ErrorPageError
( $title, $mockMessage,
$params
);
27
$this->assertEquals( $title,
$e
->title );
28
$this->assertEquals( $mockMessage,
$e
->msg );
29
$this->assertEquals(
$params
,
$e
->params );
30
}
31
32
public
function
testReport
() {
33
$mockMessage = $this->
getMockMessage
();
34
$title =
'Foo'
;
35
$params
= [
'Baz'
];
36
37
$mock = $this->getMockBuilder( OutputPage::class )
38
->disableOriginalConstructor()
39
->getMock();
40
$mock->expects( $this->once() )
41
->method(
'showErrorPage'
)
42
->with( $title, $mockMessage,
$params
);
43
$mock->expects( $this->once() )
44
->method(
'output'
);
45
$this->
setMwGlobals
(
'wgOut'
, $mock );
46
$this->
setMwGlobals
(
'wgCommandLineMode'
,
false
);
47
48
$e
=
new
ErrorPageError
( $title, $mockMessage,
$params
);
49
$e
->report();
50
}
51
52
}
ErrorPageErrorTest
ErrorPageError.
Definition
ErrorPageErrorTest.php:7
ErrorPageErrorTest\getMockMessage
getMockMessage()
Definition
ErrorPageErrorTest.php:9
ErrorPageErrorTest\testConstruction
testConstruction()
Definition
ErrorPageErrorTest.php:22
ErrorPageErrorTest\testReport
testReport()
Definition
ErrorPageErrorTest.php:32
ErrorPageError
An error page which can definitely be safely rendered using the OutputPage.
Definition
ErrorPageError.php:27
MediaWikiTestCase
Definition
MediaWikiTestCase.php:17
MediaWikiTestCase\setMwGlobals
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
Definition
MediaWikiTestCase.php:678
$e
returning false will NOT prevent logging $e
Definition
hooks.txt:2176
$params
$params
Definition
styleTest.css.php:40
tests
phpunit
includes
exception
ErrorPageErrorTest.php
Generated on Mon Nov 25 2024 15:36:21 for MediaWiki by
1.10.0