diff --git a/Math.alias.php b/Math.alias.php
index 91de3f577..01a9a594c 100644
--- a/Math.alias.php
+++ b/Math.alias.php
@@ -10,5 +10,6 @@ $specialPageAliases = array();
/** English (English) */
$specialPageAliases['en'] = array(
- 'MathShowImage' => array( 'MathShowImage', 'MathShowImage' ) // No need to translate! The PageTitle does not appear.
+ 'MathShowImage' => array( 'MathShowImage', 'MathShowImage' ), // No need to translate! The PageTitle does not appear.
+ 'MathStatus' => array( 'MathStatus', 'MathStatus' )
);
diff --git a/Math.php b/Math.php
index 4dca145dc..30929dc3d 100644
--- a/Math.php
+++ b/Math.php
@@ -230,6 +230,7 @@ $wgAutoloadClasses['MathLaTeXML'] = $dir . 'MathLaTeXML.php';
$wgAutoloadClasses['MathInputCheck'] = $dir . 'MathInputCheck.php';
$wgAutoloadClasses['MathInputCheckTexvc'] = $dir . 'MathInputCheckTexvc.php';
$wgAutoloadClasses['SpecialMathShowImage'] = $dir . 'SpecialMathShowImage.php';
+$wgAutoloadClasses['SpecialMathStatus'] = $dir . 'SpecialMathStatus.php';
$wgMessagesDirs['Math'] = __DIR__ . '/i18n';
$wgExtensionMessagesFiles['Math'] = $dir . 'Math.i18n.php';
$wgExtensionMessagesFiles['MathAlias'] = $dir . 'Math.alias.php';
@@ -237,7 +238,9 @@ $wgExtensionMessagesFiles['MathAlias'] = $dir . 'Math.alias.php';
$wgParserTestFiles[] = $dir . 'mathParserTests.txt';
$wgSpecialPageGroups[ 'MathShowImage' ] = 'other';
+$wgSpecialPageGroups[ 'MathStatus' ] = 'other';
$wgSpecialPages['MathShowImage'] = 'SpecialMathShowImage';
+$wgSpecialPages['MathStatus'] = 'SpecialMathStatus';
$wgResourceModules['ext.math.styles'] = array(
'localBasePath' => __DIR__ . '/modules',
diff --git a/SpecialMathStatus.php b/SpecialMathStatus.php
new file mode 100644
index 000000000..39cb34dd8
--- /dev/null
+++ b/SpecialMathStatus.php
@@ -0,0 +1,138 @@
+setHeaders();
+ if ( ! ( $this->getUser()->isAllowed( 'purge' ) ) ) {
+ // The effect of loading this page is comparable to purge a page.
+ // If desired a dedicated right e.g. "viewmathstatus" could be used instead.
+ throw new PermissionsError( 'purge' );
+ }
+
+ $out = $this->getOutput();
+ $out->addWikiMsg( 'math-status-introduction' );
+ $enabledMathModes = MathHooks::getMathNames();
+ foreach ( $enabledMathModes as $modeNr => $modeName ){
+ $out->addWikiText( "* $modeName" );
+ switch( $modeNr ){
+ case MW_MATH_MATHML:
+ $this->runMathMLTest( $modeName );
+ break;
+ case MW_MATH_LATEXML:
+ $this->runMathLaTeXMLTest( $modeName );
+ }
+ }
+ }
+
+ private function runMathMLTest( $modeName ) {
+ $this->getOutput()->addWikiMsgArray( 'math-test-start', $modeName );
+ $this->testSpecialCaseText();
+ $this->testMathMLIntegration();
+ $this->testPmmlInput();
+ $this->getOutput()->addWikiMsgArray( 'math-test-end', $modeName );
+ }
+
+ private function runMathLaTeXMLTest( $modeName ) {
+ $this->getOutput()->addWikiMsgArray( 'math-test-start', $modeName );
+ $this->testMathMLIntegration();
+ $this->getOutput()->addWikiMsgArray( 'math-test-end', $modeName );
+ }
+
+ public function testSpecialCaseText() {
+ $renderer = MathRenderer::getRenderer( 'x^2+\text{a sample Text}', array(), MW_MATH_MATHML );
+ $expected = 'a sample Text';
+ $this->assertTrue( $renderer->render(), 'Rendering the input "x^2+\text{a sample Text}"' );
+ $this->assertContains( $expected, $renderer->getHtmlOutput(), 'Comparing to the reference rendering' );
+ }
+
+ /**
+ * Checks the basic functionality
+ * i.e. if the span element is generated right.
+ */
+ public function testMathMLIntegration() {
+ $svgRef = '
+
+';
+ $renderer = MathRenderer::getRenderer( "a+b", array(), MW_MATH_MATHML );
+ $this->assertTrue( $renderer->render( true ), "Rendering of a+b in plain MathML mode" );
+ $real = str_replace( "\n", '', $renderer->getHtmlOutput() );
+ $expected = '+';
+ $this->assertContains( $expected, $real, "Checking the presence of '+' in the MathML output" );
+ $this->assertEquals( $svgRef, $renderer->getSvg(), "Comparing the generated SVG with the reference" );
+ }
+
+ /**
+ * Checks the experimental option to 'render' MathML input
+ */
+ public function testPmmlInput() {
+ // sample from 'Navajo Coal Combustion and Respiratory Health Near Shiprock, New Mexico' in ''Journal of Environmental and Public Health'' , vol. 2010p.
+ // authors Joseph E. Bunnell; Linda V. Garcia; Jill M. Furst; Harry Lerch; Ricardo A. Olea; Stephen E. Suitt; Allan Kolker
+ $inputSample = ' P i j = 100 d i j 6.75 r j , ';
+ $attribs = array( 'type' => 'pmml' );
+ $renderer = new MathMathML( $inputSample, $attribs );
+ $this->assertEquals( 'pmml', $renderer->getInputType(), 'Checking if MathML input is supported' );
+ $this->assertTrue( $renderer->render(), 'Rendering Presentation MathML sample' );
+ $real = MathRenderer::renderMath( $inputSample, $attribs, MW_MATH_MATHML );
+ $expected = 'hash=5628b8248b79267ecac656102334d5e3&mode=5';
+ $this->assertContains( $expected, $real, 'Checking if the link to SVG image is correct' );
+ }
+
+ /**
+ * Checks the basic functionality
+ * i.e. if the span element is generated right.
+ */
+ public function testLaTeXMLIntegration() {
+ $renderer = MathRenderer::getRenderer( "a+b", array(), MW_MATH_LATEXML );
+ $this->assertTrue( $renderer->render( true ), "Rendering of a+b in LaTeXML mode" );
+ $expected = '';
+ $real = preg_replace( "/\n\s*/", '', $renderer->getHtmlOutput() );
+ $this->assertContains( $expected, $real
+ , "Comparing the output to the MathML reference rendering" .
+ $renderer->getLastError() );
+ }
+
+ private function assertTrue( $expression, $message = '' ) {
+ if ( $expression ){
+ $this->getOutput()->addWikiMsgArray( 'math-test-success' , $message );
+ } else {
+ $this->getOutput()->addWikiMsgArray( 'math-test-fail' , $message );
+ }
+ }
+
+ private function assertContains( $expected, $real, $message = '' ) {
+ $this->assertTrue( strpos( $real, $expected ) , $message );
+ }
+
+ private function assertEquals( $expected, $real, $message = '' ) {
+ $this->assertTrue( $expected == $real, $message );
+ }
+}
\ No newline at end of file
diff --git a/i18n/en.json b/i18n/en.json
index 75ec763eb..5c9d86859 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -26,8 +26,13 @@
"math_notexvccheck": "Missing texvccheck
executable. Please see math/README to configure.",
"math_output_error": "Cannot store math image on filesystem.",
"math_sample": "Insert formula here",
+ "math-status-introduction" : "This page displays information about the enabled math rendering modes.\n\nThe following rendering mode is/rendering modes are enabled.",
"math_syntax_error": "syntax error",
"math_timeout": "$1 timeout from \"$2\".",
+ "math-test-end": "Backend tests for rendering mode \"$1\" completed.",
+ "math-test-fail": "Test \"$1\" failed.",
+ "math-test-start": "Running backend tests for rendering mode \"$1\".",
+ "math-test-success": "Test \"$1\" succeeded.",
"math_tip": "Mathematical formula (LaTeX)",
"math_unknown_error": "unknown error",
"math_unknown_function": "unknown function \"$1\"",
@@ -38,5 +43,6 @@
"mw_math_mathml": "MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools)",
"mw_math_png": "PNG images",
"mw_math_source": "TeX source (for text browsers)",
- "prefs-math": "Math"
+ "prefs-math": "Math",
+ "mathstatus": "Math status"
}
diff --git a/i18n/qqq.json b/i18n/qqq.json
index ad05ea639..b26ba3e1c 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -36,8 +36,13 @@
"math_notexvccheck": "Used as error message.\n\nThis message follows the message {{msg-mw|Math failure}}.\n\nSee also:\n* {{msg-mw|Math notexvc}}",
"math_output_error": "Used as error message if the texvc output file could not be stored.\n\nThis message follows the message {{msg-mw|Math failure}}.",
"math_sample": "The sample formula text that you get when you press the fourth button from the right on the edit toolbar.",
+ "math-status-introduction": "Used as special-page text.",
"math_syntax_error": "Used as error message for a texvc syntax error.\n\nThis message follows the message {{msg-mw|Math failure}}.\n{{Identical|Syntax error}}",
"math_timeout": "Used as error message.\n\nParameters:\n* $1 - rendering type (either LaTeXML or Mathoid)\n* $2 - hostname or URL",
+ "math-test-end": "Used as special-page text.\n\nParameters:\n* $1 rendering mode",
+ "math-test-fail": "Used as special-page text.\n\nParameters:\n* $1 test name",
+ "math-test-start": "Used as special-page text.\n\nParameters:\n* $1 rendering mode",
+ "math-test-success": "Used as special-page text.\n\nParameters:\n* $1 test name",
"math_tip": "This is the text that appears when you hover the mouse over the fourth button from the right on the edit toolbar.",
"math_unknown_error": "Used as error message for unknown texvc error.\n\nThis message follows the message {{msg-mw|Math failure}}.\n{{Identical|Unknown error}}",
"math_unknown_function": "Used as error message when texvc encounters an unknown function.\n\nPreceded by the message {{msg-mw|Math failure}}.\n\nParameters:\n* $1 - name of unknown function",
@@ -48,5 +53,6 @@
"mw_math_mathml": "Used as label for MathML radio button.\n\nSee also:\n* {{msg-mw|Mw math png}}\n* {{msg-mw|Mw math source}}\n* {{msg-mw|Mw math latexml}}",
"mw_math_png": "In user preferences. All mw_math_* messages MUST be different, things will break otherwise!\n\nUsed as label for radio button.\n\nSee also:\n* {{msg-mw|Mw math source}}\n* {{msg-mw|Mw math mathjax}}\n* {{msg-mw|Mw math latexml}}",
"mw_math_source": "In user preferences (math). All mw_math_* messages MUST be different, things will break otherwise!\n\nUsed as label for source radio button.\n\nSee also:\n* {{msg-mw|Mw math png}}\n* {{msg-mw|Mw math mathjax}}\n* {{msg-mw|Mw math latexml}}",
- "prefs-math": "Used in user preferences as a section heading.\n{{Identical|Math}}"
+ "prefs-math": "Used in user preferences as a section heading.\n{{Identical|Math}}",
+ "mathstatus": "Label for special-page"
}
diff --git a/tests/MathLaTeXMLTest.php b/tests/MathLaTeXMLTest.php
index fc401214c..0b98b60a8 100644
--- a/tests/MathLaTeXMLTest.php
+++ b/tests/MathLaTeXMLTest.php
@@ -33,20 +33,4 @@ class MathLaTeXMLTest extends MediaWikiTestCase {
'test serialization of a string setting'
);
}
-
- /**
- * Checks the basic functionality
- * i.e. if the span element is generated right.
- */
- public function testIntegration() {
- $this->setMwGlobals( 'wgMathLaTeXMLTimeout', 20 );
- $this->setMwGlobals( 'wgMathValidModes', array( MW_MATH_LATEXML ) );
- $renderer = MathRenderer::getRenderer( "a+b", array(), MW_MATH_LATEXML );
- $this->assertTrue( $renderer->render( true ) );
- $expected = '';
- $real = preg_replace( "/\n\s*/", '', $renderer->getHtmlOutput() );
- $this->assertContains( $expected, $real
- , "Rendering of a+b in plain Text mode." .
- $renderer->getLastError() );
- }
}
diff --git a/tests/MathMathMLTest.php b/tests/MathMathMLTest.php
index 5182a0afb..610b5361f 100644
--- a/tests/MathMathMLTest.php
+++ b/tests/MathMathMLTest.php
@@ -25,17 +25,6 @@ class MathMathMLTest extends MediaWikiTestCase {
self::$timeout = $timeout;
}
- /**
- * Test rendering the string '0' see
- * https://trac.mathweb.org/LaTeXML/ticket/1752
- */
- public function testSpecialCaseText() {
- $renderer = MathRenderer::getRenderer( 'x^2+\text{a sample Text}', array(), MW_MATH_MATHML );
- $expected = 'a sample Text';
- $this->assertTrue( $renderer->render() );
- $this->assertContains( $expected, $renderer->getHtmlOutput(), 'Rendering the String "\text{CR}"' );
- }
-
/**
* Tests behavior of makeRequest() that communicates with the host.
* Testcase: Invalid request.
@@ -115,72 +104,6 @@ class MathMathMLTest extends MediaWikiTestCase {
$this->assertFalse( $renderer->isValidMathML( $invalidSample ), 'test if math expression is invalid mathml sample' );
}
-
- /**
- * Checks the basic functionality
- * i.e. if the span element is generated right.
- */
- public function testIntegration() {
- global $wgMathMathMLTimeout;
- $svgRef = '
-
-';
- $wgMathMathMLTimeout = 20;
- $renderer = MathRenderer::getRenderer( "a+b", array(), MW_MATH_MATHML );
- $this->assertTrue( $renderer->render( true ) );
- $real = str_replace( "\n", '', $renderer->getHtmlOutput() );
- $expected = '+';
- $this->assertContains( $expected, $real, "Rendering of a+b in plain MathML mode" );
- $this->assertEquals( $svgRef, $renderer->getSvg() );
- }
-
- /**
- * Checks the experimental option to 'render' MathML input
- */
- public function testPmmlInput() {
- // sample from 'Navajo Coal Combustion and Respiratory Health Near Shiprock, New Mexico' in ''Journal of Environmental and Public Health'' , vol. 2010p.
- // authors Joseph E. Bunnell; Linda V. Garcia; Jill M. Furst; Harry Lerch; Ricardo A. Olea; Stephen E. Suitt; Allan Kolker
- $inputSample = ' P i j = 100 d i j 6.75 r j , ';
- $attribs = array( 'type' => 'pmml' );
- $renderer = new MathMathML( $inputSample, $attribs );
- $this->assertEquals( 'pmml', $renderer->getInputType(), 'Input type was not set correctly' );
- $this->assertTrue( $renderer->render(), 'Failed to render with error:' . $renderer->getLastError() );
- $real = MathRenderer::renderMath( $inputSample, $attribs, MW_MATH_MATHML );
- $expected = 'hash=5628b8248b79267ecac656102334d5e3&mode=5';
- $this->assertContains( $expected, $real, 'Link to SVG image missing' );
- }
-
- /**
- * Checks the creation of the math table with debugging enabled.
- * @covers MathHooks::onLoadExtensionSchemaUpdates
- */
- public function testDebug() {
- $dbr = wfGetDB( DB_SLAVE );
- if ( $dbr->getType() !== 'mysql' ) {
- $this->markTestSkipped( 'No math debug support for SQLite' );
- }
- $this->setMwGlobals( 'wgMathValidModes', array( MW_MATH_MATHML ) );
- $this->setMwGlobals( 'wgMathDebug', true );
- $renderer = MathRenderer::getRenderer( "a+b", array(), MW_MATH_MATHML );
- $this->assertTrue( $renderer->render( true ) );
- $hash = $renderer->getInputHash();
- $row = $dbr->selectRow("mathlog", "*", array( "math_inputhash" => $hash ) , __METHOD__,
- array("order by" => "math_timestamp desc"));
- $this->assertContains( "success", $row->math_log );
- $this->assertEquals( "type=inline-TeX&q=%7B%5Cdisplaystyle%20a%2Bb%7D", $row->math_post );
- $this->assertEquals( 5, $row->math_mode);
- }
}
/**