2019-01-12 19:03:01 +00:00
|
|
|
<?php
|
|
|
|
|
2022-07-30 22:43:58 +00:00
|
|
|
namespace MediaWiki\Extension\Scribunto\Tests;
|
2022-04-07 23:12:32 +00:00
|
|
|
|
2022-07-30 22:43:58 +00:00
|
|
|
use MediaWiki\Extension\Scribunto\Hooks;
|
|
|
|
use MediaWikiCoversValidator;
|
|
|
|
use Monolog\Test\TestCase;
|
|
|
|
use Title;
|
|
|
|
|
2022-10-08 19:51:24 +00:00
|
|
|
/**
|
|
|
|
* @covers \MediaWiki\Extension\Scribunto\Hooks
|
|
|
|
*/
|
2022-07-30 22:43:58 +00:00
|
|
|
class HooksTest extends 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 ],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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;
|
2022-07-30 22:43:58 +00:00
|
|
|
$ret = Hooks::contentHandlerDefaultModelFor( $title, $model );
|
2019-01-12 19:03:01 +00:00
|
|
|
$this->assertSame( $retVal, $ret );
|
|
|
|
$this->assertSame( $expected, $model );
|
|
|
|
}
|
|
|
|
}
|