mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-12-19 11:21:48 +00:00
ffafba0695
Returning true is the same as returning nothing. It's only meaningful when a hook handler can also return false. Some actually do this. I'm not touching these. See Icccf60b for the reasoning why the added `@return void` are beneficial. Change-Id: I6de7addee853ff183058e6c84e87a5b275c785e8
42 lines
1.1 KiB
PHP
42 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 ],
|
|
[ 'Module:Foo/doc', null ],
|
|
[ 'Module:Foo/styles.css', 'sanitized-css', 'sanitized-css' ],
|
|
[ 'Module:Foo.json', CONTENT_MODEL_JSON ],
|
|
[ 'Module:Foo/subpage.json', CONTENT_MODEL_JSON ],
|
|
[ 'Main Page', null ],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @dataProvider provideContentHandlerDefaultModelFor
|
|
*/
|
|
public function testContentHandlerDefaultModelFor( $name, $expected,
|
|
$before = null
|
|
) {
|
|
$title = Title::newFromText( $name );
|
|
$model = $before;
|
|
( new Hooks(
|
|
MediaWikiServices::getInstance()->getMainConfig()
|
|
) )->onContentHandlerDefaultModelFor( $title, $model );
|
|
$this->assertSame( $expected, $model );
|
|
}
|
|
}
|