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