MediaWiki REL1_31
ImportLogFormatterTest.php
Go to the documentation of this file.
1<?php
2
7
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
56 public function testUploadLogDatabaseRows( $row, $extra ) {
57 $this->doTestLogFormatter( $row, $extra );
58 }
59
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
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}
testInterwikiLogDatabaseRows( $row, $extra)
provideInterwikiLogDatabaseRows
static provideUploadLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility.
static provideInterwikiLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility.
testUploadLogDatabaseRows( $row, $extra)
provideUploadLogDatabaseRows
doTestLogFormatter( $row, $extra)
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
const NS_MAIN
Definition Defines.php:74