Soeren.oldag has uploaded a new change for review.

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

Change subject: Fixed wrong merging.
......................................................................

Fixed wrong merging.

Change-Id: I9ab49d26dc152d41c40d7d571b9d51e7cebf020f
---
A tests/phpunit/CrossCheck/Comparer/DataValueComparerBaseTest.php
D tests/phpunit/CrossCheck/Comparer/DataValueComparerTestBase.php
2 files changed, 84 insertions(+), 65 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataQualityExternalValidation
 refs/changes/99/207399/1

diff --git a/tests/phpunit/CrossCheck/Comparer/DataValueComparerBaseTest.php 
b/tests/phpunit/CrossCheck/Comparer/DataValueComparerBaseTest.php
new file mode 100644
index 0000000..ea12f77
--- /dev/null
+++ b/tests/phpunit/CrossCheck/Comparer/DataValueComparerBaseTest.php
@@ -0,0 +1,84 @@
+<?php
+
+namespace WikidataQuality\ExternalValidation\Tests\CrossCheck\Comparer;
+
+use DataValues\DataValue;
+use WikidataQuality\ExternalValidation\CrossCheck\Comparer\DataValueComparer;
+
+/**
+ * @author BP2014N1
+ * @license GNU GPL v2+
+ */
+abstract class DataValueComparerBaseTest extends \MediaWikiTestCase {
+
+    /**
+     * @return DataValueComparer
+     */
+    protected abstract function buildComparer();
+
+
+    public function testImplementsDataValueComparerInterface() {
+        $this->assertInstanceOf( 
'WikidataQuality\ExternalValidation\CrossCheck\Comparer\DataValueComparer', 
$this->buildComparer() );
+    }
+
+
+    /**
+     * @dataProvider comparableProvider
+     */
+    public function testIsComparerForReturnsTrue( DataValue $dataValue ) {
+        $comparer = $this->buildComparer();
+        $this->assertTrue( $comparer->isComparerFor( $dataValue->getType() ) );
+    }
+
+    public abstract function comparableProvider();
+
+
+    /**
+     * @dataProvider nonComparableProvider
+     */
+    public function testIsComparerForReturnsFalse( DataValue $dataValue ) {
+        $comparer = $this->buildComparer();
+        $this->assertFalse( $comparer->isComparerFor( $dataValue->getType() ) 
);
+    }
+
+    public abstract function nonComparableProvider();
+
+
+    /**
+     * @dataProvider nonComparableProvider
+     */
+    public function testComparerThrowsInvalidArgumentException( DataValue 
$dataValue ) {
+        $this->setExpectedException( 'InvalidArgumentException' );
+        $this->buildComparer()->compare( $dataValue, array(), 
$this->getDumpMetaInformationMock() );
+    }
+
+
+    /**
+     * @dataProvider comparisonProvider
+     */
+    public function testComparison( $expectedResult, $localValue, 
$externalValues, $dumpMetaInformation = null ) {
+        if ( !$dumpMetaInformation ) {
+            $dumpMetaInformation = $this->getDumpMetaInformationMock();
+        }
+
+        $actualResult = $this->buildComparer()->compare( $localValue, 
$externalValues, $dumpMetaInformation );
+
+        $this->assertEquals( $expectedResult, $actualResult );
+    }
+
+    public abstract function comparisonProvider();
+
+
+    protected function getDumpMetaInformationMock( $language = 'en' ) {
+        $mock = $this->getMockBuilder( 
'WikidataQuality\ExternalValidation\DumpMetaInformation' )
+            ->disableOriginalConstructor()
+            ->setMethods( array( 'getLanguage' ) )
+            ->getMock();
+
+        $mock->expects( $this->any() )
+            ->method( 'getLanguage' )
+            ->willReturn( $language );
+
+        return $mock;
+    }
+}
\ No newline at end of file
diff --git a/tests/phpunit/CrossCheck/Comparer/DataValueComparerTestBase.php 
b/tests/phpunit/CrossCheck/Comparer/DataValueComparerTestBase.php
deleted file mode 100644
index 4f11cff..0000000
--- a/tests/phpunit/CrossCheck/Comparer/DataValueComparerTestBase.php
+++ /dev/null
@@ -1,65 +0,0 @@
-<?php
-
-namespace WikidataQuality\ExternalValidation\Tests\CrossCheck\Comparer;
-
-
-/**
- * @group WikidataQuality
- * @group WikidataQuality\ExternalValidation
- *
- * @uses   WikidataQuality\ExternalValidation\CrossCheck\Result\CompareResult
- * @uses   
WikidataQuality\ExternalValidation\CrossCheck\Comparer\DataValueComparer
- *
- * @author BP2014N1
- * @license GNU GPL v2+
- */
-abstract class DataValueComparerTestBase extends \MediaWikiTestCase {
-    /**
-     * @dataProvider executeDataProvider
-     */
-    public function testExecute( $dumpMetaInformation, $localValue, 
$externalValues, $expectedDataMismatch, $expectedExternalValues ) {
-        $comparer = $this->createComparer( $dumpMetaInformation, $localValue, 
$externalValues );
-        $result = $comparer->execute();
-
-        if ( $result ) {
-            $this->assertEquals( $localValue, $result->getLocalValue() );
-            $this->assertEquals( $expectedExternalValues, 
$result->getExternalValues() );
-            $this->assertEquals( $expectedDataMismatch, 
$result->hasDataMismatchOccurred() );
-        } else {
-            $this->assertNull( $expectedDataMismatch );
-            $this->assertNull( $expectedExternalValues );
-        }
-    }
-
-    /*
-     * Test cases for testExecute
-     * @return array
-     */
-    public abstract function executeDataProvider();
-
-    /*
-     * Returns new instance of the comparer being tested with given arguments.
-     *
-     * @return DataValueComparer
-     */
-    protected abstract function createComparer( $dumpMetaInformation, 
$localValue, $externalValues );
-
-
-    /**
-     * Returns DumpMetaInformation mock with given language
-     *
-     * @param $language
-     * @return \PHPUnit_Framework_MockObject_MockObject
-     */
-    protected function getDumpMetaInformationMock( $language ) {
-        $mock = $this->getMockBuilder( 
'WikidataQuality\ExternalValidation\DumpMetaInformation\DumpMetaInformation' )
-            ->setMethods( array( 'getLanguage' ) )
-            ->disableOriginalConstructor()
-            ->getMock();
-        $mock->expects( $this->any() )
-            ->method( 'getLanguage' )
-            ->willReturn( $language );
-
-        return $mock;
-    }
-}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9ab49d26dc152d41c40d7d571b9d51e7cebf020f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikidataQualityExternalValidation
Gerrit-Branch: v1
Gerrit-Owner: Soeren.oldag <soeren_ol...@freenet.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to