Thiemo Mättig (WMDE) has uploaded a new change for review. https://gerrit.wikimedia.org/r/250446
Change subject: Split all lines longer that 132 characters ...................................................................... Split all lines longer that 132 characters I'm not touching the phpcs.xml settings in this patch on purpose. Reducing the hard line length limit should be done when all team members agree. However, I still think this patch is usefull. This will make it much, much easier to actually reduce the hard limit later. Change-Id: I3420ac8316ce2be083864b79f77e161a9b4ee227 --- M client/includes/specials/SpecialUnconnectedPages.php M client/tests/phpunit/includes/DataAccess/Scribunto/WikibaseLuaBindingsTest.php M client/tests/phpunit/includes/Usage/PageEntityUsagesTest.php M client/tests/phpunit/includes/Usage/Sql/EntityUsageTableTest.php M client/tests/phpunit/includes/Usage/UsageLookupContractTester.php M repo/includes/rdf/HashDedupeBag.php M repo/includes/rdf/SnakRdfBuilder.php M repo/maintenance/importProperties.php M repo/tests/phpunit/includes/Validators/NumberRangeValidatorTest.php M repo/tests/phpunit/includes/Validators/StringLengthValidatorTest.php M repo/tests/phpunit/includes/Validators/TermValidatorFactoryTest.php M repo/tests/phpunit/includes/api/FormatSnakValueTest.php M repo/tests/phpunit/includes/api/GetEntitiesRedirectTest.php M repo/tests/phpunit/includes/store/sql/PropertyInfoTableBuilderTest.php M repo/tests/phpunit/includes/store/sql/WikiPageEntityStoreTest.php 15 files changed, 127 insertions(+), 43 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/46/250446/1 diff --git a/client/includes/specials/SpecialUnconnectedPages.php b/client/includes/specials/SpecialUnconnectedPages.php index c69785c..9edd729 100644 --- a/client/includes/specials/SpecialUnconnectedPages.php +++ b/client/includes/specials/SpecialUnconnectedPages.php @@ -142,13 +142,19 @@ 'value' => 'page_id', 'namespace' => 'page_namespace', 'title' => 'page_title', - 'page_num_iwlinks' => '0', // placeholder, we'll get this from page_props in the future + // Placeholder, we'll get this from page_props in the future. + 'page_num_iwlinks' => '0', ), 'conds' => $conds, - 'options' => array(), // sorting is determined getOrderFields(), which returns array( 'value' ) per default. + // Sorting is determined getOrderFields(), which returns array( 'value' ) per default. + 'options' => array(), 'join_conds' => array( - // TODO: also get explicit_langlink_count from page_props once that is populated. Could even filter or sort by it via pp_sortkey. - 'page_props' => array( 'LEFT JOIN', array( 'page_id = pp_page', "pp_propname = 'wikibase_item'" ) ), + // TODO Also get explicit_langlink_count from page_props once that is populated. + // Could even filter or sort by it via pp_sortkey. + 'page_props' => array( + 'LEFT JOIN', + array( 'page_id = pp_page', "pp_propname = 'wikibase_item'" ) + ), ) ); } diff --git a/client/tests/phpunit/includes/DataAccess/Scribunto/WikibaseLuaBindingsTest.php b/client/tests/phpunit/includes/DataAccess/Scribunto/WikibaseLuaBindingsTest.php index 1424733..7ebbf94 100644 --- a/client/tests/phpunit/includes/DataAccess/Scribunto/WikibaseLuaBindingsTest.php +++ b/client/tests/phpunit/includes/DataAccess/Scribunto/WikibaseLuaBindingsTest.php @@ -100,14 +100,21 @@ $usages ); - $itemId = $wikibaseLuaBindings->getEntityId( 'Rome' ); - $this->assertEquals( 'Q33', $itemId ); + $id = $wikibaseLuaBindings->getEntityId( 'Rome' ); + $this->assertSame( 'Q33', $id ); - $this->assertTrue( $this->hasUsage( $usages->getUsages(), new ItemId( $itemId ), EntityUsage::TITLE_USAGE ), 'title usage' ); - $this->assertFalse( $this->hasUsage( $usages->getUsages(), new ItemId( $itemId ), EntityUsage::SITELINK_USAGE ), 'sitelink usage' ); + $itemId = new ItemId( $id ); + $this->assertTrue( + $this->hasUsage( $usages->getUsages(), $itemId, EntityUsage::TITLE_USAGE ), + 'title usage' + ); + $this->assertFalse( + $this->hasUsage( $usages->getUsages(), $itemId, EntityUsage::SITELINK_USAGE ), + 'sitelink usage' + ); - $itemId = $wikibaseLuaBindings->getEntityId( 'Barcelona' ); - $this->assertSame( null, $itemId ); + $id = $wikibaseLuaBindings->getEntityId( 'Barcelona' ); + $this->assertNull( $id ); } public function getLabelProvider() { diff --git a/client/tests/phpunit/includes/Usage/PageEntityUsagesTest.php b/client/tests/phpunit/includes/Usage/PageEntityUsagesTest.php index b2e09f7..2a550fa 100644 --- a/client/tests/phpunit/includes/Usage/PageEntityUsagesTest.php +++ b/client/tests/phpunit/includes/Usage/PageEntityUsagesTest.php @@ -55,10 +55,22 @@ $this->assertEquals( $expectedAspects, $pageUsages->getAspects(), 'getAspects' ); $this->assertEquals( $expectedAspectKeys, $pageUsages->getAspectKeys(), 'getAspectKeys' ); - $this->assertEquals( array( 'Q11' => $q11, 'Q7' => $q7 ), $pageUsages->getEntityIds(), 'getEntityIds' ); - $this->assertEquals( array( 'Q11#L.de', 'Q11#L.en', 'Q11#T', 'Q7#X' ), array_keys( $pageUsages->getUsages() ), 'getUsagesCallback' ); + $this->assertEquals( + array( 'Q11' => $q11, 'Q7' => $q7 ), + $pageUsages->getEntityIds(), + 'getEntityIds' + ); + $this->assertEquals( + array( 'Q11#L.de', 'Q11#L.en', 'Q11#T', 'Q7#X' ), + array_keys( $pageUsages->getUsages() ), + 'getUsagesCallback' + ); - $this->assertEquals( $expectedAspectKeysQ11, $pageUsages->getUsageAspectKeys( $q11 ), 'getUsageAspects' ); + $this->assertEquals( + $expectedAspectKeysQ11, + $pageUsages->getUsageAspectKeys( $q11 ), + 'getUsageAspects' + ); } } diff --git a/client/tests/phpunit/includes/Usage/Sql/EntityUsageTableTest.php b/client/tests/phpunit/includes/Usage/Sql/EntityUsageTableTest.php index eb46603..730d030 100644 --- a/client/tests/phpunit/includes/Usage/Sql/EntityUsageTableTest.php +++ b/client/tests/phpunit/includes/Usage/Sql/EntityUsageTableTest.php @@ -448,8 +448,16 @@ foreach ( $expected as $key => $expectedUsages ) { $actualUsages = $actual[$key]; - $this->assertEquals( $expectedUsages->getPageId(), $actualUsages->getPageId(), $message . "[Page $key] " . 'Page ID mismatches!' ); - $this->assertEquals( $expectedUsages->getUsages(), $actualUsages->getUsages(), $message . "[Page $key] " . 'Usages:' ); + $this->assertEquals( + $expectedUsages->getPageId(), + $actualUsages->getPageId(), + $message . "[Page $key] " . 'Page ID mismatches!' + ); + $this->assertEquals( + $expectedUsages->getUsages(), + $actualUsages->getUsages(), + $message . "[Page $key] " . 'Usages:' + ); } $this->assertEmpty( array_slice( $actual, count( $expected ) ), $message . 'Extra entries found!' ); diff --git a/client/tests/phpunit/includes/Usage/UsageLookupContractTester.php b/client/tests/phpunit/includes/Usage/UsageLookupContractTester.php index e518d66..44b38de 100644 --- a/client/tests/phpunit/includes/Usage/UsageLookupContractTester.php +++ b/client/tests/phpunit/includes/Usage/UsageLookupContractTester.php @@ -140,8 +140,16 @@ Assert::assertArrayHasKey( $key, $actual, 'Page ID' ); $actualUsages = $actual[$key]; - Assert::assertEquals( $expectedUsages->getPageId(), $actualUsages->getPageId(), $message . "[Page $key] " . 'Page ID mismatches!' ); - Assert::assertEquals( $expectedUsages->getUsages(), $actualUsages->getUsages(), $message . "[Page $key] " . 'Usages:' ); + Assert::assertEquals( + $expectedUsages->getPageId(), + $actualUsages->getPageId(), + $message . "[Page $key] " . 'Page ID mismatches!' + ); + Assert::assertEquals( + $expectedUsages->getUsages(), + $actualUsages->getUsages(), + $message . "[Page $key] " . 'Usages:' + ); } Assert::assertEmpty( array_slice( $actual, count( $expected ) ), $message . 'Extra entries found!' ); diff --git a/repo/includes/rdf/HashDedupeBag.php b/repo/includes/rdf/HashDedupeBag.php index 1e6cce8..c2fdbb7 100644 --- a/repo/includes/rdf/HashDedupeBag.php +++ b/repo/includes/rdf/HashDedupeBag.php @@ -9,8 +9,10 @@ * as a hash that just evicts old values when a collision occurs. * * The idea for this implementation was taken mainly from from blog posts: - * - "The Invertible Bloom Filter" by Mike James http://www.i-programmer.info/programming/theory/4641-the-invertible-bloom-filter.html - * - "The Opposite of a Bloom Filter" by Jeff Hodges http://www.somethingsimilar.com/2012/05/21/the-opposite-of-a-bloom-filter/ + * - "The Invertible Bloom Filter" by Mike James + * http://www.i-programmer.info/programming/theory/4641-the-invertible-bloom-filter.html + * - "The Opposite of a Bloom Filter" by Jeff Hodges + * http://www.somethingsimilar.com/2012/05/21/the-opposite-of-a-bloom-filter/ * * The implementation of alreadySeen() works as follows: * diff --git a/repo/includes/rdf/SnakRdfBuilder.php b/repo/includes/rdf/SnakRdfBuilder.php index 6ddb205..6c5885d 100644 --- a/repo/includes/rdf/SnakRdfBuilder.php +++ b/repo/includes/rdf/SnakRdfBuilder.php @@ -47,7 +47,11 @@ * @param DataValueRdfBuilder $valueBuilder * @param PropertyDataTypeLookup $propertyLookup */ - public function __construct( RdfVocabulary $vocabulary, DataValueRdfBuilder $valueBuilder, PropertyDataTypeLookup $propertyLookup ) { + public function __construct( + RdfVocabulary $vocabulary, + DataValueRdfBuilder $valueBuilder, + PropertyDataTypeLookup $propertyLookup + ) { $this->vocabulary = $vocabulary; $this->valueBuilder = $valueBuilder; $this->propertyLookup = $propertyLookup; diff --git a/repo/maintenance/importProperties.php b/repo/maintenance/importProperties.php index 84490b1..87d3405 100644 --- a/repo/maintenance/importProperties.php +++ b/repo/maintenance/importProperties.php @@ -12,11 +12,13 @@ /** * Maintenance script for importing properties in Wikidata. * - * For using it with the included en-elements-properties.csv and fill the database with properties of chemical elements, use it thusly: + * For using it with the included en-elements-properties.csv and fill the database with properties + * of chemical elements, use it thusly: * * php importInterlang.php --verbose --ignore-errors en en-elements-properties.csv * - * For now, this script is little more than a copy of importInterlang.php. Once we have more interesting properties, this will change. + * For now, this script is little more than a copy of importInterlang.php. Once we have more + * interesting properties, this will change. * * @since 0.1 * diff --git a/repo/tests/phpunit/includes/Validators/NumberRangeValidatorTest.php b/repo/tests/phpunit/includes/Validators/NumberRangeValidatorTest.php index 31ef910..e2a17f2 100644 --- a/repo/tests/phpunit/includes/Validators/NumberRangeValidatorTest.php +++ b/repo/tests/phpunit/includes/Validators/NumberRangeValidatorTest.php @@ -40,7 +40,10 @@ if ( !$expected ) { $errors = $result->getErrors(); $this->assertCount( 1, $errors, $message ); - $this->assertTrue( in_array( $errors[0]->getCode(), array( 'too-low', 'too-high' ) ), $message . "\n" . $errors[0]->getCode() ); + $this->assertTrue( + in_array( $errors[0]->getCode(), array( 'too-low', 'too-high' ) ), + $message . "\n" . $errors[0]->getCode() + ); $localizer = new ValidatorErrorLocalizer(); $msg = $localizer->getErrorMessage( $errors[0] ); diff --git a/repo/tests/phpunit/includes/Validators/StringLengthValidatorTest.php b/repo/tests/phpunit/includes/Validators/StringLengthValidatorTest.php index 49d2321..aeada93 100644 --- a/repo/tests/phpunit/includes/Validators/StringLengthValidatorTest.php +++ b/repo/tests/phpunit/includes/Validators/StringLengthValidatorTest.php @@ -41,7 +41,10 @@ if ( !$expected ) { $errors = $result->getErrors(); $this->assertCount( 1, $errors, $message ); - $this->assertTrue( in_array( $errors[0]->getCode(), array( 'too-long', 'too-short' ) ), $message . "\n" . $errors[0]->getCode() ); + $this->assertTrue( + in_array( $errors[0]->getCode(), array( 'too-long', 'too-short' ) ), + $message . "\n" . $errors[0]->getCode() + ); $localizer = new ValidatorErrorLocalizer(); $msg = $localizer->getErrorMessage( $errors[0] ); diff --git a/repo/tests/phpunit/includes/Validators/TermValidatorFactoryTest.php b/repo/tests/phpunit/includes/Validators/TermValidatorFactoryTest.php index 7c28ac6..bda1dca 100644 --- a/repo/tests/phpunit/includes/Validators/TermValidatorFactoryTest.php +++ b/repo/tests/phpunit/includes/Validators/TermValidatorFactoryTest.php @@ -69,8 +69,14 @@ $q99 = new ItemId( 'Q99' ); - $this->assertTrue( $validator->validateFingerprint( $goodFingerprint, $q99 )->isValid(), 'isValid(good)' ); - $this->assertFalse( $validator->validateFingerprint( $labelDupeFingerprint, $q99 )->isValid(), 'isValid(bad): label/description' ); + $this->assertTrue( + $validator->validateFingerprint( $goodFingerprint, $q99 )->isValid(), + 'isValid(good)' + ); + $this->assertFalse( + $validator->validateFingerprint( $labelDupeFingerprint, $q99 )->isValid(), + 'isValid(bad): label/description' + ); } public function testGetLanguageValidator() { diff --git a/repo/tests/phpunit/includes/api/FormatSnakValueTest.php b/repo/tests/phpunit/includes/api/FormatSnakValueTest.php index 15df8b0..217b4d3 100644 --- a/repo/tests/phpunit/includes/api/FormatSnakValueTest.php +++ b/repo/tests/phpunit/includes/api/FormatSnakValueTest.php @@ -116,7 +116,8 @@ 'wikibase-item', SnakFormatter::FORMAT_HTML, null, - '/^Q404' . $wordSeparator . '<span class="wb-entity-undefinedinfo">\(' . preg_quote( $deletedItem, '/' ) . '\)<\/span>$/' + '/^Q404' . $wordSeparator . '<span class="wb-entity-undefinedinfo">\(' + . preg_quote( $deletedItem, '/' ) . '\)<\/span>$/' ), array( new EntityIdValue( new ItemId( 'Q23' ) ), @@ -130,7 +131,8 @@ 'wikibase-item', SnakFormatter::FORMAT_HTML, array( 'lang' => 'de-ch' ), // fallback - '/^<a title="[^"]*Q23" href="[^"]+Q23" lang="en">George Washington<\/a><sup class="wb-language-fallback-indicator">[^<>]+<\/sup>$/' + '/^<a title="[^"]*Q23" href="[^"]+Q23" lang="en">George Washington<\/a>' + . '<sup class="wb-language-fallback-indicator">[^<>]+<\/sup>$/' ), // @TODO: Test an existing Item id diff --git a/repo/tests/phpunit/includes/api/GetEntitiesRedirectTest.php b/repo/tests/phpunit/includes/api/GetEntitiesRedirectTest.php index fbab918..0ba37ad 100644 --- a/repo/tests/phpunit/includes/api/GetEntitiesRedirectTest.php +++ b/repo/tests/phpunit/includes/api/GetEntitiesRedirectTest.php @@ -67,9 +67,12 @@ list( $result,, ) = $this->doApiRequest( $params, null, false, $user ); $this->assertArrayHasKey( 'entities', $result ); - $this->assertArrayHasKey( $redirectKey, $result['entities'], 'the id from the request should be used as a key in the result' ); - $this->assertArrayNotHasKey( $targetKey, $result['entities'], 'the id from the request should be used as a key in the result' ); - $this->assertArrayHasKey( 'labels', $result['entities'][$redirectKey], 'the redirect should be resolve to a full entity' ); + $this->assertArrayHasKey( $redirectKey, $result['entities'], + 'the id from the request should be used as a key in the result' ); + $this->assertArrayNotHasKey( $targetKey, $result['entities'], + 'the id from the request should be used as a key in the result' ); + $this->assertArrayHasKey( 'labels', $result['entities'][$redirectKey], + 'the redirect should be resolve to a full entity' ); $this->assertEquals( $targetKey, $result['entities'][$redirectKey]['id'], @@ -81,15 +84,19 @@ list( $result,, ) = $this->doApiRequest( $params, null, false, $user ); $this->assertArrayHasKey( 'entities', $result ); - $this->assertArrayHasKey( $doubleRedirectKey, $result['entities'], 'the id from the request should be used as a key in the result' ); - $this->assertArrayNotHasKey( $redirectKey, $result['entities'], 'the id from the request should be used as a key in the result' ); + $this->assertArrayHasKey( $doubleRedirectKey, $result['entities'], + 'the id from the request should be used as a key in the result' ); + $this->assertArrayNotHasKey( $redirectKey, $result['entities'], + 'the id from the request should be used as a key in the result' ); $this->assertEquals( $doubleRedirectKey, $result['entities'][$doubleRedirectKey]['id'], 'the reported entitiy id should be the id of the redirect' ); - $this->assertArrayHasKey( 'missing', $result['entities'][$doubleRedirectKey], 'the entity should be labeled as missing' ); - $this->assertArrayNotHasKey( 'labels', $result['entities'][$doubleRedirectKey], 'the unresolved redirect should not have labels' ); + $this->assertArrayHasKey( 'missing', $result['entities'][$doubleRedirectKey], + 'the entity should be labeled as missing' ); + $this->assertArrayNotHasKey( 'labels', $result['entities'][$doubleRedirectKey], + 'the unresolved redirect should not have labels' ); // if redirect resolution is disabled, the redirect should be treated like a missing entity $params['redirects'] = 'no'; @@ -97,15 +104,19 @@ list( $result,, ) = $this->doApiRequest( $params, null, false, $user ); $this->assertArrayHasKey( 'entities', $result ); - $this->assertArrayHasKey( $redirectKey, $result['entities'], 'the id from the request should be used as a key in the result' ); - $this->assertArrayNotHasKey( $targetKey, $result['entities'], 'the id from the request should be used as a key in the result' ); + $this->assertArrayHasKey( $redirectKey, $result['entities'], + 'the id from the request should be used as a key in the result' ); + $this->assertArrayNotHasKey( $targetKey, $result['entities'], + 'the id from the request should be used as a key in the result' ); $this->assertEquals( $redirectKey, $result['entities'][$redirectKey]['id'], 'the reported entitiy id should be the id of the redirect' ); - $this->assertArrayHasKey( 'missing', $result['entities'][$redirectKey], 'the entity should be labeled as missing' ); - $this->assertArrayNotHasKey( 'labels', $result['entities'][$redirectKey], 'the unresolved redirect should not have labels' ); + $this->assertArrayHasKey( 'missing', $result['entities'][$redirectKey], + 'the entity should be labeled as missing' ); + $this->assertArrayNotHasKey( 'labels', $result['entities'][$redirectKey], + 'the unresolved redirect should not have labels' ); } } diff --git a/repo/tests/phpunit/includes/store/sql/PropertyInfoTableBuilderTest.php b/repo/tests/phpunit/includes/store/sql/PropertyInfoTableBuilderTest.php index b0973fe..04ab8ae 100644 --- a/repo/tests/phpunit/includes/store/sql/PropertyInfoTableBuilderTest.php +++ b/repo/tests/phpunit/includes/store/sql/PropertyInfoTableBuilderTest.php @@ -128,10 +128,17 @@ private function assertTableHasProperties( array $properties, PropertyInfoTable $table ) { foreach ( $properties as $propId => $expected ) { $info = $table->getPropertyInfo( new PropertyId( $propId ) ); - $this->assertEquals( $expected[PropertyInfoStore::KEY_DATA_TYPE], $info[PropertyInfoStore::KEY_DATA_TYPE], "Property $propId" ); + $this->assertEquals( + $expected[PropertyInfoStore::KEY_DATA_TYPE], + $info[PropertyInfoStore::KEY_DATA_TYPE], + "Property $propId" + ); if ( isset( $expected[PropertyInfoStore::KEY_FORMATTER_URL] ) ) { - $this->assertEquals( $expected[PropertyInfoStore::KEY_FORMATTER_URL], $info[PropertyInfoStore::KEY_FORMATTER_URL] ); + $this->assertEquals( + $expected[PropertyInfoStore::KEY_FORMATTER_URL], + $info[PropertyInfoStore::KEY_FORMATTER_URL] + ); } else { $this->assertArrayNotHasKey( PropertyInfoStore::KEY_FORMATTER_URL, $info ); } diff --git a/repo/tests/phpunit/includes/store/sql/WikiPageEntityStoreTest.php b/repo/tests/phpunit/includes/store/sql/WikiPageEntityStoreTest.php index 9200b77..1b24807 100644 --- a/repo/tests/phpunit/includes/store/sql/WikiPageEntityStoreTest.php +++ b/repo/tests/phpunit/includes/store/sql/WikiPageEntityStoreTest.php @@ -538,8 +538,11 @@ $store->deleteEntity( $entityId, 'testing', $user ); // check that it's gone - $this->assertFalse( $lookup->getLatestRevisionId( $entityId, EntityRevisionLookup::LATEST_FROM_MASTER ), 'getLatestRevisionId()' ); - $this->assertNull( $lookup->getEntityRevision( $entityId ), 'getEntityRevision()' ); + $this->assertFalse( + $lookup->getLatestRevisionId( $entityId, EntityRevisionLookup::LATEST_FROM_MASTER ), + 'getLatestRevisionId' + ); + $this->assertNull( $lookup->getEntityRevision( $entityId ), 'getEntityRevision' ); // check that the term index got updated (via a DataUpdate). $termIndex = WikibaseRepo::getDefaultInstance()->getStore()->getTermIndex(); -- To view, visit https://gerrit.wikimedia.org/r/250446 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3420ac8316ce2be083864b79f77e161a9b4ee227 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits