4 * Helper for generating test recent changes entries.
7 * @author Katie Filbert < aude.wiki@gmail.com >
9 class TestRecentChangesHelper
{
11 public function makeEditRecentChange( User
$user, $titleText, $curid, $thisid, $lastid,
12 $timestamp, $counter, $watchingUsers
15 $attribs = array_merge(
16 $this->getDefaultAttributes( $titleText, $timestamp ),
18 'rc_user' => $user->getId(),
19 'rc_user_text' => $user->getName(),
20 'rc_this_oldid' => $thisid,
21 'rc_last_oldid' => $lastid,
26 return $this->makeRecentChange( $attribs, $counter, $watchingUsers );
29 public function makeLogRecentChange( $logType, $logAction, User
$user, $titleText, $timestamp, $counter,
32 $attribs = array_merge(
33 $this->getDefaultAttributes( $titleText, $timestamp ),
36 'rc_user' => $user->getId(),
37 'rc_user_text' => $user->getName(),
44 'rc_log_type' => $logType,
45 'rc_log_action' => $logAction,
46 'rc_source' => 'mw.log'
50 return $this->makeRecentChange( $attribs, $counter, $watchingUsers );
53 public function makeDeletedEditRecentChange( User
$user, $titleText, $timestamp, $curid,
54 $thisid, $lastid, $counter, $watchingUsers
56 $attribs = array_merge(
57 $this->getDefaultAttributes( $titleText, $timestamp ),
59 'rc_user' => $user->getId(),
60 'rc_user_text' => $user->getName(),
62 'rc_cur_id' => $curid,
63 'rc_this_oldid' => $thisid,
64 'rc_last_oldid' => $lastid
68 return $this->makeRecentChange( $attribs, $counter, $watchingUsers );
71 public function makeNewBotEditRecentChange( User
$user, $titleText, $curid, $thisid, $lastid,
72 $timestamp, $counter, $watchingUsers
75 $attribs = array_merge(
76 $this->getDefaultAttributes( $titleText, $timestamp ),
78 'rc_user' => $user->getId(),
79 'rc_user_text' => $user->getName(),
80 'rc_this_oldid' => $thisid,
81 'rc_last_oldid' => $lastid,
82 'rc_cur_id' => $curid,
85 'rc_source' => 'mw.new'
89 return $this->makeRecentChange( $attribs, $counter, $watchingUsers );
92 private function makeRecentChange( $attribs, $counter, $watchingUsers ) {
93 $change = new RecentChange();
94 $change->setAttribs( $attribs );
95 $change->counter
= $counter;
96 $change->numberofWatchingusers
= $watchingUsers;
101 private function getDefaultAttributes( $titleText, $timestamp ) {
105 'rc_user_text' => '127.0.0.1',
106 'rc_ip' => '127.0.0.1',
107 'rc_title' => $titleText,
109 'rc_timestamp' => $timestamp,
119 'rc_log_type' => null,
120 'rc_log_action' => '',
122 'rc_source' => 'mw.edit'
126 public function getTestContext( User
$user ) {
127 $context = new RequestContext();
128 $context->setLanguage( Language
::factory( 'en' ) );
130 $context->setUser( $user );
132 $title = Title
::newFromText( 'RecentChanges', NS_SPECIAL
);
133 $context->setTitle( $title );