| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Tests\Parser\Parsoid\Config; |
| 4 |
|
| 5 |
use MediaWiki\Content\TextContentHandler; |
| 6 |
use MediaWiki\MainConfigNames; |
| 7 |
use MediaWikiIntegrationTestCase; |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
class SiteConfigTest extends MediaWikiIntegrationTestCase { |
| 13 |
|
| 14 |
public static function provideSupportsContentModels() { |
| 15 |
yield [ CONTENT_MODEL_WIKITEXT, true ]; |
| 16 |
yield [ CONTENT_MODEL_JSON, true ]; |
| 17 |
yield [ CONTENT_MODEL_JAVASCRIPT, false ]; |
| 18 |
yield [ 'with-text', true ]; |
| 19 |
yield [ 'xyzzy', false ]; |
| 20 |
} |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
public function testSupportsContentModel( $model, $expected ) { |
| 26 |
$contentHandlers = $this->getConfVar( MainConfigNames::ContentHandlers ); |
| 27 |
$this->overrideConfigValue( MainConfigNames::ContentHandlers, [ |
| 28 |
'with-text' => [ 'factory' => static function () { |
| 29 |
return new TextContentHandler( 'with-text', [ CONTENT_FORMAT_WIKITEXT, 'plain/test' ] ); |
| 30 |
} ], |
| 31 |
] + $contentHandlers ); |
| 32 |
|
| 33 |
$this->resetServices(); |
| 34 |
$siteConfig = $this->getServiceContainer()->getParsoidSiteConfig(); |
| 35 |
$this->assertSame( $expected, $siteConfig->supportsContentModel( $model ) ); |
| 36 |
} |
| 37 |
} |