Tobias Gritschacher has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/66392


Change subject: Moving entity operations into separate ChangeOps
......................................................................

Moving entity operations into separate ChangeOps

- part of EditEntity (API) refactoring

Bug: 48137

Change-Id: Id9146d20893f300a66b377f96bf85dc709e3d022
---
M repo/Wikibase.classes.php
M repo/Wikibase.hooks.php
M repo/includes/api/EditEntity.php
A repo/includes/changeop/ChangeOp.php
A repo/includes/changeop/ChangeOpDescription.php
A repo/includes/changeop/ChangeOpLabel.php
A repo/includes/changeop/ChangeOps.php
A repo/tests/phpunit/includes/changeop/ChangeOpDescriptionTest.php
A repo/tests/phpunit/includes/changeop/ChangeOpLabelTest.php
A repo/tests/phpunit/includes/changeop/ChangeOpsTest.php
10 files changed, 570 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/92/66392/1

diff --git a/repo/Wikibase.classes.php b/repo/Wikibase.classes.php
index 5b6fb22..3041c56 100644
--- a/repo/Wikibase.classes.php
+++ b/repo/Wikibase.classes.php
@@ -49,6 +49,10 @@
                'Wikibase\PropertyView' => 'includes/PropertyView.php',
                'Wikibase\Summary' => 'includes/Summary.php',
                'Wikibase\Repo\WikibaseRepo' => 'includes/WikibaseRepo.php',
+               'Wikibase\ChangeOps' => 'includes/changeop/ChangeOps.php',
+               'Wikibase\ChangeOp' => 'includes/changeop/ChangeOp.php',
+               'Wikibase\ChangeOpLabel' => 
'includes/changeop/ChangeOpLabel.php',
+               'Wikibase\ChangeOpDescription' => 
'includes/changeop/ChangeOpDescription.php',
 
                // includes/actions
                'Wikibase\HistoryEntityAction' => 
'includes/actions/HistoryEntityAction.php',
diff --git a/repo/Wikibase.hooks.php b/repo/Wikibase.hooks.php
index 5b1114b..45b0ae9 100755
--- a/repo/Wikibase.hooks.php
+++ b/repo/Wikibase.hooks.php
@@ -184,6 +184,10 @@
                        'api/RemoveReferences',
                        'api/SetClaim',
 
+                       'changeop/ChangeOps',
+                       'changeop/ChangeOpLabel',
+                       'changeop/ChangeOpDescription',
+
                        'content/EntityContentFactory',
                        'content/EntityHandler',
                        'content/ItemContent',
diff --git a/repo/includes/api/EditEntity.php b/repo/includes/api/EditEntity.php
index 5dd2e45..774ddd1 100644
--- a/repo/includes/api/EditEntity.php
+++ b/repo/includes/api/EditEntity.php
@@ -2,6 +2,14 @@
 
 namespace Wikibase\Api;
 
+use Wikibase\ChangeOps;
+
+use Diff\DiffOpChange;
+use Diff\DiffOpRemove;
+
+use Wikibase\ChangeOpLabel;
+use Wikibase\ChangeOpDescription;
+
 use ApiBase, User, Status, SiteList;
 
 use Wikibase\SiteLink;
@@ -95,6 +103,8 @@
                wfProfileIn( __METHOD__ );
                $status = Status::newGood();
                $summary = $this->createSummary( $params );
+               $entity = $entityContent->getEntity();
+               $changeOps = new ChangeOps();
 
                if ( isset( $params['id'] ) XOR ( isset( $params['site'] ) && 
isset( $params['title'] ) ) ) {
                        $summary->setAction( $params['clear'] === false ? 
'update' : 'override' );
@@ -181,11 +191,16 @@
 
                                        foreach ( $list as $langCode => $arg ) {
                                                $status->merge( 
$this->checkMultilangArgs( $arg, $langCode, $languages ) );
-                                               if ( array_key_exists( 
'remove', $arg ) || $arg['value'] === "" ) {
-                                                       
$entityContent->getEntity()->removeLabel( $arg['language'] );
+
+                                               $language = $arg['language'];
+                                               $newLabel = Utils::trimToNFC( 
$arg['value'] );
+                                               $oldLabel = $entity->getLabel( 
$language );
+
+                                               if ( array_key_exists( 
'remove', $arg ) || $newLabel === "" ) {
+                                                       $changeOps->add( new 
ChangeOpLabel( $language, new DiffOpRemove( $entity->getLabel( $language ) ) ) 
);
                                                }
                                                else {
-                                                       
$entityContent->getEntity()->setLabel( $arg['language'], Utils::trimToNFC( 
$arg['value'] ) );
+                                                       $changeOps->add( new 
ChangeOpLabel( $language, new DiffOpChange( $entity->getLabel( $language ), 
$newLabel ) ) );
                                                }
                                        }
 
@@ -204,11 +219,16 @@
 
                                        foreach ( $list as $langCode => $arg ) {
                                                $status->merge( 
$this->checkMultilangArgs( $arg, $langCode, $languages ) );
-                                               if ( array_key_exists( 
'remove', $arg ) || $arg['value'] === "" ) {
-                                                       
$entityContent->getEntity()->removeDescription( $arg['language'] );
+
+                                               $language = $arg['language'];
+                                               $newDescription = 
Utils::trimToNFC( $arg['value'] );
+                                               $oldDescription = 
$entity->getDescription( $language );
+
+                                               if ( array_key_exists( 
'remove', $arg ) || $newDescription === "" ) {
+                                                       $changeOps->add( new 
ChangeOpDescription( $language, new DiffOpRemove( $entity->getDescription( 
$language ) ) ) );
                                                }
                                                else {
-                                                       
$entityContent->getEntity()->setDescription( $arg['language'], 
Utils::trimToNFC( $arg['value'] ) );
+                                                       $changeOps->add( new 
ChangeOpDescription( $language, new DiffOpChange( $entity->getDescription( 
$language ), $newDescription ) ) );
                                                }
                                        }
 
@@ -335,6 +355,8 @@
                        }
                }
 
+               $changeOps->apply( $entity );
+
                // This is already done in createEntity
                if ( $entityContent->isNew() ) {
                        // if the entity doesn't exist yet, create it
diff --git a/repo/includes/changeop/ChangeOp.php 
b/repo/includes/changeop/ChangeOp.php
new file mode 100644
index 0000000..6f8b1a0
--- /dev/null
+++ b/repo/includes/changeop/ChangeOp.php
@@ -0,0 +1,35 @@
+<?php
+
+namespace Wikibase;
+
+/**
+ * Base class for change operations.
+ * 
+ * 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] >
+ */
+interface ChangeOp {
+
+       public function apply( Entity $entity );
+
+}
diff --git a/repo/includes/changeop/ChangeOpDescription.php 
b/repo/includes/changeop/ChangeOpDescription.php
new file mode 100644
index 0000000..0d79705
--- /dev/null
+++ b/repo/includes/changeop/ChangeOpDescription.php
@@ -0,0 +1,82 @@
+<?php
+
+namespace Wikibase;
+
+use Diff\DiffOp;
+use Diff\DiffOpRemove;
+use InvalidArgumentException;
+
+/**
+ * Class for description 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
+ *
+ * @ingroup WikibaseRepo
+ *
+ * @licence GNU GPL v2+
+ * @author Tobias Gritschacher < [email protected] >
+ */
+class ChangeOpDescription implements ChangeOp {
+
+       /**
+        * @since 0.4
+        *
+        * @var string
+        */
+       protected $language;
+
+       /**
+        * @since 0.4
+        *
+        * @var DiffOp
+        */
+       protected $diffOp;
+
+       /**
+        * @since 0.4
+        *
+        * @param string $language
+        * @param DiffOp $diffOp
+        *
+        * @throws InvalidArgumentException
+        */
+       public function __construct( $language, DiffOp $diffOp ) {
+               if ( !is_string( $language ) ) {
+                       throw new InvalidArgumentException( '$language needs to 
be a string' );
+               }
+
+               $this->language = $language;
+               $this->diffOp = $diffOp;
+       }
+
+       /**
+        * Applies the change to the given entity
+        * 
+        * @since 0.4
+        *
+        * @param Entity $entity
+        */
+       public function apply( Entity $entity ) {
+               if ( $this->diffOp instanceof DiffOpRemove ) {
+                       $entity->removeDescription( $this->language );
+               } else {
+                       $entity->setDescription( $this->language, 
$this->diffOp->getNewValue() );
+               }
+       }
+
+}
diff --git a/repo/includes/changeop/ChangeOpLabel.php 
b/repo/includes/changeop/ChangeOpLabel.php
new file mode 100644
index 0000000..0a82d04
--- /dev/null
+++ b/repo/includes/changeop/ChangeOpLabel.php
@@ -0,0 +1,82 @@
+<?php
+
+namespace Wikibase;
+
+use Diff\DiffOp;
+use Diff\DiffOpRemove;
+use InvalidArgumentException;
+
+/**
+ * Class for label 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
+ *
+ * @ingroup WikibaseRepo
+ *
+ * @licence GNU GPL v2+
+ * @author Tobias Gritschacher < [email protected] >
+ */
+class ChangeOpLabel implements ChangeOp {
+
+       /**
+        * @since 0.4
+        *
+        * @var string
+        */
+       protected $language;
+
+       /**
+        * @since 0.4
+        *
+        * @var DiffOp
+        */
+       protected $diffOp;
+
+       /**
+        * @since 0.4
+        *
+        * @param string $language
+        * @param DiffOp $diffOp
+        *
+        * @throws InvalidArgumentException
+        */
+       public function __construct( $language, DiffOp $diffOp ) {
+               if ( !is_string( $language ) ) {
+                       throw new InvalidArgumentException( '$language needs to 
be a string' );
+               }
+
+               $this->language = $language;
+               $this->diffOp = $diffOp;
+       }
+
+       /**
+        * Applies the change to the given entity
+        *
+        * @since 0.4
+        *
+        * @param Entity $entity
+        */
+       public function apply( Entity $entity ) {
+               if ( $this->diffOp instanceof DiffOpRemove ) {
+                       $entity->removeLabel( $this->language );
+               } else {
+                       $entity->setLabel( $this->language, 
$this->diffOp->getNewValue() );
+               }
+       }
+
+}
diff --git a/repo/includes/changeop/ChangeOps.php 
b/repo/includes/changeop/ChangeOps.php
new file mode 100644
index 0000000..47c1591
--- /dev/null
+++ b/repo/includes/changeop/ChangeOps.php
@@ -0,0 +1,81 @@
+<?php
+
+namespace Wikibase;
+
+/**
+ * Class for holding a batch of change operations
+ *
+ * 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
+ *
+ * @ingroup WikibaseRepo
+ *
+ * @licence GNU GPL v2+
+ * @author Tobias Gritschacher < [email protected] >
+ */
+class ChangeOps {
+
+       /**
+        * @since 0.4
+        *
+        * @var ChangeOp[]
+        */
+       protected $ops;
+
+       /**
+        * @since 0.4
+        *
+        */
+       public function __construct() {
+               $this->ops = array();
+       }
+
+       /**
+        * Adds a changeOp
+        *
+        * @since 0.4
+        *
+        * @param ChangeOp $changeOp
+        */
+       public function add( ChangeOp $changeOp ) {
+               $this->ops[] = $changeOp;
+       }
+
+       /**
+        * Get the array of changeOps
+        *
+        * @since 0.4
+        *
+        * @return ChangeOp[]
+        */
+       public function getChangeOps() {
+               return $this->ops;
+       }
+
+       /**
+        * Applies all changes to the given entity
+        * @since 0.4
+        *
+        * @param Entity $entity
+        */
+       public function apply( Entity $entity ) {
+               foreach ( $this->ops as $op ) {
+                       $op->apply( $entity );
+               }
+       }
+
+}
diff --git a/repo/tests/phpunit/includes/changeop/ChangeOpDescriptionTest.php 
b/repo/tests/phpunit/includes/changeop/ChangeOpDescriptionTest.php
new file mode 100644
index 0000000..c929414
--- /dev/null
+++ b/repo/tests/phpunit/includes/changeop/ChangeOpDescriptionTest.php
@@ -0,0 +1,76 @@
+<?php
+
+namespace Wikibase\Test;
+
+use Diff\DiffOpChange;
+use Diff\DiffOpRemove;
+use Diff\DiffOpAdd;
+use Wikibase\ChangeOpDescription;
+use Wikibase\ItemContent;
+use InvalidArgumentException;
+
+/**
+ * @covers Wikibase\ChangeOpDescription
+ *
+ * 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
+ *
+ * @file
+ * @since 0.4
+ *
+ * @ingroup Wikibase
+ * @ingroup Test
+ *
+ * @group Wikibase
+ * @group WikibaseRepo
+ * @group ChangeOp
+ *
+ * @licence GNU GPL v2+
+ * @author Tobias Gritschacher < [email protected] >
+ */
+class ChangeOpDescriptionTest extends \PHPUnit_Framework_TestCase {
+
+       /**
+        * @expectedException InvalidArgumentException
+        */
+       public function testInvalidConstruct() {
+               $changeOpDescription = new ChangeOpDescription( 42, new 
DiffOpChange( 'myOld', 'myNew' ) );
+       }
+
+       public function changeOpDescriptionProvider() {
+               $args = array();
+               $args[] = array ( new ChangeOpDescription( 'en', new 
DiffOpChange( 'myOld', 'myNew' ) ), 'myNew' );
+               $args[] = array ( new ChangeOpDescription( 'en', new 
DiffOpRemove( 'myOld' ) ), '' );
+               $args[] = array ( new ChangeOpDescription( 'en', new DiffOpAdd( 
'myNew' ) ), 'myNew' );
+
+               return $args;
+       }
+
+       /**
+        * @dataProvider changeOpDescriptionProvider
+        *
+        * @param ChangeOpDescription $changeOpDescription
+        * @param string $expectedDescription
+        */
+       public function testApply( $changeOpDescription, $expectedDescription ) 
{
+               $item = ItemContent::newEmpty();
+               $entity = $item->getEntity();
+               $entity->setDescription( 'en', 'test' );
+
+               $changeOpDescription->apply( $entity );
+
+               $this->assertEquals( $expectedDescription, 
$entity->getDescription( 'en' ) );
+       }
+
+}
diff --git a/repo/tests/phpunit/includes/changeop/ChangeOpLabelTest.php 
b/repo/tests/phpunit/includes/changeop/ChangeOpLabelTest.php
new file mode 100644
index 0000000..0728afc
--- /dev/null
+++ b/repo/tests/phpunit/includes/changeop/ChangeOpLabelTest.php
@@ -0,0 +1,76 @@
+<?php
+
+namespace Wikibase\Test;
+
+use Diff\DiffOpChange;
+use Diff\DiffOpRemove;
+use Diff\DiffOpAdd;
+use Wikibase\ChangeOpLabel;
+use Wikibase\ItemContent;
+use InvalidArgumentException;
+
+/**
+ * @covers Wikibase\ChangeOpLabel
+ *
+ * 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
+ *
+ * @file
+ * @since 0.4
+ *
+ * @ingroup Wikibase
+ * @ingroup Test
+ *
+ * @group Wikibase
+ * @group WikibaseRepo
+ * @group ChangeOp
+ *
+ * @licence GNU GPL v2+
+ * @author Tobias Gritschacher < [email protected] >
+ */
+class ChangeOpLabelTest extends \PHPUnit_Framework_TestCase {
+
+       /**
+        * @expectedException InvalidArgumentException
+        */
+       public function testInvalidConstruct() {
+               $changeOpLabel = new ChangeOpLabel( 42, new DiffOpChange( 
'myOld', 'myNew' ) );
+       }
+
+       public function changeOpLabelProvider() {
+               $args = array();
+               $args[] = array ( new ChangeOpLabel( 'en', new DiffOpChange( 
'myOld', 'myNew' ) ), 'myNew' );
+               $args[] = array ( new ChangeOpLabel( 'en', new DiffOpRemove( 
'myOld' ) ), '' );
+               $args[] = array ( new ChangeOpLabel( 'en', new DiffOpAdd( 
'myNew' ) ), 'myNew' );
+
+               return $args;
+       }
+
+       /**
+        * @dataProvider changeOpLabelProvider
+        *
+        * @param ChangeOpLabel $changeOpLabel
+        * @param string $expectedLabel
+        */
+       public function testApply( $changeOpLabel, $expectedLabel ) {
+               $item = ItemContent::newEmpty();
+               $entity = $item->getEntity();
+               $entity->setLabel( 'en', 'test' );
+
+               $changeOpLabel->apply( $entity );
+
+               $this->assertEquals( $expectedLabel, $entity->getLabel( 'en' ) 
);
+       }
+
+}
diff --git a/repo/tests/phpunit/includes/changeop/ChangeOpsTest.php 
b/repo/tests/phpunit/includes/changeop/ChangeOpsTest.php
new file mode 100644
index 0000000..eb8289a
--- /dev/null
+++ b/repo/tests/phpunit/includes/changeop/ChangeOpsTest.php
@@ -0,0 +1,102 @@
+<?php
+
+use Wikibase\ItemContent;
+
+namespace Wikibase\Test;
+
+use Diff\DiffOpChange;
+use Diff\DiffOpRemove;
+use Diff\DiffOpAdd;
+use Wikibase\ChangeOpLabel;
+use Wikibase\ChangeOpDescription;
+use Wikibase\ChangeOps;
+use Wikibase\ItemContent;
+
+/**
+ * @covers Wikibase\ChangeOps
+ *
+ * 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
+ *
+ * @file
+ * @since 0.4
+ *
+ * @ingroup Wikibase
+ * @ingroup Test
+ *
+ * @group Wikibase
+ * @group WikibaseRepo
+ * @group ChangeOp
+ *
+ * @licence GNU GPL v2+
+ * @author Tobias Gritschacher < [email protected] >
+ */
+class ChangeOpsTest extends \PHPUnit_Framework_TestCase {
+
+       public function testEmptyChangeOps() {
+               $changeOps = new ChangeOps();
+               $this->assertEmpty( $changeOps->getChangeOps() );
+       }
+
+       /**
+        * @return \Wikibase\ChangeOp[]
+        */
+       public function changeOpProvider() {
+               $ops = array();
+               $ops[] = array ( new ChangeOpLabel( 'en', new DiffOpChange( 
'myOld', 'myNew' ) ) );
+               $ops[] = array ( new ChangeOpDescription( 'de', new 
DiffOpChange( 'myOldDescr', 'myNewDescr' ) ) );
+               $ops[] = array ( new ChangeOpLabel( 'en', new DiffOpRemove( 
'myOld' ) ) );
+               $ops[] = array ( new ChangeOpLabel( 'en', new DiffOpAdd( 
'myNew' ) ) );
+
+               return $ops;
+       }
+
+       /**
+        * @dataProvider changeOpProvider
+        *
+        * @param ChangeOp $changeOp
+        */
+       public function testAdd( $changeOp ) {
+               $changeOps = new ChangeOps();
+               $changeOps->add( $changeOp );
+               $this->assertEquals( array( $changeOp ), 
$changeOps->getChangeOps() );
+       }
+
+       public function changeOpsProvider() {
+               $args = array();
+
+               $language = 'en';
+               $changeOps = new ChangeOps();
+               $changeOps->add( new ChangeOpLabel( $language, new DiffOpAdd( 
'newLabel' ) ) );
+               $changeOps->add( new ChangeOpDescription( $language, new 
DiffOpAdd( 'newDescription' ) ) );
+               $args[] = array( $changeOps, $language, 'newLabel', 
'newDescription' );
+
+               return $args;
+       }
+
+       /**
+        * @dataProvider changeOpsProvider
+        *
+        * @param ChangeOps $changeOps
+        */
+       public function testApply( $changeOps, $language, $expectedLabel, 
$expectedDescription ) {
+               $item = ItemContent::newEmpty();
+               $entity = $item->getEntity();
+
+               $changeOps->apply( $entity );
+               $this->assertEquals( $expectedLabel, $entity->getLabel( 
$language ) );
+               $this->assertEquals( $expectedDescription, 
$entity->getDescription( $language ) );
+       }
+
+}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id9146d20893f300a66b377f96bf85dc709e3d022
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Tobias Gritschacher <[email protected]>

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

Reply via email to