Addshore has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/77888


Change subject: METestBase now uses doLogin
......................................................................

METestBase now uses doLogin

Also getting rid of other things we no longer need
Change-Id: I9816b7ccb994ac98c5b3e44e44c0defdf7cf871d
---
M repo/tests/phpunit/includes/api/BotEditTest.php
M repo/tests/phpunit/includes/api/EditEntityTest.php
M repo/tests/phpunit/includes/api/EditPageTest.php
M repo/tests/phpunit/includes/api/ModifyEntityTestBase.php
4 files changed, 14 insertions(+), 27 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/88/77888/1

diff --git a/repo/tests/phpunit/includes/api/BotEditTest.php 
b/repo/tests/phpunit/includes/api/BotEditTest.php
index e0fbe2a..2e0675d 100644
--- a/repo/tests/phpunit/includes/api/BotEditTest.php
+++ b/repo/tests/phpunit/includes/api/BotEditTest.php
@@ -72,7 +72,7 @@
                );
                $wgUser = self::$users['wbbot']->user;
 
-               $this->login( 'wbbot' );
+               $this->doLogin( 'wbbot' );
        }
 
        /**
diff --git a/repo/tests/phpunit/includes/api/EditEntityTest.php 
b/repo/tests/phpunit/includes/api/EditEntityTest.php
index 60bc354..0a6dbb1 100644
--- a/repo/tests/phpunit/includes/api/EditEntityTest.php
+++ b/repo/tests/phpunit/includes/api/EditEntityTest.php
@@ -100,7 +100,7 @@
         * Check if an entity can not be created whithout a token
         */
        function testEditEntityNoToken() {
-               $this->login();
+               $this->doLogin();
 
                if ( self::$usetoken ) {
                        try {
diff --git a/repo/tests/phpunit/includes/api/EditPageTest.php 
b/repo/tests/phpunit/includes/api/EditPageTest.php
index 4c6f5bd..114e391 100644
--- a/repo/tests/phpunit/includes/api/EditPageTest.php
+++ b/repo/tests/phpunit/includes/api/EditPageTest.php
@@ -57,7 +57,7 @@
 
                $this->assertTrue( $status->isOK(), $status->getMessage() ); // 
sanity check
 
-               $this->login();
+               $this->doLogin();
 
                $content->getItem()->setLabel( "de", "Test" );
                $data = $content->getItem()->toArray();
@@ -84,7 +84,7 @@
                $id = new \Wikibase\EntityId( \Wikibase\Item::ENTITY_TYPE, 
1234567 );
                $page = 
\Wikibase\EntityContentFactory::singleton()->getWikiPageForId( $id );
 
-               $this->login();
+               $this->doLogin();
 
                $text = "hallo welt";
 
diff --git a/repo/tests/phpunit/includes/api/ModifyEntityTestBase.php 
b/repo/tests/phpunit/includes/api/ModifyEntityTestBase.php
index 78c83e4..7072cd1 100644
--- a/repo/tests/phpunit/includes/api/ModifyEntityTestBase.php
+++ b/repo/tests/phpunit/includes/api/ModifyEntityTestBase.php
@@ -57,16 +57,6 @@
        protected static $entityInput = null; // entities in input format, 
using handles as keys
        protected static $entityOutput = array(); // entities in output format, 
using handles as keys
 
-       protected static $loginSession = null;
-       protected static $loginUser = null;
-       protected static $token = null;
-
-       protected $setUpComplete = false;
-
-       protected function isSetUp() {
-               return $this->setUpComplete;
-       }
-
        public function setUp() {
                global $wgUser;
                parent::setUp();
@@ -91,12 +81,7 @@
 
                $wgUser = self::$users['wbeditor']->user;
 
-               //TODO: preserve session and token between calls?!
-               self::$loginSession = false;
-               self::$token = false;
-
                self::initEntities();
-               $this->setUpComplete = true;
        }
 
        /**
@@ -266,17 +251,16 @@
        /**
         * Performs a login, if necessary, and returns the resulting session.
         */
-       function login( $user = 'wbeditor' ) {
-               self::doLogin( $user );
-               self::$loginUser = self::$users[ $user ];
-               return self::$loginSession;
+       function doLogin( $user = 'wbeditor' ) {
+               parent::doLogin( $user );
        }
 
        /**
         *  Appends an edit token to a request
         */
        function doApiRequestWithToken( array $params, array $session = null, 
User $user = null ) {
-               $params['token'] = self::getToken( 'edittoken', 
self::$loginUser );
+               global $wgUser;
+               $params['token'] = self::getToken( 'edittoken', $wgUser );
                return $this->doApiRequest( $params, $session, false, $user );
        }
 
@@ -285,6 +269,7 @@
         * entities in the database.
         */
        function createEntities() {
+               global $wgUser;
                if ( self::$entityOutput ) {
                        return;
                }
@@ -293,7 +278,7 @@
 
                foreach ( self::$entityInput as $entity ) {
                        $handle = $entity['handle'];
-                       $createdEntity = $this->setEntity( $entity, 
self::getToken( 'edittoken', self::$loginUser ) );
+                       $createdEntity = $this->setEntity( $entity, 
self::getToken( 'edittoken', $wgUser ) );
 
                        self::$entityOutput[ $handle ] = $createdEntity;
                }
@@ -303,12 +288,13 @@
         * Restores all well known entities test in the database to their 
original state.
         */
        function resetEntities() {
+               global $wgUser;
                $this->createEntities();
 
                foreach ( self::$entityInput as $handle => $entity ) {
                        $entity['id'] = $this->getEntityId( $handle );
 
-                       $data = $this->setEntity( $entity, self::getToken( 
'edittoken', self::$loginUser ) );
+                       $data = $this->setEntity( $entity, self::getToken( 
'edittoken', $wgUser ) );
 
                        self::$entityOutput[ $handle ] = $data;
                }
@@ -318,10 +304,11 @@
         * Restores the entity with the given handle to its original state
         */
        function resetEntity( $handle ) {
+               global $wgUser;
                $entity = $this->getEntityInput( $handle );
                $entity['id'] = $this->getEntityId( $handle );
 
-               $token = self::getToken( 'edittoken', self::$loginUser );
+               $token = self::getToken( 'edittoken', $wgUser );
                $data = $this->setEntity( $entity, $token );
 
                self::$entityOutput[ $handle ] = $data;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9816b7ccb994ac98c5b3e44e44c0defdf7cf871d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>

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

Reply via email to