Debian Codegraph @

extensions/Math/tests/phpunit/MathSourceTest.php

raw symbols SCIP
1 <?php
2
3 use MediaWiki\Extension\Math\MathConfig;
4 use MediaWiki\Extension\Math\MathSource;
5
6 /**
7 * Test the TeX source output format.
8 *
9 * @covers \MediaWiki\Extension\Math\MathSource
10 *
11 * @license GPL-2.0-or-later
12 */
13 class MathSourceTest extends MediaWikiIntegrationTestCase {
14
15 /**
16 * Checks the basic functionality
17 * i.e. if the span element is generated right.
18 */
19 public function testBasics() {
20 $renderer = $this->getServiceContainer()
21 ->get( 'Math.RendererFactory' )
22 ->getRenderer( 'a+b', [], MathConfig::MODE_SOURCE );
23 $renderer->render();
24 $real = $renderer->getHtmlOutput();
25 $this->assertEquals(
26 '<span class="mwe-math-fallback-source-inline tex" dir="ltr">$ a+b $</span>',
27 $real,
28 "Rendering of a+b in plain Text mode"
29 );
30 }
31
32 /**
33 * Checks if newlines are converted to spaces correctly.
34 */
35 public function testNewLines() {
36 $renderer = $this->getServiceContainer()
37 ->get( 'Math.RendererFactory' )
38 ->getRenderer( "a\n b", [], MathConfig::MODE_SOURCE );
39 $renderer->render();
40 $real = $renderer->getHtmlOutput();
41 $this->assertSame(
42 '<span class="mwe-math-fallback-source-inline tex" dir="ltr">$ a b $</span>',
43 $real,
44 "converting newlines to spaces"
45 );
46 }
47
48 public function testConstructor() {
49 $renderer = new MathSource( 'a' );
50
51 $this->assertEquals( MathConfig::MODE_SOURCE, $renderer->getMode() );
52 }
53
54 public function testRender() {
55 $renderer = new MathSource( 'a+b' );
56
57 $this->assertTrue( $renderer->render() );
58 $this->assertFalse( $renderer->isChanged() );
59 }
60 }