mediawiki-extensions-Math/tests/phpunit/unit/WikiTexVC/ParserTest.php
thiemowmde cd4ce78d31 Make use of actual @dataProviders in tests
Instead of manually crafted $this->testCase properties.

Also make use of the dedicated PHPUnit feature to mark as test as
passed. While assertTrue( true ) is a very common hack it can be
confusing.

Change-Id: Ic071bf561929c2a79537111bee18631865f91366
2024-08-31 11:49:04 +00:00

48 lines
1.1 KiB
PHP

<?php
namespace MediaWiki\Extension\Math\Tests\WikiTexVC;
use MediaWiki\Extension\Math\WikiTexVC\Parser;
use MediaWikiUnitTestCase;
/**
* @covers \MediaWiki\Extension\Math\WikiTexVC\Parser
*/
class ParserTest extends MediaWikiUnitTestCase {
/** @var Parser */
private $parser;
protected function setUp(): void {
parent::setUp();
$this->parser = new Parser();
}
public function provideTestCases() {
yield [ '' ];
yield [ 'a' ];
yield [ 'a^2' ];
yield [ 'a^2+b^{2}' ];
yield [ 'l_a^2+l_b^2=l_c^2' ];
}
/**
* @dataProvider provideTestCases
*/
public function testSimpleParse( string $input ) {
$this->parser->parse( $input, [ 'debug' => true ] );
$this->addToAssertionCount( 1 );
}
public function testExample() {
$this->parser->parse( '\\sin(x)+{}{}\\cos(x)^2 newcommand', [ 'debug' => true ] );
$this->addToAssertionCount( 1 );
}
public function testSpecific() {
$resultR = $this->parser->parse( '\\reals' );
$resultS = $this->parser->parse( '\\mathbb{R}' );
$this->assertEquals( $resultR, $resultS, 'Should parse texVC specific functions' );
}
}