Merge "Documentation: Remove paragraph about not creating a 2nd WebRequest"
[lhc/web/wiklou.git] / tests / phpunit / includes / logging / UploadLogFormatterTest.php
1 <?php
2
3 class UploadLogFormatterTest extends LogFormatterTestCase {
4
5 /**
6 * Provide different rows from the logging table to test
7 * for backward compatibility.
8 * Do not change the existing data, just add a new database row
9 */
10 public static function provideUploadLogDatabaseRows() {
11 return array(
12 // Current format
13 array(
14 array(
15 'type' => 'upload',
16 'action' => 'upload',
17 'comment' => 'upload comment',
18 'namespace' => NS_FILE,
19 'title' => 'File.png',
20 'params' => array(
21 'img_sha1' => 'hash',
22 'img_timestamp' => '20150101000000',
23 ),
24 ),
25 array(
26 'text' => 'User uploaded File:File.png',
27 'api' => array(
28 'img_sha1' => 'hash',
29 'img_timestamp' => '2015-01-01T00:00:00Z',
30 ),
31 ),
32 ),
33
34 // Old format without params
35 array(
36 array(
37 'type' => 'upload',
38 'action' => 'upload',
39 'comment' => 'upload comment',
40 'namespace' => NS_FILE,
41 'title' => 'File.png',
42 'params' => array(),
43 ),
44 array(
45 'text' => 'User uploaded File:File.png',
46 'api' => array(),
47 ),
48 ),
49 );
50 }
51
52 /**
53 * @dataProvider provideUploadLogDatabaseRows
54 */
55 public function testUploadLogDatabaseRows( $row, $extra ) {
56 $this->doTestLogFormatter( $row, $extra );
57 }
58
59 /**
60 * Provide different rows from the logging table to test
61 * for backward compatibility.
62 * Do not change the existing data, just add a new database row
63 */
64 public static function provideOverwriteLogDatabaseRows() {
65 return array(
66 // Current format
67 array(
68 array(
69 'type' => 'upload',
70 'action' => 'overwrite',
71 'comment' => 'upload comment',
72 'namespace' => NS_FILE,
73 'title' => 'File.png',
74 'params' => array(
75 'img_sha1' => 'hash',
76 'img_timestamp' => '20150101000000',
77 ),
78 ),
79 array(
80 'text' => 'User uploaded a new version of File:File.png',
81 'api' => array(
82 'img_sha1' => 'hash',
83 'img_timestamp' => '2015-01-01T00:00:00Z',
84 ),
85 ),
86 ),
87
88 // Old format without params
89 array(
90 array(
91 'type' => 'upload',
92 'action' => 'overwrite',
93 'comment' => 'upload comment',
94 'namespace' => NS_FILE,
95 'title' => 'File.png',
96 'params' => array(),
97 ),
98 array(
99 'text' => 'User uploaded a new version of File:File.png',
100 'api' => array(),
101 ),
102 ),
103 );
104 }
105
106 /**
107 * @dataProvider provideOverwriteLogDatabaseRows
108 */
109 public function testOverwriteLogDatabaseRows( $row, $extra ) {
110 $this->doTestLogFormatter( $row, $extra );
111 }
112
113 /**
114 * Provide different rows from the logging table to test
115 * for backward compatibility.
116 * Do not change the existing data, just add a new database row
117 */
118 public static function provideRevertLogDatabaseRows() {
119 return array(
120 // Current format
121 array(
122 array(
123 'type' => 'upload',
124 'action' => 'revert',
125 'comment' => 'upload comment',
126 'namespace' => NS_FILE,
127 'title' => 'File.png',
128 'params' => array(
129 'img_sha1' => 'hash',
130 'img_timestamp' => '20150101000000',
131 ),
132 ),
133 array(
134 'text' => 'User uploaded File:File.png',
135 'api' => array(
136 'img_sha1' => 'hash',
137 'img_timestamp' => '2015-01-01T00:00:00Z',
138 ),
139 ),
140 ),
141
142 // Old format without params
143 array(
144 array(
145 'type' => 'upload',
146 'action' => 'revert',
147 'comment' => 'upload comment',
148 'namespace' => NS_FILE,
149 'title' => 'File.png',
150 'params' => array(),
151 ),
152 array(
153 'text' => 'User uploaded File:File.png',
154 'api' => array(),
155 ),
156 ),
157 );
158 }
159
160 /**
161 * @dataProvider provideRevertLogDatabaseRows
162 */
163 public function testRevertLogDatabaseRows( $row, $extra ) {
164 $this->doTestLogFormatter( $row, $extra );
165 }
166 }