wiki.techinc.nl/tests/phpunit/integration/includes/parser/Parsoid/Config/SiteConfigTest.php
thiemowmde 4bd95cd96b Use MainConfigNames constants in tests where possible
I believe this makes the code less brittle, and also makes it a bit
more obvious what these strings are meant to represent.

Change-Id: Ia39b5c80af4b495931d0a68fd091b783645dd709
2024-07-10 10:11:22 +00:00

37 lines
1.1 KiB
PHP

<?php
namespace MediaWiki\Tests\Parser\Parsoid\Config;
use MediaWiki\Content\TextContentHandler;
use MediaWiki\MainConfigNames;
use MediaWikiIntegrationTestCase;
/**
* @covers \MediaWiki\Parser\Parsoid\Config\SiteConfig
*/
class SiteConfigTest extends MediaWikiIntegrationTestCase {
public static function provideSupportsContentModels() {
yield [ CONTENT_MODEL_WIKITEXT, true ];
yield [ CONTENT_MODEL_JSON, true ];
yield [ CONTENT_MODEL_JAVASCRIPT, false ];
yield [ 'with-text', true ];
yield [ 'xyzzy', false ];
}
/**
* @dataProvider provideSupportsContentModels
*/
public function testSupportsContentModel( $model, $expected ) {
$contentHandlers = $this->getConfVar( 'ContentHandlers' );
$this->overrideConfigValue( MainConfigNames::ContentHandlers, [
'with-text' => [ 'factory' => static function () {
return new TextContentHandler( 'with-text', [ CONTENT_FORMAT_WIKITEXT, 'plain/test' ] );
} ],
] + $contentHandlers );
$this->resetServices();
$siteConfig = $this->getServiceContainer()->getParsoidSiteConfig();
$this->assertSame( $expected, $siteConfig->supportsContentModel( $model ) );
}
}