Debian Codegraph @

extensions/Math/tests/phpunit/unit/WikiTexVC/Nodes/Fun1nbTest.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\Fun1nb;
7 use MediaWiki\Extension\Math\WikiTexVC\Nodes\Literal;
8 use MediaWikiUnitTestCase;
9 use TypeError;
10
11 /**
12 * @covers \MediaWiki\Extension\Math\WikiTexVC\Nodes\Fun1nb
13 */
14 class Fun1nbTest extends MediaWikiUnitTestCase {
15
16 public function testEmptyFun1nb() {
17 $this->expectException( ArgumentCountError::class );
18 new Fun1nb();
19 throw new ArgumentCountError( 'Should not create an empty fun1nb' );
20 }
21
22 public function testOneArgumentFun1nb() {
23 $this->expectException( ArgumentCountError::class );
24 new Fun1nb( '\\f' );
25 throw new ArgumentCountError( 'Should not create a fun1nb with one argument' );
26 }
27
28 public function testIncorrectTypeFun1nb() {
29 $this->expectException( TypeError::class );
30 new Fun1nb( '\\f', 'x' );
31 throw new TypeError( 'Should not create a fun1nb with incorrect type' );
32 }
33
34 public function testBasicFunctionFun1nb() {
35 $fun1nb = new Fun1nb( '\\f', new Literal( 'a' ) );
36 $this->assertEquals( '\\f {a} ', $fun1nb->render(), 'Should create a basic function' );
37 }
38
39 public function testGetters() {
40 $fun1nb = new Fun1nb( '\\f', new Literal( 'a' ) );
41 $this->assertNotEmpty( $fun1nb->getFname() );
42 $this->assertNotEmpty( $fun1nb->getArg() );
43 }
44
45 public function testCurliesFun1nb() {
46 $f = new Fun1nb( '\\f', new Literal( 'a' ) );
47 $this->assertEquals( '{\\f {a} }', $f->inCurlies(),
48 'Should create exactly one set of curlies' );
49 }
50 }