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

Change subject: Add more EditEntity API tests for (non-) conflicting edits
......................................................................


Add more EditEntity API tests for (non-) conflicting edits

This is a follow-up to Iaafbf9b.

Bug: 103019
Change-Id: I04a8b7577ba40f432cc78a2923bff8976212b8b3
---
M repo/tests/phpunit/includes/api/EditEntityTest.php
M repo/tests/phpunit/includes/api/WikibaseApiTestCase.php
M repo/tests/phpunit/includes/store/sql/TermSqlIndexTest.php
3 files changed, 59 insertions(+), 17 deletions(-)

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



diff --git a/repo/tests/phpunit/includes/api/EditEntityTest.php 
b/repo/tests/phpunit/includes/api/EditEntityTest.php
index cf764db..826706c 100644
--- a/repo/tests/phpunit/includes/api/EditEntityTest.php
+++ b/repo/tests/phpunit/includes/api/EditEntityTest.php
@@ -538,20 +538,47 @@
                $this->doTestQueryExceptions( $params, $expected['exception'] );
        }
 
-       public function testLabelDescriptionConflict() {
-               // FIXME: MySQL doesn't support self-joins on temporary tables,
-               //        so skip this check during unit tests on MySQL!
-               //        There is a similar check to this in TermSqlIndex
-               if ( $this->db->getType() == 'mysql' ) {
-                       $this->markTestSkipped( 'MySQL doesn\'t support 
self-joins on temporary tables' );
-               }
+       public function testPropertyLabelConflict() {
+               $params = array(
+                       'action' => 'wbeditentity',
+                       'data' => '{
+                               "datatype": "string",
+                               "labels": { "de": { "language": "de", "value": 
"LabelConflict" } }
+                       }',
+                       'new' => 'property',
+               );
+               $this->doApiRequestWithToken( $params );
+
+               $expectedException = array(
+                       'type' => 'UsageException',
+                       'code' => 'failed-save',
+               );
+               // Repeating the same request with the same label should fail.
+               $this->doTestQueryExceptions( $params, $expectedException );
+       }
+
+       public function testItemLabelWithoutDescriptionNotConflicting() {
+               $params = array(
+                       'action' => 'wbeditentity',
+                       'data' => '{ "labels": { "de": { "language": "de", 
"value": "NotConflicting" } } }',
+                       'new' => 'item',
+               );
+               $this->doApiRequestWithToken( $params );
+
+               // Repeating the same request with the same label should not 
fail.
+               list( $result, , ) = $this->doApiRequestWithToken( $params );
+               $this->assertArrayHasKey( 'success', $result );
+       }
+
+       public function testItemLabelDescriptionConflict() {
+               $this->markTestSkippedOnMySql();
 
                $params = array(
                        'action' => 'wbeditentity',
                        'new' => 'item',
                        'data' => '{
-                               "labels": { "de": { "language": "de", "value": 
"LabelWithDescriptionConflict" } },
-                               "descriptions": { "de": { "language": "de", 
"value": "LabelWithDescriptionConflict" } }
+                               "labels": { "de": { "language": "de", "value": 
"LabelDescriptionConflict" } },
+                               "descriptions": { "de": { "language": "de", 
"value": "LabelDescriptionConflict" } }
                        }',
                );
                $this->doApiRequestWithToken( $params );
@@ -560,6 +587,7 @@
                        'type' => 'UsageException',
                        'code' => 'modification-failed',
                );
+               // Repeating the same request with the same label and 
description should fail.
                $this->doTestQueryExceptions( $params, $expectedException );
        }
 
@@ -588,4 +616,14 @@
                $this->doTestQueryExceptions( $params, $expectedException );
        }
 
+       /**
+        * @see http://bugs.mysql.com/bug.php?id=10327
+        * @see TermSqlIndexTest::markTestSkippedOnMySql
+        */
+       private function markTestSkippedOnMySql() {
+               if ( $this->db->getType() === 'mysql' ) {
+                       $this->markTestSkipped( 'MySQL doesn\'t support 
self-joins on temporary tables' );
+               }
+       }
+
 }
diff --git a/repo/tests/phpunit/includes/api/WikibaseApiTestCase.php 
b/repo/tests/phpunit/includes/api/WikibaseApiTestCase.php
index 3b0477e..25f6ef3 100644
--- a/repo/tests/phpunit/includes/api/WikibaseApiTestCase.php
+++ b/repo/tests/phpunit/includes/api/WikibaseApiTestCase.php
@@ -78,7 +78,7 @@
         * @param array|null $session
         * @param User|null $user
         *
-        * @return array
+        * @return array( $resultData, $request, $sessionArray )
         */
        protected function doApiRequestWithToken( array $params, array $session 
= null, User $user = null ) {
                if ( !$user ) {
diff --git a/repo/tests/phpunit/includes/store/sql/TermSqlIndexTest.php 
b/repo/tests/phpunit/includes/store/sql/TermSqlIndexTest.php
index 9945d6d..723a2ec 100644
--- a/repo/tests/phpunit/includes/store/sql/TermSqlIndexTest.php
+++ b/repo/tests/phpunit/includes/store/sql/TermSqlIndexTest.php
@@ -89,13 +89,7 @@
         * @dataProvider labelWithDescriptionConflictProvider
         */
        public function testGetLabelWithDescriptionConflicts( $entities, 
$entityType, $labels, $descriptions, $expected ) {
-
-               if ( wfGetDB( DB_MASTER )->getType() === 'mysql' ) {
-                       // Mysql fails 
(http://bugs.mysql.com/bug.php?id=10327), so we cannot test this properly when 
using MySQL.
-                       $this->markTestSkipped( 'Can\'t test self-joins on 
MySQL' );
-
-                       return;
-               }
+               $this->markTestSkippedOnMySql();
 
                parent::testGetLabelWithDescriptionConflicts( $entities, 
$entityType, $labels, $descriptions, $expected );
        }
@@ -269,4 +263,14 @@
                );
        }
 
+       /**
+        * @see http://bugs.mysql.com/bug.php?id=10327
+        * @see EditEntityTest::markTestSkippedOnMySql
+        */
+       private function markTestSkippedOnMySql() {
+               if ( $this->db->getType() === 'mysql' ) {
+                       $this->markTestSkipped( 'MySQL doesn\'t support 
self-joins on temporary tables' );
+               }
+       }
+
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I04a8b7577ba40f432cc78a2923bff8976212b8b3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de>
Gerrit-Reviewer: Addshore <addshorew...@gmail.com>
Gerrit-Reviewer: Aude <aude.w...@gmail.com>
Gerrit-Reviewer: Bene <benestar.wikime...@gmail.com>
Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to