mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-12-18 19:02:27 +00:00
4ccebcdf4b
Pages ending with a ".json" suffix in the Module namespace will use the built-in JSON content model by default. Previously editors had to use Special:ChangeContentModel to get a JSON page, which requires the "editcontentmodel" userright that is not granted to a wide set of users by default. Bug: T144475 Change-Id: I1546fcad823a55a8c5a93177df8715844de1e87c
33 lines
1,009 B
PHP
33 lines
1,009 B
PHP
<?php
|
|
|
|
use MediaWiki\Extension\Scribunto\Hooks as ScribuntoHooks;
|
|
|
|
class ScribuntoHooksTest extends PHPUnit\Framework\TestCase {
|
|
use MediaWikiCoversValidator;
|
|
|
|
public function provideContentHandlerDefaultModelFor() {
|
|
return [
|
|
[ 'Module:Foo', CONTENT_MODEL_SCRIBUNTO, true ],
|
|
[ 'Module:Foo/doc', null, true ],
|
|
[ 'Module:Foo/styles.css', 'sanitized-css', true, 'sanitized-css' ],
|
|
[ 'Module:Foo.json', CONTENT_MODEL_JSON, true ],
|
|
[ 'Module:Foo/subpage.json', CONTENT_MODEL_JSON, true ],
|
|
[ 'Main Page', null, true ],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @covers \MediaWiki\Extension\Scribunto\Hooks::contentHandlerDefaultModelFor
|
|
* @dataProvider provideContentHandlerDefaultModelFor
|
|
*/
|
|
public function testContentHandlerDefaultModelFor( $name, $expected,
|
|
$retVal, $before = null
|
|
) {
|
|
$title = Title::newFromText( $name );
|
|
$model = $before;
|
|
$ret = ScribuntoHooks::contentHandlerDefaultModelFor( $title, $model );
|
|
$this->assertSame( $retVal, $ret );
|
|
$this->assertSame( $expected, $model );
|
|
}
|
|
}
|