mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-11-15 11:48:23 +00:00
b409746fc6
composer: * mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0 npm: * postcss: 7.0.35 → 7.0.36 * https://npmjs.com/advisories/1693 (CVE-2021-23368) * ws: 7.3.0 → 7.5.3 * https://npmjs.com/advisories/1748 (CVE-2021-32640) * glob-parent: 5.1.1 → 5.1.2 * https://npmjs.com/advisories/1751 (CVE-2020-28469) * trim-newlines: 3.0.0 → 3.0.1 * https://npmjs.com/advisories/1753 (CVE-2021-33623) * normalize-url: 4.5.0 → 4.5.1 * https://npmjs.com/advisories/1755 (CVE-2021-33502) Change-Id: Ie14979780cdbd04fa2804f5317e8b0f6b0029470
65 lines
2 KiB
PHP
65 lines
2 KiB
PHP
<?php
|
|
|
|
use Wikibase\DataModel\Entity\PropertyId;
|
|
use Wikibase\DataModel\Services\Entity\PropertyDataTypeMatcher;
|
|
use Wikibase\DataModel\Snak\PropertyNoValueSnak;
|
|
use Wikibase\DataModel\Statement\Statement;
|
|
|
|
/**
|
|
* Test the MathDataUpdater for Wikidata
|
|
*
|
|
* @covers \MediaWiki\Extension\Math\MathDataUpdater
|
|
*
|
|
* @license GPL-2.0-or-later
|
|
*/
|
|
class MathDataUpdaterTest extends MediaWikiTestCase {
|
|
|
|
/**
|
|
* @var PropertyId
|
|
*/
|
|
private $mathProperty;
|
|
/**
|
|
* @var PropertyId
|
|
*/
|
|
private $otherProperty;
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
protected function setUp(): void {
|
|
parent::setUp();
|
|
$this->mathProperty = new PropertyId( 'P' . DummyPropertyDataTypeLookup::$mathId );
|
|
$this->otherProperty = new PropertyId( 'P' . ( DummyPropertyDataTypeLookup::$mathId + 1 ) );
|
|
}
|
|
|
|
public function testNoMath() {
|
|
$matcher = new PropertyDataTypeMatcher( new DummyPropertyDataTypeLookup() );
|
|
$updater = new MathDataUpdater( $matcher );
|
|
$statement = new Statement( new PropertyNoValueSnak( $this->otherProperty ) );
|
|
$updater->processStatement( $statement );
|
|
$parserOutput = $this->getMockBuilder( ParserOutput::class )->onlyMethods( [
|
|
'addModules',
|
|
'addModuleStyles',
|
|
] )->getMock();
|
|
$parserOutput->expects( $this->never() )->method( 'addModules' );
|
|
$parserOutput->expects( $this->never() )->method( 'addModuleStyles' );
|
|
/** @var ParserOutput $parserOutput */
|
|
$updater->updateParserOutput( $parserOutput );
|
|
}
|
|
|
|
public function testMath() {
|
|
$matcher = new PropertyDataTypeMatcher( new DummyPropertyDataTypeLookup() );
|
|
$updater = new MathDataUpdater( $matcher );
|
|
$statement = new Statement( new PropertyNoValueSnak( $this->mathProperty ) );
|
|
$updater->processStatement( $statement );
|
|
$parserOutput = $this->getMockBuilder( ParserOutput::class )->onlyMethods( [
|
|
'addModules',
|
|
'addModuleStyles',
|
|
] )->getMock();
|
|
$parserOutput->expects( $this->once() )->method( 'addModules' );
|
|
$parserOutput->expects( $this->once() )->method( 'addModuleStyles' );
|
|
/** @var ParserOutput $parserOutput */
|
|
$updater->updateParserOutput( $parserOutput );
|
|
}
|
|
}
|