1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
<?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' => [
'class' => PageLangLogFormatter::class,
'services' => [
'LanguageNameUtils',
]
]
]
);
}
/**
* 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 );
}
}
|