mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-11-27 17:01:07 +00:00
Abort test execution on unsuccessful rendering
The SpecialPage MathStatus tried to get the HTML output even if the rendering was not successful. This did lead to logged errors. * Skip the rest of the tests if the rendering is not successful. Bug: T366293 Change-Id: Id7396fcdc1df96fa3c19e36b56068da4aba3d18f
This commit is contained in:
parent
4f82ce56de
commit
a5b9cffb09
|
@ -74,7 +74,9 @@ class SpecialMathStatus extends SpecialPage {
|
|||
private function runNativeTest( $modeName ) {
|
||||
$this->getOutput()->addWikiMsgArray( 'math-test-start', [ $modeName ] );
|
||||
$renderer = $this->rendererFactory->getRenderer( "a+b", [], MathConfig::MODE_NATIVE_MML );
|
||||
$this->assertTrue( $renderer->render(), "Rendering of a+b in $modeName" );
|
||||
if ( !$this->assertTrue( $renderer->render(), "Rendering of a+b in $modeName" ) ) {
|
||||
return;
|
||||
}
|
||||
$real = str_replace( "\n", '', $renderer->getHtmlOutput() );
|
||||
$expected = '<mo>+</mo>';
|
||||
$this->assertContains( $expected, $real, "Checking the presence of '+' in the MathML output" );
|
||||
|
@ -99,7 +101,9 @@ class SpecialMathStatus extends SpecialPage {
|
|||
public function testSpecialCaseText() {
|
||||
$renderer = $this->rendererFactory->getRenderer( 'x^2+\text{a sample Text}', [], MathConfig::MODE_MATHML );
|
||||
$expected = 'a sample Text</mtext>';
|
||||
$this->assertTrue( $renderer->render(), 'Rendering the input "x^2+\text{a sample Text}"' );
|
||||
if ( !$this->assertTrue( $renderer->render(), 'Rendering the input "x^2+\text{a sample Text}"' ) ) {
|
||||
return;
|
||||
}
|
||||
$this->assertContains(
|
||||
$expected, $renderer->getHtmlOutput(), 'Comparing to the reference rendering'
|
||||
);
|
||||
|
@ -111,7 +115,9 @@ class SpecialMathStatus extends SpecialPage {
|
|||
*/
|
||||
public function testMathMLIntegration() {
|
||||
$renderer = $this->rendererFactory->getRenderer( "a+b", [], MathConfig::MODE_MATHML );
|
||||
$this->assertTrue( $renderer->render(), "Rendering of a+b in plain MathML mode" );
|
||||
if ( !$this->assertTrue( $renderer->render(), "Rendering of a+b in plain MathML mode" ) ) {
|
||||
return;
|
||||
}
|
||||
$real = str_replace( "\n", '', $renderer->getHtmlOutput() );
|
||||
$expected = '<mo>+</mo>';
|
||||
$this->assertContains( $expected, $real, "Checking the presence of '+' in the MathML output" );
|
||||
|
@ -135,7 +141,9 @@ class SpecialMathStatus extends SpecialPage {
|
|||
$attribs = [ 'type' => 'pmml' ];
|
||||
$renderer = $this->rendererFactory->getRenderer( $inputSample, $attribs, MathConfig::MODE_MATHML );
|
||||
$this->assertEquals( 'pmml', $renderer->getInputType(), 'Checking if MathML input is supported' );
|
||||
$this->assertTrue( $renderer->render(), 'Rendering Presentation MathML sample' );
|
||||
if ( !$this->assertTrue( $renderer->render(), 'Rendering Presentation MathML sample' ) ) {
|
||||
return;
|
||||
}
|
||||
$real = $renderer->getHtmlOutput();
|
||||
$this->assertContains( 'mode=mathml', $real, 'Checking if the link to SVG image is in correct mode' );
|
||||
}
|
||||
|
@ -146,7 +154,9 @@ class SpecialMathStatus extends SpecialPage {
|
|||
*/
|
||||
public function testLaTeXMLIntegration() {
|
||||
$renderer = $this->rendererFactory->getRenderer( "a+b", [], MathConfig::MODE_LATEXML );
|
||||
$this->assertTrue( $renderer->render(), "Rendering of a+b in LaTeXML mode" );
|
||||
if ( !$this->assertTrue( $renderer->render(), "Rendering of a+b in LaTeXML mode" ) ) {
|
||||
return;
|
||||
}
|
||||
// phpcs:ignore Generic.Files.LineLength.TooLong
|
||||
$expected = '<math xmlns="http://www.w3.org/1998/Math/MathML" ';
|
||||
$real = preg_replace( "/\n\\s*/", '', $renderer->getHtmlOutput() );
|
||||
|
@ -170,7 +180,9 @@ class SpecialMathStatus extends SpecialPage {
|
|||
$tex .= $testMax;
|
||||
$renderer = new MathLaTeXML( $tex, [ 'display' => 'linebreak' ] );
|
||||
$renderer->setPurge();
|
||||
$this->assertTrue( $renderer->render(), "Rendering of linebreak test in LaTeXML mode" );
|
||||
if ( !$this->assertTrue( $renderer->render(), "Rendering of linebreak test in LaTeXML mode" ) ) {
|
||||
return;
|
||||
}
|
||||
$expected = 'mtr';
|
||||
$real = preg_replace( "/\n\\s*/", '', $renderer->getHtmlOutput() );
|
||||
$this->assertContains( $expected, $real, "Checking for linebreak" .
|
||||
|
|
Loading…
Reference in a new issue