Debian Codegraph @

tests/phpunit/includes/logging/ImportLogFormatterTest.php

raw symbols SCIP
1 <?php
2
3 use MediaWiki\Tests\Unit\DummyServicesTrait;
4
5 /**
6 * @covers \ImportLogFormatter
7 */
8 class ImportLogFormatterTest extends LogFormatterTestCase {
9 use DummyServicesTrait;
10
11 /**
12 * Provide different rows from the logging table to test
13 * for backward compatibility.
14 * Do not change the existing data, just add a new database row
15 */
16 public static function provideUploadLogDatabaseRows() {
17 return [
18 // Current format
19 [
20 [
21 'type' => 'import',
22 'action' => 'upload',
23 'comment' => 'upload comment',
24 'namespace' => NS_MAIN,
25 'title' => 'ImportPage',
26 'params' => [
27 '4:number:count' => '1',
28 ],
29 ],
30 [
31 'text' => 'User imported ImportPage by file upload (1 revision)',
32 'api' => [
33 'count' => 1,
34 ],
35 ],
36 ],
37
38 // old format - without details
39 [
40 [
41 'type' => 'import',
42 'action' => 'upload',
43 'comment' => '1 revision: import comment',
44 'namespace' => NS_MAIN,
45 'title' => 'ImportPage',
46 'params' => [],
47 ],
48 [
49 'text' => 'User imported ImportPage by file upload',
50 'api' => [],
51 ],
52 ],
53 ];
54 }
55
56 /**
57 * @dataProvider provideUploadLogDatabaseRows
58 */
59 public function testUploadLogDatabaseRows( $row, $extra ) {
60 $this->doTestLogFormatter( $row, $extra );
61 }
62
63 /**
64 * Provide different rows from the logging table to test
65 * for backward compatibility.
66 * Do not change the existing data, just add a new database row
67 */
68 public static function provideInterwikiLogDatabaseRows() {
69 return [
70 // Current format
71 [
72 [
73 'type' => 'import',
74 'action' => 'interwiki',
75 'comment' => 'interwiki comment',
76 'namespace' => NS_MAIN,
77 'title' => 'ImportPage',
78 'params' => [
79 '4:number:count' => '1',
80 '5:title-link:interwiki' => 'importiw:PageImport',
81 ],
82 ],
83 [
84 'text' => 'User imported ImportPage from importiw:PageImport (1 revision)',
85 'api' => [
86 'count' => 1,
87 'interwiki_ns' => 0,
88 'interwiki_title' => 'importiw:PageImport',
89 ],
90 ],
91 ],
92
93 // old format - without details
94 [
95 [
96 'type' => 'import',
97 'action' => 'interwiki',
98 'comment' => '1 revision from importiw:PageImport: interwiki comment',
99 'namespace' => NS_MAIN,
100 'title' => 'ImportPage',
101 'params' => [],
102 ],
103 [
104 'text' => 'User imported ImportPage from another wiki',
105 'api' => [],
106 ],
107 ],
108 ];
109 }
110
111 /**
112 * @dataProvider provideInterwikiLogDatabaseRows
113 */
114 public function testInterwikiLogDatabaseRows( $row, $extra ) {
115 // Setup importiw: as interwiki prefix
116 $interwikiLookup = $this->getDummyInterwikiLookup( [ 'importiw' ] );
117 $this->setService( 'InterwikiLookup', $interwikiLookup );
118
119 $this->doTestLogFormatter( $row, $extra );
120 }
121 }