Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7430637
MathoidCliTest.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
MathoidCliTest.php
View Options
<?php
use
MediaWiki\Extension\Math\MathMathMLCli
;
/**
* @covers \MediaWiki\Extension\Math\MathMathMLCli
*
* @group Math
*
* @license GPL-2.0-or-later
*/
class
MathoidCliTest
extends
MediaWikiIntegrationTestCase
{
/** @var string */
private
$goodInput
=
'
\s
in
\l
eft(
\f
rac12x
\r
ight)'
;
/** @var string */
private
$badInput
=
'
\n
ewcommand{
\t
ext{do evil things}}'
;
/** @var true|null */
protected
static
$hasMathoidCli
;
public
static
function
setUpBeforeClass
():
void
{
global
$wgMathoidCli
;
if
(
is_array
(
$wgMathoidCli
)
&&
is_executable
(
$wgMathoidCli
[
0
]
)
)
{
self
::
$hasMathoidCli
=
true
;
}
}
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected
function
setUp
():
void
{
parent
::
setUp
();
if
(
!
self
::
$hasMathoidCli
)
{
$this
->
markTestSkipped
(
"No mathoid cli configured on server"
);
}
}
public
function
testGood
()
{
$mml
=
new
MathMathMLCli
(
$this
->
goodInput
);
$input
=
[
'good'
=>
$mml
];
MathMathMLCli
::
batchEvaluate
(
$input
);
$this
->
assertTrue
(
$mml
->
render
(),
'assert that renders'
);
$this
->
assertStringContainsString
(
'</mo>'
,
$mml
->
getMathml
()
);
}
public
function
testUndefinedFunctionError
()
{
$mml
=
new
MathMathMLCli
(
$this
->
badInput
);
$input
=
[
'bad'
=>
$mml
];
MathMathMLCli
::
batchEvaluate
(
$input
);
$this
->
assertFalse
(
$mml
->
render
(),
'assert that fails'
);
$this
->
assertStringContainsString
(
'newcommand'
,
$mml
->
getLastError
()
);
}
public
function
testSyntaxError
()
{
$mml
=
new
MathMathMLCli
(
'^'
);
$input
=
[
'bad'
=>
$mml
];
MathMathMLCli
::
batchEvaluate
(
$input
);
$this
->
assertFalse
(
$mml
->
render
(),
'assert that fails'
);
$this
->
assertStringContainsString
(
'SyntaxError'
,
$mml
->
getLastError
()
);
}
public
function
testCeError
()
{
$mml
=
new
MathMathMLCli
(
'
\c
e{H2O}'
);
$input
=
[
'bad'
=>
$mml
];
MathMathMLCli
::
batchEvaluate
(
$input
);
$this
->
assertFalse
(
$mml
->
render
(),
'assert that fails'
);
$this
->
assertStringContainsString
(
'SyntaxError'
,
$mml
->
getLastError
()
);
}
public
function
testEmpty
()
{
$mml
=
new
MathMathMLCli
(
''
);
$input
=
[
'bad'
=>
$mml
];
MathMathMLCli
::
batchEvaluate
(
$input
);
$this
->
assertFalse
(
$mml
->
render
(),
'assert that renders'
);
$this
->
assertFalse
(
$mml
->
isTexSecure
()
);
$this
->
assertStringContainsString
(
'empty'
,
$mml
->
getLastError
()
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Nov 22, 10:34 (9 h, 3 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
de/75/7a4843bf2d79d80d9f53268f942c
Default Alt Text
MathoidCliTest.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment