mediawiki-extensions-Math/tests/phpunit/unit/WikiTexVC/RenderTest.php
Andre Klapper 5c6bc704a2 Use explicit nullable type on parameter arguments (for PHP 8.4)
Implicitly marking parameter $... as nullable is deprecated in PHP
8.4. The explicit nullable type must be used instead.

Bug: T376276
Change-Id: Idcd0b50c1c01a33c4cabeed3e31828f77c3f6443
2024-10-26 15:15:30 +02:00

56 lines
1.1 KiB
PHP

<?php
namespace MediaWiki\Extension\Math\Tests\WikiTexVC;
use MediaWiki\Extension\Math\WikiTexVC\Parser;
use MediaWikiUnitTestCase;
/**
* @covers \MediaWiki\Extension\Math\WikiTexVC\Parser
*/
class RenderTest extends MediaWikiUnitTestCase {
public function provideTestCases() {
return [
[
'in' => '',
],
[
'in' => 'a',
],
[
'in' => 'a^2',
'out' => 'a^{2}'
],
[
'in' => 'a^2+b^{2}',
'out' => 'a^{2}+b^{2}'
],
[
'in' => 'a^{2}+b^{2}',
],
[
'in' => 'l_a^2+l_b^2=l_c^2',
'out' => 'l_{a}^{2}+l_{b}^{2}=l_{c}^{2}'
],
[
'in' => '\\sin(x)+{}{}\\cos(x)^2 newcommand',
'out' => '\\sin(x)+{}{}\\cos(x)^{2}newcommand'
]
];
}
/**
* @dataProvider provideTestCases
*/
public function testRendering( string $in, ?string $out = null ) {
$parser = new Parser();
$out ??= $in;
$result = $parser->parse( $in );
$rendered = $result->render();
$this->assertSame( $out, $rendered, 'Error rendering input: '
. $in . ' rendered output is: ' . $rendered . ' should be: ' . $out );
}
}