Move ResultWrapper subclasses to Rdbms
[mediawiki.git] / tests / phpunit / includes / logging / RightsLogFormatterTest.php
blobf48507d8ab2a0084adcf6ec4221579d02491c5f6
1 <?php
3 class RightsLogFormatterTest extends LogFormatterTestCase {
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 provideRightsLogDatabaseRows() {
11 return [
12 // Current format
15 'type' => 'rights',
16 'action' => 'rights',
17 'comment' => 'rights comment',
18 'user' => 0,
19 'user_text' => 'Sysop',
20 'namespace' => NS_USER,
21 'title' => 'User',
22 'params' => [
23 '4::oldgroups' => [],
24 '5::newgroups' => [ 'sysop', 'bureaucrat' ],
25 'oldmetadata' => [],
26 'newmetadata' => [
27 [ 'expiry' => null ],
28 [ 'expiry' => '20160101123456' ]
33 'text' => 'Sysop changed group membership for User from (none) to '
34 . 'bureaucrat (temporary, until 12:34, 1 January 2016) and administrator',
35 'api' => [
36 'oldgroups' => [],
37 'newgroups' => [ 'sysop', 'bureaucrat' ],
38 'oldmetadata' => [],
39 'newmetadata' => [
40 [ 'group' => 'sysop', 'expiry' => 'infinity' ],
41 [ 'group' => 'bureaucrat', 'expiry' => '2016-01-01T12:34:56Z' ],
47 // Previous format (oldgroups and newgroups as arrays, no metadata)
50 'type' => 'rights',
51 'action' => 'rights',
52 'comment' => 'rights comment',
53 'user' => 0,
54 'user_text' => 'Sysop',
55 'namespace' => NS_USER,
56 'title' => 'User',
57 'params' => [
58 '4::oldgroups' => [],
59 '5::newgroups' => [ 'sysop', 'bureaucrat' ],
63 'text' => 'Sysop changed group membership for User from (none) to '
64 . 'administrator and bureaucrat',
65 'api' => [
66 'oldgroups' => [],
67 'newgroups' => [ 'sysop', 'bureaucrat' ],
68 'oldmetadata' => [],
69 'newmetadata' => [
70 [ 'group' => 'sysop', 'expiry' => 'infinity' ],
71 [ 'group' => 'bureaucrat', 'expiry' => 'infinity' ],
77 // Legacy format (oldgroups and newgroups as numeric-keyed strings)
80 'type' => 'rights',
81 'action' => 'rights',
82 'comment' => 'rights comment',
83 'user' => 0,
84 'user_text' => 'Sysop',
85 'namespace' => NS_USER,
86 'title' => 'User',
87 'params' => [
88 '',
89 'sysop, bureaucrat',
93 'legacy' => true,
94 'text' => 'Sysop changed group membership for User from (none) to '
95 . 'administrator and bureaucrat',
96 'api' => [
97 'oldgroups' => [],
98 'newgroups' => [ 'sysop', 'bureaucrat' ],
99 'oldmetadata' => [],
100 'newmetadata' => [
101 [ 'group' => 'sysop', 'expiry' => 'infinity' ],
102 [ 'group' => 'bureaucrat', 'expiry' => 'infinity' ],
108 // Really old entry
111 'type' => 'rights',
112 'action' => 'rights',
113 'comment' => 'rights comment',
114 'user' => 0,
115 'user_text' => 'Sysop',
116 'namespace' => NS_USER,
117 'title' => 'User',
118 'params' => [],
121 'legacy' => true,
122 'text' => 'Sysop changed group membership for User',
123 'api' => [],
130 * @dataProvider provideRightsLogDatabaseRows
132 public function testRightsLogDatabaseRows( $row, $extra ) {
133 $this->doTestLogFormatter( $row, $extra );
137 * Provide different rows from the logging table to test
138 * for backward compatibility.
139 * Do not change the existing data, just add a new database row
141 public static function provideAutopromoteLogDatabaseRows() {
142 return [
143 // Current format
146 'type' => 'rights',
147 'action' => 'autopromote',
148 'comment' => 'rights comment',
149 'user' => 0,
150 'user_text' => 'Sysop',
151 'namespace' => NS_USER,
152 'title' => 'Sysop',
153 'params' => [
154 '4::oldgroups' => [ 'sysop' ],
155 '5::newgroups' => [ 'sysop', 'bureaucrat' ],
159 'text' => 'Sysop was automatically promoted from administrator to '
160 . 'administrator and bureaucrat',
161 'api' => [
162 'oldgroups' => [ 'sysop' ],
163 'newgroups' => [ 'sysop', 'bureaucrat' ],
164 'oldmetadata' => [
165 [ 'group' => 'sysop', 'expiry' => 'infinity' ],
167 'newmetadata' => [
168 [ 'group' => 'sysop', 'expiry' => 'infinity' ],
169 [ 'group' => 'bureaucrat', 'expiry' => 'infinity' ],
175 // Legacy format
178 'type' => 'rights',
179 'action' => 'autopromote',
180 'comment' => 'rights comment',
181 'user' => 0,
182 'user_text' => 'Sysop',
183 'namespace' => NS_USER,
184 'title' => 'Sysop',
185 'params' => [
186 'sysop',
187 'sysop, bureaucrat',
191 'legacy' => true,
192 'text' => 'Sysop was automatically promoted from administrator to '
193 . 'administrator and bureaucrat',
194 'api' => [
195 'oldgroups' => [ 'sysop' ],
196 'newgroups' => [ 'sysop', 'bureaucrat' ],
197 'oldmetadata' => [
198 [ 'group' => 'sysop', 'expiry' => 'infinity' ],
200 'newmetadata' => [
201 [ 'group' => 'sysop', 'expiry' => 'infinity' ],
202 [ 'group' => 'bureaucrat', 'expiry' => 'infinity' ],
211 * @dataProvider provideAutopromoteLogDatabaseRows
213 public function testAutopromoteLogDatabaseRows( $row, $extra ) {
214 $this->doTestLogFormatter( $row, $extra );