4 * @covers \NewUsersLogFormatter
7 class NewUsersLogFormatterTest
extends LogFormatterTestCase
{
9 protected function setUp(): void
{
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,
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() {
33 'action' => 'newusers',
34 'comment' => 'newusers comment',
36 'user_text' => 'New user',
37 'namespace' => NS_USER
,
38 'title' => 'New user',
43 'text' => 'User account New user was created',
51 * @dataProvider provideNewUsersLogDatabaseRows
53 public function testNewUsersLogDatabaseRows( $row, $extra ) {
54 $this->doTestLogFormatter( $row, $extra );
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() {
69 'comment' => 'newusers comment',
71 'user_text' => 'New user',
72 'namespace' => NS_USER
,
73 'title' => 'New user',
79 'text' => 'User account New user was created',
89 * @dataProvider provideCreateLogDatabaseRows
91 public function testCreateLogDatabaseRows( $row, $extra ) {
92 $this->doTestLogFormatter( $row, $extra );
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() {
105 'type' => 'newusers',
106 'action' => 'create2',
107 'comment' => 'newusers comment',
109 'user_text' => 'User',
110 'namespace' => NS_USER
,
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() {
130 'type' => 'newusers',
131 'action' => 'byemail',
132 'comment' => 'newusers comment',
134 'user_text' => 'Sysop',
135 'namespace' => NS_USER
,
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() {
167 'type' => 'newusers',
168 'action' => 'autocreate',
169 'comment' => 'newusers comment',
171 'user_text' => 'New user',
172 'namespace' => NS_USER
,
173 'title' => 'New user',
179 'text' => 'User account New user was created automatically',
189 * @dataProvider provideAutocreateLogDatabaseRows
191 public function testAutocreateLogDatabaseRows( $row, $extra ) {
192 $this->doTestLogFormatter( $row, $extra );