Debian Codegraph @

extensions/Math/tests/phpunit/unit/WikiTexVC/RenderTest.php

raw symbols SCIP
1 <?php
2
3 namespace MediaWiki\Extension\Math\Tests\WikiTexVC;
4
5 use MediaWiki\Extension\Math\WikiTexVC\Parser;
6 use MediaWikiUnitTestCase;
7
8 /**
9 * @covers \MediaWiki\Extension\Math\WikiTexVC\Parser
10 */
11 class RenderTest extends MediaWikiUnitTestCase {
12
13 public function provideTestCases() {
14 return [
15 [
16 'in' => '',
17 ],
18 [
19 'in' => 'a',
20 ],
21 [
22 'in' => 'a^2',
23 'out' => 'a^{2}'
24 ],
25 [
26 'in' => 'a^2+b^{2}',
27 'out' => 'a^{2}+b^{2}'
28 ],
29 [
30 'in' => 'a^{2}+b^{2}',
31 ],
32 [
33 'in' => 'l_a^2+l_b^2=l_c^2',
34 'out' => 'l_{a}^{2}+l_{b}^{2}=l_{c}^{2}'
35 ],
36 [
37 'in' => '\\sin(x)+{}{}\\cos(x)^2 newcommand',
38 'out' => '\\sin(x)+{}{}\\cos(x)^{2}newcommand'
39 ]
40 ];
41 }
42
43 /**
44 * @dataProvider provideTestCases
45 */
46 public function testRendering( string $in, ?string $out = null ) {
47 $parser = new Parser();
48
49 $out ??= $in;
50 $result = $parser->parse( $in );
51 $rendered = $result->render();
52 $this->assertSame( $out, $rendered, 'Error rendering input: '
53 . $in . ' rendered output is: ' . $rendered . ' should be: ' . $out );
54 }
55 }