Addshore has uploaded a new change for review.
https://gerrit.wikimedia.org/r/232918
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(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/18/232918/1
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..19e6a6a
--- /dev/null
+++ b/repo/tests/phpunit/data/api/setaliases-removed.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<api success="1">
+ <entity id="Q6" 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..08a6879
--- /dev/null
+++ b/repo/tests/phpunit/data/api/setdescription-removed.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<api success="1">
+ <entity id="Q5" 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..7d494cd
--- /dev/null
+++ b/repo/tests/phpunit/data/api/setlabel-removed.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<api success="1">
+ <entity id="Q5" 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..801eacc
--- /dev/null
+++ b/repo/tests/phpunit/data/api/setsitelink-removed.xml
@@ -0,0 +1,9 @@
+<api success="1">
+ <entity id="Q7" 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..8b64b5f 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\SetDescription', 'wbsetdescription', $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: newchange
Gerrit-Change-Id: Icabe3b826f8546f73a5a334c05b5d0175b1f822a
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