Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7405028
MathVariantTest.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
MathVariantTest.php
View Options
<?php
use
MediaWiki\Extension\Math\WikiTexVC\MMLmappings\MathVariant
;
use
MediaWiki\Extension\Math\WikiTexVC\MMLmappings\TexConstants\Variants
;
use
PHPUnit\Framework\TestCase
;
/**
* @covers \MediaWiki\Extension\Math\WikiTexVC\MMLmappings\MathVariant
*/
class
MathVariantTest
extends
TestCase
{
public
function
testGetJsonFile
()
{
$this
->
assertIsString
(
MathVariant
::
getJsonFile
()
);
}
public
function
testRemoveMathVariantAttribute
()
{
$attributes
=
[
'mathvariant'
=>
Variants
::
BOLD
,
'class'
=>
'some-class'
,
];
MathVariant
::
removeMathVariantAttribute
(
$attributes
);
$this
->
assertArrayNotHasKey
(
'mathvariant'
,
$attributes
);
$this
->
assertArrayHasKey
(
'class'
,
$attributes
);
$this
->
assertEquals
(
'some-class'
,
$attributes
[
'class'
]
);
}
public
function
testRemoveMathVariantAttributeNormal
()
{
$attributes
=
[
'mathvariant'
=>
Variants
::
NORMAL
,
];
MathVariant
::
removeMathVariantAttribute
(
$attributes
);
$this
->
assertArrayHasKey
(
'mathvariant'
,
$attributes
);
$this
->
assertEquals
(
Variants
::
NORMAL
,
$attributes
[
'mathvariant'
]
);
}
public
function
testTranslateInvalid
()
{
$this
->
expectException
(
InvalidArgumentException
::
class
);
MathVariant
::
translate
(
'some'
,
'invalid'
);
}
/**
* @dataProvider provideTranslateValidData
*/
public
function
testTranslateValid
(
string
$input
,
string
$variant
,
string
$expected
)
{
$this
->
assertEquals
(
$expected
,
MathVariant
::
translate
(
$input
,
$variant
)
);
}
public
function
provideTranslateValidData
():
array
{
return
[
'bold translation'
=>
[
'A'
,
'bold'
,
'๐'
],
'numeric translation'
=>
[
'1'
,
'double-struck'
,
'๐'
],
'italic translation'
=>
[
'x'
,
'italic'
,
'๐ฅ'
],
'arabic double-struck translation'
=>
[
'ุจ'
,
'double-struck'
,
'๐บก'
],
'non-existing fraktur'
=>
[
'0'
,
'fraktur'
,
'0'
],
'composite fraktur'
=>
[
'0AB'
,
'fraktur'
,
'0๐๐ '
],
];
}
public
function
testGetInstance
()
{
MathVariant
::
tearDown
();
$instance
=
MathVariant
::
getInstance
();
$this
->
assertInstanceOf
(
MathVariant
::
class
,
$instance
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Nov 21, 19:33 (1 d, 3 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
2e/cb/0232343f37ec7e0594712e8b6d57
Default Alt Text
MathVariantTest.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment