mediawiki-extensions-Math/tests/phpunit/MathSourceTest.php
Thiemo Kreuz b189280467 Make all @covers tags absolute, and fix some
Some mentioned a "__constructor", which should be "__construct".

The leading backslash is not strictly needed by all tools. But some
need it. I learned it's best practice to always have it.

Change-Id: I22fe3a3b4828c02ab5a457aba9af5af1c72567ea
2019-11-26 11:01:23 +01:00

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() );
}
}