Permalink
Browse files

Added very basic ItemUpdaterTest

Change-Id: Id7d3e5db445e7b8f5d043d55e62c49d677b8505d
  • Loading branch information...
1 parent c9db3a2 commit 3c91d657e36aa5aecf63fe523b59231abc879a96 @JeroenDeDauw committed Aug 7, 2012
Showing with 71 additions and 0 deletions.
  1. +1 −0 client/WikibaseClient.hooks.php
  2. +70 −0 client/tests/phpunit/includes/ItemUpdaterTest.php
@@ -69,6 +69,7 @@ public static function registerUnitTests( array &$files ) {
'General',
'Sorting',
+ 'includes/ItemUpdater',
'includes/LocalItemsTable',
'includes/LocalItem',
);
@@ -0,0 +1,70 @@
+<?php
+
+namespace Wikibase\Test;
+use Wikibase\ItemUpdater as ItemUpdater;
+use \Wikibase\ItemChange as ItemChange;
+use \Wikibase\ItemObject as ItemObject;
+
+/**
+ * Tests for the Wikibase\ItemUpdater class.
+ *
+ * @file
+ * @since 0.1
+ *
+ * @ingroup WikibaseClient
+ * @ingroup Test
+ *
+ * @group Database
+ * @group Wikibase
+ * @group WikibaseClient
+ * @group WikibaseItemUpdater
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < jeroendedauw@gmail.com >
+ */
+class ItemUpdaterTest extends \MediaWikiTestCase {
+
+ public function constructorProvider() {
+ return array(
+ array(),
+ );
+ }
+
+ /**
+ * @dataProvider constructorProvider
+ */
+ public function testConstructor() {
+ $reflector = new \ReflectionClass( '\Wikibase\ItemUpdater' );
+ $instance = $reflector->newInstanceArgs( func_get_args() );
+ $this->assertInstanceOf( '\Wikibase\ItemUpdater', $instance );
+ }
+
+ public function handleChangeProvider() {
+ $argLists = array();
+
+ $sourceItem = ItemObject::newEmpty();
+ $sourceItem->setId( 42 );
+ $targetItem = clone $sourceItem;
+ $targetItem->setLabel( 'en', 'ohi there' );
+ $change = ItemChange::newFromItems( $sourceItem, $targetItem );
+
+ $argLists[] = array( $change, $sourceItem, $targetItem );
+
+ return $argLists;
+ }
+
+ /**
+ * @dataProvider handleChangeProvider
+ */
+ public function testHandleChange( ItemChange $change, ItemObject $sourceItem, ItemObject $targetItem ) {
+ $itemUpdater = new ItemUpdater();
+
+ $itemUpdater->handleChange( $change );
+
+ // TODO: test if the result matches expected behaviour
+ $this->assertTrue( true );
+ }
+
+
+}
+

0 comments on commit 3c91d65

Please sign in to comment.