mediawiki-extensions-Math/tests/phpunit/unit/WikiTexVC/MMLmappings/MMLParsingUtilTest.php
physikerwelt 63b47f21ef
Add mathfraktur rendering for chrome
Chrome and similar browsers do not support the
mathvariant attribute that can be used to change
math fonts conveniently. Like for mathcal there is
a table that can be used to translate from latin
to mathfraktur chars.

Bug: T378433
Change-Id: Id8c3e121ed104ba3f08329b4151a7e3bec699754
2024-10-29 11:30:51 +01:00

52 lines
1.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace MediaWiki\Extension\Math\Tests\WikiTexVC\MMLmappings;
use MediaWiki\Extension\Math\WikiTexVC\MMLmappings\Util\MMLParsingUtil;
use MediaWikiUnitTestCase;
/**
* @covers \MediaWiki\Extension\Math\WikiTexVC\MMLmappings\Util\MMLParsingUtil
*/
class MMLParsingUtilTest extends MediaWikiUnitTestCase {
public function testInvalidColor() {
$result = MMLParsingUtil::parseDefineColorExpression( "INVALID" );
$this->assertNull( $result );
}
public function testRGBOne() {
$result = MMLParsingUtil::parseDefineColorExpression(
"\\definecolor {ultramarine}{rgb}{0,0.12549019607843,0.37647058823529}" );
$this->assertEquals( 'ultramarine', $result['name'] );
$this->assertEquals( 'rgb', $result['type'] );
$this->assertEquals( '#002060', $result['hex'] );
}
public function testInvalidColorString() {
$result = MMLParsingUtil::parseDefineColorExpression(
"\\definecolor {gray}{0.123}" );
$this->assertNull( $result );
}
public function testUnicode_afr() {
$result = MMLParsingUtil::mapToFrakturUnicode( 'a' );
$this->assertEquals( '&#x1D51E;', $result );
}
public function testUnicode_bfr() {
$result = MMLParsingUtil::mapToFrakturUnicode( 'B' );
$this->assertEquals( '&#x1D505;', $result );
}
public function testUnicode_Cfr() {
$result = MMLParsingUtil::mapToFrakturUnicode( 'C' );
$this->assertEquals( '&#x0212D;', $result );
}
public function testUnicodeUtf8Input() {
$result = MMLParsingUtil::mapToFrakturUnicode( '𝔄' );
$this->assertEquals( '𝔄', $result );
}
}