Debian Codegraph @

extensions/Math/tests/phpunit/unit/WikiTexVC/Nodes/MhchemTest.php

raw symbols SCIP
1 <?php
2
3 namespace MediaWiki\Extension\Math\Tests\WikiTexVC\Nodes;
4
5 use ArgumentCountError;
6 use MediaWiki\Extension\Math\WikiTexVC\Nodes\Literal;
7 use MediaWiki\Extension\Math\WikiTexVC\Nodes\Mhchem;
8 use MediaWikiUnitTestCase;
9 use TypeError;
10
11 /**
12 * @covers \MediaWiki\Extension\Math\WikiTexVC\Nodes\Mhchem
13 */
14 class MhchemTest extends MediaWikiUnitTestCase {
15
16 public function testEmptyMhchem() {
17 $this->expectException( ArgumentCountError::class );
18 new Mhchem();
19 throw new ArgumentCountError( 'Should not create an empty Mhchem' );
20 }
21
22 public function testOneArgumentMhchem() {
23 $this->expectException( ArgumentCountError::class );
24 new Mhchem( '\\f' );
25 throw new ArgumentCountError( 'Should not create a Mhchem with one argument' );
26 }
27
28 public function testIncorrectTypeMhchem() {
29 $this->expectException( TypeError::class );
30 new Mhchem( '\\f', 'x' );
31 throw new TypeError( 'Should not create a Mhchem with incorrect type' );
32 }
33
34 public function testBasicFunctionMhchem() {
35 $f = new Mhchem( '\\f', new Literal( 'a' ) );
36 $this->assertEquals( '{\\f {a}}', $f->render(), 'Should create a basic function' );
37 }
38
39 public function testCurliesMhchem() {
40 $f = new Mhchem( '\\f', new Literal( 'a' ) );
41 $this->assertEquals( '{{\\f {a}}}', $f->inCurlies(),
42 'Should create curlies' );
43 }
44
45 public function testExtractIdentifiersMhchem() {
46 $n = new Mhchem( '\\f', new Literal( 'a' ) );
47 $this->assertEquals( [], $n->extractIdentifiers(),
48 'Should extract identifiers' );
49 }
50 }