Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4142638
ApiBlockInfoTraitTest.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
ApiBlockInfoTraitTest.php
View Options
<?php
namespace
MediaWiki\Tests\Api
;
use
MediaWiki\Api\ApiBlockInfoTrait
;
use
MediaWiki\Block\CompositeBlock
;
use
MediaWiki\Block\DatabaseBlock
;
use
MediaWiki\Block\SystemBlock
;
use
MediaWiki\Tests\Unit\DummyServicesTrait
;
use
MediaWikiIntegrationTestCase
;
use
Wikimedia\TestingAccessWrapper
;
/**
* @covers \MediaWiki\Api\ApiBlockInfoTrait
*/
class
ApiBlockInfoTraitTest
extends
MediaWikiIntegrationTestCase
{
use
DummyServicesTrait
;
protected
function
setUp
():
void
{
parent
::
setUp
();
$this
->
setService
(
'DBLoadBalancerFactory'
,
$this
->
getDummyDBLoadBalancerFactory
()
);
}
/**
* @dataProvider provideGetBlockDetails
*/
public
function
testGetBlockDetails
(
$block
,
$expectedInfo
)
{
$language
=
$this
->
getServiceContainer
()->
getLanguageFactory
()->
getLanguage
(
'en'
);
$mock
=
$this
->
getMockForTrait
(
ApiBlockInfoTrait
::
class
);
$mock
->
method
(
'getLanguage'
)->
willReturn
(
$language
);
$info
=
TestingAccessWrapper
::
newFromObject
(
$mock
)->
getBlockDetails
(
$block
);
$subset
=
array_merge
(
[
'blockid'
=>
null
,
'blockedby'
=>
''
,
'blockedbyid'
=>
0
,
'blockreason'
=>
''
,
'blockexpiry'
=>
'infinite'
,
'blockemail'
=>
false
,
'blockowntalk'
=>
true
,
],
$expectedInfo
);
$this
->
assertArraySubmapSame
(
$subset
,
$info
,
"Matching block details"
);
}
public
static
function
provideGetBlockDetails
()
{
return
[
'Sitewide block'
=>
[
new
DatabaseBlock
(),
[
'blockpartial'
=>
false
],
],
'Partial block'
=>
[
new
DatabaseBlock
(
[
'sitewide'
=>
false
]
),
[
'blockpartial'
=>
true
],
],
'Email block'
=>
[
new
DatabaseBlock
(
[
'blockEmail'
=>
true
]
),
[
'blockemail'
=>
true
]
],
'System block'
=>
[
new
SystemBlock
(
[
'systemBlock'
=>
'proxy'
]
),
[
'systemblocktype'
=>
'proxy'
]
],
'Composite block'
=>
[
CompositeBlock
::
createFromBlocks
(
new
DatabaseBlock
(
[
'blockEmail'
=>
false
]
),
new
DatabaseBlock
(
[
'blockEmail'
=>
true
]
)
),
[
'blockemail'
=>
true
,
'blockreason'
=>
'There are multiple blocks against your account and/or IP address'
,
'blockcomponents'
=>
[
[
'blockemail'
=>
false
],
[
'blockemail'
=>
true
],
],
],
],
];
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Aug 19 2026, 16:27 (4 w, 2 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
5f/af/e8b4fc7f8ebeca46a564e8fd5678
Default Alt Text
ApiBlockInfoTraitTest.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment