mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/TemplateStyles
synced 2024-12-04 04:38:33 +00:00
920c0a13d6
Doesn't really make a difference, but I find it easier to read. Change-Id: I3d58fe7806b0428930d7cabb7936f9eb33e326a2
43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
use MediaWiki\Extension\TemplateStyles\CodeEditorHooks;
|
|
use MediaWiki\Title\Title;
|
|
|
|
/**
|
|
* @group TemplateStyles
|
|
* @covers \MediaWiki\Extension\TemplateStyles\CodeEditorHooks
|
|
*/
|
|
class TemplateStylesCodeEditorHooksTest extends MediaWikiLangTestCase {
|
|
|
|
protected function setUp(): void {
|
|
parent::setUp();
|
|
|
|
$this->markTestSkippedIfExtensionNotLoaded( 'CodeEditor' );
|
|
}
|
|
|
|
/**
|
|
* @dataProvider provideOnCodeEditorGetPageLanguage
|
|
*/
|
|
public function testOnCodeEditorGetPageLanguage( $useCodeEditor, $model, $expect ) {
|
|
$this->overrideConfigValue( 'TemplateStylesUseCodeEditor', $useCodeEditor );
|
|
|
|
$title = Title::makeTitle( NS_TEMPLATE, 'Test.css' );
|
|
$lang = 'unchanged';
|
|
$ret = ( new CodeEditorHooks )->onCodeEditorGetPageLanguage(
|
|
$title, $lang, $model, 'text/x-whatever'
|
|
);
|
|
$this->assertSame( !$expect, $ret );
|
|
$this->assertSame( $expect ? 'css' : 'unchanged', $lang );
|
|
}
|
|
|
|
public static function provideOnCodeEditorGetPageLanguage() {
|
|
return [
|
|
[ true, 'wikitext', false ],
|
|
[ true, 'css', false ],
|
|
[ true, 'sanitized-css', true ],
|
|
[ false, 'sanitized-css', false ],
|
|
];
|
|
}
|
|
|
|
}
|