Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F3993985
GrantsLocalizationTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
GrantsLocalizationTest.php
View Options
<?php
namespace
MediaWiki\Tests\Integration\Permissions
;
use
MediaWiki\Html\Html
;
use
MediaWiki\Message\Message
;
use
MediaWiki\Permissions\GrantsLocalization
;
use
MediaWiki\SpecialPage\SpecialPage
;
use
MediaWikiIntegrationTestCase
;
use
Wikimedia\HtmlArmor\HtmlArmor
;
/**
* @author Zabe
*
* @covers \MediaWiki\Permissions\GrantsLocalization
*/
class
GrantsLocalizationTest
extends
MediaWikiIntegrationTestCase
{
private
GrantsLocalization
$grantsLocalization
;
protected
function
setUp
():
void
{
parent
::
setUp
();
$this
->
grantsLocalization
=
$this
->
getServiceContainer
()->
getGrantsLocalization
();
}
/**
* @dataProvider provideGrantDescriptions
*/
public
function
testGetGrantDescription
(
string
$grant
)
{
$message
=
new
Message
(
'grant-'
.
$grant
);
$this
->
assertSame
(
$message
->
text
(),
$this
->
grantsLocalization
->
getGrantDescription
(
$grant
)
);
$this
->
assertSame
(
$message
->
inLanguage
(
'de'
)->
text
(),
$this
->
grantsLocalization
->
getGrantDescription
(
$grant
,
'de'
)
);
}
public
static
function
provideGrantDescriptions
()
{
yield
[
'blockusers'
];
yield
[
'createeditmovepage'
];
yield
[
'delete'
];
}
public
function
testGetNonExistingGrantDescription
()
{
$message
=
(
new
Message
(
'grant-generic'
)
)->
params
(
'foo'
);
$this
->
assertSame
(
$message
->
text
(),
$this
->
grantsLocalization
->
getGrantDescription
(
'foo'
)
);
$this
->
assertSame
(
$message
->
inLanguage
(
'zh'
)->
text
(),
$this
->
grantsLocalization
->
getGrantDescription
(
'foo'
,
'zh'
)
);
}
public
function
testGetGrantDescriptions
()
{
$this
->
assertSame
(
[
'blockusers'
=>
(
new
Message
(
'grant-blockusers'
)
)->
inLanguage
(
'de'
)->
text
(),
'delete'
=>
(
new
Message
(
'grant-delete'
)
)->
inLanguage
(
'de'
)->
text
(),
],
$this
->
grantsLocalization
->
getGrantDescriptions
(
[
'blockusers'
,
'delete'
,
],
'de'
)
);
}
public
function
testGetGrantsLink
()
{
$this
->
assertSame
(
$this
->
getServiceContainer
()->
getLinkRenderer
()->
makeKnownLink
(
SpecialPage
::
getTitleFor
(
'Listgrants'
,
false
,
'delete'
),
new
HtmlArmor
(
(
new
Message
(
'grant-delete'
)
)->
escaped
()
.
' '
.
Html
::
element
(
'span'
,
[
'class'
=>
'mw-grant mw-grantriskgroup-vandalism'
],
(
new
Message
(
'grantriskgroup-vandalism'
)
)->
text
()
)
)
),
$this
->
grantsLocalization
->
getGrantsLink
(
'delete'
)
);
}
public
function
testGetGrantsWikiText
()
{
$this
->
assertSame
(
"*<span class=
\"
mw-grantgroup
\"
>Perform high volume activity</span>
\n
:High-volume (bot) access
\n\n
"
,
$this
->
grantsLocalization
->
getGrantsWikiText
(
[
'highvolume'
]
)
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Aug 14 2026, 03:35 (15 w, 6 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
1f/19/15fcde7fa8b93afc04953220f49f
Default Alt Text
GrantsLocalizationTest.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment