Addshore has uploaded a new change for review.
https://gerrit.wikimedia.org/r/77705
Change subject: ModifyEntityTestBase should look like ApiTestCase
......................................................................
ModifyEntityTestBase should look like ApiTestCase
No point in having init() that isnt needed
Also no point in having the same code in the bot test
Change-Id: I878223d01372e2afe16acf241e2eb35c91887236
---
M repo/tests/phpunit/includes/api/BotEditTest.php
M repo/tests/phpunit/includes/api/ModifyEntityTestBase.php
2 files changed, 14 insertions(+), 45 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/05/77705/1
diff --git a/repo/tests/phpunit/includes/api/BotEditTest.php
b/repo/tests/phpunit/includes/api/BotEditTest.php
index 6d25025..e0fbe2a 100644
--- a/repo/tests/phpunit/includes/api/BotEditTest.php
+++ b/repo/tests/phpunit/includes/api/BotEditTest.php
@@ -59,24 +59,10 @@
class BotEditTest extends ModifyEntityTestBase {
protected static $baseOfItemIds = 1;
- protected static $usepost;
- protected static $usetoken;
- protected static $userights;
public function setUp() {
global $wgUser;
parent::setUp();
-
- static $hasSites = false;
-
- if ( !$hasSites ) {
- \TestSites::insertIntoDb();
- $hasSites = true;
- }
-
- self::$usepost = Settings::get( 'apiInDebug' ) ? Settings::get(
'apiDebugWithPost' ) : true;
- self::$usetoken = Settings::get( 'apiInDebug' ) ?
Settings::get( 'apiDebugWithTokens' ) : true;
- self::$userights = Settings::get( 'apiInDebug' ) ?
Settings::get( 'apiDebugWithRights' ) : true;
ApiTestCase::$users['wbbot'] = new TestUser(
'Apitestbot',
@@ -96,7 +82,7 @@
*/
function testTokensAndRights() {
// check if there is a production-like environment available
- if ( !self::$usetoken || !self::$userights ) {
+ if ( !parent::$usetoken || !parent::$userights ) {
$this->markTestSkipped(
"The current setup does not include use of
tokens or user rights"
);
diff --git a/repo/tests/phpunit/includes/api/ModifyEntityTestBase.php
b/repo/tests/phpunit/includes/api/ModifyEntityTestBase.php
index 4f96e94..54d3d86 100644
--- a/repo/tests/phpunit/includes/api/ModifyEntityTestBase.php
+++ b/repo/tests/phpunit/includes/api/ModifyEntityTestBase.php
@@ -61,41 +61,15 @@
protected static $loginUser = null;
protected static $token = null;
- protected $user = null;
protected $setUpComplete = false;
protected function isSetUp() {
return $this->setUpComplete;
}
- protected function init() {
- global $wgUser;
-
- if ( !$this->user ) {
- self::$usepost = Settings::get( 'apiInDebug' ) ?
Settings::get( 'apiDebugWithPost' ) : true;
- self::$usetoken = Settings::get( 'apiInDebug' ) ?
Settings::get( 'apiDebugWithTokens' ) : true;
- self::$userights = Settings::get( 'apiInDebug' ) ?
Settings::get( 'apiDebugWithRights' ) : true;
-
- $this->user = new TestUser(
- 'Apitesteditor',
- 'Api Test Editor',
- '[email protected]',
- array( 'wbeditor' )
- );
-
- ApiTestCase::$users['wbeditor'] = $this->user;
- }
-
- $wgUser = $this->user->user;
- }
-
public function setUp() {
global $wgUser;
parent::setUp();
-
- $this->setMwGlobals( array( 'wgUser' => $wgUser ) );
-
- $this->init();
static $hasSites = false;
@@ -103,6 +77,19 @@
\TestSites::insertIntoDb();
$hasSites = true;
}
+
+ self::$usepost = Settings::get( 'apiInDebug' ) ? Settings::get(
'apiDebugWithPost' ) : true;
+ self::$usetoken = Settings::get( 'apiInDebug' ) ?
Settings::get( 'apiDebugWithTokens' ) : true;
+ self::$userights = Settings::get( 'apiInDebug' ) ?
Settings::get( 'apiDebugWithRights' ) : true;
+
+ ApiTestCase::$users['wbeditor'] = new TestUser(
+ 'Apitesteditor',
+ 'Api Test Editor',
+ '[email protected]',
+ array( 'wbeditor' )
+ );
+
+ $wgUser = self::$users['wbeditor']->user;
//TODO: preserve session and token between calls?!
self::$loginSession = false;
@@ -288,8 +275,6 @@
$user = self::$users['wbeditor'];
}
- $this->init();
-
if ( self::$loginSession && $user->username ==
self::$loginUser->username ) {
return self::$loginSession;
}
@@ -325,8 +310,6 @@
* Gets an entity edit token. Returns a cached token if available.
*/
function getEditToken() {
- $this->init();
-
if ( !self::$usetoken ) {
return "";
}
--
To view, visit https://gerrit.wikimedia.org/r/77705
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I878223d01372e2afe16acf241e2eb35c91887236
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits