Debian Codegraph @

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