mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-12-12 07:55:11 +00:00
551340ee11
When running tests locally I don't want to install wikibase if I'm not working on wikibase-math integration. It's annoying that some of the tests fail in this schenario. Depends-On: Id996abdb353547b95d795494ba961b9a215ef2ef Change-Id: I836c7a3bab5393b7482e985d9148226373ae0a58
66 lines
2.1 KiB
PHP
66 lines
2.1 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->markTestSkippedIfExtensionNotLoaded( 'WikibaseClient' );
|
|
$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 );
|
|
}
|
|
}
|