Merge "Add documentation for wfClientAcceptsGzip()"
[lhc/web/wiklou.git] / tests / phpunit / includes / logging / NewUsersLogFormatterTest.php
1 <?php
2
3 /**
4 * @group Database
5 */
6 class NewUsersLogFormatterTest extends LogFormatterTestCase {
7
8 protected function setUp() {
9 parent::setUp();
10
11 // Register LogHandler, see $wgNewUserLog in Setup.php
12 $this->mergeMwGlobalArrayValue( 'wgLogActionsHandlers', [
13 'newusers/newusers' => 'NewUsersLogFormatter',
14 'newusers/create' => 'NewUsersLogFormatter',
15 'newusers/create2' => 'NewUsersLogFormatter',
16 'newusers/byemail' => 'NewUsersLogFormatter',
17 'newusers/autocreate' => 'NewUsersLogFormatter',
18 ] );
19 }
20
21 /**
22 * Provide different rows from the logging table to test
23 * for backward compatibility.
24 * Do not change the existing data, just add a new database row
25 */
26 public static function provideNewUsersLogDatabaseRows() {
27 return [
28 // Only old logs
29 [
30 [
31 'type' => 'newusers',
32 'action' => 'newusers',
33 'comment' => 'newusers comment',
34 'user' => 0,
35 'user_text' => 'New user',
36 'namespace' => NS_USER,
37 'title' => 'New user',
38 'params' => [],
39 ],
40 [
41 'legacy' => true,
42 'text' => 'User account New user was created',
43 'api' => [],
44 ],
45 ],
46 ];
47 }
48
49 /**
50 * @dataProvider provideNewUsersLogDatabaseRows
51 */
52 public function testNewUsersLogDatabaseRows( $row, $extra ) {
53 $this->doTestLogFormatter( $row, $extra );
54 }
55
56 /**
57 * Provide different rows from the logging table to test
58 * for backward compatibility.
59 * Do not change the existing data, just add a new database row
60 */
61 public static function provideCreateLogDatabaseRows() {
62 return [
63 // Current format
64 [
65 [
66 'type' => 'newusers',
67 'action' => 'create',
68 'comment' => 'newusers comment',
69 'user' => 0,
70 'user_text' => 'New user',
71 'namespace' => NS_USER,
72 'title' => 'New user',
73 'params' => [
74 '4::userid' => 1,
75 ],
76 ],
77 [
78 'text' => 'User account New user was created',
79 'api' => [
80 'userid' => 1,
81 ],
82 ],
83 ],
84 ];
85 }
86
87 /**
88 * @dataProvider provideCreateLogDatabaseRows
89 */
90 public function testCreateLogDatabaseRows( $row, $extra ) {
91 $this->doTestLogFormatter( $row, $extra );
92 }
93
94 /**
95 * Provide different rows from the logging table to test
96 * for backward compatibility.
97 * Do not change the existing data, just add a new database row
98 */
99 public static function provideCreate2LogDatabaseRows() {
100 return [
101 // Current format
102 [
103 [
104 'type' => 'newusers',
105 'action' => 'create2',
106 'comment' => 'newusers comment',
107 'user' => 0,
108 'user_text' => 'User',
109 'namespace' => NS_USER,
110 'title' => 'UTSysop',
111 'params' => [
112 '4::userid' => 1,
113 ],
114 ],
115 [
116 'text' => 'User account UTSysop was created by User',
117 'api' => [
118 'userid' => 1,
119 ],
120 ],
121 ],
122 ];
123 }
124
125 /**
126 * @dataProvider provideCreate2LogDatabaseRows
127 */
128 public function testCreate2LogDatabaseRows( $row, $extra ) {
129 $this->doTestLogFormatter( $row, $extra );
130 }
131
132 /**
133 * Provide different rows from the logging table to test
134 * for backward compatibility.
135 * Do not change the existing data, just add a new database row
136 */
137 public static function provideByemailLogDatabaseRows() {
138 return [
139 // Current format
140 [
141 [
142 'type' => 'newusers',
143 'action' => 'byemail',
144 'comment' => 'newusers comment',
145 'user' => 0,
146 'user_text' => 'Sysop',
147 'namespace' => NS_USER,
148 'title' => 'UTSysop',
149 'params' => [
150 '4::userid' => 1,
151 ],
152 ],
153 [
154 'text' => 'User account UTSysop was created by Sysop and password was sent by email',
155 'api' => [
156 'userid' => 1,
157 ],
158 ],
159 ],
160 ];
161 }
162
163 /**
164 * @dataProvider provideByemailLogDatabaseRows
165 */
166 public function testByemailLogDatabaseRows( $row, $extra ) {
167 $this->doTestLogFormatter( $row, $extra );
168 }
169
170 /**
171 * Provide different rows from the logging table to test
172 * for backward compatibility.
173 * Do not change the existing data, just add a new database row
174 */
175 public static function provideAutocreateLogDatabaseRows() {
176 return [
177 // Current format
178 [
179 [
180 'type' => 'newusers',
181 'action' => 'autocreate',
182 'comment' => 'newusers comment',
183 'user' => 0,
184 'user_text' => 'New user',
185 'namespace' => NS_USER,
186 'title' => 'New user',
187 'params' => [
188 '4::userid' => 1,
189 ],
190 ],
191 [
192 'text' => 'User account New user was created automatically',
193 'api' => [
194 'userid' => 1,
195 ],
196 ],
197 ],
198 ];
199 }
200
201 /**
202 * @dataProvider provideAutocreateLogDatabaseRows
203 */
204 public function testAutocreateLogDatabaseRows( $row, $extra ) {
205 $this->doTestLogFormatter( $row, $extra );
206 }
207 }