jenkins-bot has submitted this change and it was merged.
Change subject: Throw ChangeOpException on error in ChangeOps
......................................................................
Throw ChangeOpException on error in ChangeOps
Change-Id: I341cd81a63627416279e409de2c705d7b9749dda
---
M repo/Wikibase.classes.php
M repo/includes/api/CreateClaim.php
M repo/includes/api/EditEntity.php
M repo/includes/api/ModifyClaim.php
M repo/includes/api/RemoveClaims.php
M repo/includes/api/RemoveQualifiers.php
M repo/includes/api/SetClaimValue.php
M repo/includes/api/SetQualifier.php
M repo/includes/changeop/ChangeOp.php
M repo/includes/changeop/ChangeOpAliases.php
A repo/includes/changeop/ChangeOpException.php
M repo/includes/changeop/ChangeOpMainSnak.php
M repo/includes/changeop/ChangeOpQualifier.php
M repo/includes/changeop/ChangeOpSiteLink.php
M repo/includes/changeop/ChangeOps.php
M repo/tests/phpunit/includes/changeop/ChangeOpAliasesTest.php
M repo/tests/phpunit/includes/changeop/ChangeOpMainSnakTest.php
M repo/tests/phpunit/includes/changeop/ChangeOpsTest.php
18 files changed, 218 insertions(+), 53 deletions(-)
Approvals:
Addshore: Looks good to me, approved
jenkins-bot: Verified
diff --git a/repo/Wikibase.classes.php b/repo/Wikibase.classes.php
index f4f4db3..36b6968 100644
--- a/repo/Wikibase.classes.php
+++ b/repo/Wikibase.classes.php
@@ -59,6 +59,7 @@
'Wikibase\ChangeOpSiteLink' =>
'includes/changeop/ChangeOpSiteLink.php',
'Wikibase\ChangeOpMainSnak' =>
'includes/changeop/ChangeOpMainSnak.php',
'Wikibase\ChangeOpQualifier' =>
'includes/changeop/ChangeOpQualifier.php',
+ 'Wikibase\ChangeOpException' =>
'includes/changeop/ChangeOpException.php',
// includes/actions
'Wikibase\HistoryEntityAction' =>
'includes/actions/HistoryEntityAction.php',
diff --git a/repo/includes/api/CreateClaim.php
b/repo/includes/api/CreateClaim.php
index d95bc2f..901fd32 100644
--- a/repo/includes/api/CreateClaim.php
+++ b/repo/includes/api/CreateClaim.php
@@ -2,13 +2,12 @@
namespace Wikibase\Api;
-use ApiBase, MWException;
-use ApiMain;
+use ApiBase;
use Wikibase\EntityId;
use Wikibase\Repo\WikibaseRepo;
use Wikibase\Claims;
use Wikibase\ChangeOpMainSnak;
-use ValueParsers\ParseException;
+use Wikibase\ChangeOpException;
/**
* API module for creating claims.
@@ -64,7 +63,13 @@
$summary = $this->claimModificationHelper->createSummary(
$params, $this );
$changeOp = new ChangeOpMainSnak( '', $snak,
WikibaseRepo::getDefaultInstance()->getIdFormatter() );
- $changeOp->apply( $entity, $summary );
+
+ try {
+ $changeOp->apply( $entity, $summary );
+ } catch ( ChangeOpException $e ) {
+ $this->dieUsage( $e->getMessage(), 'failed-save' );
+ }
+
$claims = new Claims( $entity->getClaims() );
$claim = $claims->getClaimWithGuid( $changeOp->getClaimGuid() );
diff --git a/repo/includes/api/EditEntity.php b/repo/includes/api/EditEntity.php
index e3ea4c2..cc8c9c0 100644
--- a/repo/includes/api/EditEntity.php
+++ b/repo/includes/api/EditEntity.php
@@ -9,6 +9,7 @@
use Wikibase\ChangeOpDescription;
use Wikibase\ChangeOpAliases;
use Wikibase\ChangeOpSiteLink;
+use Wikibase\ChangeOpException;
use ApiBase, User, Status, SiteList;
use Wikibase\SiteLink;
use Wikibase\Entity;
@@ -159,9 +160,11 @@
$this->dieUsage( "Edit failed: $1", 'failed-save' );
}
- if ( $changeOps->apply( $entity ) === false ) {
+ try {
+ $changeOps->apply( $entity );
+ } catch ( ChangeOpException $e ) {
wfProfileOut( __METHOD__ );
- $this->dieUsage( 'Change could not be applied to
entity', 'failed-save' );
+ $this->dieUsage( 'Change could not be applied to
entity: ' . $e->getMessage(), 'failed-save' );
}
$this->addLabelsToResult( $entity->getLabels(), 'entity' );
diff --git a/repo/includes/api/ModifyClaim.php
b/repo/includes/api/ModifyClaim.php
index 1b2b2ea..786cd78 100644
--- a/repo/includes/api/ModifyClaim.php
+++ b/repo/includes/api/ModifyClaim.php
@@ -2,7 +2,7 @@
namespace Wikibase\Api;
use ApiMain;
-use ApiBase, MWException;
+use ApiBase;
use Wikibase\EntityContent;
use Wikibase\Claim;
use Wikibase\Summary;
@@ -99,6 +99,18 @@
}
/**
+ * @see ApiBase::getPossibleErrors()
+ */
+ public function getPossibleErrors() {
+ return array_merge(
+ parent::getPossibleErrors(),
+ array(
+ array( 'code' => 'failed-save', 'info' =>
$this->msg( 'wikibase-api-failed-save' )->text() ),
+ )
+ );
+ }
+
+ /**
* @see \Api::getRequiredPermissions()
*/
protected function getRequiredPermissions( Entity $entity, array
$params ) {
diff --git a/repo/includes/api/RemoveClaims.php
b/repo/includes/api/RemoveClaims.php
index 0e006f0..efcb397 100644
--- a/repo/includes/api/RemoveClaims.php
+++ b/repo/includes/api/RemoveClaims.php
@@ -2,15 +2,14 @@
namespace Wikibase\Api;
+use ApiBase;
use Wikibase\Claims;
-
-use ApiBase, ApiMain;
-use MWException;
use Wikibase\EntityId;
use Wikibase\Entity;
use Wikibase\Repo\WikibaseRepo;
use Wikibase\ChangeOps;
use Wikibase\ChangeOpMainSnak;
+use Wikibase\ChangeOpException;
/**
* API module for removing claims.
@@ -60,7 +59,12 @@
$changeOps = new ChangeOps();
$changeOps->add( $this->getChangeOps( $params ) );
- $changeOps->apply( $entityContent->getEntity(), $summary );
+
+ try {
+ $changeOps->apply( $entityContent->getEntity(),
$summary );
+ } catch ( ChangeOpException $e ) {
+ $this->dieUsage( $e->getMessage(), 'failed-save' );
+ }
$this->saveChanges( $entityContent, $summary );
diff --git a/repo/includes/api/RemoveQualifiers.php
b/repo/includes/api/RemoveQualifiers.php
index ffdb63b..9bfdb78 100644
--- a/repo/includes/api/RemoveQualifiers.php
+++ b/repo/includes/api/RemoveQualifiers.php
@@ -9,6 +9,7 @@
use Wikibase\Repo\WikibaseRepo;
use Wikibase\ChangeOpQualifier;
use Wikibase\ChangeOps;
+use Wikibase\ChangeOpException;
/**
* API module for removing qualifiers from a claim.
@@ -38,8 +39,6 @@
* @author Tobias Gritschacher < [email protected] >
*/
class RemoveQualifiers extends ModifyClaim {
-
- // TODO: claim uniqueness
/**
* @see \ApiBase::execute
@@ -74,7 +73,12 @@
$changeOps = new ChangeOps();
$changeOps->add( $this->getChangeOps( $claimGuid,
$qualifierHashes ) );
- $changeOps->apply( $entity, $summary );
+
+ try {
+ $changeOps->apply( $entity, $summary );
+ } catch ( ChangeOpException $e ) {
+ $this->dieUsage( $e->getMessage(), 'failed-save' );
+ }
$this->saveChanges( $entityContent, $summary );
diff --git a/repo/includes/api/SetClaimValue.php
b/repo/includes/api/SetClaimValue.php
index 626680c..937e449 100644
--- a/repo/includes/api/SetClaimValue.php
+++ b/repo/includes/api/SetClaimValue.php
@@ -2,12 +2,12 @@
namespace Wikibase\Api;
-use ApiBase, MWException;
-use ApiMain;
+use ApiBase;
use Wikibase\EntityId;
use Wikibase\Entity;
use Wikibase\Claims;
use Wikibase\ChangeOpMainSnak;
+use Wikibase\ChangeOpException;
use Wikibase\Repo\WikibaseRepo;
/**
@@ -70,7 +70,12 @@
$summary = $this->claimModificationHelper->createSummary(
$params, $this );
$changeOp = new ChangeOpMainSnak( $claimGuid, $snak,
WikibaseRepo::getDefaultInstance()->getIdFormatter() );
- $changeOp->apply( $entity, $summary );
+
+ try {
+ $changeOp->apply( $entity, $summary );
+ } catch ( ChangeOpException $e ) {
+ $this->dieUsage( $e->getMessage(), 'failed-save' );
+ }
$this->saveChanges( $entityContent, $summary );
diff --git a/repo/includes/api/SetQualifier.php
b/repo/includes/api/SetQualifier.php
index c668e7b..ee04fbb 100644
--- a/repo/includes/api/SetQualifier.php
+++ b/repo/includes/api/SetQualifier.php
@@ -7,6 +7,7 @@
use Wikibase\Claims;
use Wikibase\Repo\WikibaseRepo;
use Wikibase\ChangeOpQualifier;
+use Wikibase\ChangeOpException;
/**
* API module for creating a qualifier or setting the value of an existing one.
@@ -37,9 +38,6 @@
* @author Tobias Gritschacher < [email protected] >
*/
class SetQualifier extends ModifyClaim {
-
- // TODO: more explicit support for snak merging?
- // TODO: claim uniqueness
/**
* @see ApiBase::execute
@@ -72,7 +70,12 @@
$claim = $claims->getClaimWithGuid( $claimGuid );
$changeOp = $this->getChangeOp();
- $changeOp->apply( $entity, $summary );
+
+ try {
+ $changeOp->apply( $entity, $summary );
+ } catch ( ChangeOpException $e ) {
+ $this->dieUsage( $e->getMessage(), 'failed-save' );
+ }
$this->saveChanges( $entityContent, $summary );
diff --git a/repo/includes/changeop/ChangeOp.php
b/repo/includes/changeop/ChangeOp.php
index 354209e..0358217 100644
--- a/repo/includes/changeop/ChangeOp.php
+++ b/repo/includes/changeop/ChangeOp.php
@@ -36,7 +36,9 @@
* @param Entity $entity
* @param Summary|null $summary
*
- * @return bool
+ * @return bool
+ *
+ * @throws ChangeOpException
*/
abstract public function apply( Entity $entity, Summary $summary = null
);
diff --git a/repo/includes/changeop/ChangeOpAliases.php
b/repo/includes/changeop/ChangeOpAliases.php
index 867738f..f1cf61a 100644
--- a/repo/includes/changeop/ChangeOpAliases.php
+++ b/repo/includes/changeop/ChangeOpAliases.php
@@ -3,7 +3,6 @@
namespace Wikibase;
use InvalidArgumentException;
-use MWException;
/**
* Class for aliases change operation
@@ -86,7 +85,7 @@
*
* @return bool
*
- * @throws MWException
+ * @throws ChangeOpException
*/
public function apply( Entity $entity, Summary $summary = null ) {
if ( $this->action === "" || $this->action === "set" ) {
@@ -99,7 +98,7 @@
$this->updateSummary( $summary, 'remove',
$this->language, $this->aliases );
$entity->removeAliases( $this->language, $this->aliases
);
} else {
- throw new \MWException( "Unknown action: $this->action"
);
+ throw new ChangeOpException( "Unknown action for change
op: $this->action" );
}
return true;
}
diff --git a/repo/includes/changeop/ChangeOpException.php
b/repo/includes/changeop/ChangeOpException.php
new file mode 100644
index 0000000..b945447
--- /dev/null
+++ b/repo/includes/changeop/ChangeOpException.php
@@ -0,0 +1,33 @@
+<?php
+
+namespace Wikibase;
+
+/**
+ * Exception thrown during an invalid change operation.
+ *
+ * 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
+ *
+ * @since 0.4
+ *
+ * @file
+ * @ingroup WikibaseRepo
+ *
+ * @licence GNU GPL v2+
+ * @author Tobias Gritschacher < [email protected] >
+ */
+class ChangeOpException extends \RuntimeException {
+
+}
diff --git a/repo/includes/changeop/ChangeOpMainSnak.php
b/repo/includes/changeop/ChangeOpMainSnak.php
index 59a4a37..247e5a1 100644
--- a/repo/includes/changeop/ChangeOpMainSnak.php
+++ b/repo/includes/changeop/ChangeOpMainSnak.php
@@ -100,29 +100,19 @@
* @param Summary|null $summary
*
* @return bool
+ *
+ * @throws ChangeOpException
*/
public function apply( Entity $entity, Summary $summary = null ) {
$claims = new Claims( $entity->getClaims() );
if ( $this->claimGuid === '' ) {
- //create claim
- $claim = $entity->newClaim( $this->snak );
- $claims->addClaim( $claim );
- $this->updateSummary( $summary, 'create', '',
$this->getClaimSummaryArgs( $this->snak ) );
- $this->claimGuid = $claim->getGuid();
+ $this->addClaim( $entity, $claims, $summary );
} else {
- if( !$claims->hasClaimWithGuid( $this->claimGuid ) ) {
- return false;
- }
if ( $this->snak !== null ) {
- //set claim
- $claims->getClaimWithGuid( $this->claimGuid
)->setMainSnak( $this->snak );
- $this->updateSummary( $summary, null, '',
$this->getClaimSummaryArgs( $this->snak ) );
+ $this->setClaim( $claims, $summary );
} else {
- //remove claim
- $removedSnak = $claims->getClaimWithGuid(
$this->claimGuid )->getMainSnak();
- $claims->removeClaimWithGuid( $this->claimGuid
);
- $this->updateSummary( $summary, 'remove', '',
$this->getClaimSummaryArgs( $removedSnak ) );
+ $this->removeClaim( $claims, $summary );
}
}
@@ -134,6 +124,54 @@
/**
* @since 0.4
*
+ * @param Entity $entity
+ * @param Claims $claims
+ * @param Summary $summary
+ */
+ protected function addClaim( Entity $entity, Claims $claims, Summary
$summary = null ) {
+ //TODO: check for claim uniqueness?
+ $claim = $entity->newClaim( $this->snak );
+ $claims->addClaim( $claim );
+ $this->updateSummary( $summary, 'create', '',
$this->getClaimSummaryArgs( $this->snak ) );
+ $this->claimGuid = $claim->getGuid();
+ }
+
+ /**
+ * @since 0.4
+ *
+ * @param Claims $claims
+ * @param Summary $summary
+ *
+ * @throws ChangeOpException
+ */
+ protected function setClaim( Claims $claims, Summary $summary = null ) {
+ if( !$claims->hasClaimWithGuid( $this->claimGuid ) ) {
+ throw new ChangeOpException( "Entity does not have
claim with GUID $this->claimGuid" );
+ }
+ $claims->getClaimWithGuid( $this->claimGuid )->setMainSnak(
$this->snak );
+ $this->updateSummary( $summary, null, '',
$this->getClaimSummaryArgs( $this->snak ) );
+ }
+
+ /**
+ * @since 0.4
+ *
+ * @param Claims $claims
+ * @param Summary $summary
+ *
+ * @throws ChangeOpException
+ */
+ protected function removeClaim( Claims $claims, Summary $summary = null
) {
+ if( !$claims->hasClaimWithGuid( $this->claimGuid ) ) {
+ throw new ChangeOpException( "Entity does not have
claim with GUID $this->claimGuid" );
+ }
+ $removedSnak = $claims->getClaimWithGuid( $this->claimGuid
)->getMainSnak();
+ $claims->removeClaimWithGuid( $this->claimGuid );
+ $this->updateSummary( $summary, 'remove', '',
$this->getClaimSummaryArgs( $removedSnak ) );
+ }
+
+ /**
+ * @since 0.4
+ *
* @param Snak $mainSnak
*
* @return array
diff --git a/repo/includes/changeop/ChangeOpQualifier.php
b/repo/includes/changeop/ChangeOpQualifier.php
index 1fba153..d4c05eb 100644
--- a/repo/includes/changeop/ChangeOpQualifier.php
+++ b/repo/includes/changeop/ChangeOpQualifier.php
@@ -110,13 +110,14 @@
* @param Summary|null $summary
*
* @return bool
+ *
+ * @throws ChangeOpException
*/
public function apply( Entity $entity, Summary $summary = null ) {
$claims = new Claims( $entity->getClaims() );
if( !$claims->hasClaimWithGuid( $this->claimGuid ) ) {
- //TODO: throwing an error would probably be the better
solution
- return false;
+ throw new ChangeOpException( "Entity does not have
claim with GUID $this->claimGuid" );
}
$claim = $claims->getClaimWithGuid( $this->claimGuid );
@@ -125,10 +126,6 @@
if ( $this->snakHash === '' ) {
$this->addQualifier( $qualifiers, $summary );
} else {
- if ( !$qualifiers->hasSnakHash( $this->snakHash ) ) {
- //TODO: throw an error
- return false;
- }
if ( $this->snak != null ) {
$this->setQualifier( $qualifiers, $summary );
} else {
@@ -147,9 +144,13 @@
*
* @param Snaks $qualifiers
* @param Summary $summary
+ *
+ * @throws ChangeOpException
*/
protected function addQualifier( Snaks $qualifiers, Summary $summary =
null ) {
- //TODO: claimUniqueness: check if snak with same hash already
exists and throw error in that case
+ if ( $qualifiers->hasSnak( $this->snak ) ) {
+ throw new ChangeOpException( "Claim has already a
qualifier with hash $this->snak->getHash()" );
+ }
$qualifiers->addSnak( $this->snak );
//TODO: add the mainsnak as autocomment-arg & change messages
$this->updateSummary( $summary, 'add', '',
$this->getSnakSummaryArgs( $this->snak ) );
@@ -160,9 +161,16 @@
*
* @param Snaks $qualifiers
* @param Summary $summary
+ *
+ * @throws ChangeOpException
*/
protected function setQualifier( Snaks $qualifiers, Summary $summary =
null ) {
- //TODO: claimUniqueness: check if snak with same hash already
exists and throw error in that case
+ if ( !$qualifiers->hasSnakHash( $this->snakHash ) ) {
+ throw new ChangeOpException( "Qualifier with hash
$this->snakHash does not exist" );
+ }
+ if ( $qualifiers->hasSnak( $this->snak ) ) {
+ throw new ChangeOpException( "Claim has already a
qualifier with hash $this->snak->getHash()" );
+ }
$qualifiers->removeSnakHash( $this->snakHash );
$qualifiers->addSnak( $this->snak );
$this->updateSummary( $summary, 'update', '',
$this->getSnakSummaryArgs( $this->snak ) );
@@ -173,8 +181,13 @@
*
* @param Snaks $qualifiers
* @param Summary $summary
+ *
+ * @throws ChangeOpException
*/
protected function removeQualifiers( Snaks $qualifiers, Summary
$summary = null ) {
+ if ( !$qualifiers->hasSnakHash( $this->snakHash ) ) {
+ throw new ChangeOpException( "Qualifier with hash
$this->snakHash does not exist" );
+ }
$removedQualifier = $qualifiers->getSnak( $this->snakHash );
$qualifiers->removeSnakHash( $this->snakHash );
$this->updateSummary( $summary, 'remove', '',
$this->getSnakSummaryArgs( $removedQualifier ) );
diff --git a/repo/includes/changeop/ChangeOpSiteLink.php
b/repo/includes/changeop/ChangeOpSiteLink.php
index ad4029f..9b4e408 100644
--- a/repo/includes/changeop/ChangeOpSiteLink.php
+++ b/repo/includes/changeop/ChangeOpSiteLink.php
@@ -77,6 +77,7 @@
* @param Summary|null $summary
*
* @throws InvalidArgumentException
+ * @throws ChangeOpException
*/
public function apply( Entity $entity, Summary $summary = null ) {
if ( !( $entity instanceof Item ) ) {
@@ -87,6 +88,8 @@
if ( $entity->hasLinkToSite( $this->siteId ) ) {
$this->updateSummary( $summary, 'remove',
$this->siteId, $entity->getSimpleSiteLink( $this->siteId )->getPageName() );
$entity->removeSiteLink( $this->siteId );
+ } else {
+ //TODO: throw error, or ignore silently?
}
} else {
$entity->hasLinkToSite( $this->siteId ) ? $action =
'set' : $action = 'add';
diff --git a/repo/includes/changeop/ChangeOps.php
b/repo/includes/changeop/ChangeOps.php
index f286cd8..b2f32bc 100644
--- a/repo/includes/changeop/ChangeOps.php
+++ b/repo/includes/changeop/ChangeOps.php
@@ -93,12 +93,16 @@
* @param Summary|null $summary
*
* @return bool
+ *
+ * @throws Change
*/
public function apply( Entity $entity, Summary $summary = null ) {
- foreach ( $this->ops as $op ) {
- if ( $op->apply( $entity, $summary ) === false ) {
- return false;
+ try {
+ foreach ( $this->ops as $op ) {
+ $op->apply( $entity, $summary );
}
+ } catch ( ChangeOpException $e ) {
+ throw new ChangeOpException( 'Exception while applying
changes: ' . $e->getMessage() );
}
return true;
diff --git a/repo/tests/phpunit/includes/changeop/ChangeOpAliasesTest.php
b/repo/tests/phpunit/includes/changeop/ChangeOpAliasesTest.php
index bef4658..1304ec0 100644
--- a/repo/tests/phpunit/includes/changeop/ChangeOpAliasesTest.php
+++ b/repo/tests/phpunit/includes/changeop/ChangeOpAliasesTest.php
@@ -5,7 +5,6 @@
use Wikibase\ChangeOpAliases;
use Wikibase\ItemContent;
use InvalidArgumentException;
-use MWException;
/**
* @covers Wikibase\ChangeOpAliases
@@ -88,7 +87,7 @@
}
/**
- * @expectedException MWException
+ * @expectedException Wikibase\ChangeOpException
*/
public function testApplyWithInvalidAction() {
$item = ItemContent::newEmpty();
diff --git a/repo/tests/phpunit/includes/changeop/ChangeOpMainSnakTest.php
b/repo/tests/phpunit/includes/changeop/ChangeOpMainSnakTest.php
index 337ec4d..d059931 100644
--- a/repo/tests/phpunit/includes/changeop/ChangeOpMainSnakTest.php
+++ b/repo/tests/phpunit/includes/changeop/ChangeOpMainSnakTest.php
@@ -115,6 +115,29 @@
}
}
+ public function provideChangeOps() {
+ $snak = new \Wikibase\PropertyValueSnak( 67573284, new
\DataValues\StringValue( 'test' ) );
+ $newSnak = new \Wikibase\PropertyValueSnak( 12651236, new
\DataValues\StringValue( 'newww' ) );
+ $item = $this->provideNewItemWithClaim( 'q777', $snak );
+ $claims = $item->getClaims();
+ $claimGuid = $claims[0]->getGuid();
+ $idFormatter =
WikibaseRepo::getDefaultInstance()->getIdFormatter();
+
+ $args[] = array ( new ChangeOpMainSnak( $claimGuid, $newSnak,
$idFormatter ) );
+ $args[] = array ( new ChangeOpMainSnak( $claimGuid, null,
$idFormatter ) );
+
+ return $args;
+ }
+
+ /**
+ * @dataProvider provideChangeOps
+ * @expectedException Wikibase\ChangeOpException
+ */
+ public function testInvalidApply( $changeOp ) {
+ $wrongItem = ItemContent::newEmpty();
+ $changeOp->apply( $wrongItem->getEntity() );
+ }
+
protected function provideNewItemWithClaim( $itemId, $snak ) {
$entity = ItemContent::newFromArray( array( 'entity' => $itemId
) )->getEntity();
$claim = $entity->newClaim( $snak );
diff --git a/repo/tests/phpunit/includes/changeop/ChangeOpsTest.php
b/repo/tests/phpunit/includes/changeop/ChangeOpsTest.php
index 6e15e9e..fd8145c 100644
--- a/repo/tests/phpunit/includes/changeop/ChangeOpsTest.php
+++ b/repo/tests/phpunit/includes/changeop/ChangeOpsTest.php
@@ -4,6 +4,7 @@
use Wikibase\ChangeOpLabel;
use Wikibase\ChangeOpDescription;
+use Wikibase\ChangeOpAliases;
use Wikibase\ChangeOps;
use Wikibase\ItemContent;
@@ -139,4 +140,17 @@
$this->assertEquals( $expectedDescription,
$entity->getDescription( $language ) );
}
+ /**
+ * @expectedException Wikibase\ChangeOpException
+ */
+ public function testInvalidApply() {
+ $item = ItemContent::newEmpty();
+
+ $changeOps = new ChangeOps();
+ $changeOps->add( new ChangeOpLabel( 'en', 'newLabel' ) );
+ $changeOps->add( new ChangeOpAliases( 'en', array( 'test' ),
'invalidAction' ) );
+
+ $changeOps->apply( $item->getEntity() );
+ }
+
}
--
To view, visit https://gerrit.wikimedia.org/r/77714
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I341cd81a63627416279e409de2c705d7b9749dda
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Tobias Gritschacher <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits