mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-12-22 04:43:48 +00:00
2a45dbb577
Also use private instead of public for internal function reportTiming. Change-Id: I52c301d11244436ddc142ec84a7c6740a4ea4d32
43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\Scribunto\Tests;
|
|
|
|
use MediaWiki\Extension\Scribunto\Hooks;
|
|
use MediaWiki\MediaWikiServices;
|
|
use MediaWiki\Title\Title;
|
|
use MediaWikiCoversValidator;
|
|
use Monolog\Test\TestCase;
|
|
|
|
/**
|
|
* @covers \MediaWiki\Extension\Scribunto\Hooks
|
|
*/
|
|
class HooksTest extends TestCase {
|
|
use MediaWikiCoversValidator;
|
|
|
|
public static 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 ],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @dataProvider provideContentHandlerDefaultModelFor
|
|
*/
|
|
public function testContentHandlerDefaultModelFor( $name, $expected,
|
|
$retVal, $before = null
|
|
) {
|
|
$title = Title::newFromText( $name );
|
|
$model = $before;
|
|
$ret = ( new Hooks(
|
|
MediaWikiServices::getInstance()->getMainConfig()
|
|
) )->onContentHandlerDefaultModelFor( $title, $model );
|
|
$this->assertSame( $retVal, $ret );
|
|
$this->assertSame( $expected, $model );
|
|
}
|
|
}
|