Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405724 )

Change subject: Rename @dataProvider methods to provide…()
......................................................................

Rename @dataProvider methods to provide…()

According to MediaWiki guidelines [1], the name of a data provider
should begin with “provide”. Previously, we used several styles
inconsistently in this extension (mostly “get…Provider”). This commit
brings them all in line with the MediaWiki guidelines. In my opinion,
this sometimes makes the tests more readable as well, since the method
name now documents what it actually provides, not just what the test
method to which it belongs is called.

[1]: https://www.mediawiki.org/wiki/Special:PermanentLink/2678449#Data_providers

Bug: T168240
Change-Id: I51f476ff74cf2abd4934f2568268b429f0c39651
---
M tests/phpunit/Cache/CachingMetadataTest.php
M tests/phpunit/Checker/QualifierChecker/QualifierCheckerTest.php
M tests/phpunit/Checker/RangeChecker/RangeCheckerHelperTest.php
M tests/phpunit/Checker/RangeChecker/RangeCheckerTest.php
M tests/phpunit/Checker/ReferenceCheckerTest.php
M tests/phpunit/Checker/TypeChecker/TypeCheckerHelperTest.php
M tests/phpunit/Checker/ValueOnlyCheckerTest.php
M tests/phpunit/Helper/LoggingHelperTest.php
M tests/phpunit/Helper/SparqlHelperTest.php
M tests/phpunit/Specials/SpecialConstraintReportTest.php
M tests/phpunit/WikibaseQualityConstraintsHooksTest.php
11 files changed, 32 insertions(+), 32 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/24/405724/1

diff --git a/tests/phpunit/Cache/CachingMetadataTest.php 
b/tests/phpunit/Cache/CachingMetadataTest.php
index 7d35290..8fee5dd 100644
--- a/tests/phpunit/Cache/CachingMetadataTest.php
+++ b/tests/phpunit/Cache/CachingMetadataTest.php
@@ -118,7 +118,7 @@
        }
 
        /**
-        * @dataProvider arrayRoundTripProvider
+        * @dataProvider provideCachingMetadata
         */
        public function testOfArray_RoundTrip( CachingMetadata $cm ) {
                $array = $cm->toArray();
@@ -127,7 +127,7 @@
                $this->assertEquals( $cm, $cm_ );
        }
 
-       public function arrayRoundTripProvider() {
+       public function provideCachingMetadata() {
                return [
                        [ CachingMetadata::fresh() ],
                        [ CachingMetadata::ofMaximumAgeInSeconds( 52 ) ],
diff --git a/tests/phpunit/Checker/QualifierChecker/QualifierCheckerTest.php 
b/tests/phpunit/Checker/QualifierChecker/QualifierCheckerTest.php
index 0d6796b..4cdc91b 100644
--- a/tests/phpunit/Checker/QualifierChecker/QualifierCheckerTest.php
+++ b/tests/phpunit/Checker/QualifierChecker/QualifierCheckerTest.php
@@ -37,7 +37,7 @@
        /**
         * @param string $type context type
         * @param string|null $messageKey key of violation message, or null if 
compliance is expected
-        * @dataProvider contextTypes
+        * @dataProvider provideContextTypes
         */
        public function testQualifierConstraint( $type, $messageKey ) {
                $context = $this->getMock( Context::class );
@@ -54,7 +54,7 @@
                }
        }
 
-       public function contextTypes() {
+       public function provideContextTypes() {
                return [
                        [ Context::TYPE_STATEMENT, 
'wbqc-violation-message-qualifier' ],
                        [ Context::TYPE_QUALIFIER, null ],
diff --git a/tests/phpunit/Checker/RangeChecker/RangeCheckerHelperTest.php 
b/tests/phpunit/Checker/RangeChecker/RangeCheckerHelperTest.php
index 32053bf..67caac5 100644
--- a/tests/phpunit/Checker/RangeChecker/RangeCheckerHelperTest.php
+++ b/tests/phpunit/Checker/RangeChecker/RangeCheckerHelperTest.php
@@ -41,7 +41,7 @@
        }
 
        /**
-        * @dataProvider getComparisonProvider
+        * @dataProvider provideComparisons
         */
        public function testGetComparison( $expected, DataValue $lhs, DataValue 
$rhs ) {
                $this->assertContains( $expected, [ -1, 0, 1 ], '$expected must 
be -1, 0, or 1' );
@@ -60,7 +60,7 @@
                }
        }
 
-       public function getComparisonProvider() {
+       public function provideComparisons() {
                $cases = [
                        [ -1, $this->getTimeValue( 1970 ), $this->getTimeValue( 
1971 ) ],
                        [ 0, $this->getTimeValue( 1970 ), $this->getTimeValue( 
1970 ) ],
@@ -80,7 +80,7 @@
        }
 
        /**
-        * @dataProvider getDifferenceProvider
+        * @dataProvider provideDifferences
         */
        public function testGetDifference( $expected, DataValue $minuend, 
DataValue $subtrahend ) {
                $rangeCheckHelper = $this->getRangeCheckerHelper();
@@ -89,7 +89,7 @@
                $this->assertSame( (float)$expected, $actual );
        }
 
-       public function getDifferenceProvider() {
+       public function provideDifferences() {
                $secondsPerYear = 60 * 60 * 24 * 365;
                $secondsPerLeapYear = 60 * 60 * 24 * 366;
                $cases = [
@@ -144,7 +144,7 @@
        }
 
        /**
-        * @dataProvider getDifferenceInYearsProvider
+        * @dataProvider provideDifferencesInYears
         */
        public function testGetDifferenceInYears(
                $minExpected,
@@ -162,7 +162,7 @@
                $this->assertLessThanOrEqual( $maxExpected, $actual );
        }
 
-       public function getDifferenceInYearsProvider() {
+       public function provideDifferencesInYears() {
                $spring74 = $this->getTimeValue( 1974, 04, 01 );
                $fall74 = $this->getTimeValue( 1974, 10, 01 );
                $spring75 = $this->getTimeValue( 1975, 04, 01 );
diff --git a/tests/phpunit/Checker/RangeChecker/RangeCheckerTest.php 
b/tests/phpunit/Checker/RangeChecker/RangeCheckerTest.php
index 3b62096..2fc2f98 100644
--- a/tests/phpunit/Checker/RangeChecker/RangeCheckerTest.php
+++ b/tests/phpunit/Checker/RangeChecker/RangeCheckerTest.php
@@ -310,7 +310,7 @@
        }
 
        /**
-        * @dataProvider propertyIdProvider
+        * @dataProvider providePropertyIds
         */
        public function testCheckConstraintParameters( $propertyId ) {
                $constraint = $this->getConstraintMock( [], $propertyId );
@@ -320,7 +320,7 @@
                $this->assertCount( 1, $result );
        }
 
-       public function propertyIdProvider() {
+       public function providePropertyIds() {
                return [ [ 'P1' ], [ 'P2' ] ];
        }
 
diff --git a/tests/phpunit/Checker/ReferenceCheckerTest.php 
b/tests/phpunit/Checker/ReferenceCheckerTest.php
index ab6fb56..f910d29 100644
--- a/tests/phpunit/Checker/ReferenceCheckerTest.php
+++ b/tests/phpunit/Checker/ReferenceCheckerTest.php
@@ -25,7 +25,7 @@
        /**
         * @param string $type context type
         * @param string|null $messageKey key of violation message, or null if 
compliance is expected
-        * @dataProvider contextTypes
+        * @dataProvider provideContextTypes
         */
        public function testReferenceConstraint( $type, $messageKey ) {
                $context = $this->getMock( Context::class );
@@ -42,7 +42,7 @@
                }
        }
 
-       public function contextTypes() {
+       public function provideContextTypes() {
                return [
                        [ Context::TYPE_STATEMENT, 
'wbqc-violation-message-reference' ],
                        [ Context::TYPE_QUALIFIER, 
'wbqc-violation-message-reference' ],
diff --git a/tests/phpunit/Checker/TypeChecker/TypeCheckerHelperTest.php 
b/tests/phpunit/Checker/TypeChecker/TypeCheckerHelperTest.php
index 23360f2..b2e2d73 100644
--- a/tests/phpunit/Checker/TypeChecker/TypeCheckerHelperTest.php
+++ b/tests/phpunit/Checker/TypeChecker/TypeCheckerHelperTest.php
@@ -123,7 +123,7 @@
         * @param string|null $secondRelation 'instance' or 'subclass'
         * @param string $class item ID serialization
         * @param bool $expected
-        * @dataProvider getInstanceOrSubclassOfProvider
+        * @dataProvider provideRelations
         */
        public function testHasClassInRelation_InstanceOrSubclassOf(
                $firstRelation,
@@ -166,7 +166,7 @@
                $this->assertSame( $expected, $result->getBool() );
        }
 
-       public function getInstanceOrSubclassOfProvider() {
+       public function provideRelations() {
                return [
                        'direct instance' => [ 'instance', null, 'Q1', true ],
                        'direct subclass' => [ 'subclass', null, 'Q1', true ],
diff --git a/tests/phpunit/Checker/ValueOnlyCheckerTest.php 
b/tests/phpunit/Checker/ValueOnlyCheckerTest.php
index 562bd89..5e4e5d1 100644
--- a/tests/phpunit/Checker/ValueOnlyCheckerTest.php
+++ b/tests/phpunit/Checker/ValueOnlyCheckerTest.php
@@ -25,7 +25,7 @@
        /**
         * @param string $type context type
         * @param string|null $messageKey key of violation message, or null if 
compliance is expected
-        * @dataProvider contextTypes
+        * @dataProvider provideContextTypes
         */
        public function testValueOnlyConstraint( $type, $messageKey ) {
                $context = $this->getMock( Context::class );
@@ -42,7 +42,7 @@
                }
        }
 
-       public function contextTypes() {
+       public function provideContextTypes() {
                return [
                        [ Context::TYPE_STATEMENT, null ],
                        [ Context::TYPE_QUALIFIER, 
'wbqc-violation-message-valueOnly' ],
diff --git a/tests/phpunit/Helper/LoggingHelperTest.php 
b/tests/phpunit/Helper/LoggingHelperTest.php
index eff3798..f34b83f 100644
--- a/tests/phpunit/Helper/LoggingHelperTest.php
+++ b/tests/phpunit/Helper/LoggingHelperTest.php
@@ -24,7 +24,7 @@
 class LoggingHelperTest extends \PHPUnit_Framework_TestCase {
 
        /**
-        * @dataProvider logLongConstraintProvider
+        * @dataProvider provideConstraintCheckDurationsAndLogLevels
         */
        public function testLogConstraintCheck( $durationSeconds, 
$expectedLevel, $expectedLimit ) {
                $statement = NewStatement::noValueFor( 'P1' )->build();
@@ -91,7 +91,7 @@
                );
        }
 
-       public function logLongConstraintProvider() {
+       public function provideConstraintCheckDurationsAndLogLevels() {
                return [
                        'short constraint check, nothing to log' => [ 0.5, 
null, null ],
                        'long but not extremely long constraint check, log as 
info' => [ 5.0, 'info', 1.0 ],
diff --git a/tests/phpunit/Helper/SparqlHelperTest.php 
b/tests/phpunit/Helper/SparqlHelperTest.php
index b051acd..42da07b 100644
--- a/tests/phpunit/Helper/SparqlHelperTest.php
+++ b/tests/phpunit/Helper/SparqlHelperTest.php
@@ -142,7 +142,7 @@
        }
 
        /**
-        * @dataProvider findEntitiesQualifierReferenceProvider
+        * @dataProvider provideSnaksWithSparqlValuesAndPropertyPaths
         */
        public function testFindEntitiesWithSameQualifierOrReference(
                PropertyValueSnak $snak,
@@ -202,7 +202,7 @@
                );
        }
 
-       public function findEntitiesQualifierReferenceProvider() {
+       public function provideSnaksWithSparqlValuesAndPropertyPaths() {
                $pid = new PropertyId( 'P1' );
                $globeCoordinateValue = new GlobeCoordinateValue( new 
LatLongValue( 42.0, 13.37 ) );
                $quantityValue = UnboundedQuantityValue::newFromNumber( -10, 
'ms' );
@@ -353,7 +353,7 @@
        }
 
        /**
-        * @dataProvider isTimeoutProvider
+        * @dataProvider provideTimeoutMessages
         */
        public function testIsTimeout( $content, $expected ) {
                $sparqlHelper = new SparqlHelper(
@@ -399,7 +399,7 @@
                $this->assertTrue( $actual );
        }
 
-       public function isTimeoutProvider() {
+       public function provideTimeoutMessages() {
                return [
                        'empty' => [
                                '',
@@ -431,7 +431,7 @@
        }
 
        /**
-        * @dataProvider getCacheMaxAgeProvider
+        * @dataProvider provideCacheHeaders
         */
         public function testGetCacheMaxAge( $responseHeaders, $expected ) {
                $sparqlHelper = new SparqlHelper(
@@ -451,7 +451,7 @@
                $this->assertSame( $expected, $actual );
         }
 
-        public function getCacheMaxAgeProvider() {
+        public function provideCacheHeaders() {
                 return [
                         'WDQS hit' => [
                                 [ 'x-cache-status' => [ 'hit-front' ], 
'cache-control' => [ 'public, max-age=300' ] ],
diff --git a/tests/phpunit/Specials/SpecialConstraintReportTest.php 
b/tests/phpunit/Specials/SpecialConstraintReportTest.php
index 704a331..42259f8 100644
--- a/tests/phpunit/Specials/SpecialConstraintReportTest.php
+++ b/tests/phpunit/Specials/SpecialConstraintReportTest.php
@@ -163,7 +163,7 @@
        }
 
        /**
-        * @dataProvider executeProvider
+        * @dataProvider provideRequestsAndMatchers
         */
        public function testExecute( $subPage, array $request, $userLanguage, 
array $matchers ) {
                $request = new \FauxRequest( $request );
@@ -184,7 +184,7 @@
                }
        }
 
-       public function executeProvider() {
+       public function provideRequestsAndMatchers() {
                $userLanguage = 'qqx';
                $cases = [];
                $matchers = [];
diff --git a/tests/phpunit/WikibaseQualityConstraintsHooksTest.php 
b/tests/phpunit/WikibaseQualityConstraintsHooksTest.php
index 3dc27f5..e3ee813 100644
--- a/tests/phpunit/WikibaseQualityConstraintsHooksTest.php
+++ b/tests/phpunit/WikibaseQualityConstraintsHooksTest.php
@@ -24,7 +24,7 @@
        use DefaultConfig;
 
        /**
-        * @dataProvider isConstraintStatementsChangeProvider
+        * @dataProvider provideChanges
         * @param Change $change
         * @param bool $expected
         */
@@ -36,7 +36,7 @@
                $this->assertSame( $expected, $actual );
        }
 
-       public function isConstraintStatementsChangeProvider() {
+       public function provideChanges() {
                $factory = TestChanges::getEntityChangeFactory();
                $changes = TestChanges::getChanges();
                $changeKeys = [];
@@ -105,7 +105,7 @@
        }
 
        /**
-        * @dataProvider isGadgetEnabledForUserNameProvider
+        * @dataProvider provideUserNamesAndDates
         * @param string $userName
         * @param int $timestamp
         * @param bool $expected
@@ -119,7 +119,7 @@
                $this->assertSame( $expected, $actual );
        }
 
-       public function isGadgetEnabledForUserNameProvider() {
+       public function provideUserNamesAndDates() {
                yield 'enabled for no one' => [ 'Z', strtotime( '2018-02-28' ), 
false ];
                yield 'enabled for Z' => [ 'Z', strtotime( '2018-03-01' ), true 
];
                yield 'not enabled for Y' => [ 'Y', strtotime( '2018-03-01' ), 
false ];

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I51f476ff74cf2abd4934f2568268b429f0c39651
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) <lucas.werkmeis...@wikimedia.de>

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

Reply via email to