Debian Codegraph @

tests/phpunit/integration/includes/parser/Parsoid/HtmlTransformFactoryTest.php

raw symbols SCIP
1 <?php
2
3 namespace MediaWiki\Tests\Parser\Parsoid;
4
5 use MediaWiki\Page\PageIdentityValue;
6 use MediaWiki\Parser\Parsoid\HtmlToContentTransform;
7 use MediaWiki\Parser\Parsoid\HtmlTransformFactory;
8 use MediaWikiIntegrationTestCase;
9 use Wikimedia\Parsoid\Utils\ContentUtils;
10 use Wikimedia\Parsoid\Utils\DOMCompat;
11
12 /**
13 * @coversDefaultClass \MediaWiki\Parser\Parsoid\HtmlTransformFactory
14 */
15 class HtmlTransformFactoryTest extends MediaWikiIntegrationTestCase {
16 /**
17 * @covers ::__construct
18 */
19 public function testGetContentTransformFactory() {
20 $factory = $this->getServiceContainer()->getHtmlTransformFactory();
21 $this->assertInstanceOf( HtmlTransformFactory::class, $factory );
22 }
23
24 /**
25 * @covers ::getHtmlToContentTransform
26 */
27 public function testGetHtmlToContentTransform() {
28 $factory = $this->getServiceContainer()->getHtmlTransformFactory();
29 $modifiedHTML = '<p>Hello World</p>';
30
31 $transform = $factory->getHtmlToContentTransform(
32 $modifiedHTML,
33 PageIdentityValue::localIdentity( 0, NS_MAIN, 'Test' )
34 );
35
36 $this->assertInstanceOf( HtmlToContentTransform::class, $transform );
37
38 $actualHTML = ContentUtils::toXML( DOMCompat::getBody( $transform->getModifiedDocument() ) );
39 $this->assertStringContainsString( $modifiedHTML, $actualHTML );
40 }
41
42 }