MediaWiki REL1_33
NewUsersLogFormatterTest.php
Go to the documentation of this file.
1<?php
2
8
9 protected function setUp() {
10 parent::setUp();
11
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 ] );
20 }
21
27 public static function provideNewUsersLogDatabaseRows() {
28 return [
29 // Only old logs
30 [
31 [
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' => [],
40 ],
41 [
42 'legacy' => true,
43 'text' => 'User account New user was created',
44 'api' => [],
45 ],
46 ],
47 ];
48 }
49
53 public function testNewUsersLogDatabaseRows( $row, $extra ) {
54 $this->doTestLogFormatter( $row, $extra );
55 }
56
62 public static function provideCreateLogDatabaseRows() {
63 return [
64 // Current format
65 [
66 [
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,
76 ],
77 ],
78 [
79 'text' => 'User account New user was created',
80 'api' => [
81 'userid' => 1,
82 ],
83 ],
84 ],
85 ];
86 }
87
91 public function testCreateLogDatabaseRows( $row, $extra ) {
92 $this->doTestLogFormatter( $row, $extra );
93 }
94
100 public static function provideCreate2LogDatabaseRows() {
101 return [
102 // Current format
103 [
104 [
105 'type' => 'newusers',
106 'action' => 'create2',
107 'comment' => 'newusers comment',
108 'user' => 0,
109 'user_text' => 'User',
110 'namespace' => NS_USER,
111 'title' => 'UTSysop'
112 ],
113 [
114 'text' => 'User account UTSysop was created by User'
115 ],
116 ],
117 ];
118 }
119
123 public function testCreate2LogDatabaseRows( $row, $extra ) {
124 // Make UTSysop user and use its user_id (sequence does not reset to 1 for postgres)
125 $user = static::getTestSysop()->getUser();
126 $row['params']['4::userid'] = $user->getId();
127 $extra['api']['userid'] = $user->getId();
128 $this->doTestLogFormatter( $row, $extra );
129 }
130
136 public static function provideByemailLogDatabaseRows() {
137 return [
138 // Current format
139 [
140 [
141 'type' => 'newusers',
142 'action' => 'byemail',
143 'comment' => 'newusers comment',
144 'user' => 0,
145 'user_text' => 'Sysop',
146 'namespace' => NS_USER,
147 'title' => 'UTSysop'
148 ],
149 [
150 'text' => 'User account UTSysop was created by Sysop and password was sent by email'
151 ],
152 ],
153 ];
154 }
155
159 public function testByemailLogDatabaseRows( $row, $extra ) {
160 // Make UTSysop user and use its user_id (sequence does not reset to 1 for postgres)
161 $user = static::getTestSysop()->getUser();
162 $row['params']['4::userid'] = $user->getId();
163 $extra['api']['userid'] = $user->getId();
164 $this->doTestLogFormatter( $row, $extra );
165 }
166
172 public static function provideAutocreateLogDatabaseRows() {
173 return [
174 // Current format
175 [
176 [
177 'type' => 'newusers',
178 'action' => 'autocreate',
179 'comment' => 'newusers comment',
180 'user' => 0,
181 'user_text' => 'New user',
182 'namespace' => NS_USER,
183 'title' => 'New user',
184 'params' => [
185 '4::userid' => 1,
186 ],
187 ],
188 [
189 'text' => 'User account New user was created automatically',
190 'api' => [
191 'userid' => 1,
192 ],
193 ],
194 ],
195 ];
196 }
197
201 public function testAutocreateLogDatabaseRows( $row, $extra ) {
202 $this->doTestLogFormatter( $row, $extra );
203 }
204}
doTestLogFormatter( $row, $extra)
mergeMwGlobalArrayValue( $name, $values)
Merges the given values into a MW global array variable.
NewUsersLogFormatter Database.
static provideCreate2LogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility.
static provideCreateLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility.
testNewUsersLogDatabaseRows( $row, $extra)
provideNewUsersLogDatabaseRows
testByemailLogDatabaseRows( $row, $extra)
provideByemailLogDatabaseRows
testCreate2LogDatabaseRows( $row, $extra)
provideCreate2LogDatabaseRows
static provideNewUsersLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility.
testAutocreateLogDatabaseRows( $row, $extra)
provideAutocreateLogDatabaseRows
static provideByemailLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility.
static provideAutocreateLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility.
testCreateLogDatabaseRows( $row, $extra)
provideCreateLogDatabaseRows
const NS_USER
Definition Defines.php:75
return true to allow those checks to and false if checking is done & $user
Definition hooks.txt:1510
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:37