Merge "Http::getProxy() method to get proxy configuration"
[lhc/web/wiklou.git] / tests / phpunit / includes / logging / RightsLogFormatterTest.php
1 <?php
2
3 class RightsLogFormatterTest 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 provideRightsLogDatabaseRows() {
11 return [
12 // Current format
13 [
14 [
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 ],
26 ],
27 [
28 'text' => 'Sysop changed group membership for User from (none) to '
29 . 'administrator and bureaucrat',
30 'api' => [
31 'oldgroups' => [],
32 'newgroups' => [ 'sysop', 'bureaucrat' ],
33 ],
34 ],
35 ],
36
37 // Legacy format
38 [
39 [
40 'type' => 'rights',
41 'action' => 'rights',
42 'comment' => 'rights comment',
43 'user' => 0,
44 'user_text' => 'Sysop',
45 'namespace' => NS_USER,
46 'title' => 'User',
47 'params' => [
48 '',
49 'sysop, bureaucrat',
50 ],
51 ],
52 [
53 'legacy' => true,
54 'text' => 'Sysop changed group membership for User from (none) to '
55 . 'administrator and bureaucrat',
56 'api' => [
57 'oldgroups' => [],
58 'newgroups' => [ 'sysop', 'bureaucrat' ],
59 ],
60 ],
61 ],
62
63 // Really old entry
64 [
65 [
66 'type' => 'rights',
67 'action' => 'rights',
68 'comment' => 'rights comment',
69 'user' => 0,
70 'user_text' => 'Sysop',
71 'namespace' => NS_USER,
72 'title' => 'User',
73 'params' => [],
74 ],
75 [
76 'legacy' => true,
77 'text' => 'Sysop changed group membership for User',
78 'api' => [],
79 ],
80 ],
81 ];
82 }
83
84 /**
85 * @dataProvider provideRightsLogDatabaseRows
86 */
87 public function testRightsLogDatabaseRows( $row, $extra ) {
88 $this->doTestLogFormatter( $row, $extra );
89 }
90
91 /**
92 * Provide different rows from the logging table to test
93 * for backward compatibility.
94 * Do not change the existing data, just add a new database row
95 */
96 public static function provideAutopromoteLogDatabaseRows() {
97 return [
98 // Current format
99 [
100 [
101 'type' => 'rights',
102 'action' => 'autopromote',
103 'comment' => 'rights comment',
104 'user' => 0,
105 'user_text' => 'Sysop',
106 'namespace' => NS_USER,
107 'title' => 'Sysop',
108 'params' => [
109 '4::oldgroups' => [ 'sysop' ],
110 '5::newgroups' => [ 'sysop', 'bureaucrat' ],
111 ],
112 ],
113 [
114 'text' => 'Sysop was automatically promoted from administrator to '
115 . 'administrator and bureaucrat',
116 'api' => [
117 'oldgroups' => [ 'sysop' ],
118 'newgroups' => [ 'sysop', 'bureaucrat' ],
119 ],
120 ],
121 ],
122
123 // Legacy format
124 [
125 [
126 'type' => 'rights',
127 'action' => 'autopromote',
128 'comment' => 'rights comment',
129 'user' => 0,
130 'user_text' => 'Sysop',
131 'namespace' => NS_USER,
132 'title' => 'Sysop',
133 'params' => [
134 'sysop',
135 'sysop, bureaucrat',
136 ],
137 ],
138 [
139 'legacy' => true,
140 'text' => 'Sysop was automatically promoted from administrator to '
141 . 'administrator and bureaucrat',
142 'api' => [
143 'oldgroups' => [ 'sysop' ],
144 'newgroups' => [ 'sysop', 'bureaucrat' ],
145 ],
146 ],
147 ],
148 ];
149 }
150
151 /**
152 * @dataProvider provideAutopromoteLogDatabaseRows
153 */
154 public function testAutopromoteLogDatabaseRows( $row, $extra ) {
155 $this->doTestLogFormatter( $row, $extra );
156 }
157 }