mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-12-18 10:30:51 +00:00
f5b83c720c
Following the same argument as for accents, font options should also be passed in underOver constructs. * Pass options * Add test * In I6924d712db6852f99d7896b1f11cfbd22851d757 curly learned to encapsulate its output in a mrow. Thus, the if-clause is no longer needed. Bug: T352609 Change-Id: I6dd3303d9b5ef9ae32ad33c91a4cc1bbdad46109
83 lines
2.4 KiB
PHP
83 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\Math\Tests\WikiTexVC\MMLmappings;
|
|
|
|
use MediaWiki\Extension\Math\WikiTexVC\MMLmappings\BaseParsing;
|
|
use MediaWiki\Extension\Math\WikiTexVC\Nodes\DQ;
|
|
use MediaWiki\Extension\Math\WikiTexVC\Nodes\Fun1;
|
|
use MediaWiki\Extension\Math\WikiTexVC\Nodes\Literal;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
/**
|
|
* @covers \MediaWiki\Extension\Math\WikiTexVC\MMLmappings\BaseParsing
|
|
*/
|
|
class BaseParsingTest extends TestCase {
|
|
|
|
public function testAccent() {
|
|
$node = new Fun1(
|
|
'\\widetilde',
|
|
( new Literal( 'a' ) )
|
|
);
|
|
$result = BaseParsing::accent( $node, [], null, 'widetilde', '007E' );
|
|
$this->assertStringContainsString( '~', $result );
|
|
$this->assertStringContainsString( 'mover', $result );
|
|
}
|
|
|
|
public function testAccentArgPassing() {
|
|
$node = new Fun1(
|
|
'\\widetilde',
|
|
( new Literal( 'a' ) )
|
|
);
|
|
$result = BaseParsing::accent( $node, [ 'k' => 'v' ], null, 'widetilde', '007E' );
|
|
$this->assertStringContainsString( '<mi k="v"', $result );
|
|
}
|
|
|
|
public function testUnderOver() {
|
|
$node = new Fun1(
|
|
'\\overline',
|
|
( new Literal( 'a' ) )
|
|
);
|
|
$result = BaseParsing::underover( $node, [], null, 'oXXX', '00AF' );
|
|
$this->assertStringStartsWith( '<mrow', $result );
|
|
$this->assertStringContainsString( 'mover', $result );
|
|
}
|
|
|
|
public function testUnderOverUnder() {
|
|
$node = new Fun1(
|
|
'\\overline',
|
|
( new Literal( 'a' ) )
|
|
);
|
|
$result = BaseParsing::underover( $node, [], null, 'uXXX', '00AF' );
|
|
$this->assertStringContainsString( 'munder', $result );
|
|
}
|
|
|
|
public function testUnderOverDqUnder() {
|
|
$node = new DQ(
|
|
( new Literal( 'a' ) ),
|
|
( new Literal( 'b' ) )
|
|
);
|
|
$result = BaseParsing::underover( $node, [], null, 'uXXX', '00AF' );
|
|
$this->assertStringContainsString( 'munder', $result );
|
|
$this->assertStringContainsString( 'mrow', $result );
|
|
}
|
|
|
|
public function testUnderArgPassing() {
|
|
$node = new Fun1(
|
|
'\\overline',
|
|
( new Literal( 'a' ) )
|
|
);
|
|
$result = BaseParsing::underover( $node, [ 'k' => 'v' ], null, 'oXXX', '00AF' );
|
|
$this->assertStringContainsString( '<mi k="v"', $result );
|
|
}
|
|
|
|
public function testUnderBadArgPassing() {
|
|
$node = new Fun1(
|
|
'\\overline',
|
|
( new Literal( 'a' ) )
|
|
);
|
|
$result = BaseParsing::underover( $node,
|
|
[ 'k' => '"<script>alert("problem")</script>"' ], null, 'oXXX', '00AF' );
|
|
$this->assertStringContainsString( 'k=""<script>alert("problem")', $result );
|
|
}
|
|
}
|