6 class NewUsersLogFormatterTest
extends LogFormatterTestCase
{
8 protected function setUp() {
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',
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
26 public static function provideNewUsersLogDatabaseRows() {
32 'action' => 'newusers',
33 'comment' => 'newusers comment',
35 'user_text' => 'New user',
36 'namespace' => NS_USER
,
37 'title' => 'New user',
42 'text' => 'User account New user was created',
50 * @dataProvider provideNewUsersLogDatabaseRows
52 public function testNewUsersLogDatabaseRows( $row, $extra ) {
53 $this->doTestLogFormatter( $row, $extra );
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
61 public static function provideCreateLogDatabaseRows() {
68 'comment' => 'newusers comment',
70 'user_text' => 'New user',
71 'namespace' => NS_USER
,
72 'title' => 'New user',
78 'text' => 'User account New user was created',
88 * @dataProvider provideCreateLogDatabaseRows
90 public function testCreateLogDatabaseRows( $row, $extra ) {
91 $this->doTestLogFormatter( $row, $extra );
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
99 public static function provideCreate2LogDatabaseRows() {
104 'type' => 'newusers',
105 'action' => 'create2',
106 'comment' => 'newusers comment',
108 'user_text' => 'User',
109 'namespace' => NS_USER
,
113 'text' => 'User account UTSysop was created by User'
120 * @dataProvider provideCreate2LogDatabaseRows
122 public function testCreate2LogDatabaseRows( $row, $extra ) {
123 // Make UTSysop user and use its user_id (sequence does not reset to 1 for postgres)
124 $user = static::getTestSysop()->getUser();
125 $row['params']['4::userid'] = $user->getId();
126 $extra['api']['userid'] = $user->getId();
127 $this->doTestLogFormatter( $row, $extra );
131 * Provide different rows from the logging table to test
132 * for backward compatibility.
133 * Do not change the existing data, just add a new database row
135 public static function provideByemailLogDatabaseRows() {
140 'type' => 'newusers',
141 'action' => 'byemail',
142 'comment' => 'newusers comment',
144 'user_text' => 'Sysop',
145 'namespace' => NS_USER
,
149 'text' => 'User account UTSysop was created by Sysop and password was sent by email'
156 * @dataProvider provideByemailLogDatabaseRows
158 public function testByemailLogDatabaseRows( $row, $extra ) {
159 // Make UTSysop user and use its user_id (sequence does not reset to 1 for postgres)
160 $user = static::getTestSysop()->getUser();
161 $row['params']['4::userid'] = $user->getId();
162 $extra['api']['userid'] = $user->getId();
163 $this->doTestLogFormatter( $row, $extra );
167 * Provide different rows from the logging table to test
168 * for backward compatibility.
169 * Do not change the existing data, just add a new database row
171 public static function provideAutocreateLogDatabaseRows() {
176 'type' => 'newusers',
177 'action' => 'autocreate',
178 'comment' => 'newusers comment',
180 'user_text' => 'New user',
181 'namespace' => NS_USER
,
182 'title' => 'New user',
188 'text' => 'User account New user was created automatically',
198 * @dataProvider provideAutocreateLogDatabaseRows
200 public function testAutocreateLogDatabaseRows( $row, $extra ) {
201 $this->doTestLogFormatter( $row, $extra );