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

Change subject: All tests now use the base
......................................................................


All tests now use the base

This allows us to use the requestWithToken
Change-Id: I563266b33e4dc984f77918015df5e52926c1b219
---
M repo/tests/phpunit/includes/api/CreateClaimTest.php
M repo/tests/phpunit/includes/api/RemoveClaimsTest.php
M repo/tests/phpunit/includes/api/RemoveQualifiersTest.php
M repo/tests/phpunit/includes/api/RemoveReferencesTest.php
M repo/tests/phpunit/includes/api/SetClaimTest.php
M repo/tests/phpunit/includes/api/SetClaimValueTest.php
M repo/tests/phpunit/includes/api/SetQualifierTest.php
M repo/tests/phpunit/includes/api/SetReferenceTest.php
M repo/tests/phpunit/includes/api/SetStatementRankTest.php
9 files changed, 32 insertions(+), 58 deletions(-)

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



diff --git a/repo/tests/phpunit/includes/api/CreateClaimTest.php 
b/repo/tests/phpunit/includes/api/CreateClaimTest.php
index 535c2be..498bc80 100644
--- a/repo/tests/phpunit/includes/api/CreateClaimTest.php
+++ b/repo/tests/phpunit/includes/api/CreateClaimTest.php
@@ -39,7 +39,7 @@
  * @licence GNU GPL v2+
  * @author Jeroen De Dauw < [email protected] >
  */
-class CreateClaimTest extends \ApiTestCase {
+class CreateClaimTest extends ModifyEntityTestBase {
 
        protected static function getNewEntityAndProperty() {
                $entity = \Wikibase\Item::newEmpty();
@@ -77,10 +77,9 @@
                        'snaktype' => 'value',
                        'property' => $this->getFormattedIdForEntity( $property 
),
                        'value' => '"Foo.png"',
-                       'token' => $GLOBALS['wgUser']->getEditToken()
                );
 
-               list( $resultArray, ) = $this->doApiRequest( $params );
+               list( $resultArray, ) = $this->doApiRequestWithToken( $params );
 
                $this->assertRequestValidity( $resultArray );
 
@@ -226,8 +225,6 @@
                 */
                list( $entity, $property ) = 
self::getEntityAndPropertyForInvalid();
 
-               $params['token'] = $GLOBALS['wgUser']->getEditToken();
-
                if ( array_key_exists( 'entity', $params ) && $params['entity'] 
=== '-' ) {
                        $params['entity'] = $this->getFormattedIdForEntity( 
$entity );
                }
@@ -237,8 +234,8 @@
                }
 
                try {
-                       $this->doApiRequest( $params );
-                       $this->assertFalse( true, 'Invalid request should raise 
an exception' );
+                       $this->doApiRequestWithToken( $params );
+                       $this->fail( 'Invalid request should raise an 
exception' );
                }
                catch ( \UsageException $e ) {
                        $this->assertEquals( $errorCode, $e->getCodeString(), 
'Invalid request raised correct error' );
@@ -267,10 +264,9 @@
                        'snaktype' => 'value',
                        'property' => $this->getFormattedIdForEntity( $property 
),
                        'value' => '"Foo.png"',
-                       'token' => $GLOBALS['wgUser']->getEditToken()
                );
 
-               list( $resultArray, ) = $this->doApiRequest( $params );
+               list( $resultArray, ) = $this->doApiRequestWithToken( $params );
 
                $this->assertRequestValidity( $resultArray );
 
@@ -284,11 +280,10 @@
                        'snaktype' => 'value',
                        'property' => $this->getFormattedIdForEntity( $property 
),
                        'value' => '"Bar.jpg"',
-                       'token' => $GLOBALS['wgUser']->getEditToken(),
                        'baserevid' => $revId
                );
 
-               list( $resultArray, ) = $this->doApiRequest( $params );
+               list( $resultArray, ) = $this->doApiRequestWithToken( $params );
 
                $this->assertRequestValidity( $resultArray );
 
diff --git a/repo/tests/phpunit/includes/api/RemoveClaimsTest.php 
b/repo/tests/phpunit/includes/api/RemoveClaimsTest.php
index ea84cdc..ed2971a 100644
--- a/repo/tests/phpunit/includes/api/RemoveClaimsTest.php
+++ b/repo/tests/phpunit/includes/api/RemoveClaimsTest.php
@@ -40,7 +40,7 @@
  * @author Jeroen De Dauw < [email protected] >
  * @author Katie Filbert < [email protected] >
  */
-class RemoveClaimsTest extends \ApiTestCase {
+class RemoveClaimsTest extends ModifyEntityTestBase {
 
        /**
         * @param Entity $entity
@@ -131,10 +131,9 @@
                $params = array(
                        'action' => 'wbremoveclaims',
                        'claim' => implode( '|', $claimGuids ),
-                       'token' => $GLOBALS['wgUser']->getEditToken()
                );
 
-               list( $resultArray, ) = $this->doApiRequest( $params );
+               list( $resultArray, ) = $this->doApiRequestWithToken( $params );
 
                $this->assertInternalType( 'array', $resultArray, 'top level 
element is an array' );
                $this->assertArrayHasKey( 'claims', $resultArray, 'top level 
element has a claims key' );
@@ -155,10 +154,9 @@
                $params = array(
                        'action' => 'wbremoveclaims',
                        'claim' => is_array( $claimGuids ) ? implode( '|', 
$claimGuids ) : $claimGuids,
-                       'token' => $GLOBALS['wgUser']->getEditToken()
                );
 
-               $this->doApiRequest( $params );
+               $this->doApiRequestWithToken( $params );
        }
 
        public function invalidClaimProvider() {
diff --git a/repo/tests/phpunit/includes/api/RemoveQualifiersTest.php 
b/repo/tests/phpunit/includes/api/RemoveQualifiersTest.php
index fe5ea6c..20cfb82 100644
--- a/repo/tests/phpunit/includes/api/RemoveQualifiersTest.php
+++ b/repo/tests/phpunit/includes/api/RemoveQualifiersTest.php
@@ -40,7 +40,7 @@
  * @author Jeroen De Dauw < [email protected] >
  * @author Katie Filbert < [email protected] >
  */
-class RemoveQualifiersTest extends \ApiTestCase {
+class RemoveQualifiersTest extends ModifyEntityTestBase {
 
        /**
         * @return Snak[]
@@ -127,10 +127,9 @@
                        'action' => 'wbremovequalifiers',
                        'claim' => $statementGuid,
                        'qualifiers' => implode( '|', $hashes ),
-                       'token' => $GLOBALS['wgUser']->getEditToken()
                );
 
-               list( $resultArray, ) = $this->doApiRequest( $params );
+               list( $resultArray, ) = $this->doApiRequestWithToken( $params );
 
                $this->assertInternalType( 'array', $resultArray, 'top level 
element is an array' );
                $this->assertArrayHasKey( 'pageinfo', $resultArray, 'top level 
element has a pageinfo key' );
@@ -143,11 +142,10 @@
                        'action' => 'wbremovequalifiers',
                        'claim' => $statementGuid,
                        'qualifiers' => implode( '|', $hashes ),
-                       'token' => $GLOBALS['wgUser']->getEditToken()
                );
 
                try {
-                       $this->doApiRequest( $params );
+                       $this->doApiRequestWithToken( $params );
                        $this->fail( 'Invalid request should raise an 
exception' );
                }
                catch ( \UsageException $e ) {
@@ -168,11 +166,10 @@
                        'action' => 'wbremovequalifiers',
                        'claim' => $claimGuid,
                        'qualifiers' => $hash,
-                       'token' => $GLOBALS['wgUser']->getEditToken()
                );
 
                try {
-                       $this->doApiRequest( $params );
+                       $this->doApiRequestWithToken( $params );
                        $this->fail( 'Invalid claim guid did not throw an 
error' );
                } catch ( \UsageException $e ) {
                        $this->assertEquals( $e->getCodeString(), 
'invalid-guid', 'Invalid claim guid raised correct error' );
diff --git a/repo/tests/phpunit/includes/api/RemoveReferencesTest.php 
b/repo/tests/phpunit/includes/api/RemoveReferencesTest.php
index 964845b..8fdcfcb 100644
--- a/repo/tests/phpunit/includes/api/RemoveReferencesTest.php
+++ b/repo/tests/phpunit/includes/api/RemoveReferencesTest.php
@@ -41,7 +41,7 @@
  * @author Jeroen De Dauw < [email protected] >
  * @author Katie Filbert < [email protected] >
  */
-class RemoveReferencesTest extends \ApiTestCase {
+class RemoveReferencesTest extends ModifyEntityTestBase {
 
        /**
         * @return Snak[]
@@ -128,10 +128,9 @@
                        'action' => 'wbremovereferences',
                        'statement' => $statementGuid,
                        'references' => implode( '|', $hashes ),
-                       'token' => $GLOBALS['wgUser']->getEditToken()
                );
 
-               list( $resultArray, ) = $this->doApiRequest( $params );
+               list( $resultArray, ) = $this->doApiRequestWithToken( $params );
 
                $this->assertInternalType( 'array', $resultArray, 'top level 
element is an array' );
                $this->assertArrayHasKey( 'pageinfo', $resultArray, 'top level 
element has a pageinfo key' );
@@ -144,11 +143,10 @@
                        'action' => 'wbremovereferences',
                        'statement' => $statementGuid,
                        'references' => implode( '|', $hashes ),
-                       'token' => $GLOBALS['wgUser']->getEditToken()
                );
 
                try {
-                       $this->doApiRequest( $params );
+                       $this->doApiRequestWithToken( $params );
                        $this->fail( 'Invalid request should raise an 
exception' );
                }
                catch ( \UsageException $e ) {
@@ -169,11 +167,10 @@
                        'action' => 'wbremovereferences',
                        'statement' => $statementGuid,
                        'references' => $hash,
-                       'token' => $GLOBALS['wgUser']->getEditToken()
                );
 
                try {
-                       $this->doApiRequest( $params );
+                       $this->doApiRequestWithToken( $params );
                        $this->fail( 'Invalid claim guid did not throw an 
error' );
                } catch ( \UsageException $e ) {
                        $this->assertEquals( 'invalid-guid', 
$e->getCodeString(),  'Invalid claim guid raised correct error' );
diff --git a/repo/tests/phpunit/includes/api/SetClaimTest.php 
b/repo/tests/phpunit/includes/api/SetClaimTest.php
index 1bd2a4d..f4f64ba 100644
--- a/repo/tests/phpunit/includes/api/SetClaimTest.php
+++ b/repo/tests/phpunit/includes/api/SetClaimTest.php
@@ -42,7 +42,7 @@
  * @author Jeroen De Dauw < [email protected] >
  * @author Daniel Kinzler
  */
-class SetClaimTest extends \ApiTestCase {
+class SetClaimTest extends ModifyEntityTestBase {
 
        /**
         * @return \Wikibase\Snak[]
@@ -150,7 +150,6 @@
                $params = array(
                        'action' => 'wbsetclaim',
                        'claim' => \FormatJson::encode( 
$serializer->getSerialized( $claim ) ),
-                       'token' => $GLOBALS['wgUser']->getEditToken()
                );
 
                $this->makeValidRequest( $params );
@@ -167,7 +166,7 @@
        }
 
        protected function makeValidRequest( array $params ) {
-               list( $resultArray, ) = $this->doApiRequest( $params );
+               list( $resultArray, ) = $this->doApiRequestWithToken( $params );
 
                $this->assertInternalType( 'array', $resultArray, 'top level 
element is an array' );
                $this->assertArrayHasKey( 'pageinfo', $resultArray, 'top level 
element has a pageinfo key' );
diff --git a/repo/tests/phpunit/includes/api/SetClaimValueTest.php 
b/repo/tests/phpunit/includes/api/SetClaimValueTest.php
index 4929a91..23fdf2f 100644
--- a/repo/tests/phpunit/includes/api/SetClaimValueTest.php
+++ b/repo/tests/phpunit/includes/api/SetClaimValueTest.php
@@ -41,7 +41,7 @@
  * @author Jeroen De Dauw < [email protected] >
  * @author Katie Filbert < [email protected] >
  */
-class SetClaimValueTest extends \ApiTestCase {
+class SetClaimValueTest extends ModifyEntityTestBase {
 
        /**
         * @param Entity $entity
@@ -106,10 +106,9 @@
                        'claim' => $claimGuid,
                        'value' => \FormatJson::encode( $value ),
                        'snaktype' => 'value',
-                       'token' => $GLOBALS['wgUser']->getEditToken()
                );
 
-               list( $resultArray, ) = $this->doApiRequest( $params );
+               list( $resultArray, ) = $this->doApiRequestWithToken( $params );
 
                $this->assertInternalType( 'array', $resultArray, 'top level 
element is an array' );
                $this->assertArrayHasKey( 'claim', $resultArray, 'top level 
element has a claim key' );
@@ -141,11 +140,10 @@
                        'claim' => $claimGuid,
                        'snaktype' => 'value',
                        'value' => 'abc',
-                       'token' => $GLOBALS['wgUser']->getEditToken()
                );
 
                try {
-                       $this->doApiRequest( $params );
+                       $this->doApiRequestWithToken( $params );
                        $this->fail( 'Invalid claim guid did not raise an 
error' );
                } catch ( \UsageException $e ) {
                        $this->assertEquals( 'invalid-guid', 
$e->getCodeString(),  'Invalid claim guid raised correct error' );
diff --git a/repo/tests/phpunit/includes/api/SetQualifierTest.php 
b/repo/tests/phpunit/includes/api/SetQualifierTest.php
index a5dd084..528169e 100644
--- a/repo/tests/phpunit/includes/api/SetQualifierTest.php
+++ b/repo/tests/phpunit/includes/api/SetQualifierTest.php
@@ -172,14 +172,11 @@
        }
 
        protected function makeAddRequest( $statementGuid, Snak $qualifier, 
EntityId $entityId ) {
-               $token = $this->getEditToken();
-
                $params = array(
                        'action' => 'wbsetqualifier',
                        'claim' => $statementGuid,
                        'snaktype' => $qualifier->getType(),
                        'property' => 
$qualifier->getPropertyId()->getPrefixedId(),
-                       'token' => $token
                );
 
                if ( $qualifier instanceof \Wikibase\PropertyValueSnak ) {
@@ -206,7 +203,7 @@
        }
 
        protected function makeValidRequest( array $params ) {
-               list( $resultArray, ) = $this->doApiRequest( $params );
+               list( $resultArray, ) = $this->doApiRequestWithToken( $params );
 
                $this->assertInternalType( 'array', $resultArray, 'top level 
element is an array' );
                $this->assertArrayHasKey( 'pageinfo', $resultArray, 'top level 
element has a pageinfo key' );
@@ -228,11 +225,10 @@
                        'property' => 7,
                        'snaktype' => 'value',
                        'value' => 'abc',
-                       'token' => $GLOBALS['wgUser']->getEditToken()
                );
 
                try {
-                       $this->doApiRequest( $params );
+                       $this->doApiRequestWithToken( $params );
                        $this->fail( 'Invalid claim guid did not throw an 
error' );
                } catch ( \UsageException $e ) {
                        $this->assertEquals( 'invalid-guid', 
$e->getCodeString(),  'Invalid claim guid raised correct error' );
diff --git a/repo/tests/phpunit/includes/api/SetReferenceTest.php 
b/repo/tests/phpunit/includes/api/SetReferenceTest.php
index ff87038..d8428f1 100644
--- a/repo/tests/phpunit/includes/api/SetReferenceTest.php
+++ b/repo/tests/phpunit/includes/api/SetReferenceTest.php
@@ -41,7 +41,7 @@
  * @author Katie Filbert < [email protected] >
  * @author Daniel Kinzler
  */
-class SetReferenceTest extends \ApiTestCase {
+class SetReferenceTest extends ModifyEntityTestBase {
 
        public function setUp() {
                static $hasProperties = false;
@@ -110,10 +110,9 @@
                        'statement' => $statementGuid,
                        'reference' => $referenceHash,
                        'snaks' => \FormatJson::encode( 
$serializedReference['snaks'] ),
-                       'token' => $GLOBALS['wgUser']->getEditToken()
                );
 
-               list( $resultArray, ) = $this->doApiRequest( $params );
+               list( $resultArray, ) = $this->doApiRequestWithToken( $params );
 
                $this->assertInternalType( 'array', $resultArray, 'top level 
element is an array' );
                $this->assertArrayHasKey( 'reference', $resultArray, 'top level 
element has a reference key' );
@@ -134,11 +133,10 @@
                        'statement' => $statementGuid,
                        'reference' => $referenceHash,
                        'snaks' => \FormatJson::encode( 
$serializedReference['snaks'] ),
-                       'token' => $GLOBALS['wgUser']->getEditToken()
                );
 
                try {
-                       $this->doApiRequest( $params );
+                       $this->doApiRequestWithToken( $params );
                        $this->assertFalse( true, 'Invalid request should raise 
an exception' );
                }
                catch ( \UsageException $e ) {
@@ -155,11 +153,10 @@
                        'statement' => $claimGuid,
                        'snaks' => $snakHash,
                        'reference' => $refHash,
-                       'token' => $GLOBALS['wgUser']->getEditToken()
                );
 
                try {
-                       $this->doApiRequest( $params );
+                       $this->doApiRequestWithToken( $params );
                        $this->fail( "Exception with code $expectedError 
expected" );
                } catch ( \UsageException $e ) {
                        $this->assertEquals( $expectedError, 
$e->getCodeString(), 'Error code' );
diff --git a/repo/tests/phpunit/includes/api/SetStatementRankTest.php 
b/repo/tests/phpunit/includes/api/SetStatementRankTest.php
index c476d72..567c76c 100644
--- a/repo/tests/phpunit/includes/api/SetStatementRankTest.php
+++ b/repo/tests/phpunit/includes/api/SetStatementRankTest.php
@@ -42,7 +42,7 @@
  * @author Jeroen De Dauw < [email protected] >
  * @author Katie Filbert < [email protected] >
  */
-class SetStatementRankTest extends \ApiTestCase {
+class SetStatementRankTest extends ModifyEntityTestBase {
 
        /**
         * @return Snak[]
@@ -143,10 +143,9 @@
                        'action' => 'wbsetstatementrank',
                        'statement' => $statementGuid,
                        'rank' => $statementRank,
-                       'token' => $GLOBALS['wgUser']->getEditToken()
                );
 
-               list( $resultArray, ) = $this->doApiRequest( $params );
+               list( $resultArray, ) = $this->doApiRequestWithToken( $params );
 
                $this->assertInternalType( 'array', $resultArray, 'top level 
element is an array' );
                $this->assertArrayHasKey( 'pageinfo', $resultArray, 'top level 
element has a pageinfo key' );
@@ -183,11 +182,10 @@
                        'action' => 'wbsetstatementrank',
                        'statement' => $statementGuid,
                        'rank' => $statementRank,
-                       'token' => $GLOBALS['wgUser']->getEditToken()
                );
 
                try {
-                       $this->doApiRequest( $params );
+                       $this->doApiRequestWithToken( $params );
                        $this->fail( 'Invalid request should raise an 
exception' );
                }
                catch ( \Exception $e ) {
@@ -218,11 +216,10 @@
                        'action' => 'wbsetstatementrank',
                        'statement' => $claimGuid,
                        'rank' => $ranks[0],
-                       'token' => $GLOBALS['wgUser']->getEditToken()
                );
 
                try {
-                       $this->doApiRequest( $params );
+                       $this->doApiRequestWithToken( $params );
                        $this->fail( 'Invalid claim guid did not throw an 
error' );
                } catch ( \UsageException $e ) {
                        $this->assertEquals( 'invalid-guid', 
$e->getCodeString(), 'Invalid claim guid raised correct error' );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I563266b33e4dc984f77918015df5e52926c1b219
Gerrit-PatchSet: 5
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