Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4086907
HooksTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
HooksTest.php
View Options
<?php
namespace
MediaWiki\Extension\MultimediaViewer\Tests
;
use
MediaWiki\Extension\MultimediaViewer\Hooks
;
use
MediaWiki\Output\OutputPage
;
use
MediaWiki\Skin\SkinTemplate
;
use
MediaWiki\Title\Title
;
use
MediaWikiIntegrationTestCase
;
/**
* @covers \MediaWiki\Extension\MultimediaViewer\Hooks
*/
class
HooksTest
extends
MediaWikiIntegrationTestCase
{
public
function
newHooksInstance
()
{
return
new
Hooks
(
$this
->
getServiceContainer
()->
getMainConfig
(),
$this
->
getServiceContainer
()->
getSpecialPageFactory
(),
$this
->
getServiceContainer
()->
getUserOptionsLookup
(),
null
);
}
public
static
function
provideOnBeforePageDisplay
()
{
return
[
'no files'
=>
[
'Main Page'
,
0
,
false
],
'with files'
=>
[
'Main Page'
,
1
,
true
],
'special with files'
=>
[
'Special:ListFiles'
,
0
,
true
],
'special no files'
=>
[
'Special:Watchlist'
,
0
,
false
],
];
}
/**
* @dataProvider provideOnBeforePageDisplay
*/
public
function
testOnBeforePageDisplay
(
$pagename
,
$fileCount
,
$modulesExpected
)
{
$t
=
Title
::
newFromText
(
$pagename
);
// Force content model to avoid DB queries
$t
->
setContentModel
(
CONTENT_MODEL_WIKITEXT
);
$skin
=
new
SkinTemplate
();
$output
=
$this
->
createMock
(
OutputPage
::
class
);
$output
->
method
(
'getTitle'
)->
willReturn
(
$t
);
$output
->
method
(
'getFileSearchOptions'
)->
willReturn
(
array_fill
(
0
,
$fileCount
,
null
)
);
$output
->
expects
(
$this
->
exactly
(
$modulesExpected
?
1
:
0
)
)->
method
(
'addModules'
);
$this
->
newHooksInstance
()->
onBeforePageDisplay
(
$output
,
$skin
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Aug 18 2026, 09:15 (6 w, 3 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
63/2e/3b4298e13fd338ea98c9d67813fb
Default Alt Text
HooksTest.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment