Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7435369
MessageUpdateParameterTest.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
MessageUpdateParameterTest.php
View Options
<?php
namespace
MediaWiki\Extension\Translate\Synchronization
;
use
MediaWiki\Title\Title
;
use
MediaWikiUnitTestCase
;
/** @covers \MediaWiki\Extension\Translate\Synchronization\MessageUpdateParameter */
class
MessageUpdateParameterTest
extends
MediaWikiUnitTestCase
{
/** @dataProvider provideSerializable */
public
function
testSerializable
(
string
$title
,
string
$content
,
bool
$isRename
,
string
$target
=
''
,
string
$replacement
=
''
,
bool
$isFuzzy
=
false
,
array
$otherLangs
=
[]
)
{
$job
=
$this
->
getJobFromInput
(
$title
,
$content
,
$isRename
,
$target
,
$replacement
,
$isFuzzy
,
$otherLangs
);
$messageParam
=
MessageUpdateParameter
::
createFromJob
(
$job
);
$serializedMessageParam
=
unserialize
(
serialize
(
$messageParam
)
);
$this
->
assertEquals
(
$messageParam
,
$serializedMessageParam
);
}
/** @dataProvider provideSerializable */
public
function
testCreateFromJob
(
string
$title
,
string
$content
,
bool
$isRename
,
string
$target
=
''
,
string
$replacement
=
''
,
bool
$isFuzzy
=
false
,
array
$otherLangs
=
[]
)
{
$job
=
$this
->
getJobFromInput
(
$title
,
$content
,
$isRename
,
$target
,
$replacement
,
$isFuzzy
,
$otherLangs
);
$messageParams
=
MessageUpdateParameter
::
createFromJob
(
$job
);
$this
->
assertEquals
(
$title
,
$messageParams
->
getPageName
()
);
$this
->
assertEquals
(
$content
,
$messageParams
->
getContent
()
);
$this
->
assertEquals
(
$isRename
,
$messageParams
->
isRename
()
);
$this
->
assertEquals
(
$isFuzzy
,
$messageParams
->
isFuzzy
()
);
if
(
$isRename
)
{
$this
->
assertEquals
(
$target
,
$messageParams
->
getTargetValue
()
);
$this
->
assertEquals
(
$replacement
,
$messageParams
->
getReplacementValue
()
);
$this
->
assertEquals
(
$otherLangs
,
$messageParams
->
getOtherLangs
()
);
}
else
{
$this
->
assertNull
(
$messageParams
->
getOtherLangs
()
);
}
}
private
function
getJobFromInput
(
string
$title
,
string
$content
,
bool
$isRename
,
string
$target
,
string
$replacement
,
bool
$isFuzzy
,
array
$otherLangs
):
UpdateMessageJob
{
$title
=
Title
::
makeTitle
(
NS_MAIN
,
$title
);
if
(
$isRename
)
{
$job
=
UpdateMessageJob
::
newRenameJob
(
$title
,
$target
,
$replacement
,
$isFuzzy
,
$content
,
$otherLangs
);
}
else
{
$job
=
UpdateMessageJob
::
newJob
(
$title
,
$content
,
$isFuzzy
);
}
return
$job
;
}
public
static
function
provideSerializable
()
{
yield
[
'Normal_Job/en'
,
'Hello World!'
,
false
,
];
yield
[
'Rename_Job/en'
,
'Hello World - Rename!'
,
true
,
'target'
,
'replacement'
,
true
,
[
'hello'
=>
'world'
]
];
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Nov 22, 12:54 (1 h, 47 m ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
7e/91/b1e78d0bf21ae1f3275eed89fc96
Default Alt Text
MessageUpdateParameterTest.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment