mediawiki-extensions-Math/tests/phpunit/unit/TexVC/Nodes/FQTest.php
Stegmujo 08b16c99df
Fix preceding subscript
* example: "{}_1^2\!\Omega_3^4"
* MMLFullcoverageTest cases: 119, 381
* Add isEmpty method to TexNode
* Add empty mrow for prescripts

Bug: T327391
Change-Id: If60e5211bf43e50465072c049d8c432e621832b8
2023-04-05 13:00:06 +02:00

54 lines
1.7 KiB
PHP

<?php
namespace MediaWiki\Extension\Math\Tests\TexVC\Nodes;
use ArgumentCountError;
use MediaWiki\Extension\Math\TexVC\MMLnodes\MMLmrow;
use MediaWiki\Extension\Math\TexVC\Nodes\Curly;
use MediaWiki\Extension\Math\TexVC\Nodes\FQ;
use MediaWiki\Extension\Math\TexVC\Nodes\Literal;
use MediaWiki\Extension\Math\TexVC\Nodes\TexArray;
use MediaWikiUnitTestCase;
use TypeError;
/**
* @covers \MediaWiki\Extension\Math\TexVC\Nodes\FQ
*/
class FQTest extends MediaWikiUnitTestCase {
public function testEmptyFQ() {
$this->expectException( ArgumentCountError::class );
new FQ();
throw new ArgumentCountError( 'Should not create an empty fq' );
}
public function testOneArgumentFQ() {
$this->expectException( ArgumentCountError::class );
new FQ( new Literal( 'a' ) );
throw new ArgumentCountError( 'Should not create a fq with one argument' );
}
public function testIncorrectTypeFQ() {
$this->expectException( TypeError::class );
new FQ( 'a', 'b', 'c' );
throw new TypeError( 'Should not create a fq with incorrect type' );
}
public function testBasicFQ() {
$fq = new FQ( new Literal( 'a' ), new Literal( 'b' ), new Literal( 'c' ) );
$this->assertEquals( 'a_{b}^{c}', $fq->render(), 'Should create a basic fq' );
}
public function testGetters() {
$fq = new FQ( new Literal( 'a' ), new Literal( 'b' ), new Literal( 'c' ) );
$this->assertNotEmpty( $fq->getBase() );
$this->assertNotEmpty( $fq->getUp() );
$this->assertNotEmpty( $fq->getDown() );
}
public function testRenderEmptyDq() {
$fq = new FQ( new Curly( new TexArray() ), new Literal( 'b' ), new Literal( 'c' ) );
$this->assertStringContainsString( ( new MMLmrow() )->getEmpty(), $fq->renderMML() );
}
}