mediawiki-extensions-Scribunto/tests/phpunit/HooksTest.php
thiemowmde ffafba0695 Remove meaningless return true from hook handler functions
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
2024-08-27 08:47:46 +00:00

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 );
}
}