Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5979593
UserBlockedErrorTest.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
UserBlockedErrorTest.php
View Options
<?php
use
MediaWiki\Block\AbstractBlock
;
use
MediaWiki\Block\BlockErrorFormatter
;
use
MediaWiki\Context\RequestContext
;
use
MediaWiki\Language\FormatterFactory
;
use
MediaWiki\Language\Language
;
use
MediaWiki\Language\RawMessage
;
use
MediaWiki\User\UserIdentity
;
/**
* @covers \UserBlockedError
*/
class
UserBlockedErrorTest
extends
MediaWikiIntegrationTestCase
{
private
function
setUpMockBlockFormatter
(
$expectedBlock
,
$expectedUser
,
$expectedLanguage
,
$expectedIp
,
$returnMessages
)
{
$mockBlockErrorFormatter
=
$this
->
createMock
(
BlockErrorFormatter
::
class
);
$mockBlockErrorFormatter
->
expects
(
$this
->
once
()
)
->
method
(
'getMessages'
)
->
with
(
$expectedBlock
,
$expectedUser
,
$expectedIp
)
->
willReturn
(
$returnMessages
);
$formatterFactory
=
$this
->
createNoOpMock
(
FormatterFactory
::
class
,
[
'getBlockErrorFormatter'
]
);
$formatterFactory
->
method
(
'getBlockErrorFormatter'
)->
willReturn
(
$mockBlockErrorFormatter
);
$this
->
setService
(
'FormatterFactory'
,
$formatterFactory
);
}
public
function
testConstructionProvidedOnlyBlockParameter
()
{
$context
=
RequestContext
::
getMain
();
$block
=
$this
->
createMock
(
AbstractBlock
::
class
);
$this
->
setUpMockBlockFormatter
(
$block
,
$context
->
getUser
(),
$context
->
getLanguage
(),
$context
->
getRequest
()->
getIP
(),
[
new
RawMessage
(
'testing'
)
]
);
$e
=
new
UserBlockedError
(
$block
);
$this
->
assertSame
(
(
new
RawMessage
(
'testing'
)
)->
text
(),
$e
->
getMessageObject
()->
text
(),
'UserBlockedError did not use the expected message.'
);
}
public
function
testConstructionProvidedAllParametersWithMultipleBlockMessages
()
{
$mockUser
=
$this
->
createMock
(
UserIdentity
::
class
);
$mockLanguage
=
$this
->
createMock
(
Language
::
class
);
$block
=
$this
->
createMock
(
AbstractBlock
::
class
);
$this
->
setUpMockBlockFormatter
(
$block
,
$mockUser
,
$mockLanguage
,
'1.2.3.4'
,
[
new
RawMessage
(
'testing'
),
new
RawMessage
(
'testing2'
)
]
);
$e
=
new
UserBlockedError
(
$block
,
$mockUser
,
$mockLanguage
,
'1.2.3.4'
);
$this
->
assertSame
(
"* testing
\n
* testing2"
,
$e
->
getMessageObject
()->
text
(),
'UserBlockedError did not use the expected message.'
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Oct 3, 20:59 (5 d, 1 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
d9/fe/01e70d21038f86fdd507ccc33371
Default Alt Text
UserBlockedErrorTest.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment