| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Extension\Math\Tests\WikiTexVC\Nodes; |
| 4 |
|
| 5 |
use ArgumentCountError; |
| 6 |
use MediaWiki\Extension\Math\WikiTexVC\Nodes\Big; |
| 7 |
use MediaWiki\Extension\Math\WikiTexVC\Nodes\Literal; |
| 8 |
use MediaWikiUnitTestCase; |
| 9 |
use RuntimeException; |
| 10 |
use TypeError; |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
class BigTest extends MediaWikiUnitTestCase { |
| 16 |
|
| 17 |
public function testEmptyBig() { |
| 18 |
$this->expectException( ArgumentCountError::class ); |
| 19 |
new Big(); |
| 20 |
throw new ArgumentCountError( 'Should not create an empty big' ); |
| 21 |
} |
| 22 |
|
| 23 |
public function testOneArgumentBig() { |
| 24 |
$this->expectException( ArgumentCountError::class ); |
| 25 |
new Big( '\\big' ); |
| 26 |
throw new ArgumentCountError( 'Should not create a big with one argument' ); |
| 27 |
} |
| 28 |
|
| 29 |
public function testIncorrectTypeBig() { |
| 30 |
$this->expectException( TypeError::class ); |
| 31 |
new Big( '\\big', new Literal( 'a' ) ); |
| 32 |
throw new RuntimeException( 'Should not create a big with incorrect type' ); |
| 33 |
} |
| 34 |
|
| 35 |
public function testBasicFunctionBig() { |
| 36 |
$big = new Big( '\\big', 'a' ); |
| 37 |
$this->assertEquals( '{\\big a}', $big->render(), 'Should create a basic function' ); |
| 38 |
} |
| 39 |
|
| 40 |
public function testGetters() { |
| 41 |
$big = new Big( '\\big', 'a' ); |
| 42 |
$this->assertNotEmpty( $big->getArg() ); |
| 43 |
$this->assertNotEmpty( $big->getFname() ); |
| 44 |
} |
| 45 |
|
| 46 |
public function testExtractIdentifiersBig() { |
| 47 |
$big = new Big( '\\big', 'a' ); |
| 48 |
$this->assertEquals( [], $big->extractIdentifiers(), 'Should extract identifiers' ); |
| 49 |
} |
| 50 |
|
| 51 |
public function testCurliesBig() { |
| 52 |
$big = new Big( '\\big', 'a' ); |
| 53 |
$this->assertEquals( '{\\big a}', $big->inCurlies(), 'Should create exactly one set of curlies' ); |
| 54 |
} |
| 55 |
|
| 56 |
public function testRenderMML() { |
| 57 |
$big = new Big( '\\big', 'a' ); |
| 58 |
$this->assertStringContainsString( '</mrow>', $big->renderMML(), 'Should render to MathML' ); |
| 59 |
} |
| 60 |
} |