Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4156095
CitationToolDefinitionTest.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
CitationToolDefinitionTest.php
View Options
<?php
namespace
Cite\Tests\Unit
;
use
Cite\ResourceLoader\CitationToolDefinition
;
use
MediaWiki\Message\Message
;
use
MediaWiki\ResourceLoader\Context
;
/**
* @covers \Cite\ResourceLoader\CitationToolDefinition
* @license GPL-2.0-or-later
*/
class
CitationToolDefinitionTest
extends
\MediaWikiUnitTestCase
{
public
function
testGetScript
()
{
$context
=
$this
->
createResourceLoaderContext
();
$expected
=
[
[
'name'
=>
'no-message'
,
'title'
=>
'Hard-coded title'
],
[
'name'
=>
'missing-message'
,
'title'
=>
'missing-message'
],
[
'name'
=>
'n'
,
'title'
=>
't'
],
];
$this
->
assertSame
(
've.ui.mwCitationTools = '
.
json_encode
(
$expected
)
.
';'
,
CitationToolDefinition
::
makeScript
(
$context
)
);
}
private
function
createResourceLoaderContext
():
Context
{
$definition
=
[
// We expect broken and incomplete entries to be skipped
[],
[
'name'
=>
''
],
[
'name'
=>
'no-message'
,
'title'
=>
'Hard-coded title'
],
[
'name'
=>
'missing-message'
],
[
'name'
=>
'n'
],
];
$msg
=
$this
->
createMock
(
Message
::
class
);
$msg
->
method
(
'inContentLanguage'
)
->
willReturnSelf
();
$msg
->
method
(
'plain'
)
->
willReturn
(
json_encode
(
$definition
)
);
$msg
->
method
(
'text'
)
->
willReturn
(
't'
);
$disabled
=
$this
->
createMock
(
Message
::
class
);
$disabled
->
method
(
'isDisabled'
)->
willReturn
(
true
);
$context
=
$this
->
createStub
(
Context
::
class
);
$context
->
method
(
'msg'
)
->
willReturnMap
(
[
[
'cite-tool-definition.json'
,
$msg
],
[
'visualeditor-cite-tool-definition.json'
,
$msg
],
[
'visualeditor-cite-tool-name-missing-message'
,
$disabled
],
[
'visualeditor-cite-tool-name-n'
,
$msg
]
]
);
$context
->
method
(
'encodeJson'
)->
willReturnCallback
(
'json_encode'
);
return
$context
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Aug 19 2026, 22:06 (8 w, 1 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
70/b7/8e0c5ade555b5b840a019fda6fdc
Default Alt Text
CitationToolDefinitionTest.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment