From f756414e210a0a61ad1c3a5773311f2281877323 Mon Sep 17 00:00:00 2001 From: "physikerwelt (Moritz Schubotz)" Date: Sun, 8 Feb 2015 20:18:49 +0100 Subject: [PATCH] Move debug integration test to special-page Since all other LaTexML integration tests will be performed from the math status special page, it seems reasonable to run the debug tests from this specialpage as well. Change-Id: I47c405dbe16c2585907b9f67cdc01ed76e51892a --- SpecialMathStatus.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/SpecialMathStatus.php b/SpecialMathStatus.php index c4c97b3e1..ec9a7beb8 100644 --- a/SpecialMathStatus.php +++ b/SpecialMathStatus.php @@ -51,8 +51,18 @@ class SpecialMathStatus extends SpecialPage { } private function runMathLaTeXMLTest( $modeName ) { + global $wgMathDebug; $this->getOutput()->addWikiMsgArray( 'math-test-start', $modeName ); $this->testMathMLIntegration(); + if ( $wgMathDebug ){ + try { + $this->testDebug(); + }catch ( Exception $e){ + $this->getOutput()->addWikiText( + 'Math debug test failed. Please run mwscript update.php'); + $this->getOutput()->addWikiText( $e->getMessage() ); + } + } $this->getOutput()->addWikiMsgArray( 'math-test-end', $modeName ); } @@ -120,6 +130,27 @@ class SpecialMathStatus extends SpecialPage { $renderer->getLastError() ); } + /** + * 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->getOutput()->addWikiText( 'Debug columns not supported in ' . $dbr->getType() ); + return; + } + $renderer = MathRenderer::getRenderer( "a+b", array(), MW_MATH_MATHML ); + $this->assertTrue( $renderer->render( true ) , "MathDebug: Rendering a+b"); + $hash = $renderer->getInputHash(); + $row = $dbr->selectRow("mathlog", "*", array( "math_inputhash" => $hash ) , __METHOD__, + array("order by" => "math_timestamp desc")); + $this->assertContains( "success", $row->math_log ,"MathDebug: Search for 'success' in the log file" ); + $this->assertEquals( "type=inline-TeX&q=%7B%5Cdisplaystyle%20a%2Bb%7D", $row->math_post, + "MathDebug: Check post variables in the log file" ); + $this->assertEquals( 5, $row->math_mode, "MathDebug: Check rendering mode"); + } + private function assertTrue( $expression, $message = '' ) { if ( $expression ){ $this->getOutput()->addWikiMsgArray( 'math-test-success' , $message );