mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-12-18 17:50:43 +00:00
650d2c296d
There is much more to test, but it's a start. Intentionally build as pure unit tests to make them as fast as possible. Bug: T354215 Bug: T358652 Change-Id: Iae1a8086b8f2b9e5b11e0117bd3f19fdaa087df0
37 lines
959 B
PHP
37 lines
959 B
PHP
<?php
|
|
|
|
namespace Cite\Tests\Unit;
|
|
|
|
use Cite\Parsoid\References;
|
|
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();
|
|
$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
|
|
|
|
}
|