Debian Codegraph @

extensions/Math/tests/phpunit/unit/WikiTexVC/Nodes/ChemFun2uTest.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\ChemFun2u;
7 use MediaWiki\Extension\Math\WikiTexVC\Nodes\Literal;
8 use MediaWikiUnitTestCase;
9 use TypeError;
10
11 /**
12 * @covers \MediaWiki\Extension\Math\WikiTexVC\Nodes\ChemFun2u
13 */
14 class ChemFun2uTest extends MediaWikiUnitTestCase {
15
16 public function testEmptyChemFun2u() {
17 $this->expectException( ArgumentCountError::class );
18 new ChemFun2u();
19 throw new ArgumentCountError( 'Should not create an empty ChemFun2u' );
20 }
21
22 public function testOneArgumentChemFun2u() {
23 $this->expectException( ArgumentCountError::class );
24 new ChemFun2u( 'a' );
25 throw new ArgumentCountError( 'Should not create a ChemFun2u with one argument' );
26 }
27
28 public function testIncorrectTypeChemFun2u() {
29 $this->expectException( TypeError::class );
30 new ChemFun2u( 'a', 'b', 'c' );
31 throw new TypeError( 'Should not create a ChemFun2u with incorrect type' );
32 }
33
34 public function testBasicChemFun2u() {
35 $fun2u = new ChemFun2u( 'a', new Literal( 'b' ), new Literal( 'c' ) );
36 $this->assertEquals( 'a{b}_{c}', $fun2u->render(), 'Should create a basic ChemFun2u' );
37 }
38
39 public function testGetters() {
40 $fun2u = new ChemFun2u( 'a', new Literal( 'b' ), new Literal( 'c' ) );
41 $this->assertNotEmpty( $fun2u->getFname() );
42 $this->assertNotEmpty( $fun2u->getLeft() );
43 $this->assertNotEmpty( $fun2u->getRight() );
44 }
45
46 public function testExtractIdentifiers() {
47 $fun2u = new ChemFun2u( 'a', new Literal( 'b' ), new Literal( 'c' ) );
48 $this->assertEquals( [], $fun2u->extractIdentifiers(), 'Should extract identifiers' );
49 }
50 }