mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-12-12 16:05:09 +00:00
dcce2100d0
composer: * mediawiki/mediawiki-codesniffer: 39.0.0 → 41.0.0 npm: * cookiejar: 2.1.3 → 2.1.4 * https://github.com/advisories/GHSA-h452-7996-h45h * http-cache-semantics: 4.1.0 → 4.1.1 * https://github.com/advisories/GHSA-rc47-6667-2j5j * ua-parser-js: 1.0.2 → 1.0.34 * https://github.com/advisories/GHSA-fhg7-m89q-25r3 Change-Id: I4198e1cbdc115d27c9fe5b8d0ce813b514524796
66 lines
1.9 KiB
PHP
66 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\Math\Tests\TexVC\Nodes;
|
|
|
|
use ArgumentCountError;
|
|
use InvalidArgumentException;
|
|
use MediaWiki\Extension\Math\TexVC\Nodes\Literal;
|
|
use MediaWiki\Extension\Math\TexVC\Nodes\Matrix;
|
|
use MediaWiki\Extension\Math\TexVC\Nodes\TexArray;
|
|
use MediaWikiUnitTestCase;
|
|
use TypeError;
|
|
|
|
/**
|
|
* @covers \MediaWiki\Extension\Math\TexVC\Nodes\Matrix
|
|
*/
|
|
class MatrixTest extends MediaWikiUnitTestCase {
|
|
private $sampleMatrix;
|
|
|
|
protected function setUp(): void {
|
|
parent::setUp();
|
|
$this->sampleMatrix = new Matrix( 'align',
|
|
new TexArray( new TexArray( new Literal( 'a' ) ) ) );
|
|
}
|
|
|
|
public function testEmptyMatrix() {
|
|
$this->expectException( ArgumentCountError::class );
|
|
new Matrix();
|
|
throw new TypeError( 'Should not create an empty matrix' );
|
|
}
|
|
|
|
public function testNestedArguments() {
|
|
$this->expectException( InvalidArgumentException::class );
|
|
new Matrix(
|
|
'align',
|
|
new TexArray(
|
|
new Literal( 'a' ) ) );
|
|
throw new TypeError( 'Nested arguments have to be type of TexArray' );
|
|
}
|
|
|
|
public function testInstanceOfTexNode() {
|
|
// this was an instance of TexNode validation didnt verify in php, for review: is this workaround sufficient ?
|
|
$this->assertEquals( 'MediaWiki\\Extension\\Math\\TexVC\\Nodes\\TexNode',
|
|
get_parent_class( $this->sampleMatrix ),
|
|
'Should create an instance of TexNode' );
|
|
}
|
|
|
|
public function testGetters() {
|
|
$this->assertNotEmpty( $this->sampleMatrix->getTop() );
|
|
$this->assertNotEmpty( $this->sampleMatrix->getMainarg() );
|
|
}
|
|
|
|
public function testRenderMatrix() {
|
|
$this->assertEquals( '{\\begin{align}a\\end{align}}', $this->sampleMatrix->render() );
|
|
}
|
|
|
|
public function testExtractCurlies() {
|
|
$this->assertEquals( '{\\begin{align}a\\end{align}}', $this->sampleMatrix->inCurlies(),
|
|
'Should not create extra curlies' );
|
|
}
|
|
|
|
public function testExtractIdentifiers() {
|
|
$this->assertEquals( [ 'a' ], $this->sampleMatrix->extractIdentifiers(),
|
|
'Should extract identifiers' );
|
|
}
|
|
}
|