MediaWiki  1.23.2
RecentChangeTest.php
Go to the documentation of this file.
1 <?php
2 
7  protected $title;
8  protected $target;
9  protected $user;
10  protected $user_comment;
11  protected $context;
12 
13  public function __construct() {
14  parent::__construct();
15 
16  $this->title = Title::newFromText( 'SomeTitle' );
17  $this->target = Title::newFromText( 'TestTarget' );
18  $this->user = User::newFromName( 'UserName' );
19 
20  $this->user_comment = '<User comment about action>';
21  $this->context = RequestContext::newExtraneousContext( $this->title );
22  }
23 
60  public function testIrcMsgForLogTypeBlock() {
61  $sep = $this->context->msg( 'colon-separator' )->text();
62 
63  # block/block
64  $this->assertIRCComment(
65  $this->context->msg( 'blocklogentry', 'SomeTitle' )->plain() . $sep . $this->user_comment,
66  'block', 'block',
67  array(),
69  );
70  # block/unblock
71  $this->assertIRCComment(
72  $this->context->msg( 'unblocklogentry', 'SomeTitle' )->plain() . $sep . $this->user_comment,
73  'block', 'unblock',
74  array(),
76  );
77  }
78 
82  public function testIrcMsgForLogTypeDelete() {
83  $sep = $this->context->msg( 'colon-separator' )->text();
84 
85  # delete/delete
86  $this->assertIRCComment(
87  $this->context->msg( 'deletedarticle', 'SomeTitle' )->plain() . $sep . $this->user_comment,
88  'delete', 'delete',
89  array(),
91  );
92 
93  # delete/restore
94  $this->assertIRCComment(
95  $this->context->msg( 'undeletedarticle', 'SomeTitle' )->plain() . $sep . $this->user_comment,
96  'delete', 'restore',
97  array(),
99  );
100  }
101 
105  public function testIrcMsgForLogTypeNewusers() {
106  $this->assertIRCComment(
107  'New user account',
108  'newusers', 'newusers',
109  array()
110  );
111  $this->assertIRCComment(
112  'New user account',
113  'newusers', 'create',
114  array()
115  );
116  $this->assertIRCComment(
117  'created new account SomeTitle',
118  'newusers', 'create2',
119  array()
120  );
121  $this->assertIRCComment(
122  'Account created automatically',
123  'newusers', 'autocreate',
124  array()
125  );
126  }
127 
131  public function testIrcMsgForLogTypeMove() {
132  $move_params = array(
133  '4::target' => $this->target->getPrefixedText(),
134  '5::noredir' => 0,
135  );
136  $sep = $this->context->msg( 'colon-separator' )->text();
137 
138  # move/move
139  $this->assertIRCComment(
140  $this->context->msg( '1movedto2', 'SomeTitle', 'TestTarget' )
141  ->plain() . $sep . $this->user_comment,
142  'move', 'move',
143  $move_params,
145  );
146 
147  # move/move_redir
148  $this->assertIRCComment(
149  $this->context->msg( '1movedto2_redir', 'SomeTitle', 'TestTarget' )
150  ->plain() . $sep . $this->user_comment,
151  'move', 'move_redir',
152  $move_params,
154  );
155  }
156 
160  public function testIrcMsgForLogTypePatrol() {
161  # patrol/patrol
162  $this->assertIRCComment(
163  $this->context->msg( 'patrol-log-line', 'revision 777', '[[SomeTitle]]', '' )->plain(),
164  'patrol', 'patrol',
165  array(
166  '4::curid' => '777',
167  '5::previd' => '666',
168  '6::auto' => 0,
169  )
170  );
171  }
172 
176  public function testIrcMsgForLogTypeProtect() {
177  $protectParams = array(
178  '[edit=sysop] (indefinite) ‎[move=sysop] (indefinite)'
179  );
180  $sep = $this->context->msg( 'colon-separator' )->text();
181 
182  # protect/protect
183  $this->assertIRCComment(
184  $this->context->msg( 'protectedarticle', 'SomeTitle ' . $protectParams[0] )
185  ->plain() . $sep . $this->user_comment,
186  'protect', 'protect',
187  $protectParams,
189  );
190 
191  # protect/unprotect
192  $this->assertIRCComment(
193  $this->context->msg( 'unprotectedarticle', 'SomeTitle' )->plain() . $sep . $this->user_comment,
194  'protect', 'unprotect',
195  array(),
197  );
198 
199  # protect/modify
200  $this->assertIRCComment(
201  $this->context->msg( 'modifiedarticleprotection', 'SomeTitle ' . $protectParams[0] )
202  ->plain() . $sep . $this->user_comment,
203  'protect', 'modify',
204  $protectParams,
206  );
207  }
208 
212  public function testIrcMsgForLogTypeUpload() {
213  $sep = $this->context->msg( 'colon-separator' )->text();
214 
215  # upload/upload
216  $this->assertIRCComment(
217  $this->context->msg( 'uploadedimage', 'SomeTitle' )->plain() . $sep . $this->user_comment,
218  'upload', 'upload',
219  array(),
221  );
222 
223  # upload/overwrite
224  $this->assertIRCComment(
225  $this->context->msg( 'overwroteimage', 'SomeTitle' )->plain() . $sep . $this->user_comment,
226  'upload', 'overwrite',
227  array(),
229  );
230  }
231 
237  /*
238  public function testIrcMsgForBlankingAES() {
239  // $this->context->msg( 'autosumm-blank', .. );
240  }
241 
242  public function testIrcMsgForReplaceAES() {
243  // $this->context->msg( 'autosumm-replace', .. );
244  }
245 
246  public function testIrcMsgForRollbackAES() {
247  // $this->context->msg( 'revertpage', .. );
248  }
249 
250  public function testIrcMsgForUndoAES() {
251  // $this->context->msg( 'undo-summary', .. );
252  }
253  */
254 
263  protected function assertIRCComment( $expected, $type, $action, $params,
264  $comment = null, $msg = ''
265  ) {
266  $logEntry = new ManualLogEntry( $type, $action );
267  $logEntry->setPerformer( $this->user );
268  $logEntry->setTarget( $this->title );
269  if ( $comment !== null ) {
270  $logEntry->setComment( $comment );
271  }
272  $logEntry->setParameters( $params );
273 
274  $formatter = LogFormatter::newFromEntry( $logEntry );
275  $formatter->setContext( $this->context );
276 
277  // Apply the same transformation as done in IRCColourfulRCFeedFormatter::getLine for rc_comment
278  $ircRcComment = IRCColourfulRCFeedFormatter::cleanupForIRC( $formatter->getIRCActionComment() );
279 
280  $this->assertEquals(
281  $expected,
282  $ircRcComment,
283  $msg
284  );
285  }
286 }
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:189
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
RecentChangeTest\$context
$context
Definition: RecentChangeTest.php:11
RecentChangeTest\$target
$target
Definition: RecentChangeTest.php:8
RecentChangeTest\testIrcMsgForLogTypeBlock
testIrcMsgForLogTypeBlock()
The testIrcMsgForAction* tests are supposed to cover the hacky LogFormatter::getIRCActionText / bug 3...
Definition: RecentChangeTest.php:60
$params
$params
Definition: styleTest.css.php:40
User\newFromName
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:388
title
to move a page</td >< td > &*You are moving the page across *A non empty talk page already exists under the new or *You uncheck the box below In those you will have to move or merge the page manually if desired</td >< td > be sure to &You are responsible for making sure that links continue to point where they are supposed to go Note that the page will &a page at the new title
Definition: All_system_messages.txt:2703
RecentChangeTest\testIrcMsgForLogTypePatrol
testIrcMsgForLogTypePatrol()
@covers LogFormatter::getIRCActionText
Definition: RecentChangeTest.php:160
MediaWikiTestCase
Definition: MediaWikiTestCase.php:6
RecentChangeTest\testIrcMsgForLogTypeNewusers
testIrcMsgForLogTypeNewusers()
@covers LogFormatter::getIRCActionText
Definition: RecentChangeTest.php:105
RequestContext\newExtraneousContext
static newExtraneousContext(Title $title, $request=array())
Create a new extraneous context.
Definition: RequestContext.php:535
RecentChangeTest\testIrcMsgForLogTypeProtect
testIrcMsgForLogTypeProtect()
@covers LogFormatter::getIRCActionText
Definition: RecentChangeTest.php:176
RecentChangeTest\testIrcMsgForLogTypeMove
testIrcMsgForLogTypeMove()
@covers LogFormatter::getIRCActionText
Definition: RecentChangeTest.php:131
RecentChangeTest\testIrcMsgForLogTypeUpload
testIrcMsgForLogTypeUpload()
@covers LogFormatter::getIRCActionText
Definition: RecentChangeTest.php:212
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
RecentChangeTest\testIrcMsgForLogTypeDelete
testIrcMsgForLogTypeDelete()
@covers LogFormatter::getIRCActionText
Definition: RecentChangeTest.php:82
$comment
$comment
Definition: importImages.php:107
user
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such and we might be restricted by PHP settings such as safe mode or open_basedir We cannot assume that the software even has read access anywhere useful Many shared hosts run all users web applications under the same user
Definition: distributors.txt:9
RecentChangeTest\$user_comment
$user_comment
Definition: RecentChangeTest.php:10
RecentChangeTest\__construct
__construct()
Definition: RecentChangeTest.php:13
IRCColourfulRCFeedFormatter\cleanupForIRC
static cleanupForIRC( $text)
Remove newlines, carriage returns and decode html entites.
Definition: IRCColourfulRCFeedFormatter.php:118
RecentChangeTest\$user
$user
Definition: RecentChangeTest.php:9
ManualLogEntry
Class for creating log entries manually, for example to inject them into the database.
Definition: LogEntry.php:339
RecentChangeTest\$title
$title
Definition: RecentChangeTest.php:7
RecentChangeTest
@group Database
Definition: RecentChangeTest.php:6
RecentChangeTest\assertIRCComment
assertIRCComment( $expected, $type, $action, $params, $comment=null, $msg='')
Definition: RecentChangeTest.php:263
LogFormatter\newFromEntry
static newFromEntry(LogEntry $entry)
Constructs a new formatter suitable for given entry.
Definition: LogFormatter.php:45
$type
$type
Definition: testCompression.php:46