Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5987691
HooksTest.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
HooksTest.php
View Options
<?php
namespace
MediaWiki\Extension\Nuke\Test\Integration
;
use
MediaWiki\Extension\Nuke\Hooks
;
use
MediaWiki\Permissions\UltimateAuthority
;
use
MediaWiki\Specials\SpecialContributions
;
use
MediaWiki\Title\Title
;
use
MediaWikiIntegrationTestCase
;
/**
* @group Database
* @covers \MediaWiki\Extension\Nuke\Hooks
*/
class
HooksTest
extends
MediaWikiIntegrationTestCase
{
public
function
testNormal
()
{
$sysop
=
$this
->
getTestSysop
()->
getUser
();
$performer
=
new
UltimateAuthority
(
$sysop
);
$specialPage
=
$this
->
newSpecialContribsPage
();
$context
=
$specialPage
->
getContext
();
$context
->
setAuthority
(
$performer
);
$this
->
setUserLang
(
"qqx"
);
$tools
=
[];
(
new
Hooks
()
)->
onContributionsToolLinks
(
$sysop
->
getId
(),
$sysop
->
getUserPage
(),
$tools
,
$specialPage
);
$this
->
assertArrayHasKey
(
'nuke'
,
$tools
);
}
public
function
testNoPermission
()
{
$this
->
overrideConfigValues
(
[
"GroupPermissions"
=>
[
"testgroup"
=>
[
"nuke"
=>
false
,
"delete"
=>
true
]
]
]
);
$testUser
=
$this
->
getTestUser
(
[
"testgroup"
]
);
$specialPage
=
$this
->
newSpecialContribsPage
();
$context
=
$specialPage
->
getContext
();
$context
->
setAuthority
(
$testUser
->
getAuthority
()
);
$this
->
setUserLang
(
"qqx"
);
$tools
=
[];
(
new
Hooks
()
)->
onContributionsToolLinks
(
$testUser
->
getUser
()->
getId
(),
$testUser
->
getUser
()->
getUserPage
(),
$tools
,
$specialPage
);
$this
->
assertArrayNotHasKey
(
'nuke'
,
$tools
);
}
public
function
testIPRange
()
{
$sysop
=
$this
->
getTestSysop
()->
getUser
();
$performer
=
new
UltimateAuthority
(
$sysop
);
$specialPage
=
$this
->
newSpecialContribsPage
();
$context
=
$specialPage
->
getContext
();
$context
->
setAuthority
(
$performer
);
$this
->
setUserLang
(
"qqx"
);
$tools
=
[];
(
new
Hooks
()
)->
onContributionsToolLinks
(
0
,
Title
::
makeTitle
(
NS_USER
,
'127.0.0.1/24'
),
$tools
,
$specialPage
);
$this
->
assertArrayNotHasKey
(
'nuke'
,
$tools
);
}
private
function
newSpecialContribsPage
():
SpecialContributions
{
$services
=
$this
->
getServiceContainer
();
return
new
SpecialContributions
(
$services
->
getLinkBatchFactory
(),
$services
->
getPermissionManager
(),
$services
->
getDBLoadBalancerFactory
(),
$services
->
getRevisionStore
(),
$services
->
getNamespaceInfo
(),
$services
->
getUserNameUtils
(),
$services
->
getUserNamePrefixSearch
(),
$services
->
getUserOptionsLookup
(),
$services
->
getCommentFormatter
(),
$services
->
getUserFactory
(),
$services
->
getUserIdentityLookup
(),
$services
->
getDatabaseBlockStore
(),
$services
->
getTempUserConfig
()
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Oct 4, 00:32 (2 w, 6 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
ef/67/fa73dac0cfed115eb97457a244f4
Default Alt Text
HooksTest.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment