Add @covers tags to logging tests
[lhc/web/wiklou.git] / tests / phpunit / includes / logging / UploadLogFormatterTest.php
1 <?php
2
3 /**
4 * @covers UploadLogFormatter
5 */
6 class UploadLogFormatterTest 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' => '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
55 /**
56 * @dataProvider provideUploadLogDatabaseRows
57 */
58 public function testUploadLogDatabaseRows( $row, $extra ) {
59 $this->doTestLogFormatter( $row, $extra );
60 }
61
62 /**
63 * Provide different rows from the logging table to test
64 * for backward compatibility.
65 * Do not change the existing data, just add a new database row
66 */
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
109 /**
110 * @dataProvider provideOverwriteLogDatabaseRows
111 */
112 public function testOverwriteLogDatabaseRows( $row, $extra ) {
113 $this->doTestLogFormatter( $row, $extra );
114 }
115
116 /**
117 * Provide different rows from the logging table to test
118 * for backward compatibility.
119 * Do not change the existing data, just add a new database row
120 */
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
163 /**
164 * @dataProvider provideRevertLogDatabaseRows
165 */
166 public function testRevertLogDatabaseRows( $row, $extra ) {
167 $this->doTestLogFormatter( $row, $extra );
168 }
169 }