2019-01-12 19:03:01 +00:00
|
|
|
<?php
|
|
|
|
|
2022-04-07 23:12:32 +00:00
|
|
|
use MediaWiki\Extension\Scribunto\Hooks as ScribuntoHooks;
|
|
|
|
|
2022-08-03 10:03:12 +00:00
|
|
|
class ScribuntoHooksTest extends PHPUnit\Framework\TestCase {
|
2019-07-22 00:49:41 +00:00
|
|
|
use MediaWikiCoversValidator;
|
2019-01-12 19:03:01 +00:00
|
|
|
|
|
|
|
public function provideContentHandlerDefaultModelFor() {
|
|
|
|
return [
|
2018-10-18 13:37:23 +00:00
|
|
|
[ 'Module:Foo', CONTENT_MODEL_SCRIBUNTO, true ],
|
2019-01-12 19:03:01 +00:00
|
|
|
[ 'Module:Foo/doc', null, true ],
|
2018-10-18 13:37:23 +00:00
|
|
|
[ 'Module:Foo/styles.css', 'sanitized-css', true, 'sanitized-css' ],
|
2022-09-22 06:19:39 +00:00
|
|
|
[ 'Module:Foo.json', CONTENT_MODEL_JSON, true ],
|
|
|
|
[ 'Module:Foo/subpage.json', CONTENT_MODEL_JSON, true ],
|
2019-01-12 19:03:01 +00:00
|
|
|
[ 'Main Page', null, true ],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-04-07 23:12:32 +00:00
|
|
|
* @covers \MediaWiki\Extension\Scribunto\Hooks::contentHandlerDefaultModelFor
|
2019-01-12 19:03:01 +00:00
|
|
|
* @dataProvider provideContentHandlerDefaultModelFor
|
|
|
|
*/
|
2018-10-18 13:37:23 +00:00
|
|
|
public function testContentHandlerDefaultModelFor( $name, $expected,
|
|
|
|
$retVal, $before = null
|
|
|
|
) {
|
2019-01-12 19:03:01 +00:00
|
|
|
$title = Title::newFromText( $name );
|
2018-10-18 13:37:23 +00:00
|
|
|
$model = $before;
|
2019-01-12 19:03:01 +00:00
|
|
|
$ret = ScribuntoHooks::contentHandlerDefaultModelFor( $title, $model );
|
|
|
|
$this->assertSame( $retVal, $ret );
|
|
|
|
$this->assertSame( $expected, $model );
|
|
|
|
}
|
|
|
|
}
|