Localisation updates from https://translatewiki.net.
[mediawiki.git] / tests / phpunit / includes / logging / NewUsersLogFormatterTest.php
blob4f85a5b6d11c5af4eb0e104e503f023aeabfca31
1 <?php
3 /**
4 * @covers \NewUsersLogFormatter
5 * @group Database
6 */
7 class NewUsersLogFormatterTest extends LogFormatterTestCase {
9 protected function setUp(): void {
10 parent::setUp();
12 // Register LogHandler, see $wgNewUserLog in Setup.php
13 $this->mergeMwGlobalArrayValue( 'wgLogActionsHandlers', [
14 'newusers/newusers' => NewUsersLogFormatter::class,
15 'newusers/create' => NewUsersLogFormatter::class,
16 'newusers/create2' => NewUsersLogFormatter::class,
17 'newusers/byemail' => NewUsersLogFormatter::class,
18 'newusers/autocreate' => NewUsersLogFormatter::class,
19 ] );
22 /**
23 * Provide different rows from the logging table to test
24 * for backward compatibility.
25 * Do not change the existing data, just add a new database row
27 public static function provideNewUsersLogDatabaseRows() {
28 return [
29 // Only old logs
32 'type' => 'newusers',
33 'action' => 'newusers',
34 'comment' => 'newusers comment',
35 'user' => 0,
36 'user_text' => 'New user',
37 'namespace' => NS_USER,
38 'title' => 'New user',
39 'params' => [],
42 'legacy' => true,
43 'text' => 'User account New user was created',
44 'api' => [],
50 /**
51 * @dataProvider provideNewUsersLogDatabaseRows
53 public function testNewUsersLogDatabaseRows( $row, $extra ) {
54 $this->doTestLogFormatter( $row, $extra );
57 /**
58 * Provide different rows from the logging table to test
59 * for backward compatibility.
60 * Do not change the existing data, just add a new database row
62 public static function provideCreateLogDatabaseRows() {
63 return [
64 // Current format
67 'type' => 'newusers',
68 'action' => 'create',
69 'comment' => 'newusers comment',
70 'user' => 0,
71 'user_text' => 'New user',
72 'namespace' => NS_USER,
73 'title' => 'New user',
74 'params' => [
75 '4::userid' => 1,
79 'text' => 'User account New user was created',
80 'api' => [
81 'userid' => 1,
88 /**
89 * @dataProvider provideCreateLogDatabaseRows
91 public function testCreateLogDatabaseRows( $row, $extra ) {
92 $this->doTestLogFormatter( $row, $extra );
95 /**
96 * Provide different rows from the logging table to test
97 * for backward compatibility.
98 * Do not change the existing data, just add a new database row
100 public static function provideCreate2LogDatabaseRows() {
101 return [
102 // Current format
105 'type' => 'newusers',
106 'action' => 'create2',
107 'comment' => 'newusers comment',
108 'user' => 0,
109 'user_text' => 'User',
110 'namespace' => NS_USER,
111 'title' => 'UTSysop'
114 'text' => 'User account UTSysop was created by User'
121 * Provide different rows from the logging table to test
122 * for backward compatibility.
123 * Do not change the existing data, just add a new database row
125 public static function provideByemailLogDatabaseRows() {
126 return [
127 // Current format
130 'type' => 'newusers',
131 'action' => 'byemail',
132 'comment' => 'newusers comment',
133 'user' => 0,
134 'user_text' => 'Sysop',
135 'namespace' => NS_USER,
136 'title' => 'UTSysop'
139 'text' => 'User account UTSysop was created by Sysop and password was sent by email'
146 * @dataProvider provideCreate2LogDatabaseRows
147 * @dataProvider provideByemailLogDatabaseRows
149 public function testCreate2LogDatabaseRows( $row, $extra ) {
150 // Make UTSysop user and use its user_id (sequence does not reset to 1 for postgres)
151 $user = static::getTestSysop()->getUser();
152 $row['params']['4::userid'] = $user->getId();
153 $extra['api']['userid'] = $user->getId();
154 $this->doTestLogFormatter( $row, $extra );
158 * Provide different rows from the logging table to test
159 * for backward compatibility.
160 * Do not change the existing data, just add a new database row
162 public static function provideAutocreateLogDatabaseRows() {
163 return [
164 // Current format
167 'type' => 'newusers',
168 'action' => 'autocreate',
169 'comment' => 'newusers comment',
170 'user' => 0,
171 'user_text' => 'New user',
172 'namespace' => NS_USER,
173 'title' => 'New user',
174 'params' => [
175 '4::userid' => 1,
179 'text' => 'User account New user was created automatically',
180 'api' => [
181 'userid' => 1,
189 * @dataProvider provideAutocreateLogDatabaseRows
191 public function testAutocreateLogDatabaseRows( $row, $extra ) {
192 $this->doTestLogFormatter( $row, $extra );