[MediaWiki-commits] [Gerrit] Test case generator - change (mediawiki...MathSearch)
Physikerwelt has uploaded a new change for review. https://gerrit.wikimedia.org/r/112354 Change subject: Test case generator .. Test case generator Generates phpUnitTest data from a given page. * Not compatible to dev branch. Bug: 61090 Change-Id: Ia406df98de94f9c9849c50f9d801c97466a53039 --- M SpecialMathDebug.php 1 file changed, 33 insertions(+), 12 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MathSearch refs/changes/54/112354/1 diff --git a/SpecialMathDebug.php b/SpecialMathDebug.php index f364ccb..ddff598 100644 --- a/SpecialMathDebug.php +++ b/SpecialMathDebug.php @@ -18,8 +18,6 @@ function execute( $par ) { global $wgMathDebug, $wgRequest; - $output = $this-getOutput(); - $this-setHeaders(); $offset = $wgRequest-getVal( 'offset', 0 ); $length = $wgRequest-getVal( 'length', 10 ); $page = $wgRequest-getVal( 'page', 'Testpage' ); @@ -27,19 +25,26 @@ $purge = $wgRequest-getVal( 'purge', '' ); if ( !$this-userCanExecute( $this-getUser() ) ) { $this-displayRestrictionError(); - return; } else { - $this-displayButtons( $offset, $length, $page, $action, $purge ); - if ( $action == 'parserTest' ) { - $this-generateLaTeXMLOutput( $offset, $length, $page ); - return; - } elseif ( $action == 'parserDiff' ) { - $this-compareParser( $offset, $length, $page ); - return; - } else { - $this-testParser( $offset, $length, $page, $purge=='checked'?true:false ); + if ( $action != 'generateParserTests' ){ + $this-setHeaders(); + $this-displayButtons( $offset, $length, $page, $action, $purge ); + } + switch ( $action ){ + case 'parserTest': + $this-generateLaTeXMLOutput( $offset, $length, $page ); + break; + case 'parserDiff': + $this-compareParser( $offset, $length, $page ); + break; + case 'generateParserTests': + $this-generateParserTests( $offset, $length, $page ); + break; + default: + $this-testParser( $offset, $length, $page, $purge=='checked'?true:false ); } } + return; } function displayButtons( $offset = 0, $length = 10, $page = 'Testpage', $action = 'show', $purge='' ) { $out = $this-getOutput(); @@ -137,6 +142,22 @@ echo $i; } + public function generateParserTests( $offset = 0, $length = 10, $page = 'Testpage' , $purge = true ) { + $res = $this-getRequest()-response(); + $res-header('Content-Type: application/octet-stream'); + $res-header('charset=utf-8'); + $res-header('Content-Disposition: attachment;filename=ParserTest.data'); + + $out = $this-getOutput(); + $out-setArticleBodyOnly( true ); + $parserTests= array(); + foreach ( array_slice( self::getMathTagsFromPage( $page ), $offset, $length, true ) as $key = $input ) { + $output = MathRenderer::renderMath( $input, array(), MW_MATH_PNG ); + $parserTests[(string) $input ]= $output; + } + $out-addHTML( serialize($parserTests) ); + } + function generateLaTeXMLOutput( $offset = 0, $length = 10, $page = 'Testpage' ) { global $wgMathUseLaTeXML; $out = $this-getOutput(); -- To view, visit https://gerrit.wikimedia.org/r/112354 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia406df98de94f9c9849c50f9d801c97466a53039 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MathSearch Gerrit-Branch: master Gerrit-Owner: Physikerwelt w...@physikerwelt.de ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Test case generator - change (mediawiki...MathSearch)
Physikerwelt has submitted this change and it was merged. Change subject: Test case generator .. Test case generator Generates phpUnitTest data from a given page. * Not compatible to dev branch. Bug: 61090 Change-Id: Ia406df98de94f9c9849c50f9d801c97466a53039 --- M SpecialMathDebug.php 1 file changed, 33 insertions(+), 12 deletions(-) Approvals: Physikerwelt: Verified; Looks good to me, approved diff --git a/SpecialMathDebug.php b/SpecialMathDebug.php index f364ccb..ddff598 100644 --- a/SpecialMathDebug.php +++ b/SpecialMathDebug.php @@ -18,8 +18,6 @@ function execute( $par ) { global $wgMathDebug, $wgRequest; - $output = $this-getOutput(); - $this-setHeaders(); $offset = $wgRequest-getVal( 'offset', 0 ); $length = $wgRequest-getVal( 'length', 10 ); $page = $wgRequest-getVal( 'page', 'Testpage' ); @@ -27,19 +25,26 @@ $purge = $wgRequest-getVal( 'purge', '' ); if ( !$this-userCanExecute( $this-getUser() ) ) { $this-displayRestrictionError(); - return; } else { - $this-displayButtons( $offset, $length, $page, $action, $purge ); - if ( $action == 'parserTest' ) { - $this-generateLaTeXMLOutput( $offset, $length, $page ); - return; - } elseif ( $action == 'parserDiff' ) { - $this-compareParser( $offset, $length, $page ); - return; - } else { - $this-testParser( $offset, $length, $page, $purge=='checked'?true:false ); + if ( $action != 'generateParserTests' ){ + $this-setHeaders(); + $this-displayButtons( $offset, $length, $page, $action, $purge ); + } + switch ( $action ){ + case 'parserTest': + $this-generateLaTeXMLOutput( $offset, $length, $page ); + break; + case 'parserDiff': + $this-compareParser( $offset, $length, $page ); + break; + case 'generateParserTests': + $this-generateParserTests( $offset, $length, $page ); + break; + default: + $this-testParser( $offset, $length, $page, $purge=='checked'?true:false ); } } + return; } function displayButtons( $offset = 0, $length = 10, $page = 'Testpage', $action = 'show', $purge='' ) { $out = $this-getOutput(); @@ -137,6 +142,22 @@ echo $i; } + public function generateParserTests( $offset = 0, $length = 10, $page = 'Testpage' , $purge = true ) { + $res = $this-getRequest()-response(); + $res-header('Content-Type: application/octet-stream'); + $res-header('charset=utf-8'); + $res-header('Content-Disposition: attachment;filename=ParserTest.data'); + + $out = $this-getOutput(); + $out-setArticleBodyOnly( true ); + $parserTests= array(); + foreach ( array_slice( self::getMathTagsFromPage( $page ), $offset, $length, true ) as $key = $input ) { + $output = MathRenderer::renderMath( $input, array(), MW_MATH_PNG ); + $parserTests[(string) $input ]= $output; + } + $out-addHTML( serialize($parserTests) ); + } + function generateLaTeXMLOutput( $offset = 0, $length = 10, $page = 'Testpage' ) { global $wgMathUseLaTeXML; $out = $this-getOutput(); -- To view, visit https://gerrit.wikimedia.org/r/112354 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ia406df98de94f9c9849c50f9d801c97466a53039 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MathSearch Gerrit-Branch: master Gerrit-Owner: Physikerwelt w...@physikerwelt.de Gerrit-Reviewer: Physikerwelt w...@physikerwelt.de ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits