2012-02-25 21:22:49 +00:00
|
|
|
<?php
|
2014-03-12 17:08:40 +00:00
|
|
|
|
2012-03-23 17:18:07 +00:00
|
|
|
/**
|
|
|
|
|
* @group Database
|
|
|
|
|
*/
|
2012-02-25 21:22:49 +00:00
|
|
|
class RecentChangeTest extends MediaWikiTestCase {
|
|
|
|
|
protected $title;
|
|
|
|
|
protected $target;
|
|
|
|
|
protected $user;
|
|
|
|
|
protected $user_comment;
|
2012-03-05 21:21:34 +00:00
|
|
|
protected $context;
|
2012-02-25 21:22:49 +00:00
|
|
|
|
2013-10-21 21:09:13 +00:00
|
|
|
public function __construct() {
|
2012-02-25 21:22:49 +00:00
|
|
|
parent::__construct();
|
|
|
|
|
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title = Title::newFromText( 'SomeTitle' );
|
2012-02-25 21:22:49 +00:00
|
|
|
$this->target = Title::newFromText( 'TestTarget' );
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->user = User::newFromName( 'UserName' );
|
2012-02-25 21:22:49 +00:00
|
|
|
|
|
|
|
|
$this->user_comment = '<User comment about action>';
|
2012-03-05 21:21:34 +00:00
|
|
|
$this->context = RequestContext::newExtraneousContext( $this->title );
|
2012-02-25 21:22:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The testIrcMsgForAction* tests are supposed to cover the hacky
|
|
|
|
|
* LogFormatter::getIRCActionText / bug 34508
|
|
|
|
|
*
|
|
|
|
|
* Third parties bots listen to those messages. They are clever enough
|
|
|
|
|
* to fetch the i18n messages from the wiki and then analyze the IRC feed
|
|
|
|
|
* to reverse engineer the $1, $2 messages.
|
|
|
|
|
* One thing bots can not detect is when MediaWiki change the meaning of
|
|
|
|
|
* a message like what happened when we deployed 1.19. $1 became the user
|
|
|
|
|
* performing the action which broke basically all bots around.
|
|
|
|
|
*
|
2012-02-28 00:39:01 +00:00
|
|
|
* Should cover the following log actions (which are most commonly used by bots):
|
|
|
|
|
* - block/block
|
|
|
|
|
* - block/unblock
|
2014-08-04 21:12:53 +00:00
|
|
|
* - block/reblock
|
2012-02-28 00:39:01 +00:00
|
|
|
* - delete/delete
|
|
|
|
|
* - delete/restore
|
|
|
|
|
* - newusers/create
|
|
|
|
|
* - newusers/create2
|
|
|
|
|
* - newusers/autocreate
|
|
|
|
|
* - move/move
|
|
|
|
|
* - move/move_redir
|
|
|
|
|
* - protect/protect
|
|
|
|
|
* - protect/modifyprotect
|
|
|
|
|
* - protect/unprotect
|
2015-04-08 10:12:15 +00:00
|
|
|
* - protect/move_prot
|
2012-02-28 00:39:01 +00:00
|
|
|
* - upload/upload
|
2014-08-04 17:10:51 +00:00
|
|
|
* - merge/merge
|
2014-08-04 19:35:18 +00:00
|
|
|
* - import/upload
|
|
|
|
|
* - import/interwiki
|
2012-02-28 00:39:01 +00:00
|
|
|
*
|
|
|
|
|
* As well as the following Auto Edit Summaries:
|
|
|
|
|
* - blank
|
|
|
|
|
* - replace
|
|
|
|
|
* - rollback
|
|
|
|
|
* - undo
|
2012-02-25 21:22:49 +00:00
|
|
|
*/
|
|
|
|
|
|
2015-06-10 12:39:17 +00:00
|
|
|
/**
|
|
|
|
|
* @covers RecentChange::parseParams
|
|
|
|
|
*/
|
|
|
|
|
public function testParseParams() {
|
|
|
|
|
$params = array(
|
|
|
|
|
'root' => array(
|
|
|
|
|
'A' => 1,
|
|
|
|
|
'B' => 'two'
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$this->assertParseParams(
|
|
|
|
|
$params,
|
|
|
|
|
'a:1:{s:4:"root";a:2:{s:1:"A";i:1;s:1:"B";s:3:"two";}}'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$this->assertParseParams(
|
|
|
|
|
null,
|
|
|
|
|
null
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$this->assertParseParams(
|
|
|
|
|
null,
|
|
|
|
|
serialize( false )
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$this->assertParseParams(
|
|
|
|
|
null,
|
|
|
|
|
'not-an-array'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param array $expectedParseParams
|
|
|
|
|
* @param string|null $rawRcParams
|
|
|
|
|
*/
|
|
|
|
|
protected function assertParseParams( $expectedParseParams, $rawRcParams ) {
|
|
|
|
|
$rc = new RecentChange;
|
|
|
|
|
$rc->setAttribs( array( 'rc_params' => $rawRcParams ) );
|
|
|
|
|
|
|
|
|
|
$actualParseParams = $rc->parseParams();
|
|
|
|
|
|
|
|
|
|
$this->assertEquals( $expectedParseParams, $actualParseParams );
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-25 21:22:49 +00:00
|
|
|
}
|