jenkins-bot has submitted this change and it was merged.

Change subject: Improvements to RCCacheEntryFactoryTest and helper class
......................................................................


Improvements to RCCacheEntryFactoryTest and helper class

* pass User as argument when making the test context
* override rc_source when applicable

Change-Id: Id2094978d9f5ba962e76de7df29638e15a7547c3
---
M tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php
M tests/phpunit/includes/changes/TestRecentChangesHelper.php
2 files changed, 42 insertions(+), 25 deletions(-)

Approvals:
  Legoktm: Looks good to me, approved
  Daniel Kinzler: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php 
b/tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php
index 3acc8ad..c3b8ce6 100644
--- a/tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php
+++ b/tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php
@@ -57,8 +57,6 @@
        }
 
        public function editChangeProvider() {
-               $user = $this->testRecentChangesHelper->getTestUser();
-
                return array(
                        array(
                                array(
@@ -73,7 +71,7 @@
                                $this->getContext(),
                                $this->getMessages(),
                                
$this->testRecentChangesHelper->makeEditRecentChange(
-                                       $user,
+                                       $this->getTestUser(),
                                        'Xyz',
                                        5, // curid
                                        191, // thisid
@@ -113,8 +111,6 @@
        }
 
        public function deleteChangeProvider() {
-               $user = $this->testRecentChangesHelper->getTestUser();
-
                return array(
                        array(
                                array(
@@ -127,7 +123,8 @@
                                $this->getContext(),
                                $this->getMessages(),
                                
$this->testRecentChangesHelper->makeLogRecentChange(
-                                       $user,
+                                       'delete',
+                                       $this->getTestUser(),
                                        'Abc',
                                        '20131103212153',
                                        0, // counter
@@ -166,8 +163,6 @@
        }
 
        public function revUserDeleteProvider() {
-               $user = $this->testRecentChangesHelper->getTestUser();
-
                return array(
                        array(
                                array(
@@ -182,7 +177,7 @@
                                $this->getContext(),
                                $this->getMessages(),
                                
$this->testRecentChangesHelper->makeDeletedEditRecentChange(
-                                       $user,
+                                       $this->getTestUser(),
                                        'Zzz',
                                        '20131103212153',
                                        191, // thisid
@@ -313,8 +308,19 @@
                );
        }
 
+       private function getTestUser() {
+               $user = User::newFromName( 'TestRecentChangesUser' );
+
+               if ( !$user->getId() ) {
+                       $user->addToDatabase();
+               }
+
+               return $user;
+       }
+
        private function getContext() {
-               $context = $this->testRecentChangesHelper->getTestContext();
+               $user = $this->getTestUser();
+               $context = $this->testRecentChangesHelper->getTestContext( 
$user );
 
                $title = Title::newFromText( 'RecentChanges', NS_SPECIAL );
                $context->setTitle( $title );
diff --git a/tests/phpunit/includes/changes/TestRecentChangesHelper.php 
b/tests/phpunit/includes/changes/TestRecentChangesHelper.php
index 1f6b1e0..bb6ebec 100644
--- a/tests/phpunit/includes/changes/TestRecentChangesHelper.php
+++ b/tests/phpunit/includes/changes/TestRecentChangesHelper.php
@@ -26,7 +26,7 @@
                return $this->makeRecentChange( $attribs, $counter, 
$watchingUsers );
        }
 
-       public function makeLogRecentChange( User $user, $titleText, 
$timestamp, $counter,
+       public function makeLogRecentChange( $logType, User $user, $titleText, 
$timestamp, $counter,
                $watchingUsers
        ) {
                $attribs = array_merge(
@@ -41,8 +41,9 @@
                                'rc_new_len' => null,
                                'rc_type' => 3,
                                'rc_logid' => 25,
-                               'rc_log_type' => 'delete',
-                               'rc_log_action' => 'delete'
+                               'rc_log_type' => $logType,
+                               'rc_log_action' => $logType,
+                               'rc_source' => 'mw.log'
                        )
                );
 
@@ -61,6 +62,27 @@
                                'rc_cur_id' => $curid,
                                'rc_this_oldid' => $thisid,
                                'rc_last_oldid' => $lastid
+                       )
+               );
+
+               return $this->makeRecentChange( $attribs, $counter, 
$watchingUsers );
+       }
+
+       public function makeNewBotEditRecentChange( User $user, $titleText, 
$curid, $thisid, $lastid,
+               $timestamp, $counter, $watchingUsers
+       ) {
+
+               $attribs = array_merge(
+                       $this->getDefaultAttributes( $titleText, $timestamp ),
+                       array(
+                               'rc_user' => $user->getId(),
+                               'rc_user_text' => $user->getName(),
+                               'rc_this_oldid' => $thisid,
+                               'rc_last_oldid' => $lastid,
+                               'rc_cur_id' => $curid,
+                               'rc_type' => 1,
+                               'rc_bot' => 1,
+                               'rc_source' => 'mw.new'
                        )
                );
 
@@ -101,21 +123,10 @@
                );
        }
 
-       public function getTestUser() {
-               $user = User::newFromName( 'TestRecentChangesUser' );
-
-               if ( !$user->getId() ) {
-                       $user->addToDatabase();
-               }
-
-               return $user;
-       }
-
-       public function getTestContext() {
+       public function getTestContext( User $user ) {
                $context = new RequestContext();
                $context->setLanguage( Language::factory( 'en' ) );
 
-               $user = $this->getTestUser();
                $context->setUser( $user );
 
                return $context;

-- 
To view, visit https://gerrit.wikimedia.org/r/149304
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Id2094978d9f5ba962e76de7df29638e15a7547c3
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aude <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to