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

Change subject: Refactor LangAttribute Api Test Cases
......................................................................


Refactor LangAttribute Api Test Cases

Bug: 51681
Change-Id: I5f23647d964beae9d3fdeb5a9b090ababe4e3e1c
---
M repo/Wikibase.classes.php
M repo/tests/phpunit/includes/api/ItemByTitleHelperTest.php
D repo/tests/phpunit/includes/api/LangAttributeBase.php
A repo/tests/phpunit/includes/api/LangAttributeTestCase.php
A repo/tests/phpunit/includes/api/LangAttributeTestHelper.php
M repo/tests/phpunit/includes/api/SetAliasesTest.php
M repo/tests/phpunit/includes/api/SetDescriptionTest.php
M repo/tests/phpunit/includes/api/SetLabelTest.php
8 files changed, 298 insertions(+), 191 deletions(-)

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



diff --git a/repo/Wikibase.classes.php b/repo/Wikibase.classes.php
index 66711e2..272a82a 100644
--- a/repo/Wikibase.classes.php
+++ b/repo/Wikibase.classes.php
@@ -171,8 +171,9 @@
                'Wikibase\Test\TestItemContents' => 
'tests/phpunit/TestItemContents.php',
                'Wikibase\Test\ActionTestCase' => 
'tests/phpunit/includes/actions/ActionTestCase.php',
                'Wikibase\Test\Api\WikibaseApiTestCase' => 
'tests/phpunit/includes/api/WikibaseApiTestCase.php',
+               'Wikibase\Test\Api\LangAttributeTestCase' => 
'tests/phpunit/includes/api/LangAttributeTestCase.php',
+               'Wikibase\Test\Api\LangAttributeTestHelper' => 
'tests/phpunit/includes/api/LangAttributeTestHelper.php',
                'Wikibase\Test\Api\EntityTestHelper' => 
'tests/phpunit/includes/api/EntityTestHelper.php',
-               'Wikibase\Test\Api\LangAttributeBase' => 
'tests/phpunit/includes/api/LangAttributeBase.php',
                'Wikibase\Test\EntityContentTest' => 
'tests/phpunit/includes/content/EntityContentTest.php',
                'Wikibase\Test\EntityHandlerTest' => 
'tests/phpunit/includes/content/EntityHandlerTest.php',
                'Wikibase\Test\RdfBuilderTest' => 
'tests/phpunit/includes/rdf/RdfBuilderTest.php',
diff --git a/repo/tests/phpunit/includes/api/ItemByTitleHelperTest.php 
b/repo/tests/phpunit/includes/api/ItemByTitleHelperTest.php
index 1b2f6d8..1880be8 100644
--- a/repo/tests/phpunit/includes/api/ItemByTitleHelperTest.php
+++ b/repo/tests/phpunit/includes/api/ItemByTitleHelperTest.php
@@ -126,7 +126,7 @@
         */
        public function testGetEntityIdNormalized() {
                $itemByTitleHelper = new ItemByTitleHelper(
-                       // Two values should be added: The normalization and 
the failure to find an entity
+               // Two values should be added: The normalization and the 
failure to find an entity
                        $this->getApiBaseMock( 2 ),
                        $this->getSiteLinkCacheMock( false ),
                        $this->getSiteStoreMock(),
@@ -148,7 +148,7 @@
         */
        public function testGetEntityIdsNotFound() {
                $itemByTitleHelper = new ItemByTitleHelper(
-                       // Two result values should be added (for both titles 
which wont be found)
+               // Two result values should be added (for both titles which 
wont be found)
                        $this->getApiBaseMock( 2 ),
                        $this->getSiteLinkCacheMock( false ),
                        $this->getSiteStoreMock(),
diff --git a/repo/tests/phpunit/includes/api/LangAttributeBase.php 
b/repo/tests/phpunit/includes/api/LangAttributeBase.php
deleted file mode 100644
index 6c1ac48..0000000
--- a/repo/tests/phpunit/includes/api/LangAttributeBase.php
+++ /dev/null
@@ -1,137 +0,0 @@
-<?php
-
-namespace Wikibase\Test\Api;
-
-/**
- * Tests for the ApiWikibaseSetAliases API module.
- *
- * The tests are using "Database" to get its own set of temporal tables.
- * This is nice so we avoid poisoning an existing database.
- *
- * The tests are using "medium" so they are able to run alittle longer before 
they are killed.
- * Without this they will be killed after 1 second, but the setup of the 
tables takes so long
- * time that the first few tests get killed.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- * @since 0.1
- *
- * @ingroup WikibaseRepoTest
- * @ingroup Test
- *
- * The database group has as a side effect that temporal database tables are 
created. This makes
- * it possible to test without poisoning a production database.
- * @group Database
- *
- * Some of the tests takes more time, and needs therefor longer time before 
they can be aborted
- * as non-functional. The reason why tests are aborted is assumed to be set up 
of temporal databases
- * that hold the first tests in a pending state awaiting access to the 
database.
- * @group medium
- *
- * @group API
- * @group Wikibase
- * @group WikibaseAPI
- * @group LanguageAttributeTest
- * @group BreakingTheSlownessBarrier
- *
- * @licence GNU GPL v2+
- * @author John Erling Blad < [email protected] >
- * @author Daniel Kinzler
- */
-abstract class LangAttributeBase extends WikibaseApiTestCase {
-
-       public static function makeOverlyLongString( $text = "Test", $length = 
null ) {
-               if ( $length === null ) {
-                       $limits = \Wikibase\Settings::get( 'multilang-limits' );
-                       $length = $limits['length'];
-               }
-
-               $rep = $length / strlen( $text ) + 1;
-               $s = str_repeat( $text, $rep );
-
-               return $s;
-       }
-
-       /**
-        * @dataProvider paramProvider
-        */
-       public function doLanguageAttribute( $handle, $action, $attr, 
$langCode, $value, $exception = null ) {
-               $id = EntityTestHelper::getId( $handle );
-
-               // update the item 
----------------------------------------------------------------
-               $req = array(
-                       'id' => $id,
-                       'action' => $action,
-                       'language' => $langCode,
-                       'value' => $value
-               );
-
-               try {
-                       list( $apiResponse,, ) = $this->doApiRequestWithToken( 
$req, null, self::$users['wbeditor']->user );
-
-                       if ( $exception ) {
-                               $this->fail( "expected exception $exception" );
-                       }
-               }
-               catch ( \Exception $e ) {
-                       if ( $exception !== null && ! $e instanceof 
\PHPUnit_Framework_Exception ) {
-                               $this->assertTrue( is_a( $e, $exception ), "Not 
the expected exception" );
-                               return;
-                       }
-                       else {
-                               throw $e;
-                       }
-               }
-
-               $this->assertResultSuccess( $apiResponse );
-
-               $item = $apiResponse['entity'];
-               $section = "{$attr}s";
-               $record = null;
-
-               foreach ( $item[$section] as $rec ) {
-                       if ( $rec['language'] == $langCode ) {
-                               $record = $rec;
-                               break;
-                       }
-               }
-
-               $this->assertNotNull( $record, "no $attr entry found for 
$langCode" );
-
-               if ( $value === '' ) {
-                       $this->assertArrayHasKey( 'removed', $record );
-               } else {
-                       $this->assertEquals( $value, $record['value'] );
-               }
-
-               // check item in the database 
----------------------------------------------------------------
-               $item = $this->loadEntity( $id );
-               $values = self::flattenArray( $item[$section], 'language', 
'value' );
-
-               if ( $value !== '' ) {
-                       $this->assertArrayHasKey( $langCode, $values, "should 
be present" );
-                       $this->assertEquals( $value, $values[$langCode], 
"should have been updated" );
-               } else {
-                       $this->assertArrayNotHasKey( $langCode, $values, 
"should have been removed" );
-               }
-
-               $this->assertRevisionSummary(
-                       array( $action, "1", $langCode, "*/", $value ),
-                       $apiResponse['entity']['lastrevid'] );
-       }
-
-}
diff --git a/repo/tests/phpunit/includes/api/LangAttributeTestCase.php 
b/repo/tests/phpunit/includes/api/LangAttributeTestCase.php
new file mode 100644
index 0000000..1f0e849
--- /dev/null
+++ b/repo/tests/phpunit/includes/api/LangAttributeTestCase.php
@@ -0,0 +1,227 @@
+<?php
+
+namespace Wikibase\Test\Api;
+
+/**
+ * Test case for language attributes API modules.
+ *
+ * The tests are using "Database" to get its own set of temporal tables.
+ * This is nice so we avoid poisoning an existing database.
+ *
+ * The tests are using "medium" so they are able to run alittle longer before 
they are killed.
+ * Without this they will be killed after 1 second, but the setup of the 
tables takes so long
+ * time that the first few tests get killed.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @since 0.1
+ *
+ * @ingroup WikibaseRepoTest
+ * @ingroup Test
+ *
+ * The database group has as a side effect that temporal database tables are 
created. This makes
+ * it possible to test without poisoning a production database.
+ * @group Database
+ *
+ * Some of the tests takes more time, and needs therefor longer time before 
they can be aborted
+ * as non-functional. The reason why tests are aborted is assumed to be set up 
of temporal databases
+ * that hold the first tests in a pending state awaiting access to the 
database.
+ * @group medium
+ *
+ * @group API
+ * @group Wikibase
+ * @group WikibaseAPI
+ * @group LanguageAttributeTest
+ * @group BreakingTheSlownessBarrier
+ *
+ * @licence GNU GPL v2+
+ * @author Adam Shorland
+ */
+class LangAttributeTestCase extends WikibaseApiTestCase {
+
+       protected static $testAction;
+       protected static $testId;
+       private static $hasSetup;
+
+       public function setUp() {
+               parent::setUp();
+
+               if( !isset( self::$hasSetup ) ){
+                       $this->initTestEntities( array( 'Empty') );
+               }
+               self::$hasSetup = true;
+       }
+
+       public static function provideData() {
+               return array(
+                       // p => params, e => expected
+
+                       // -- Test valid sequence -----------------------------
+                       array( //0
+                               'p' => array( 'language' => 'en', 'value' => '' 
),
+                               'e' => array( 'warning' => 'edit-no-change' ) ),
+                       array( //1
+                               'p' => array( 'language' => 'en', 'value' => 
'Value' ),
+                               'e' => array( 'value' => array( 'en' => 'Value' 
) ) ),
+                       array( //2
+                               'p' => array( 'language' => 'en', 'value' => 
'Value' ),
+                               'e' => array( 'value' => array( 'en' => 'Value' 
), 'warning' => 'edit-no-change' ) ),
+                       array( //3
+                               'p' => array( 'language' => 'en', 'value' => 
'Another Value', 'summary' => 'Test summary!' ),
+                               'e' => array( 'value' => array( 'en' => 
'Another Value' ) ) ),
+                       array( //4
+                               'p' => array( 'language' => 'en', 'value' => 
'Different Value' ),
+                               'e' => array( 'value' => array( 'en' => 
'Different Value' ) ) ),
+                       array( //5
+                               'p' => array( 'language' => 'bat-smg', 'value' 
=> 'V?sata' ),
+                               'e' => array( 'value' => array( 'bat-smg' => 
'V?sata','en' => 'Different Value' ) ) ),
+                       array( //6
+                               'p' => array( 'language' => 'en', 'value' => '' 
),
+                               'e' => array( 'value' => array( 'bat-smg' => 
'V?sata' ) ) ),
+                       array( //7
+                               'p' => array( 'language' => 'bat-smg', 'value' 
=> '' ),
+                               'e' => array( ) ),
+               );
+       }
+       
+       public function doTestSetLangAttribute( $attribute ,$params, $expected 
){
+               // -- set any defaults ------------------------------------
+               $params['action'] = self::$testAction;
+               if( !array_key_exists( 'id', $params ) ){
+                       $params['id'] = EntityTestHelper::getId( 'Empty' );
+               }
+               if( !array_key_exists( 'value', $expected ) ){
+                       $expected['value'] = array();
+               }
+
+               // -- do the request 
--------------------------------------------------
+               list( $result,, ) = $this->doApiRequestWithToken( $params );
+
+               // -- check the result 
------------------------------------------------
+               $this->assertArrayHasKey( 'success', $result, "Missing 
'success' marker in response." );
+               $this->assertResultHasEntityType( $result );
+               $this->assertArrayHasKey( 'entity', $result, "Missing 'entity' 
section in response." );
+
+               // -- check the result only has our changed data (if any)  
------------
+               $this->assertEquals( 1, count( $result['entity'][$attribute] ), 
"Entity return contained more than a single language" );
+               $this->assertArrayHasKey( $params['language'], 
$result['entity'][$attribute], "Entity doesn't return expected language");
+               $this->assertEquals( $params['language'], 
$result['entity'][$attribute][ $params['language'] ]['language'], "Returned 
incorrect language" );
+               if( array_key_exists( $params['language'], $expected['value'] ) 
){
+                       $this->assertEquals( $expected['value'][ 
$params['language'] ], 
$result['entity'][$attribute][$params['language']]['value'] , "Returned 
incorrect label" );
+               } else if( empty( $value ) ){
+                       $this->assertArrayHasKey( 'removed', 
$result['entity'][$attribute][ $params['language'] ], "Entity doesn't return 
expected 'removed' marker");
+               }
+
+               // -- check any warnings 
----------------------------------------------
+               if( array_key_exists( 'warning', $expected ) ){
+                       $this->assertArrayHasKey( 'warnings', $result, "Missing 
'warnings' section in response." );
+                       $this->assertEquals( $expected['warning'], 
$result['warnings']['messages']['0']['name']);
+                       $this->assertArrayHasKey( 'html', 
$result['warnings']['messages'] );
+               }
+
+               // -- check item in database 
-------------------------------------------
+               $dbEntity = $this->loadEntity( EntityTestHelper::getId( 'Empty' 
) );
+               if( count( $expected['value'] ) ){
+                       $this->assertArrayHasKey( $attribute, $dbEntity );
+                       $dbLabels = self::flattenArray( $dbEntity[$attribute], 
'language', 'value', true );
+                       foreach( $expected['value'] as $valueLanguage => $value 
){
+                               $this->assertArrayHasKey( $valueLanguage, 
$dbLabels );
+                               $this->assertEquals( $value, 
$dbLabels[$valueLanguage][0] );
+                       }
+               } else {
+                       $this->assertArrayNotHasKey( $attribute, $dbEntity );
+               }
+
+               // -- check the edit summary 
--------------------------------------------
+               if( !array_key_exists( 'warning', $expected ) || 
$expected['warning'] != 'edit-no-change' ){
+                       $this->assertRevisionSummary( array( self::$testAction, 
$params['language'] ), $result['entity']['lastrevid'] );
+                       if( array_key_exists( 'summary', $params) ){
+                               $this->assertRevisionSummary( 
"/{$params['summary']}/" , $result['entity']['lastrevid'] );
+                       }
+               }
+       }
+
+       public static function provideExceptionData() {
+               return array(
+                       // p => params, e => expected
+
+                       // -- Test Exceptions -----------------------------
+                       array( //0
+                               'p' => array( 'language' => '', 'value' => '' ),
+                               'e' => array( 'exception' => array( 'type' => 
'UsageException', 'code' => 'unknown_language' ) ) ),
+                       array( //1
+                               'p' => array( 'language' => 'nl', 'value' => 
LangAttributeTestHelper::makeOverlyLongString() ),
+                               'e' => array( 'exception' => array( 'type' => 
'UsageException', 'code' => 'failed-save' ) ) ),
+                       array( //2
+                               'p' => array( 'language' => 'pt', 'value' => 
'normalValue' ),
+                               'e' => array( 'exception' => array( 'type' => 
'UsageException', 'code' => 'badtoken', 'message' => 'loss of session data' ) ) 
),
+                       array( //3
+                               'p' => array( 'id' => 'noANid', 'language' => 
'fr', 'value' => 'normalValue' ),
+                               'e' => array( 'exception' => array( 'type' => 
'UsageException', 'code' => 'no-such-entity-id', 'message' => 'No entity found' 
) ) ),
+                       array( //4
+                               'p' => array( 'site' => 'qwerty', 'language' => 
'pl', 'value' => 'normalValue' ),
+                               'e' => array( 'exception' => array( 'type' => 
'UsageException', 'code' => 'unknown_site', 'message' => "Unrecognized value 
for parameter 'site'" ) ) ),
+                       array( //5
+                               'p' => array( 'site' => 'enwiki', 'title' => 
'GhskiDYiu2nUd', 'language' => 'en', 'value' => 'normalValue' ),
+                               'e' => array( 'exception' => array( 'type' => 
'UsageException', 'code' => 'no-such-entity-link', 'message' => 'No entity 
found matching site link' ) ) ),
+                       array( //6
+                               'p' => array( 'title' => 'Blub', 'language' => 
'en', 'value' => 'normalValue' ),
+                               'e' => array( 'exception' => array( 'type' => 
'UsageException', 'code' => 'param-illegal', 'message' => 'Either provide the 
item "id" or pairs' ) ) ),
+                       array( //7
+                               'p' => array( 'site' => 'enwiki', 'language' => 
'en', 'value' => 'normalValue' ),
+                               'e' => array( 'exception' => array( 'type' => 
'UsageException', 'code' => 'param-illegal', 'message' => 'Either provide the 
item "id" or pairs' ) ) ),
+               );
+       }
+
+       public function doTestSetLangAttributeExceptions( $params, $expected ){
+
+               // -- set any defaults ------------------------------------
+               $params['action'] = self::$testAction;
+               if( !array_key_exists( 'id', $params )  && !array_key_exists( 
'site', $params ) && !array_key_exists( 'title', $params ) ){
+                       $params['id'] = EntityTestHelper::getId( 'Empty' );
+               }
+
+               // -- catch and check expected exceptions ---------------------
+               try{
+                       if( $expected['exception']['code'] == 'badtoken' ){
+                               if ( !self::$usetoken ) {
+                                       $this->markTestSkipped( "tokens 
disabled" );
+                               }
+                               $this->doApiRequest( $params );
+                       } else {
+                               $this->doApiRequestWithToken( $params );
+                       }
+                       $this->fail( "Failed to throw exception, 
{$expected['exception']['type']} " );
+
+               } catch( \Exception $exception ){
+
+                       /** @var $exception \UsageException */ // trick IDEs 
into not showing errors
+                       if( array_key_exists( 'type', $expected['exception'] ) 
){
+                               $this->assertInstanceOf( 
$expected['exception']['type'], $exception );
+                       }
+
+                       if( array_key_exists( 'code', $expected['exception'] ) 
){
+                               $this->assertEquals( 
$expected['exception']['code'], $exception->getCodeString() );
+                       }
+
+                       if( array_key_exists( 'message', $expected['exception'] 
) ){
+                               $this->assertContains( 
$expected['exception']['message'], $exception->getMessage() );
+                       }
+               }
+       }
+
+}
diff --git a/repo/tests/phpunit/includes/api/LangAttributeTestHelper.php 
b/repo/tests/phpunit/includes/api/LangAttributeTestHelper.php
new file mode 100644
index 0000000..05cb085
--- /dev/null
+++ b/repo/tests/phpunit/includes/api/LangAttributeTestHelper.php
@@ -0,0 +1,42 @@
+<?php
+
+namespace Wikibase\Test\Api;
+
+/**
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @since 0.1
+ *
+ * @licence GNU GPL v2+
+ * @author John Erling Blad < [email protected] >
+ * @author Daniel Kinzler
+ */
+class LangAttributeTestHelper {
+
+       public static function makeOverlyLongString( $text = "Test", $length = 
null ) {
+               if ( $length === null ) {
+                       $limits = \Wikibase\Settings::get( 'multilang-limits' );
+                       $length = $limits['length'];
+               }
+
+               $rep = $length / strlen( $text ) + 1;
+               $s = str_repeat( $text, $rep );
+
+               return $s;
+       }
+
+}
diff --git a/repo/tests/phpunit/includes/api/SetAliasesTest.php 
b/repo/tests/phpunit/includes/api/SetAliasesTest.php
index 159d959..aec5450 100644
--- a/repo/tests/phpunit/includes/api/SetAliasesTest.php
+++ b/repo/tests/phpunit/includes/api/SetAliasesTest.php
@@ -137,7 +137,7 @@
                $id = EntityTestHelper::getId( $handle );
                $langCode = 'en';
                $op = 'add';
-               $value = LangAttributeBase::makeOverlyLongString();
+               $value = LangAttributeTestHelper::makeOverlyLongString();
                $exception = 'UsageException';
 
                // update the item 
----------------------------------------------------------------
diff --git a/repo/tests/phpunit/includes/api/SetDescriptionTest.php 
b/repo/tests/phpunit/includes/api/SetDescriptionTest.php
index 2c5f102..855e725 100644
--- a/repo/tests/phpunit/includes/api/SetDescriptionTest.php
+++ b/repo/tests/phpunit/includes/api/SetDescriptionTest.php
@@ -50,39 +50,26 @@
  * @group BreakingTheSlownessBarrier
  *
  * @licence GNU GPL v2+
- * @author John Erling Blad < [email protected] >
- * @author Daniel Kinzler
+ * @author Adam Shorland
  */
-class SetDescriptionTest extends LangAttributeBase {
-
-       private static $hasSetup;
+class SetDescriptionTest extends LangAttributeTestCase {
 
        public function setUp() {
+               self::$testAction = 'wbsetdescription';
                parent::setUp();
-
-               if( !isset( self::$hasSetup ) ){
-                       $this->initTestEntities( array( 'Oslo' ) );
-               }
-               self::$hasSetup = true;
-       }
-
-       public function paramProvider() {
-               return array(
-                       // $handle, $langCode, $value, $exception
-                       array( 'Oslo', 'en', 'Back to capitol of Norway', null 
),
-                       //array( 'Oslo', 'en', 'Capitol of Norway', 
'UsageException' ),
-                       //array( 'Oslo', 'en', 'Not capitol of Norway', null ),
-                       array( 'Oslo', 'en', '', null ),
-                       array( 'Oslo', 'en', self::makeOverlyLongString( 'Oslo' 
), 'UsageException' ),
-               );
        }
 
        /**
-        * @dataProvider paramProvider
+        * @dataProvider provideData
         */
-       public function testLanguageAttribute( $handle, $langCode, $value, 
$exception = null ) {
-               $this->doLanguageAttribute( $handle, 'wbsetdescription', 
'description', $langCode, $value, $exception );
-               $id = EntityTestHelper::getId( $handle );
+       public function testSetLabel( $params, $expected ){
+               self::doTestSetLangAttribute( 'descriptions' ,$params, 
$expected );
        }
 
+       /**
+        * @dataProvider provideExceptionData
+        */
+       public function testSetLabelExceptions( $params, $expected ){
+               self::doTestSetLangAttributeExceptions( $params, $expected );
+       }
 }
diff --git a/repo/tests/phpunit/includes/api/SetLabelTest.php 
b/repo/tests/phpunit/includes/api/SetLabelTest.php
index 6ce3033..d18488a 100644
--- a/repo/tests/phpunit/includes/api/SetLabelTest.php
+++ b/repo/tests/phpunit/includes/api/SetLabelTest.php
@@ -50,39 +50,26 @@
  * @group BreakingTheSlownessBarrier
  *
  * @licence GNU GPL v2+
- * @author John Erling Blad < [email protected] >
- * @author Daniel Kinzler
+ * @author Adam Shorland
  */
-class SetLabelTest extends LangAttributeBase {
-
-       private static $hasSetup;
+class SetLabelTest extends LangAttributeTestCase {
 
        public function setUp() {
+               self::$testAction = 'wbsetlabel';
                parent::setUp();
-
-               if( !isset( self::$hasSetup ) ){
-                       $this->initTestEntities( array( 'Oslo' ) );
-               }
-               self::$hasSetup = true;
-       }
-
-       public static function paramProvider() {
-               return array(
-                       // $handle, $langCode, $value, $exception
-                       array( 'Oslo', 'en', 'Osloooo', null ),
-                       //array( 'Oslo', 'en', 'Oslo', 'UsageException' ),
-                       //array( 'Oslo', 'en', 'Bergen', null ),
-                       array( 'Oslo', 'en', '', null ),
-                       array( 'Oslo', 'en', self::makeOverlyLongString( 'Oslo' 
), 'UsageException' ),
-               );
        }
 
        /**
-        * @dataProvider paramProvider
+        * @dataProvider provideData
         */
-       public function testLanguageAttribute( $handle, $langCode, $value, 
$exception = null ) {
-               $this->doLanguageAttribute( $handle, 'wbsetlabel', 'label', 
$langCode, $value, $exception );
-               $id = EntityTestHelper::getId( $handle );
+       public function testSetLabel( $params, $expected ){
+               self::doTestSetLangAttribute( 'labels' ,$params, $expected );
        }
 
+       /**
+        * @dataProvider provideExceptionData
+        */
+       public function testSetLabelExceptions( $params, $expected ){
+               self::doTestSetLangAttributeExceptions( $params, $expected );
+       }
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I5f23647d964beae9d3fdeb5a9b090ababe4e3e1c
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Daniel Werner <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: Jeroen De Dauw <[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