diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 0d6d755..e52659d 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -13,18 +13,6 @@ jobs:
fail-fast: false
matrix:
include:
- - mw: 'REL1_39'
- php: 8.0
- experimental: false
- - mw: 'REL1_40'
- php: 8.1
- experimental: false
- - mw: 'REL1_41'
- php: 8.2
- experimental: false
- - mw: 'REL1_42'
- php: 8.2
- experimental: false
- mw: 'REL1_43'
php: 8.3
experimental: false
diff --git a/README.md b/README.md
index 189fde4..8090c8d 100644
--- a/README.md
+++ b/README.md
@@ -40,9 +40,9 @@ For more information, refer to the [REST API documentation].
Platform requirements:
-* [PHP] 8.0 or later (tested up to 8.4)
-* [MediaWiki] 1.37 or later (tested up to 1.43) (versions 1.37 and 1.38 require Wikibase Export 1.0.0)
-* [Wikibase] 1.37 or later (tested up to 1.43)
+* [PHP] 8.1 or later (tested up to 8.4)
+* [MediaWiki] 1.43 or later (tested up to 1.43)
+* [Wikibase] 1.43 or later (tested up to 1.43)
The recommended way to install Wikibase Export is using [Composer] with
[MediaWiki's built-in support for Composer][Composer install].
diff --git a/composer.json b/composer.json
index a9dea82..81e4ad4 100644
--- a/composer.json
+++ b/composer.json
@@ -18,7 +18,6 @@
}
],
"require": {
- "php": ">=8.0",
"composer/installers": "^2|^1.0.1",
"opis/json-schema": "^2.3.0",
"wmde/clock": "^1.0.0"
@@ -26,7 +25,7 @@
"require-dev": {
"vimeo/psalm": "^4.30.0",
"phpstan/phpstan": "^1.8.11",
- "mediawiki/mediawiki-codesniffer": "^40.0.0"
+ "mediawiki/mediawiki-codesniffer": "^52.0.0"
},
"extra": {
"installer-name": "WikibaseExport"
diff --git a/extension.json b/extension.json
index 670016c..939ca0c 100644
--- a/extension.json
+++ b/extension.json
@@ -17,7 +17,7 @@
"descriptionmsg": "wikibase-export-description",
"requires": {
- "MediaWiki": ">= 1.39.0",
+ "MediaWiki": ">= 1.43.0",
"extensions": {
"WikibaseRepository": "*"
}
@@ -38,7 +38,7 @@
"AlternateEdit": "ProfessionalWiki\\WikibaseExport\\EntryPoints\\MediaWikiHooks::onAlternateEdit",
"BeforePageDisplay": "ProfessionalWiki\\WikibaseExport\\EntryPoints\\MediaWikiHooks::onBeforePageDisplay",
"ContentHandlerDefaultModelFor": "ProfessionalWiki\\WikibaseExport\\EntryPoints\\MediaWikiHooks::onContentHandlerDefaultModelFor",
- "EditFilter": "ProfessionalWiki\\WikibaseExport\\EntryPoints\\MediaWikiHooks::onEditFilter",
+ "EditFilterMergedContent": "ProfessionalWiki\\WikibaseExport\\EntryPoints\\MediaWikiHooks::onEditFilterMergedContent",
"EditFormPreloadText": "ProfessionalWiki\\WikibaseExport\\EntryPoints\\MediaWikiHooks::onEditFormPreloadText"
},
diff --git a/i18n/en.json b/i18n/en.json
index 3951186..38f27c1 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -27,7 +27,7 @@
"wikibase-export-config-header-label": "Property Label (e.g. \"Operating revenue 2022\")",
"wikibase-export-download": "Download",
- "wikibase-export-config-invalid": "Your changes were not saved. They contain the following {{PLURAL:$1|error|errors}}:",
+ "wikibase-export-config-invalid-errors": "Your changes were not saved. They contain the following {{PLURAL:$1|error|errors}}:$2",
"wikibase-export-config-incomplete": "An administrator needs to configure Wikibase Export before it can be used.",
"wikibase-export-config-incomplete-link": "You can [[MediaWiki:WikibaseExport|configure this form]].",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 1707112..e9622c4 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -28,7 +28,7 @@
"wikibase-export-config-header-id": "This is the text of an option.",
"wikibase-export-config-header-label": "This is the text of an option.",
"wikibase-export-download": "This is the text on a button. Used for $1 in {{Msg-mw|Wikibase-export-intro}}",
- "wikibase-export-config-invalid": "Error message shown when attempting to save invalid configuration on MediaWiki:WikibaseExport",
+ "wikibase-export-config-invalid-errors": "Error message shown when attempting to save invalid configuration on MediaWiki:WikibaseExport.\n\nParameters:\n* $1 - Number of errors\n* $2 - Table listing each error",
"wikibase-export-config-incomplete": "Error message shown on \"Special:WikibaseExport\" when required configuration is incomplete.",
"wikibase-export-config-incomplete-link": "Config page link shown on \"Special:WikibaseExport\" when required configuration is incomplete.",
"wikibase-export-config-help-documentation": "Link to documentation displayed on \"MediaWiki:WikibaseExport\"",
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index 7c3f895..7231ebd 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -16,16 +16,16 @@ parameters:
path: src/Presentation/WideCsvPresenter.php
-
- message: "#^Cannot cast mixed to string\\.$#"
+ message: "#^Call to function method_exists\\(\\) with 'Wikibase\\\\\\\\Repo\\\\\\\\Domains\\\\\\\\Search\\\\\\\\WbSearch' and 'getItemSearchHelper' will always evaluate to false\\.$#"
count: 1
path: src/WikibaseExportExtension.php
-
- message: "#^If condition is always true\\.$#"
+ message: "#^Class Wikibase\\\\Repo\\\\Domains\\\\Search\\\\WbSearch not found\\.$#"
count: 1
- path: src/EntryPoints/SpecialWikibaseExport.php
+ path: src/WikibaseExportExtension.php
-
- message: "#^If condition is always true\\.$#"
+ message: "#^Cannot cast mixed to string\\.$#"
count: 1
- path: src/EntryPoints/SpecialWikibaseExportConfig.php
+ path: src/WikibaseExportExtension.php
diff --git a/psalm-baseline.xml b/psalm-baseline.xml
index 019ed71..ebe1a64 100644
--- a/psalm-baseline.xml
+++ b/psalm-baseline.xml
@@ -7,17 +7,6 @@
array_map
-
-
- profileContext
-
-
- MW_VERSION
-
-
- getRankedSearchResults
-
-
$key
@@ -28,4 +17,16 @@
isset( $this->stream )
+
+
+ WbSearch::class
+
+
+ EntitySearchHelper
+
+
+ WbSearch
+ WbSearch
+
+
diff --git a/src/Application/Export/EntityMapper.php b/src/Application/Export/EntityMapper.php
index bbdd1f9..789bd0f 100644
--- a/src/Application/Export/EntityMapper.php
+++ b/src/Application/Export/EntityMapper.php
@@ -56,7 +56,7 @@ private function buildValueSetList( EntityDocument $entity ): ValueSetList {
}
return new ValueSetList(
- array_merge( ...array_map( fn( ValueSetList $l ) => $l->sets, $lists ) )
+ array_merge( ...array_map( static fn ( ValueSetList $l ) => $l->sets, $lists ) )
);
}
diff --git a/src/Application/Export/ExportUseCase.php b/src/Application/Export/ExportUseCase.php
index e0ce222..e5d17ed 100644
--- a/src/Application/Export/ExportUseCase.php
+++ b/src/Application/Export/ExportUseCase.php
@@ -80,7 +80,7 @@ private function exportHeaders( StatementsMapper ...$mappers ): void {
$this->presenter->presentExportStarted(
array_reduce(
$mappers,
- fn( ColumnHeaders $c, StatementsMapper $mapper ) => $c->plus( $mapper->createColumnHeaders() ),
+ static fn ( ColumnHeaders $c, StatementsMapper $mapper ) => $c->plus( $mapper->createColumnHeaders() ),
new ColumnHeaders()
)
);
diff --git a/src/Application/PropertyIdList.php b/src/Application/PropertyIdList.php
index 787758e..3bacfc8 100644
--- a/src/Application/PropertyIdList.php
+++ b/src/Application/PropertyIdList.php
@@ -27,10 +27,10 @@ public function __construct( array $ids = [] ) {
public function intersect( self $ids ): self {
return new self(
array_map(
- fn ( string $id ) => new NumericPropertyId( $id ),
+ static fn ( string $id ) => new NumericPropertyId( $id ),
array_intersect(
- array_map( fn( PropertyId $id ) => $id->getSerialization(), $this->ids ),
- array_map( fn( PropertyId $id ) => $id->getSerialization(), $ids->ids ),
+ array_map( static fn ( PropertyId $id ) => $id->getSerialization(), $this->ids ),
+ array_map( static fn ( PropertyId $id ) => $id->getSerialization(), $ids->ids ),
)
)
);
diff --git a/src/Application/PropertyIdListParser.php b/src/Application/PropertyIdListParser.php
index fac4777..7db1c9a 100644
--- a/src/Application/PropertyIdListParser.php
+++ b/src/Application/PropertyIdListParser.php
@@ -22,8 +22,7 @@ public function parse( array $idStrings ): PropertyIdList {
foreach ( $idStrings as $idString ) {
try {
$ids[] = new NumericPropertyId( $idString );
- }
- catch ( \InvalidArgumentException ) {
+ } catch ( \InvalidArgumentException ) {
}
}
diff --git a/src/EntryPoints/ExportApi.php b/src/EntryPoints/ExportApi.php
index c8c4c83..d9913e1 100644
--- a/src/EntryPoints/ExportApi.php
+++ b/src/EntryPoints/ExportApi.php
@@ -77,8 +77,7 @@ private function parseIds( array $ids ): array {
foreach ( $ids as $id ) {
try {
$idObjects[] = $parser->parse( $id );
- }
- catch ( EntityIdParsingException ) {
+ } catch ( EntityIdParsingException ) {
}
}
diff --git a/src/EntryPoints/MediaWikiHooks.php b/src/EntryPoints/MediaWikiHooks.php
index cddfb72..9590bbb 100644
--- a/src/EntryPoints/MediaWikiHooks.php
+++ b/src/EntryPoints/MediaWikiHooks.php
@@ -4,14 +4,19 @@
namespace ProfessionalWiki\WikibaseExport\EntryPoints;
-use EditPage;
-use OutputPage;
+use MediaWiki\Content\Content;
+use MediaWiki\Context\IContextSource;
+use MediaWiki\EditPage\EditPage;
+use MediaWiki\Message\Message;
+use MediaWiki\Output\OutputPage;
+use MediaWiki\Status\Status;
+use MediaWiki\Title\Title;
+use MediaWiki\User\User;
use ProfessionalWiki\WikibaseExport\Persistence\ConfigJsonValidator;
use ProfessionalWiki\WikibaseExport\Presentation\ConfigJsonErrorFormatter;
use ProfessionalWiki\WikibaseExport\Presentation\ExportConfigEditPageTextBuilder;
use ProfessionalWiki\WikibaseExport\WikibaseExportExtension;
use Skin;
-use Title;
class MediaWikiHooks {
@@ -21,18 +26,28 @@ public static function onContentHandlerDefaultModelFor( Title $title, ?string &$
}
}
- public static function onEditFilter( EditPage $editPage, ?string $text, ?string $section, string &$error ): void {
- if ( !is_string( $text ) || !WikibaseExportExtension::getInstance()->isConfigTitle( $editPage->getTitle() ) ) {
+ public static function onEditFilterMergedContent(
+ IContextSource $context,
+ Content $content,
+ Status $status,
+ string $summary,
+ User $user,
+ bool $minorEdit
+ ): void {
+ $title = $context->getTitle();
+
+ if ( $title === null || !WikibaseExportExtension::getInstance()->isConfigTitle( $title ) ) {
return;
}
$validator = ConfigJsonValidator::newInstance();
- if ( !$validator->validate( $text ) ) {
+ if ( !$validator->validate( $content->serialize() ) ) {
$errors = $validator->getErrors();
- $error = \Html::errorBox(
- wfMessage( 'wikibase-export-config-invalid', count( $errors ) )->escaped() .
- ConfigJsonErrorFormatter::format( $errors )
+ $status->fatal(
+ 'wikibase-export-config-invalid-errors',
+ count( $errors ),
+ Message::rawParam( ConfigJsonErrorFormatter::format( $errors ) )
);
}
}
diff --git a/src/EntryPoints/SpecialWikibaseExport.php b/src/EntryPoints/SpecialWikibaseExport.php
index 00635a1..d56fbca 100644
--- a/src/EntryPoints/SpecialWikibaseExport.php
+++ b/src/EntryPoints/SpecialWikibaseExport.php
@@ -5,10 +5,10 @@
namespace ProfessionalWiki\WikibaseExport\EntryPoints;
use MediaWiki\MediaWikiServices;
-use Message;
+use MediaWiki\Message\Message;
+use MediaWiki\SpecialPage\SpecialPage;
use ProfessionalWiki\WikibaseExport\Application\Config;
use ProfessionalWiki\WikibaseExport\WikibaseExportExtension;
-use SpecialPage;
use Wikibase\DataModel\Entity\PropertyId;
class SpecialWikibaseExport extends SpecialPage {
@@ -38,15 +38,8 @@ public function getGroupName(): string {
return 'wikibase';
}
- /**
- * @return string|Message Returns string in MW < 1.41 and Message in MW >= 1.41
- */
- public function getDescription() {
- if ( version_compare( MW_VERSION, '1.41', '>=' ) ) {
- return $this->msg( 'special-wikibase-export' );
- } else {
- return $this->msg( 'special-wikibase-export' )->escaped();
- }
+ public function getDescription(): Message {
+ return $this->msg( 'special-wikibase-export' );
}
private function shouldShowConfigLink(): bool {
@@ -90,12 +83,12 @@ private function configToVars( Config $config ): array {
'defaultStartYear' => $config->defaultStartYear,
'defaultEndYear' => $config->defaultEndYear,
'groupedProperties' => array_map(
- fn( PropertyId $id ) => $id->getSerialization(),
+ static fn ( PropertyId $id ) => $id->getSerialization(),
$config->getPropertiesGroupedByYear()->ids
),
'showUngroupedProperties' => $this->shouldShowUngroupedProperties( $config ),
'ungroupedProperties' => array_map(
- fn( PropertyId $id ) => $id->getSerialization(),
+ static fn ( PropertyId $id ) => $id->getSerialization(),
$config->getUngroupedProperties()->ids
),
'showConfigLink' => $this->shouldShowConfigLink(),
diff --git a/src/EntryPoints/SpecialWikibaseExportConfig.php b/src/EntryPoints/SpecialWikibaseExportConfig.php
index a73b776..2a35568 100644
--- a/src/EntryPoints/SpecialWikibaseExportConfig.php
+++ b/src/EntryPoints/SpecialWikibaseExportConfig.php
@@ -4,9 +4,9 @@
namespace ProfessionalWiki\WikibaseExport\EntryPoints;
-use Message;
-use SpecialPage;
-use Title;
+use MediaWiki\Message\Message;
+use MediaWiki\SpecialPage\SpecialPage;
+use MediaWiki\Title\Title;
class SpecialWikibaseExportConfig extends SpecialPage {
@@ -28,15 +28,8 @@ public function getGroupName(): string {
return 'wikibase';
}
- /**
- * @return string|Message Returns string in MW < 1.41 and Message in MW >= 1.41
- */
- public function getDescription() {
- if ( version_compare( MW_VERSION, '1.41', '>=' ) ) {
- return $this->msg( 'special-wikibase-export-config' );
- } else {
- return $this->msg( 'special-wikibase-export-config' )->escaped();
- }
+ public function getDescription(): Message {
+ return $this->msg( 'special-wikibase-export-config' );
}
}
diff --git a/src/Persistence/PageContentConfigLookup.php b/src/Persistence/PageContentConfigLookup.php
index fa44dd8..51f35cb 100644
--- a/src/Persistence/PageContentConfigLookup.php
+++ b/src/Persistence/PageContentConfigLookup.php
@@ -4,7 +4,7 @@
namespace ProfessionalWiki\WikibaseExport\Persistence;
-use JsonContent;
+use MediaWiki\Content\JsonContent;
use ProfessionalWiki\WikibaseExport\Application\Config;
class PageContentConfigLookup implements ConfigLookup {
@@ -19,7 +19,7 @@ public function __construct(
public function getConfig(): Config {
$content = $this->contentFetcher->getPageContent( 'MediaWiki:' . $this->pageName );
- if ( $content instanceof \JsonContent ) {
+ if ( $content instanceof JsonContent ) {
return $this->configFromJsonContent( $content );
}
diff --git a/src/Persistence/PageContentFetcher.php b/src/Persistence/PageContentFetcher.php
index 15170c7..13acf2b 100644
--- a/src/Persistence/PageContentFetcher.php
+++ b/src/Persistence/PageContentFetcher.php
@@ -4,27 +4,26 @@
namespace ProfessionalWiki\WikibaseExport\Persistence;
-use Content;
-use MalformedTitleException;
+use MediaWiki\Content\Content;
+use MediaWiki\Page\PageLookup;
use MediaWiki\Revision\RevisionLookup;
-use TitleParser;
class PageContentFetcher {
public function __construct(
- private TitleParser $titleParser,
+ private PageLookup $pageLookup,
private RevisionLookup $revisionLookup
) {
}
public function getPageContent( string $pageTitle ): ?Content {
- try {
- $title = $this->titleParser->parseTitle( $pageTitle );
- } catch ( MalformedTitleException ) {
+ $page = $this->pageLookup->getPageByText( $pageTitle );
+
+ if ( $page === null ) {
return null;
}
- $revision = $this->revisionLookup->getRevisionByTitle( $title );
+ $revision = $this->revisionLookup->getRevisionByTitle( $page );
return $revision?->getContent( 'main' );
}
diff --git a/src/Presentation/ExportConfigEditPageTextBuilder.php b/src/Presentation/ExportConfigEditPageTextBuilder.php
index 7178913..0e99be2 100644
--- a/src/Presentation/ExportConfigEditPageTextBuilder.php
+++ b/src/Presentation/ExportConfigEditPageTextBuilder.php
@@ -4,11 +4,10 @@
namespace ProfessionalWiki\WikibaseExport\Presentation;
-use Html;
-use IContextSource;
-use Message;
-use SpecialPage;
-use Title;
+use MediaWiki\Context\IContextSource;
+use MediaWiki\Html\Html;
+use MediaWiki\SpecialPage\SpecialPage;
+use MediaWiki\Title\Title;
class ExportConfigEditPageTextBuilder {
diff --git a/src/Presentation/WideCsvPresenter.php b/src/Presentation/WideCsvPresenter.php
index 0e45fd6..d9c4732 100644
--- a/src/Presentation/WideCsvPresenter.php
+++ b/src/Presentation/WideCsvPresenter.php
@@ -41,7 +41,7 @@ private function writeHeaderRow( ColumnHeaders $headers ): void {
array_merge(
[ 'ID', 'Label' ],
array_map(
- fn( ColumnHeader $header ) => $header->text,
+ static fn ( ColumnHeader $header ) => $header->text,
$headers->headers
)
)
diff --git a/src/WikibaseExportExtension.php b/src/WikibaseExportExtension.php
index 42a77ca..fb6acd1 100644
--- a/src/WikibaseExportExtension.php
+++ b/src/WikibaseExportExtension.php
@@ -6,6 +6,7 @@
use MediaWiki\MediaWikiServices;
use MediaWiki\Permissions\Authority;
+use MediaWiki\Title\Title;
use ProfessionalWiki\WikibaseExport\Application\Config;
use ProfessionalWiki\WikibaseExport\Application\EntitySourceFactory;
use ProfessionalWiki\WikibaseExport\Application\Export\ExportPresenter;
@@ -24,7 +25,8 @@
use ProfessionalWiki\WikibaseExport\Persistence\ConfigLookup;
use ProfessionalWiki\WikibaseExport\Persistence\PageContentConfigLookup;
use ProfessionalWiki\WikibaseExport\Persistence\PageContentFetcher;
-use Title;
+use Wikibase\Repo\Api\EntitySearchHelper;
+use Wikibase\Repo\Domains\Search\WbSearch;
use Wikibase\Repo\WikibaseRepo;
use WMDE\Clock\SystemClock;
@@ -79,7 +81,7 @@ private function newConfigLookup(): ConfigLookup {
public function newPageContentConfigLookup(): PageContentConfigLookup {
return new PageContentConfigLookup(
contentFetcher: new PageContentFetcher(
- MediaWikiServices::getInstance()->getTitleParser(),
+ MediaWikiServices::getInstance()->getPageStore(),
MediaWikiServices::getInstance()->getRevisionLookup()
),
deserializer: $this->newConfigDeserializer(),
@@ -133,10 +135,19 @@ public function newSearchEntitiesUseCase( SearchEntitiesPresenter $presenter ):
return new SearchEntitiesUseCase(
subjectFilterPropertyId: $this->getConfig()->subjectFilterPropertyId,
subjectFilterPropertyValue: $this->getConfig()->subjectFilterPropertyValue,
- entitySearchHelper: WikibaseRepo::getEntitySearchHelper(),
+ entitySearchHelper: $this->getItemSearchHelper(),
entityLookup: WikibaseRepo::getEntityLookup(),
presenter: $presenter
);
}
+ private function getItemSearchHelper(): EntitySearchHelper {
+ // Wikibase 1.46 added WbSearch::getItemSearchHelper(), and 1.47 removed WikibaseRepo::getEntitySearchHelper()
+ if ( method_exists( WbSearch::class, 'getItemSearchHelper' ) ) {
+ return WbSearch::getItemSearchHelper();
+ }
+
+ return WikibaseRepo::getEntitySearchHelper();
+ }
+
}
diff --git a/tests/Application/Export/ProductionValueSetCreatorTest.php b/tests/Application/Export/ProductionValueSetCreatorTest.php
index 335dcdf..6e22a18 100644
--- a/tests/Application/Export/ProductionValueSetCreatorTest.php
+++ b/tests/Application/Export/ProductionValueSetCreatorTest.php
@@ -74,8 +74,7 @@ public function testHandlesEmptyStatementList(): void {
$this->assertEquals(
new ValueSet( [] ),
$this->newValueSetCreator()->statementsToValueSet(
- new StatementList(
- )
+ new StatementList()
)
);
}
diff --git a/tests/EntryPoints/ConfigPageEditValidationTest.php b/tests/EntryPoints/ConfigPageEditValidationTest.php
new file mode 100644
index 0000000..2b6da04
--- /dev/null
+++ b/tests/EntryPoints/ConfigPageEditValidationTest.php
@@ -0,0 +1,64 @@
+expectApiErrorCode( 'wikibase-export-config-invalid-errors' );
+
+ $this->edit( self::CONFIG_PAGE, self::INVALID_CONFIG );
+ }
+
+ public function testRefusalNamesTheInvalidSetting(): void {
+ $this->assertStringContainsString( 'defaultStartYear', $this->getRefusalText() );
+ }
+
+ public function testSavesValidConfig(): void {
+ $this->assertSame(
+ 'Success',
+ $this->edit( self::CONFIG_PAGE, Valid::configJson() )['edit']['result']
+ );
+ }
+
+ public function testSavesOtherPagesWithoutValidatingThem(): void {
+ $this->assertSame(
+ 'Success',
+ $this->edit( 'WikibaseExport', self::INVALID_CONFIG )['edit']['result']
+ );
+ }
+
+ private function edit( string $pageName, string $text ): array {
+ return $this->doApiRequestWithToken( [
+ 'action' => 'edit',
+ 'title' => $pageName,
+ 'text' => $text,
+ ] )[0];
+ }
+
+ private function getRefusalText(): string {
+ try {
+ $this->edit( self::CONFIG_PAGE, self::INVALID_CONFIG );
+ } catch ( ApiUsageException $exception ) {
+ return $exception->getMessage();
+ }
+
+ $this->fail( 'The edit was saved' );
+ }
+
+}
diff --git a/tests/EntryPoints/ExportApiTest.php b/tests/EntryPoints/ExportApiTest.php
index f4f6898..f7ec938 100644
--- a/tests/EntryPoints/ExportApiTest.php
+++ b/tests/EntryPoints/ExportApiTest.php
@@ -51,8 +51,6 @@ public function setUp(): void {
}
public function testEdgeToEdge(): void {
- $this->skipOnPhp81AndLater();
-
$this->saveProperty( TimeHelper::START_TIME_ID, 'time', 'Start time' );
$this->saveProperty( TimeHelper::END_TIME_ID, 'time', 'End time' );
$this->saveProperty( TimeHelper::POINT_IN_TIME_ID, 'time', 'Point in time' );
diff --git a/tests/EntryPoints/SearchEntitiesApiTest.php b/tests/EntryPoints/SearchEntitiesApiTest.php
index cd3bf36..651a1f3 100644
--- a/tests/EntryPoints/SearchEntitiesApiTest.php
+++ b/tests/EntryPoints/SearchEntitiesApiTest.php
@@ -63,8 +63,6 @@ private function saveCompany( string $id, string $label ): void {
}
public function testEdgeToEdge(): void {
- $this->skipOnPhp81AndLater();
-
$this->saveProperty( self::INSTANCE_OF_ID, 'string', 'instance of' );
$this->saveCompany( 'Q10', 'Company Foo' );
@@ -128,9 +126,6 @@ public function testEdgeToEdge(): void {
}
public function testNoMatchesReturnsEmptyResult(): void {
- $this->skipOnPhp81AndLater();
- $this->saveProperty( self::INSTANCE_OF_ID, 'string', 'instance of' );
-
$response = $this->executeHandler(
WikibaseExportExtension::searchEntitiesApiFactory(),
new RequestData( [
diff --git a/tests/Presentation/ConfigPageSmokeTest.php b/tests/Presentation/ConfigPageSmokeTest.php
index dcf5e5f..ed13916 100644
--- a/tests/Presentation/ConfigPageSmokeTest.php
+++ b/tests/Presentation/ConfigPageSmokeTest.php
@@ -12,11 +12,6 @@
*/
class ConfigPageSmokeTest extends WikibaseExportIntegrationTest {
- public function tearDown(): void {
- $this->deleteConfigPage();
- parent::tearDown();
- }
-
public function testSmoke(): void {
$this->editConfigPage( config: Valid::configJson() );
$this->assertStringContainsString(
diff --git a/tests/Presentation/WideCsvPresenterTest.php b/tests/Presentation/WideCsvPresenterTest.php
index 533f0eb..29ccef4 100644
--- a/tests/Presentation/WideCsvPresenterTest.php
+++ b/tests/Presentation/WideCsvPresenterTest.php
@@ -49,7 +49,8 @@ public function testMultipleEntities(): void {
Q42,"Item One",Foo,Bar
Q43,"Item Two",MoreFoo,MoreBar
-CSV,
+CSV
+,
$presenter
);
}
@@ -83,7 +84,8 @@ public function testMultipleValuesPerProperty(): void {
Four","Two
Three"
-CSV,
+CSV
+,
$presenter
);
}
diff --git a/tests/TestDoubles/FakeStatementsMapper.php b/tests/TestDoubles/FakeStatementsMapper.php
index 1cc39dd..a7898b5 100644
--- a/tests/TestDoubles/FakeStatementsMapper.php
+++ b/tests/TestDoubles/FakeStatementsMapper.php
@@ -28,7 +28,7 @@ public function createColumnHeaders(): ColumnHeaders {
public function buildValueSetList( StatementList $statements ): ValueSetList {
return new ValueSetList( [
new ValueSet( array_map(
- fn( Snak $snak ) => $this->header . ' ' . $snak->getPropertyId()->getSerialization(),
+ fn ( Snak $snak ) => $this->header . ' ' . $snak->getPropertyId()->getSerialization(),
$statements->getMainSnaks()
) )
] );
diff --git a/tests/TestDoubles/TimeHelper.php b/tests/TestDoubles/TimeHelper.php
index f4c8795..052056e 100644
--- a/tests/TestDoubles/TimeHelper.php
+++ b/tests/TestDoubles/TimeHelper.php
@@ -47,7 +47,7 @@ public static function newDay( string $isoLikeTime ): TimeValue {
);
}
- public static function newTimeRangeStatement( ?int $startYear, ?int $endYear, string $pId = 'P1', DataValue $value = null ): Statement {
+ public static function newTimeRangeStatement( ?int $startYear, ?int $endYear, string $pId = 'P1', ?DataValue $value = null ): Statement {
$snaks = [];
if ( $startYear !== null ) {
@@ -73,7 +73,7 @@ public static function newTimeRangeStatement( ?int $startYear, ?int $endYear, st
);
}
- public static function newDayRangeStatement( ?string $startDay, ?string $endDay, string $pId = 'P1', DataValue $value = null ): Statement {
+ public static function newDayRangeStatement( ?string $startDay, ?string $endDay, string $pId = 'P1', ?DataValue $value = null ): Statement {
$snaks = [];
if ( $startDay !== null ) {
diff --git a/tests/WikibaseExportIntegrationTest.php b/tests/WikibaseExportIntegrationTest.php
index 25579c4..ca6b412 100644
--- a/tests/WikibaseExportIntegrationTest.php
+++ b/tests/WikibaseExportIntegrationTest.php
@@ -3,9 +3,10 @@
namespace ProfessionalWiki\WikibaseExport\Tests;
use Article;
+use MediaWiki\EditPage\EditPage;
+use MediaWiki\Title\Title;
use MediaWikiIntegrationTestCase;
use ProfessionalWiki\WikibaseExport\WikibaseExportExtension;
-use Title;
use Wikibase\DataModel\Entity\EntityDocument;
use Wikibase\DataModel\Entity\NumericPropertyId;
use Wikibase\DataModel\Entity\Property;
@@ -13,7 +14,6 @@
use Wikibase\DataModel\Term\Term;
use Wikibase\DataModel\Term\TermList;
use Wikibase\Repo\WikibaseRepo;
-use WikiPage;
class WikibaseExportIntegrationTest extends MediaWikiIntegrationTestCase {
@@ -29,15 +29,6 @@ protected function editConfigPage( string $config ): void {
);
}
- protected function deleteConfigPage(): void {
- /**
- * @var Title $title
- */
- $title = Title::newFromText( 'MediaWiki:' . WikibaseExportExtension::CONFIG_PAGE_TITLE );
-
- $this->deletePage( new WikiPage( $title ) );
- }
-
protected function saveEntity( EntityDocument $entity ): void {
WikibaseRepo::getEntityStore()->saveEntity(
entity: $entity,
@@ -58,14 +49,8 @@ protected function saveProperty( string $pId, string $type, string $label ): voi
);
}
- protected function skipOnPhp81AndLater(): void {
- if ( version_compare( PHP_VERSION, '8.1.0' ) >= 0 ) {
- $this->markTestSkipped( 'Wikibase does not yet work with PHP 8.1' );
- }
- }
-
protected function getPageHtml( string $pageTitle ): string {
- $title = \Title::newFromText( $pageTitle );
+ $title = Title::newFromText( $pageTitle );
$article = new Article( $title, 0 );
$article->getContext()->getOutput()->setTitle( $title );
@@ -76,12 +61,12 @@ protected function getPageHtml( string $pageTitle ): string {
}
protected function getEditPageHtml( string $pageTitle ): string {
- $title = \Title::newFromText( $pageTitle );
+ $title = Title::newFromText( $pageTitle );
$article = new Article( $title, 0 );
$article->getContext()->getOutput()->setTitle( $title );
- $editPage = new \EditPage( $article );
+ $editPage = new EditPage( $article );
$editPage->setContextTitle( $title );
$editPage->getContext()->setUser( $this->getTestSysop()->getUser() );
$editPage->edit();