mediawiki-extensions-Math/tests/phpunit/unit/TexVC/MMLRenderTest.php
Stegmujo b7d909e0a2 Fix for sideset case
* example "\sideset{_1^2}{_3^4}\sum"
* case 3 phabricator "sideset"
* index: 90
* since result has multiscripts which is not generated by mathoid, there is an explicit test in MMLRenderTest and the previous test is in MMLTexVCUtilTest is skipped
* in MMLGenerationTexUtilTest test for sideset is deactivated
* adds a case from FullCoverageTest for sideset with FQ
* fixes an issue which occured during Phan checks for merging that genFrac throws an error

Bug : T327391

Change-Id: I4c5a5f5a901dbc906f5a1b168d3a8d04f25b9290
2023-03-13 15:38:04 +00:00

64 lines
2.4 KiB
PHP

<?php
namespace MediaWiki\Extension\Math\Tests\TexVC;
use MediaWiki\Extension\Math\TexVC\MMLmappings\Util\MMLTestUtil;
use MediaWiki\Extension\Math\TexVC\TexVC;
use MediaWikiUnitTestCase;
/**
* These are some specific testcases by MML-Rendering by TexVC.
* They are explicitly described here instead of in JSON files because
* Mathoid or LaTeXML do not generate suitable results for reference.
* @covers \MediaWiki\Extension\Math\TexVC\TexVC
*/
class MMLRenderTest extends MediaWikiUnitTestCase {
public function testSidesetError() {
$input = "\\sideset{_1^2}{_3^4}";
$mathMLtexVC = $this->generateMML( $input );
$this->assertTrue( str_contains( $mathMLtexVC, "merror" ) );
}
public function testSidesetSum() {
$input = "\\sideset{_1^2}{_3^4}\\sum";
$mathMLtexVC = $this->generateMML( $input );
$this->assertStringNotContainsString( "merror", $mathMLtexVC );
$this->assertStringContainsString( "mmultiscripts", $mathMLtexVC );
$this->assertStringContainsString( "<mprescripts/>", $mathMLtexVC );
$this->assertStringContainsString( ">&#x2211;", $mathMLtexVC );
}
public function testSidesetProd() {
$input = "\\sideset{_1^2}{_3^4}\\prod";
$mathMLtexVC = $this->generateMML( $input );
$this->assertStringNotContainsString( "merror", $mathMLtexVC );
$this->assertStringContainsString( "mmultiscripts", $mathMLtexVC );
$this->assertStringContainsString( "<mprescripts/>", $mathMLtexVC );
$this->assertStringContainsString( ">&#x220F;", $mathMLtexVC );
}
public function testSidesetFQ() {
$input = "\\sideset{_1^2}{_3^4}\prod_a^b";
$mathMLtexVC = $this->generateMML( $input );
$this->assertStringNotContainsString( "merror", $mathMLtexVC );
$this->assertStringContainsString( "mmultiscripts", $mathMLtexVC );
$this->assertStringContainsString( "<mprescripts/>", $mathMLtexVC );
$this->assertStringContainsString( ">&#x220F;", $mathMLtexVC );
$this->assertStringContainsString( "<mi>a</mi>", $mathMLtexVC );
$this->assertStringContainsString( "<mi>b</mi>", $mathMLtexVC );
$this->assertStringContainsString( "movablelimits", $mathMLtexVC );
}
private function generateMML( $input, $chem = false ) {
$texVC = new TexVC();
$resultT = $texVC->check( $input, [
'debug' => false,
'usemathrm' => false,
'oldtexvc' => false,
'usemhchem' => $chem
] );
return MMLTestUtil::getMMLwrapped( $resultT["input"] ) ?? "<math> error texvc </math>";
}
}