Debian Codegraph @

extensions/Cite/tests/phpunit/unit/Parsoid/RefTest.php

raw symbols SCIP
1 <?php
2
3 namespace Cite\Tests\Unit;
4
5 use Cite\Parsoid\Ref;
6 use MediaWikiUnitTestCase;
7 use Wikimedia\Parsoid\Ext\ParsoidExtensionAPI;
8 use Wikimedia\Parsoid\NodeData\DataMw;
9 use Wikimedia\Parsoid\Utils\DOMDataUtils;
10 use Wikimedia\Parsoid\Utils\DOMUtils;
11
12 /**
13 * @covers \Cite\Parsoid\Ref
14 * @license GPL-2.0-or-later
15 */
16 class RefTest extends MediaWikiUnitTestCase {
17
18 public function testProcessAttributeEmbeddedHTML() {
19 $doc = DOMUtils::parseHTML( '' );
20 DOMDataUtils::prepareDoc( $doc );
21 $elt = $doc->createElement( 'a' );
22 DOMDataUtils::setDataMw( $elt, new DataMw( [ 'body' => (object)[ 'html' => 'old' ] ] ) );
23
24 $group = new Ref();
25 $group->processAttributeEmbeddedHTML(
26 $this->createNoOpMock( ParsoidExtensionAPI::class ),
27 $elt,
28 fn () => 'new'
29 );
30
31 $this->assertSame( 'new', DOMDataUtils::getDataMw( $elt )->body->html );
32 }
33
34 // TODO: Incomplete, there are a few more public methods to test
35
36 }