Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4055082
FakeQqxMessageLocalizer.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
FakeQqxMessageLocalizer.php
View Options
<?php
declare
(
strict_types
=
1
);
namespace
MediaWiki\Tests\Unit
;
use
LanguageQqx
;
use
MediaWiki\Language\Language
;
use
MediaWiki\Message\Message
;
use
MessageLocalizer
;
use
Wikimedia\Message\MessageSpecifier
;
/**
* A MessageLocalizer that does not make database/service calls, for use in unit tests
*
* To be used in a phpunit unit test like so:
*
* ```php
* $output = $this->createMock( OutputPage::class );
* $output->method( 'msg' )
* ->willReturnCallback( [ new FakeQqxMessageLocalizer(), 'msg' ] );
* ```
*
* @since 1.39.4
* @license GPL-2.0-or-later
*/
class
FakeQqxMessageLocalizer
implements
MessageLocalizer
{
/** @inheritDoc */
public
function
msg
(
$key
,
...
$params
):
Message
{
$message
=
new
class
(
$key
)
extends
Message
{
protected
function
fetchMessage
():
string
{
return
"($this->key$*)"
;
}
/** @inheritDoc */
public
static
function
newFromSpecifier
(
$value
)
{
if
(
$value
instanceof
MessageSpecifier
)
{
return
new
self
(
$value
);
}
return
parent
::
newFromSpecifier
(
$value
);
}
public
function
getLanguage
():
Language
{
return
new
class
()
extends
LanguageQqx
{
public
function
__construct
()
{
}
/** @inheritDoc */
public
function
getCode
():
string
{
return
'qqx'
;
}
/**
* Support using Message::numParam()
* @inheritDoc
*/
public
function
formatNum
(
$number
):
string
{
return
(
string
)
$number
;
}
};
}
public
function
getLanguageCode
():
string
{
return
'qqx'
;
}
public
function
inContentLanguage
():
Message
{
return
$this
;
}
/** @inheritDoc */
protected
function
transformText
(
$string
):
string
{
return
$string
;
}
};
if
(
$params
)
{
// we use ->params() instead of the $params constructor parameter
// because ->params() supports some additional calling conventions,
// which our callers might also have used
$message
->
params
(
...
$params
);
}
return
$message
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Aug 16 2026, 00:13 (12 w, 3 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
0a/6c/650cf1fd6bb5be6d07f28a3b7569
Default Alt Text
FakeQqxMessageLocalizer.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment