mediawiki-extensions-Scribunto/tests/phpunit/HooksTest.php
Umherirrender 648985c981 Use HookHandlers for core hooks
The use of "HookHandlers" attribute in extension.json makes it possible
to inject services into hook handler classes in a future patch.

Bug: T271026
Change-Id: I1583f5075937c4ce71a0d8748700f7012280851c
2023-08-15 13:49:53 +02:00

40 lines
1 KiB
PHP

<?php
namespace MediaWiki\Extension\Scribunto\Tests;
use MediaWiki\Extension\Scribunto\Hooks;
use MediaWikiCoversValidator;
use Monolog\Test\TestCase;
use Title;
/**
* @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 )->onContentHandlerDefaultModelFor( $title, $model );
$this->assertSame( $retVal, $ret );
$this->assertSame( $expected, $model );
}
}