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

Change subject: Remove parts of tests which are handled by parents
......................................................................


Remove parts of tests which are handled by parents

Also remove stuff which is no longer needed
Change-Id: I36f5a3806f412901b468f0fec5ad74bdc6c475ed
---
M repo/tests/phpunit/includes/api/BotEditTest.php
M repo/tests/phpunit/includes/api/EditEntityTest.php
M repo/tests/phpunit/includes/api/GetEntitiesTest.php
M repo/tests/phpunit/includes/api/LangAttributeBase.php
M repo/tests/phpunit/includes/api/LinkTitlesTest.php
M repo/tests/phpunit/includes/api/ModifyEntityTestBase.php
M repo/tests/phpunit/includes/api/PermissionsTest.php
M repo/tests/phpunit/includes/api/SetAliasesTest.php
M repo/tests/phpunit/includes/api/SetSiteLinkTest.php
9 files changed, 41 insertions(+), 97 deletions(-)

Approvals:
  Tobias Gritschacher: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/repo/tests/phpunit/includes/api/BotEditTest.php 
b/repo/tests/phpunit/includes/api/BotEditTest.php
index e0fbe2a..2162568 100644
--- a/repo/tests/phpunit/includes/api/BotEditTest.php
+++ b/repo/tests/phpunit/includes/api/BotEditTest.php
@@ -98,14 +98,14 @@
         * @depends testTokensAndRights
         */
        function testSetItemTop() {
-               $req = array(
+               $request = array(
                        'action' => 'wbeditentity',
                        'summary' => 'Some reason',
                        'data' => '{}',
                        'new' => 'item',
                );
 
-               $second = $this->doApiRequestWithToken( $req, null, 
self::$users['wbbot']->user );
+               $second = $this->doApiRequestWithToken( $request );
 
                $this->assertArrayHasKey( 'success', $second[0],
                        "Must have an 'success' key in the second result from 
the API" );
@@ -124,7 +124,7 @@
        function testCreateItem( $handle, $bot, $new, $data ) {
                $myid = null;
 
-               $req = array(
+               $request = array(
                        'action' => 'wbeditentity',
                        'summary' => 'Some reason',
                        'data' => $data,
@@ -132,15 +132,15 @@
 
                if ( !$new ) {
                        $myid = $this->getEntityId( $handle );
-                       $req['id'] = $myid;
+                       $request['id'] = $myid;
                } else {
-                       $req['new'] = 'item';
+                       $request['new'] = 'item';
                }
                if ( $bot ) {
-                       $req['bot'] = true;
+                       $request['bot'] = true;
                }
 
-               $second = $this->doApiRequestWithToken( $req, null 
,self::$users['wbbot']->user );
+               $second = $this->doApiRequestWithToken( $request );
 
                $this->assertArrayHasKey( 'success', $second[0],
                        "Must have an 'success' key in the second result from 
the API" );
@@ -161,14 +161,14 @@
                        $myid = $second[0]['entity']['id'];
                }
 
-               $req = array(
+               $request = array(
                                'action' => 'query',
                                'list' => 'recentchanges',
                                'rcprop' => 'title|flags',
                                'rctoponly' => '1',
                                'rclimit' => 50, // hope that no more than 50 
edits where made in the last second
                );
-               $third = $this->doApiRequest( $req, null, false, 
self::$users['wbbot']->user );
+               $third = $this->doApiRequest( $request, null, false, 
self::$users['wbbot']->user );
 
                $this->assertArrayHasKey( 'query', $third[0],
                        "Must have a 'query' key in the result from the API" );
diff --git a/repo/tests/phpunit/includes/api/EditEntityTest.php 
b/repo/tests/phpunit/includes/api/EditEntityTest.php
index cccb68f..f530e07 100644
--- a/repo/tests/phpunit/includes/api/EditEntityTest.php
+++ b/repo/tests/phpunit/includes/api/EditEntityTest.php
@@ -134,10 +134,7 @@
                                'reason' => 'Some reason',
                                'data' => $data,
                                'new' => 'property',
-                       ),
-                       null,
-                       self::$users['wbeditor']->user
-               );
+                       ) );
 
                $this->assertResultSuccess( $res  );
                $this->assertResultHasKeyInPath( $res, 'entity', 'id' );
@@ -157,10 +154,7 @@
                                'reason' => 'Some reason',
                                'data' => json_encode( self::$entity ),
                                'new' => 'item',
-                       ),
-                       null,
-                       self::$users['wbeditor']->user
-               );
+                       ) );
 
                $this->assertResultSuccess( $res );
                $this->assertResultHasKeyInPath( $res, 'entity', 'id' );
@@ -189,10 +183,7 @@
                                        'reason' => 'Some reason',
                                        'data' => json_encode( array_merge( 
self::$entity, $data ) ),
                                        'new' => 'item',
-                               ),
-                               null,
-                               self::$users['wbeditor']->user
-                       );
+                               ) );
 
                        $this->fail( "Adding another entity with the same 
sitelinks should have failed" );
                }
@@ -211,10 +202,7 @@
                                'reason' => 'Some reason',
                                'data' => json_encode( self::$entity ),
                                'id' => self::$id,
-                       ),
-                       null,
-                       self::$users['wbeditor']->user
-               );
+                       ) );
 
                $this->assertResultSuccess( $res );
                $this->assertResultHasKeyInPath( $res, 'entity', 'id' );
@@ -246,10 +234,7 @@
                                                'reason' => 'Some reason',
                                                'data' => json_encode( 
array_merge( self::$entity, $data ) ),
                                                'id' => self::$id,
-                                       ),
-                                       null,
-                                       self::$users['wbeditor']->user
-                               );
+                                       ) );
                                $this->fail( "Updating the entity with wrong 
data should have failed" );
                        }
                        catch ( \UsageException $e ) {
@@ -292,10 +277,7 @@
                                                'reason' => 'Some reason',
                                                'data' => json_encode( 
array_merge( $data, self::$entity ) ),
                                                'id' => self::$id,
-                                       ),
-                                       null,
-                                       self::$users['wbeditor']->user
-                               );
+                                       ) );
                                $this->assertResultSuccess( $res );
                                $this->assertResultHasKeyInPath( $res, 
'entity', 'id' );
                                $this->assertEntityEquals( self::$expect, 
$res['entity'] );
@@ -318,10 +300,7 @@
                                        'data' => json_encode( array() ),
                                        'id' => self::$id,
                                        'clear' => true,
-                               ),
-                               null,
-                               self::$users['wbeditor']->user
-                       );
+                               ) );
                        $this->assertResultSuccess( $res );
                        $this->assertResultHasKeyInPath( $res, 'entity', 'id' );
                        $this->assertEntityEquals( array( 'id' => self::$id ), 
$res['entity'] );
@@ -444,10 +423,7 @@
                                        'reason' => 'Some reason',
                                        'data' => is_string( $data ) ? $data : 
json_encode( $data ),
                                        'new' => 'item',
-                               ),
-                               null,
-                               self::$users['wbeditor']->user
-                       );
+                               ) );
 
                        $this->fail( "Adding entity should have failed: " . ( 
is_string( $data ) ? $data : json_encode( $data ) ) );
                }
@@ -554,10 +530,7 @@
                                'reason' => 'Some reason',
                                'data' => json_encode( $data ),
                                'id' => $id,
-                       ),
-                       null,
-                       self::$users['wbeditor']->user
-               );
+                       ) );
 
                // check returned keys 
-------------------------------------------
                $this->assertResultSuccess( $res );
diff --git a/repo/tests/phpunit/includes/api/GetEntitiesTest.php 
b/repo/tests/phpunit/includes/api/GetEntitiesTest.php
index 1437389..a2fb930 100644
--- a/repo/tests/phpunit/includes/api/GetEntitiesTest.php
+++ b/repo/tests/phpunit/includes/api/GetEntitiesTest.php
@@ -49,18 +49,6 @@
  */
 class GetEntitiesTest extends ModifyEntityTestBase {
 
-       public function setup() {
-               parent::setup();
-
-               static $resetedEntities = false;
-               if ( !$resetedEntities ) {
-                       // Nasty... we shouldn't need to do this. But 
apparently some other test spills bad state.
-                       // Only do this once as the tests in here really 
shouldn't alter any entities
-                       $this->resetEntities();
-                       $resetedEntities = true;
-               }
-       }
-
        /**
         * @dataProvider provideEntityHandles
         */
diff --git a/repo/tests/phpunit/includes/api/LangAttributeBase.php 
b/repo/tests/phpunit/includes/api/LangAttributeBase.php
index 49a279f..c3402c5 100644
--- a/repo/tests/phpunit/includes/api/LangAttributeBase.php
+++ b/repo/tests/phpunit/includes/api/LangAttributeBase.php
@@ -79,7 +79,7 @@
                $id = $this->getEntityId( $handle );
 
                // update the item 
----------------------------------------------------------------
-               $req = array(
+               $request = array(
                        'id' => $id,
                        'action' => $action,
                        'language' => $langCode,
@@ -87,7 +87,7 @@
                );
 
                try {
-                       list( $apiResponse,, ) = $this->doApiRequestWithToken( 
$req, null, self::$users['wbeditor']->user );
+                       list( $apiResponse,, ) = $this->doApiRequestWithToken( 
$request );
 
                        if ( $exception ) {
                                $this->fail( "expected exception $exception" );
diff --git a/repo/tests/phpunit/includes/api/LinkTitlesTest.php 
b/repo/tests/phpunit/includes/api/LinkTitlesTest.php
index c2640cf..92e153a 100644
--- a/repo/tests/phpunit/includes/api/LinkTitlesTest.php
+++ b/repo/tests/phpunit/includes/api/LinkTitlesTest.php
@@ -145,7 +145,7 @@
                        $this->setExpectedException( 'UsageException' );
                }
 
-               list( $res,, ) = $this->doApiRequestWithToken( $req, null, 
self::$users['wbeditor']->user );
+               list( $res,, ) = $this->doApiRequestWithToken( $req );
 
                if ( $expectedFailure ) {
                        $this->fail( "Expected failure: $expectedFailure" );
diff --git a/repo/tests/phpunit/includes/api/ModifyEntityTestBase.php 
b/repo/tests/phpunit/includes/api/ModifyEntityTestBase.php
index 5849c09..cd5622c 100644
--- a/repo/tests/phpunit/includes/api/ModifyEntityTestBase.php
+++ b/repo/tests/phpunit/includes/api/ModifyEntityTestBase.php
@@ -283,14 +283,6 @@
        }
 
        /**
-        *  Appends an edit token to a request
-        */
-       function doApiRequestWithToken( array $params, array $session = null, 
User $user = null ) {
-               $params['token'] = $this->getToken();
-               return $this->doApiRequest( $params, $session, false, $user );
-       }
-
-       /**
         * Initializes the test environment with the entities defined by 
makeEntityData() by creating these
         * entities in the database.
         */
diff --git a/repo/tests/phpunit/includes/api/PermissionsTest.php 
b/repo/tests/phpunit/includes/api/PermissionsTest.php
index cdfb82c..dac0ffc 100644
--- a/repo/tests/phpunit/includes/api/PermissionsTest.php
+++ b/repo/tests/phpunit/includes/api/PermissionsTest.php
@@ -60,8 +60,6 @@
 
                $this->permissions = $wgGroupPermissions;
                $this->old_user = $wgUser;
-
-               \TestSites::insertIntoDb();
        }
 
        function tearDown() {
diff --git a/repo/tests/phpunit/includes/api/SetAliasesTest.php 
b/repo/tests/phpunit/includes/api/SetAliasesTest.php
index 33cda78..e71f6f1 100644
--- a/repo/tests/phpunit/includes/api/SetAliasesTest.php
+++ b/repo/tests/phpunit/includes/api/SetAliasesTest.php
@@ -90,14 +90,14 @@
                $expected = $expected === '' ? array() : explode( '|', 
$expected );
 
                // update the item 
----------------------------------------------------------------
-               $req = array(
+               $request = array(
                        'id' => $id,
                        'action' => 'wbsetaliases',
                        'language' => $langCode,
                        $op => $value
                );
 
-               list( $apiResponse,, ) = $this->doApiRequestWithToken( $req, 
null, self::$users['wbeditor']->user );
+               list( $apiResponse,, ) = $this->doApiRequestWithToken( $request 
);
 
                $this->assertResultSuccess( $apiResponse );
 
@@ -137,7 +137,7 @@
                $exception = 'UsageException';
 
                // update the item 
----------------------------------------------------------------
-               $req = array(
+               $request = array(
                        'id' => $id,
                        'action' => 'wbsetaliases',
                        'language' => $langCode,
@@ -145,7 +145,7 @@
                );
 
                try {
-                       list( $apiResponse,, ) = $this->doApiRequestWithToken( 
$req, null, self::$users['wbeditor']->user );
+                       list( $apiResponse,, ) = $this->doApiRequestWithToken( 
$request );
                } catch ( \Exception $e ) {
                        if ( $exception !== null && ! $e instanceof 
\PHPUnit_Framework_AssertionFailedError ) {
                                $this->assertTrue( is_a( $e, $exception ), "Not 
the expected exception" );
@@ -160,7 +160,7 @@
        public function testSetAliases_invalidId() {
                $badId = 'xyz123+++';
 
-               $req = array(
+               $request = array(
                        'id' => $badId,
                        'action' => 'wbsetaliases',
                        'language' => 'en',
@@ -168,7 +168,7 @@
                );
 
                $this->setExpectedException( 'UsageException' );
-               $this->doApiRequestWithToken( $req, null, 
self::$users['wbeditor']->user );
+               $this->doApiRequestWithToken( $request );
        }
 
        /**
diff --git a/repo/tests/phpunit/includes/api/SetSiteLinkTest.php 
b/repo/tests/phpunit/includes/api/SetSiteLinkTest.php
index ee123da..858a3c6 100644
--- a/repo/tests/phpunit/includes/api/SetSiteLinkTest.php
+++ b/repo/tests/phpunit/includes/api/SetSiteLinkTest.php
@@ -48,26 +48,19 @@
  */
 class SetSiteLinkTest extends ModifyEntityTestBase {
 
-       public function setup() {
-               parent::setup();
-
-               // Nasty... we shouldn't need to do this. But apparently some 
other test spills bad state.
-               $this->resetEntities();
-       }
-
        public function testSetLiteLinkWithNoId( ) {
-               $req = array(
+               $request = array(
                        'action' => 'wbsetsitelink',
                        'linksite' => "enwiki",
                        'linktitle' => "testSetLiteLinkWithNoId",
                );
 
                $this->setExpectedException( 'UsageException' );
-               $this->doApiRequestWithToken( $req, null, 
self::$users['wbeditor']->user );
+               $this->doApiRequestWithToken( $request );
        }
 
        public function testSetLiteLinkWithBadId( ) {
-               $req = array(
+               $request = array(
                        'action' => 'wbsetsitelink',
                        'id' => 123456789,
                        'linksite' => "enwiki",
@@ -75,11 +68,11 @@
                );
 
                $this->setExpectedException( 'UsageException' );
-               $this->doApiRequestWithToken( $req, null, 
self::$users['wbeditor']->user );
+               $this->doApiRequestWithToken( $request );
        }
 
        public function testSetLiteLinkWithBadSite( ) {
-               $req = array(
+               $request = array(
                        'action' => 'wbsetsitelink',
                        'site' => "dewiktionary",
                        'title' => "Berlin",
@@ -88,11 +81,11 @@
                );
 
                $this->setExpectedException( 'UsageException' );
-               $this->doApiRequestWithToken( $req, null, 
self::$users['wbeditor']->user );
+               $this->doApiRequestWithToken( $request );
        }
 
        public function testSetLiteLinkWithBadTitle( ) {
-               $req = array(
+               $request = array(
                        'action' => 'wbsetsitelink',
                        'site' => "dewiki",
                        'title' => "testSetLiteLinkWithBadTitle_de",
@@ -101,7 +94,7 @@
                );
 
                $this->setExpectedException( 'UsageException' );
-               $this->doApiRequestWithToken( $req, null, 
self::$users['wbeditor']->user );
+               $this->doApiRequestWithToken( $request );
        }
 
        public function testSetLiteLinkWithNoToken( ) {
@@ -110,7 +103,7 @@
                        return;
                }
 
-               $req = array(
+               $request = array(
                        'action' => 'wbsetsitelink',
                        'id' => $this->getEntityId( "Berlin" ),
                        'linksite' => "enwiki",
@@ -118,7 +111,7 @@
                );
 
                $this->setExpectedException( 'UsageException' );
-               $this->doApiRequest( $req, null, false, 
self::$users['wbeditor']->user );
+               $this->doApiRequest( $request, null, false, 
self::$users['wbeditor']->user );
        }
 
        public static function provideSetLiteLink() {
@@ -167,7 +160,7 @@
                }
 
                // set the sitelink -------------------------------
-               $req = array_merge( $item_spec, array(
+               $request = array_merge( $item_spec, array(
                        'action' => 'wbsetsitelink',
                        'linksite' => $linksite,
                        'linktitle' => $linktitle,
@@ -177,7 +170,7 @@
                        $this->setExpectedException($expectedFailure );
                }
 
-               list( $res,, ) = $this->doApiRequestWithToken( $req, null, 
self::$users['wbeditor']->user );
+               list( $res,, ) = $this->doApiRequestWithToken( $request );
 
                if ( $expectedFailure ) {
                        $this->fail( $expectedFailure );
@@ -232,7 +225,7 @@
        }
 
        public function testSetLiteLinkWithBadTargetSite( ) {
-               $req = array(
+               $request = array(
                        'action' => 'wbsetsitelink',
                        'site' => "dewiki",
                        'title' => "Berlin",
@@ -241,7 +234,7 @@
                );
 
                $this->setExpectedException( 'UsageException' );
-               $this->doApiRequestWithToken( $req, null, 
self::$users['wbeditor']->user );
+               $this->doApiRequestWithToken( $request );
        }
 }
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I36f5a3806f412901b468f0fec5ad74bdc6c475ed
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
Gerrit-Reviewer: Tobias Gritschacher <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to