mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-12-21 02:52:42 +00:00
7df30e0651
This avoids the use of Parsoid's SiteConfig::getMWConfigValue() method, which is unnecessary when the extension has direct access to MediaWiki services itself. This also fixes the omission of CiteResponsiveReferencesThreshold from the extension.json. Change-Id: I01b43136b0827f185523f1318253372b09750de4
38 lines
1 KiB
PHP
38 lines
1 KiB
PHP
<?php
|
|
|
|
namespace Cite\Tests\Unit;
|
|
|
|
use Cite\Parsoid\References;
|
|
use MediaWiki\Config\Config;
|
|
use MediaWikiUnitTestCase;
|
|
use Wikimedia\Parsoid\Ext\ParsoidExtensionAPI;
|
|
use Wikimedia\Parsoid\NodeData\DataMw;
|
|
use Wikimedia\Parsoid\Utils\DOMDataUtils;
|
|
use Wikimedia\Parsoid\Utils\DOMUtils;
|
|
|
|
/**
|
|
* @covers \Cite\Parsoid\References
|
|
* @license GPL-2.0-or-later
|
|
*/
|
|
class ReferencesTest extends MediaWikiUnitTestCase {
|
|
|
|
public function testProcessAttributeEmbeddedHTML() {
|
|
$doc = DOMUtils::parseHTML( '' );
|
|
DOMDataUtils::prepareDoc( $doc );
|
|
$elt = $doc->createElement( 'a' );
|
|
DOMDataUtils::setDataMw( $elt, new DataMw( [ 'body' => (object)[ 'html' => 'old' ] ] ) );
|
|
|
|
$refs = new References( $this->createNoOpMock( Config::class ) );
|
|
$refs->processAttributeEmbeddedHTML(
|
|
$this->createNoOpMock( ParsoidExtensionAPI::class ),
|
|
$elt,
|
|
fn () => 'new'
|
|
);
|
|
|
|
$this->assertSame( 'new', DOMDataUtils::getDataMw( $elt )->body->html );
|
|
}
|
|
|
|
// TODO: Incomplete, there are many more static and non-static methods to test
|
|
|
|
}
|