2015-04-09 09:09:36 +00:00
|
|
|
<?php
|
|
|
|
|
|
2022-08-18 16:44:16 +00:00
|
|
|
use MediaWiki\MainConfigNames;
|
|
|
|
|
use MediaWiki\MainConfigSchema;
|
|
|
|
|
|
2017-12-25 07:26:01 +00:00
|
|
|
/**
|
|
|
|
|
* @covers PageLangLogFormatter
|
|
|
|
|
*/
|
2015-04-09 09:09:36 +00:00
|
|
|
class PageLangLogFormatterTest extends LogFormatterTestCase {
|
|
|
|
|
|
2021-07-22 03:11:47 +00:00
|
|
|
protected function setUp(): void {
|
2015-04-09 09:09:36 +00:00
|
|
|
parent::setUp();
|
|
|
|
|
|
2022-11-03 10:52:52 +00:00
|
|
|
// Clear all hooks to disable cldr extension
|
|
|
|
|
$this->clearHooks();
|
|
|
|
|
|
2015-04-09 09:09:36 +00:00
|
|
|
// Register LogHandler, see $wgPageLanguageUseDB in Setup.php
|
2022-08-18 16:44:16 +00:00
|
|
|
$this->overrideConfigValue(
|
|
|
|
|
MainConfigNames::LogActionsHandlers,
|
|
|
|
|
MainConfigSchema::getDefaultValue( MainConfigNames::LogActionsHandlers ) +
|
|
|
|
|
[ 'pagelang/pagelang' => PageLangLogFormatter::class ]
|
|
|
|
|
);
|
2015-04-09 09:09:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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() {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
2015-04-09 09:09:36 +00:00
|
|
|
// Current format
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
|
|
|
|
[
|
2015-04-09 09:09:36 +00:00
|
|
|
'type' => 'pagelang',
|
|
|
|
|
'action' => 'pagelang',
|
|
|
|
|
'comment' => 'page lang comment',
|
|
|
|
|
'namespace' => NS_MAIN,
|
|
|
|
|
'title' => 'Page',
|
2016-02-17 09:09:32 +00:00
|
|
|
'params' => [
|
2015-04-09 09:09:36 +00:00
|
|
|
'4::oldlanguage' => 'en',
|
|
|
|
|
'5::newlanguage' => 'de[def]',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
[
|
2016-01-17 01:54:56 +00:00
|
|
|
'text' => 'User changed the language of Page from English (en) to Deutsch (de) [default]',
|
2016-02-17 09:09:32 +00:00
|
|
|
'api' => [
|
2015-04-09 09:09:36 +00:00
|
|
|
'oldlanguage' => 'en',
|
|
|
|
|
'newlanguage' => 'de[def]'
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
];
|
2015-04-09 09:09:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @dataProvider providePageLangLogDatabaseRows
|
|
|
|
|
*/
|
|
|
|
|
public function testPageLangLogDatabaseRows( $row, $extra ) {
|
|
|
|
|
$this->doTestLogFormatter( $row, $extra );
|
|
|
|
|
}
|
|
|
|
|
}
|