MediaWiki REL1_32
RightsLogFormatterTest.php
Go to the documentation of this file.
1<?php
2
7
13 public static function provideRightsLogDatabaseRows() {
14 return [
15 // Current format
16 [
17 [
18 'type' => 'rights',
19 'action' => 'rights',
20 'comment' => 'rights comment',
21 'user' => 0,
22 'user_text' => 'Sysop',
23 'namespace' => NS_USER,
24 'title' => 'User',
25 'params' => [
26 '4::oldgroups' => [],
27 '5::newgroups' => [ 'sysop', 'bureaucrat' ],
28 'oldmetadata' => [],
29 'newmetadata' => [
30 [ 'expiry' => null ],
31 [ 'expiry' => '20160101123456' ]
32 ],
33 ],
34 ],
35 [
36 'text' => 'Sysop changed group membership for User from (none) to '
37 . 'bureaucrat (temporary, until 12:34, 1 January 2016) and administrator',
38 'api' => [
39 'oldgroups' => [],
40 'newgroups' => [ 'sysop', 'bureaucrat' ],
41 'oldmetadata' => [],
42 'newmetadata' => [
43 [ 'group' => 'sysop', 'expiry' => 'infinity' ],
44 [ 'group' => 'bureaucrat', 'expiry' => '2016-01-01T12:34:56Z' ],
45 ],
46 ],
47 ],
48 ],
49
50 // Previous format (oldgroups and newgroups as arrays, no metadata)
51 [
52 [
53 'type' => 'rights',
54 'action' => 'rights',
55 'comment' => 'rights comment',
56 'user' => 0,
57 'user_text' => 'Sysop',
58 'namespace' => NS_USER,
59 'title' => 'User',
60 'params' => [
61 '4::oldgroups' => [],
62 '5::newgroups' => [ 'sysop', 'bureaucrat' ],
63 ],
64 ],
65 [
66 'text' => 'Sysop changed group membership for User from (none) to '
67 . 'administrator and bureaucrat',
68 'api' => [
69 'oldgroups' => [],
70 'newgroups' => [ 'sysop', 'bureaucrat' ],
71 'oldmetadata' => [],
72 'newmetadata' => [
73 [ 'group' => 'sysop', 'expiry' => 'infinity' ],
74 [ 'group' => 'bureaucrat', 'expiry' => 'infinity' ],
75 ],
76 ],
77 ],
78 ],
79
80 // Legacy format (oldgroups and newgroups as numeric-keyed strings)
81 [
82 [
83 'type' => 'rights',
84 'action' => 'rights',
85 'comment' => 'rights comment',
86 'user' => 0,
87 'user_text' => 'Sysop',
88 'namespace' => NS_USER,
89 'title' => 'User',
90 'params' => [
91 '',
92 'sysop, bureaucrat',
93 ],
94 ],
95 [
96 'legacy' => true,
97 'text' => 'Sysop changed group membership for User from (none) to '
98 . 'administrator and bureaucrat',
99 'api' => [
100 'oldgroups' => [],
101 'newgroups' => [ 'sysop', 'bureaucrat' ],
102 'oldmetadata' => [],
103 'newmetadata' => [
104 [ 'group' => 'sysop', 'expiry' => 'infinity' ],
105 [ 'group' => 'bureaucrat', 'expiry' => 'infinity' ],
106 ],
107 ],
108 ],
109 ],
110
111 // Really old entry
112 [
113 [
114 'type' => 'rights',
115 'action' => 'rights',
116 'comment' => 'rights comment',
117 'user' => 0,
118 'user_text' => 'Sysop',
119 'namespace' => NS_USER,
120 'title' => 'User',
121 'params' => [],
122 ],
123 [
124 'legacy' => true,
125 'text' => 'Sysop changed group membership for User',
126 'api' => [],
127 ],
128 ],
129 ];
130 }
131
135 public function testRightsLogDatabaseRows( $row, $extra ) {
136 $this->doTestLogFormatter( $row, $extra );
137 }
138
144 public static function provideAutopromoteLogDatabaseRows() {
145 return [
146 // Current format
147 [
148 [
149 'type' => 'rights',
150 'action' => 'autopromote',
151 'comment' => 'rights comment',
152 'user' => 0,
153 'user_text' => 'Sysop',
154 'namespace' => NS_USER,
155 'title' => 'Sysop',
156 'params' => [
157 '4::oldgroups' => [ 'sysop' ],
158 '5::newgroups' => [ 'sysop', 'bureaucrat' ],
159 ],
160 ],
161 [
162 'text' => 'Sysop was automatically promoted from administrator to '
163 . 'administrator and bureaucrat',
164 'api' => [
165 'oldgroups' => [ 'sysop' ],
166 'newgroups' => [ 'sysop', 'bureaucrat' ],
167 'oldmetadata' => [
168 [ 'group' => 'sysop', 'expiry' => 'infinity' ],
169 ],
170 'newmetadata' => [
171 [ 'group' => 'sysop', 'expiry' => 'infinity' ],
172 [ 'group' => 'bureaucrat', 'expiry' => 'infinity' ],
173 ],
174 ],
175 ],
176 ],
177
178 // Legacy format
179 [
180 [
181 'type' => 'rights',
182 'action' => 'autopromote',
183 'comment' => 'rights comment',
184 'user' => 0,
185 'user_text' => 'Sysop',
186 'namespace' => NS_USER,
187 'title' => 'Sysop',
188 'params' => [
189 'sysop',
190 'sysop, bureaucrat',
191 ],
192 ],
193 [
194 'legacy' => true,
195 'text' => 'Sysop was automatically promoted from administrator to '
196 . 'administrator and bureaucrat',
197 'api' => [
198 'oldgroups' => [ 'sysop' ],
199 'newgroups' => [ 'sysop', 'bureaucrat' ],
200 'oldmetadata' => [
201 [ 'group' => 'sysop', 'expiry' => 'infinity' ],
202 ],
203 'newmetadata' => [
204 [ 'group' => 'sysop', 'expiry' => 'infinity' ],
205 [ 'group' => 'bureaucrat', 'expiry' => 'infinity' ],
206 ],
207 ],
208 ],
209 ],
210 ];
211 }
212
216 public function testAutopromoteLogDatabaseRows( $row, $extra ) {
217 $this->doTestLogFormatter( $row, $extra );
218 }
219}
doTestLogFormatter( $row, $extra)
testRightsLogDatabaseRows( $row, $extra)
provideRightsLogDatabaseRows
testAutopromoteLogDatabaseRows( $row, $extra)
provideAutopromoteLogDatabaseRows
static provideRightsLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility.
static provideAutopromoteLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility.
const NS_USER
Definition Defines.php:66
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37