MediaWiki  1.30.0
RightsLogFormatterTest.php
Go to the documentation of this file.
1 <?php
2 
4 
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  'oldmetadata' => [],
26  'newmetadata' => [
27  [ 'expiry' => null ],
28  [ 'expiry' => '20160101123456' ]
29  ],
30  ],
31  ],
32  [
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' ],
42  ],
43  ],
44  ],
45  ],
46 
47  // Previous format (oldgroups and newgroups as arrays, no metadata)
48  [
49  [
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' ],
60  ],
61  ],
62  [
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' ],
72  ],
73  ],
74  ],
75  ],
76 
77  // Legacy format (oldgroups and newgroups as numeric-keyed strings)
78  [
79  [
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',
90  ],
91  ],
92  [
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' ],
103  ],
104  ],
105  ],
106  ],
107 
108  // Really old entry
109  [
110  [
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' => [],
119  ],
120  [
121  'legacy' => true,
122  'text' => 'Sysop changed group membership for User',
123  'api' => [],
124  ],
125  ],
126  ];
127  }
128 
132  public function testRightsLogDatabaseRows( $row, $extra ) {
133  $this->doTestLogFormatter( $row, $extra );
134  }
135 
141  public static function provideAutopromoteLogDatabaseRows() {
142  return [
143  // Current format
144  [
145  [
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' ],
156  ],
157  ],
158  [
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' ],
166  ],
167  'newmetadata' => [
168  [ 'group' => 'sysop', 'expiry' => 'infinity' ],
169  [ 'group' => 'bureaucrat', 'expiry' => 'infinity' ],
170  ],
171  ],
172  ],
173  ],
174 
175  // Legacy format
176  [
177  [
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',
188  ],
189  ],
190  [
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' ],
199  ],
200  'newmetadata' => [
201  [ 'group' => 'sysop', 'expiry' => 'infinity' ],
202  [ 'group' => 'bureaucrat', 'expiry' => 'infinity' ],
203  ],
204  ],
205  ],
206  ],
207  ];
208  }
209 
213  public function testAutopromoteLogDatabaseRows( $row, $extra ) {
214  $this->doTestLogFormatter( $row, $extra );
215  }
216 }
RightsLogFormatterTest\testRightsLogDatabaseRows
testRightsLogDatabaseRows( $row, $extra)
provideRightsLogDatabaseRows
Definition: RightsLogFormatterTest.php:132
RightsLogFormatterTest\provideRightsLogDatabaseRows
static provideRightsLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility.
Definition: RightsLogFormatterTest.php:10
php
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:35
LogFormatterTestCase
Definition: LogFormatterTestCase.php:6
LogFormatterTestCase\doTestLogFormatter
doTestLogFormatter( $row, $extra)
Definition: LogFormatterTestCase.php:8
NS_USER
const NS_USER
Definition: Defines.php:67
RightsLogFormatterTest
Definition: RightsLogFormatterTest.php:3
RightsLogFormatterTest\provideAutopromoteLogDatabaseRows
static provideAutopromoteLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility.
Definition: RightsLogFormatterTest.php:141
RightsLogFormatterTest\testAutopromoteLogDatabaseRows
testAutopromoteLogDatabaseRows( $row, $extra)
provideAutopromoteLogDatabaseRows
Definition: RightsLogFormatterTest.php:213