Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4113621
IniFormatTest.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
IniFormatTest.php
View Options
<?php
declare
(
strict_types
=
1
);
namespace
MediaWiki\Extension\Translate\FileFormatSupport
;
use
FileBasedMessageGroup
;
use
MediaWikiIntegrationTestCase
;
use
MessageGroupBase
;
use
MockMessageCollectionForExport
;
/**
* The IniFFS class is responsible for loading messages from .ini
* files, which are sometimes used for translations.
* @author Niklas Laxström
* @copyright Copyright © 2012-2013, Niklas Laxström
* @license GPL-2.0-or-later
*/
/** @covers MediaWiki\Extension\Translate\FileFormatSupport\IniFormat */
class
IniFormatTest
extends
MediaWikiIntegrationTestCase
{
private
array
$groupConfiguration
=
[
'BASIC'
=>
[
'class'
=>
FileBasedMessageGroup
::
class
,
'id'
=>
'test-id'
,
'label'
=>
'Test Label'
,
'namespace'
=>
'NS_MEDIAWIKI'
,
'description'
=>
'Test description'
,
],
'FILES'
=>
[
'format'
=>
'Ini'
,
'sourcePattern'
=>
'ignored'
,
],
];
public
function
testParsing
():
void
{
$file
=
file_get_contents
(
__DIR__
.
'/../data/IniFormatTest1.ini'
);
/** @var FileBasedMessageGroup $group */
$group
=
MessageGroupBase
::
factory
(
$this
->
groupConfiguration
);
$iniFormat
=
new
IniFormat
(
$group
);
$this
->
assertNotEmpty
(
$iniFormat
->
readFromVariable
(
$file
)[
'MESSAGES'
]
);
$parsed
=
$iniFormat
->
readFromVariable
(
$file
);
$expected
=
[
'hello'
=>
'Hello'
,
'world'
=>
'World!'
,
'all'
=>
'all = all'
,
'foo.bar'
=>
'bar'
,
'quote'
=>
"We're having fun?"
,
];
$expected
=
[
'MESSAGES'
=>
$expected
,
'AUTHORS'
=>
[
'The king of very small kingdom'
]
];
$this
->
assertEquals
(
$expected
,
$parsed
);
$invalidContent
=
'Invalid-Ini-Content'
;
$this
->
assertSame
(
[],
$iniFormat
->
readFromVariable
(
$invalidContent
)[
'MESSAGES'
]
);
}
public
function
testExport
():
void
{
global
$wgSitename
;
$file
=
file_get_contents
(
__DIR__
.
'/../data/IniFormatTest2.ini'
);
$file
=
str_replace
(
'$wgSitename'
,
$wgSitename
,
$file
);
$collection
=
new
MockMessageCollectionForExport
();
/** @var FileBasedMessageGroup $group */
$group
=
MessageGroupBase
::
factory
(
$this
->
groupConfiguration
);
$iniFormat
=
new
IniFormat
(
$group
);
$this
->
assertEquals
(
$file
,
$iniFormat
->
writeIntoVariable
(
$collection
)
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, Aug 18, 23:31 (7 h, 49 m ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
fe/08/482ead321fe0a956a2b8ff8f0e4d
Default Alt Text
IniFormatTest.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment