Addshore has uploaded a new change for review.

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


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

Remove parts of tests which are handled by parents

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/LangAttributeBase.php
M repo/tests/phpunit/includes/api/LinkTitlesTest.php
M repo/tests/phpunit/includes/api/SetAliasesTest.php
M repo/tests/phpunit/includes/api/SetSiteLinkTest.php
6 files changed, 45 insertions(+), 70 deletions(-)


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

diff --git a/repo/tests/phpunit/includes/api/BotEditTest.php 
b/repo/tests/phpunit/includes/api/BotEditTest.php
index 2e0675d..7048861 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 0a6dbb1..8e8aaeb 100644
--- a/repo/tests/phpunit/includes/api/EditEntityTest.php
+++ b/repo/tests/phpunit/includes/api/EditEntityTest.php
@@ -136,10 +136,7 @@
                                'reason' => 'Some reason',
                                'data' => $data,
                                'new' => 'property',
-                       ),
-                       null,
-                       self::$users['wbeditor']->user
-               );
+                       ) );
 
                $this->assertResultSuccess( $res  );
                $this->assertResultHasKeyInPath( $res, 'entity', 'id' );
@@ -159,10 +156,7 @@
                                'reason' => 'Some reason',
                                'data' => json_encode( self::$entity ),
                                'new' => 'item',
-                       ),
-                       null,
-                       self::$users['wbeditor']->user
-               );
+                       ) );
 
                $this->assertResultSuccess( $res );
                $this->assertResultHasKeyInPath( $res, 'entity', 'id' );
@@ -191,10 +185,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" );
                }
@@ -213,10 +204,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' );
@@ -248,10 +236,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 ) {
@@ -294,10 +279,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'] );
@@ -320,10 +302,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'] );
@@ -446,10 +425,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 ) ) );
                }
@@ -556,10 +532,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/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/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..219d70f 100644
--- a/repo/tests/phpunit/includes/api/SetSiteLinkTest.php
+++ b/repo/tests/phpunit/includes/api/SetSiteLinkTest.php
@@ -48,26 +48,28 @@
  */
 class SetSiteLinkTest extends ModifyEntityTestBase {
 
-       public function setup() {
-               parent::setup();
+       public function setUp() {
+               parent::setUp();
+
+               $this->doLogin();
 
                // 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 +77,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 +90,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 +103,7 @@
                );
 
                $this->setExpectedException( 'UsageException' );
-               $this->doApiRequestWithToken( $req, null, 
self::$users['wbeditor']->user );
+               $this->doApiRequestWithToken( $request );
        }
 
        public function testSetLiteLinkWithNoToken( ) {
@@ -110,7 +112,7 @@
                        return;
                }
 
-               $req = array(
+               $request = array(
                        'action' => 'wbsetsitelink',
                        'id' => $this->getEntityId( "Berlin" ),
                        'linksite' => "enwiki",
@@ -118,7 +120,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 +169,7 @@
                }
 
                // set the sitelink -------------------------------
-               $req = array_merge( $item_spec, array(
+               $request = array_merge( $item_spec, array(
                        'action' => 'wbsetsitelink',
                        'linksite' => $linksite,
                        'linktitle' => $linktitle,
@@ -177,7 +179,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 +234,7 @@
        }
 
        public function testSetLiteLinkWithBadTargetSite( ) {
-               $req = array(
+               $request = array(
                        'action' => 'wbsetsitelink',
                        'site' => "dewiki",
                        'title' => "Berlin",
@@ -241,7 +243,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: newchange
Gerrit-Change-Id: I36f5a3806f412901b468f0fec5ad74bdc6c475ed
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