Daniel Kinzler has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/387353 )

Change subject: Make MFMockRevision more robust against changes to Revision.
......................................................................

Make MFMockRevision more robust against changes to Revision.

This allows MFMockRevision to work with I4f24e7fbb

Change-Id: I9593276eba701e34ad93ea568441196cedcaa2fb
---
M tests/phpunit/specials/SpecialMobileDiffTest.php
1 file changed, 21 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/53/387353/1

diff --git a/tests/phpunit/specials/SpecialMobileDiffTest.php 
b/tests/phpunit/specials/SpecialMobileDiffTest.php
index cb9f39c..674cac2 100644
--- a/tests/phpunit/specials/SpecialMobileDiffTest.php
+++ b/tests/phpunit/specials/SpecialMobileDiffTest.php
@@ -3,7 +3,7 @@
 /**
  * @group MobileFrontend
  */
-class SpecialMobileDiffTest extends MediaWikiTestCase {
+class SpecialMobileDiffTest extends MediaWikiLangTestCase {
        /** Keeps track of request variables that should be unset on teardown 
**/
        private $unsetReqVals = [];
 
@@ -101,31 +101,37 @@
 }
 
 class MFMockRevision extends Revision {
-       private $id;
 
-       public function getId() {
-               return $this->id;
-       }
-
+       /**
+        * @param int $revisionId
+        */
        public function __construct( $revisionId ) {
-               if ( $revisionId > 200 ) {
-                       throw new Exception( 'Unknown revision ID' );
-               }
-               $this->id = $revisionId;
+               $title = Title::newFromText( "Page_$revisionId" );
+
+               parent::__construct( [
+                       'id' => $revisionId,
+                       'title' => $title,
+               ] );
        }
 
        public static function newFromId( $revisionId, $flags = 0 ) {
                if ( $revisionId <= 200 ) {
                        return new MFMockRevision( $revisionId );
+               } else {
+                       return null;
                }
        }
 
-       public function getTitle() {
-               return Title::newFromText( "Page_$this->id" );
+       public function getPrevious() {
+               return new MFMockRevision( $this->getId() - 1 );
        }
 
-       public function getPrevious() {
-               return new MFMockRevision( $this->id - 1 );
+       public function getSize() {
+               return 100;
+       }
+
+       public function getSha1() {
+               return 'mock-hash-' . $this->getId();
        }
 
        /**
@@ -134,7 +140,7 @@
         * @return Revision or null
         */
        public function getNext() {
-               return new MFMockRevision( $this->id + 1 );
+               return new MFMockRevision( $this->getId() + 1 );
        }
 }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9593276eba701e34ad93ea568441196cedcaa2fb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler <[email protected]>

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

Reply via email to