Since the introduction of the new hooks stystem, it is not possible to clear all hooks by setting $wgHooks. This would only clear old-style hooks. This is becoming increasingly problematic as the new hooks system is adopted by more and more extensions. Introduce a method that allows tests to reset many or all hooks. This isn't needed much in core, but extension tests need it. Change-Id: Ica3eb88fe23fe822d2aadb96ff5d15f80dce0d7b
62 lines
1.4 KiB
PHP
62 lines
1.4 KiB
PHP
<?php
|
|
|
|
use MediaWiki\MainConfigNames;
|
|
use MediaWiki\MainConfigSchema;
|
|
|
|
/**
|
|
* @covers PageLangLogFormatter
|
|
*/
|
|
class PageLangLogFormatterTest extends LogFormatterTestCase {
|
|
|
|
protected function setUp(): void {
|
|
parent::setUp();
|
|
|
|
// Clear all hooks to disable cldr extension
|
|
$this->clearHooks();
|
|
|
|
// Register LogHandler, see $wgPageLanguageUseDB in Setup.php
|
|
$this->overrideConfigValue(
|
|
MainConfigNames::LogActionsHandlers,
|
|
MainConfigSchema::getDefaultValue( MainConfigNames::LogActionsHandlers ) +
|
|
[ 'pagelang/pagelang' => PageLangLogFormatter::class ]
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Provide different rows from the logging table to test
|
|
* for backward compatibility.
|
|
* Do not change the existing data, just add a new database row
|
|
*/
|
|
public static function providePageLangLogDatabaseRows() {
|
|
return [
|
|
// Current format
|
|
[
|
|
[
|
|
'type' => 'pagelang',
|
|
'action' => 'pagelang',
|
|
'comment' => 'page lang comment',
|
|
'namespace' => NS_MAIN,
|
|
'title' => 'Page',
|
|
'params' => [
|
|
'4::oldlanguage' => 'en',
|
|
'5::newlanguage' => 'de[def]',
|
|
],
|
|
],
|
|
[
|
|
'text' => 'User changed the language of Page from English (en) to Deutsch (de) [default]',
|
|
'api' => [
|
|
'oldlanguage' => 'en',
|
|
'newlanguage' => 'de[def]'
|
|
],
|
|
],
|
|
],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @dataProvider providePageLangLogDatabaseRows
|
|
*/
|
|
public function testPageLangLogDatabaseRows( $row, $extra ) {
|
|
$this->doTestLogFormatter( $row, $extra );
|
|
}
|
|
}
|