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

Change subject: Add tests for term&label API removals in XML
......................................................................


Add tests for term&label API removals in XML

Change-Id: Icabe3b826f8546f73a5a334c05b5d0175b1f822a
---
A repo/tests/phpunit/data/api/setaliases-removed.xml
A repo/tests/phpunit/data/api/setdescription-removed.xml
A repo/tests/phpunit/data/api/setlabel-removed.xml
A repo/tests/phpunit/data/api/setsitelink-removed.xml
M repo/tests/phpunit/includes/api/ApiXmlFormatTest.php
5 files changed, 90 insertions(+), 3 deletions(-)

Approvals:
  Thiemo Mättig (WMDE): Looks good to me, approved
  Addshore: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/repo/tests/phpunit/data/api/setaliases-removed.xml 
b/repo/tests/phpunit/data/api/setaliases-removed.xml
new file mode 100644
index 0000000..c13b853
--- /dev/null
+++ b/repo/tests/phpunit/data/api/setaliases-removed.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<api success="1">
+       <entity id="$itemIdUnderTest" type="item">
+               <aliases>
+                       <alias language="en-gb" value="AA"/>
+               </aliases>
+       </entity>
+</api>
\ No newline at end of file
diff --git a/repo/tests/phpunit/data/api/setdescription-removed.xml 
b/repo/tests/phpunit/data/api/setdescription-removed.xml
new file mode 100644
index 0000000..e1b2af9
--- /dev/null
+++ b/repo/tests/phpunit/data/api/setdescription-removed.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<api success="1">
+       <entity id="$itemIdUnderTest" type="item">
+               <descriptions>
+                       <description language="en-gb" removed=""/>
+               </descriptions>
+       </entity>
+</api>
\ No newline at end of file
diff --git a/repo/tests/phpunit/data/api/setlabel-removed.xml 
b/repo/tests/phpunit/data/api/setlabel-removed.xml
new file mode 100644
index 0000000..3c93bfa
--- /dev/null
+++ b/repo/tests/phpunit/data/api/setlabel-removed.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<api success="1">
+       <entity id="$itemIdUnderTest" type="item">
+               <labels>
+                       <label language="en-gb" removed=""/>
+               </labels>
+       </entity>
+</api>
\ No newline at end of file
diff --git a/repo/tests/phpunit/data/api/setsitelink-removed.xml 
b/repo/tests/phpunit/data/api/setsitelink-removed.xml
new file mode 100644
index 0000000..159ebc3
--- /dev/null
+++ b/repo/tests/phpunit/data/api/setsitelink-removed.xml
@@ -0,0 +1,9 @@
+<api success="1">
+       <entity id="$itemIdUnderTest" type="item">
+               <sitelinks>
+                       <sitelink site="enwiki" title="Japan" removed="">
+                               <badges/>
+                       </sitelink>
+               </sitelinks>
+       </entity>
+</api>
\ No newline at end of file
diff --git a/repo/tests/phpunit/includes/api/ApiXmlFormatTest.php 
b/repo/tests/phpunit/includes/api/ApiXmlFormatTest.php
index f07157f..c325063 100644
--- a/repo/tests/phpunit/includes/api/ApiXmlFormatTest.php
+++ b/repo/tests/phpunit/includes/api/ApiXmlFormatTest.php
@@ -86,6 +86,19 @@
                $actual = $this->removePageInfoAttributes( $result, $entityId );
 
                $this->assertXmlStringEqualsXmlString( $this->getExpectedXml( 
'setlabel' ), $actual );
+
+               $params = array(
+                       'action' => 'wbsetlabel',
+                       'id' => $entityId,
+                       'language' => 'en-gb',
+                       'value' => '',
+               );
+
+               $module = $this->getApiModule( '\Wikibase\Repo\Api\SetLabel', 
'wbsetlabel', $params, true );
+               $result = $this->executeApiModule( $module );
+               $actual = $this->removePageInfoAttributes( $result, $entityId );
+
+               $this->assertXmlStringEqualsXmlString( $this->getExpectedXml( 
'setlabel-removed' ), $actual );
        }
 
        public function testSetDescriptionXmlFormat() {
@@ -104,6 +117,19 @@
                $actual = $this->removePageInfoAttributes( $result, $entityId );
 
                $this->assertXmlStringEqualsXmlString( $this->getExpectedXml( 
'setdescription' ), $actual );
+
+               $params = array(
+                       'action' => 'wbsetdescription',
+                       'id' => $entityId,
+                       'language' => 'en-gb',
+                       'value' => '',
+               );
+
+               $module = $this->getApiModule( 
'\Wikibase\Repo\Api\SetDescription', 'wbsetdescription', $params, true );
+               $result = $this->executeApiModule( $module );
+               $actual = $this->removePageInfoAttributes( $result, $entityId );
+
+               $this->assertXmlStringEqualsXmlString( $this->getExpectedXml( 
'setdescription-removed' ), $actual );
        }
 
        public function testSetAliasesXmlFormat() {
@@ -122,6 +148,19 @@
                $actual = $this->removePageInfoAttributes( $result, $entityId );
 
                $this->assertXmlStringEqualsXmlString( $this->getExpectedXml( 
'setaliases' ), $actual );
+
+               $params = array(
+                       'action' => 'wbsetaliases',
+                       'id' => $entityId,
+                       'language' => 'en-gb',
+                       'remove' => 'BB|CC',
+               );
+
+               $module = $this->getApiModule( '\Wikibase\Repo\Api\SetAliases', 
'wbsetaliases', $params, true );
+               $result = $this->executeApiModule( $module );
+               $actual = $this->removePageInfoAttributes( $result, $entityId );
+
+               $this->assertXmlStringEqualsXmlString( $this->getExpectedXml( 
'setaliases-removed' ), $actual );
        }
 
        public function testSetSitelinkXmlFormat() {
@@ -133,19 +172,34 @@
                        'id' => $entityId,
                        'linksite' => 'enwiki',
                        'linktitle' => 'Japan',
-                       //TODO test basges in output
+                       //TODO test badges in output
                );
 
                /** @var SetSiteLink $module */
                $module = $this->getApiModule( 
'\Wikibase\Repo\Api\SetSiteLink', 'wbsetsitelink', $params, true );
-               $siteTaregtProvider = new SiteLinkTargetProvider( 
MockSiteStore::newFromTestSites(), array() );
-               $module->setServices( $siteTaregtProvider );
+               $siteTargetProvider = new SiteLinkTargetProvider( 
MockSiteStore::newFromTestSites(), array() );
+               $module->setServices( $siteTargetProvider );
                $result = $this->executeApiModule( $module );
                $actual = $this->removePageInfoAttributes( $result, $entityId );
                //If a URL has been added just remove it as it is not always 
present
                $actual = str_replace( 
'url="https://en.wikipedia.org/wiki/Japan";', '', $actual );
 
                $this->assertXmlStringEqualsXmlString( $this->getExpectedXml( 
'setsitelink' ), $actual );
+
+               $params = array(
+                       'action' => 'wbsetsitelink',
+                       'id' => $entityId,
+                       'linksite' => 'enwiki',
+                       //TODO test badges in output
+               );
+
+               /** @var SetSiteLink $module */
+               $module = $this->getApiModule( 
'\Wikibase\Repo\Api\SetSiteLink', 'wbsetsitelink', $params, true );
+               $module->setServices( $siteTargetProvider );
+               $result = $this->executeApiModule( $module );
+               $actual = $this->removePageInfoAttributes( $result, $entityId );
+
+               $this->assertXmlStringEqualsXmlString( $this->getExpectedXml( 
'setsitelink-removed' ), $actual );
        }
 
        public function testSetClaimXmlFormat() {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Icabe3b826f8546f73a5a334c05b5d0175b1f822a
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: JanZerebecki <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to