MediaWiki REL1_31
UploadLogFormatterTest.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' => 'upload',
19 'action' => 'upload',
20 'comment' => 'upload comment',
21 'namespace' => NS_FILE,
22 'title' => 'File.png',
23 'params' => [
24 'img_sha1' => 'hash',
25 'img_timestamp' => '20150101000000',
26 ],
27 ],
28 [
29 'text' => 'User uploaded File:File.png',
30 'api' => [
31 'img_sha1' => 'hash',
32 'img_timestamp' => '2015-01-01T00:00:00Z',
33 ],
34 ],
35 ],
36
37 // Old format without params
38 [
39 [
40 'type' => 'upload',
41 'action' => 'upload',
42 'comment' => 'upload comment',
43 'namespace' => NS_FILE,
44 'title' => 'File.png',
45 'params' => [],
46 ],
47 [
48 'text' => 'User uploaded File:File.png',
49 'api' => [],
50 ],
51 ],
52 ];
53 }
54
58 public function testUploadLogDatabaseRows( $row, $extra ) {
59 $this->doTestLogFormatter( $row, $extra );
60 }
61
67 public static function provideOverwriteLogDatabaseRows() {
68 return [
69 // Current format
70 [
71 [
72 'type' => 'upload',
73 'action' => 'overwrite',
74 'comment' => 'upload comment',
75 'namespace' => NS_FILE,
76 'title' => 'File.png',
77 'params' => [
78 'img_sha1' => 'hash',
79 'img_timestamp' => '20150101000000',
80 ],
81 ],
82 [
83 'text' => 'User uploaded a new version of File:File.png',
84 'api' => [
85 'img_sha1' => 'hash',
86 'img_timestamp' => '2015-01-01T00:00:00Z',
87 ],
88 ],
89 ],
90
91 // Old format without params
92 [
93 [
94 'type' => 'upload',
95 'action' => 'overwrite',
96 'comment' => 'upload comment',
97 'namespace' => NS_FILE,
98 'title' => 'File.png',
99 'params' => [],
100 ],
101 [
102 'text' => 'User uploaded a new version of File:File.png',
103 'api' => [],
104 ],
105 ],
106 ];
107 }
108
112 public function testOverwriteLogDatabaseRows( $row, $extra ) {
113 $this->doTestLogFormatter( $row, $extra );
114 }
115
121 public static function provideRevertLogDatabaseRows() {
122 return [
123 // Current format
124 [
125 [
126 'type' => 'upload',
127 'action' => 'revert',
128 'comment' => 'upload comment',
129 'namespace' => NS_FILE,
130 'title' => 'File.png',
131 'params' => [
132 'img_sha1' => 'hash',
133 'img_timestamp' => '20150101000000',
134 ],
135 ],
136 [
137 'text' => 'User uploaded File:File.png',
138 'api' => [
139 'img_sha1' => 'hash',
140 'img_timestamp' => '2015-01-01T00:00:00Z',
141 ],
142 ],
143 ],
144
145 // Old format without params
146 [
147 [
148 'type' => 'upload',
149 'action' => 'revert',
150 'comment' => 'upload comment',
151 'namespace' => NS_FILE,
152 'title' => 'File.png',
153 'params' => [],
154 ],
155 [
156 'text' => 'User uploaded File:File.png',
157 'api' => [],
158 ],
159 ],
160 ];
161 }
162
166 public function testRevertLogDatabaseRows( $row, $extra ) {
167 $this->doTestLogFormatter( $row, $extra );
168 }
169}
doTestLogFormatter( $row, $extra)
testUploadLogDatabaseRows( $row, $extra)
provideUploadLogDatabaseRows
static provideOverwriteLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility.
testOverwriteLogDatabaseRows( $row, $extra)
provideOverwriteLogDatabaseRows
testRevertLogDatabaseRows( $row, $extra)
provideRevertLogDatabaseRows
static provideUploadLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility.
static provideRevertLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility.
const NS_FILE
Definition Defines.php:80