mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-11-28 01:10:09 +00:00
9a04cd6de3
Change-Id: I82d76db4b087b6472c2856806c70f4ef1ffbc8df
50 lines
1.1 KiB
PHP
50 lines
1.1 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Test the TeX source output format.
|
|
*
|
|
* @covers MathSource
|
|
*
|
|
* @license GPL-2.0-or-later
|
|
*/
|
|
class MathSourceTest extends MediaWikiTestCase {
|
|
|
|
/**
|
|
* Checks the basic functionality
|
|
* i.e. if the span element is generated right.
|
|
*/
|
|
public function testBasics() {
|
|
$real = MathRenderer::renderMath( "a+b", [], 'source' );
|
|
$this->assertEquals(
|
|
'<span class="mwe-math-fallback-source-inline tex" dir="ltr">$ a+b $</span>',
|
|
$real,
|
|
"Rendering of a+b in plain Text mode"
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Checks if newlines are converted to spaces correctly.
|
|
*/
|
|
public function testNewLines() {
|
|
$real = MathRenderer::renderMath( "a\n b", [], 'source' );
|
|
$this->assertSame(
|
|
'<span class="mwe-math-fallback-source-inline tex" dir="ltr">$ a b $</span>',
|
|
$real,
|
|
"converting newlines to spaces"
|
|
);
|
|
}
|
|
|
|
public function testConstructor() {
|
|
$renderer = new MathSource( 'a' );
|
|
|
|
$this->assertEquals( 'source', $renderer->getMode() );
|
|
}
|
|
|
|
public function testRender() {
|
|
$renderer = new MathSource( 'a+b' );
|
|
|
|
$this->assertTrue( $renderer->render() );
|
|
$this->assertFalse( $renderer->isChanged() );
|
|
}
|
|
}
|