diff --git a/tests/phpunit/CommentUtilsTest.php b/tests/phpunit/CommentUtilsTest.php index 0d1518c47..6aa67221f 100644 --- a/tests/phpunit/CommentUtilsTest.php +++ b/tests/phpunit/CommentUtilsTest.php @@ -4,6 +4,7 @@ namespace MediaWiki\Extension\DiscussionTools\Tests; use MediaWiki\Config\HashConfig; use MediaWiki\Extension\DiscussionTools\CommentUtils; +use MediaWiki\MainConfigNames; /** * @group DiscussionTools @@ -49,7 +50,7 @@ class CommentUtilsTest extends IntegrationTestCase { public static function provideGetTitleFromUrl_Decoding() { // Standard short URL configuration like on Wikimedia wikis - $config = new HashConfig( [ 'ArticlePath' => '/wiki/$1' ] ); + $config = new HashConfig( [ MainConfigNames::ArticlePath => '/wiki/$1' ] ); // In URL paths, non-percent-encoded `+` represents itself yield [ 'A+B', '/wiki/A+B', $config ]; @@ -66,7 +67,7 @@ class CommentUtilsTest extends IntegrationTestCase { public static function provideGetTitleFromUrl_ShortUrl() { // Standard short URL configuration like on Wikimedia wikis - $config = new HashConfig( [ 'ArticlePath' => '/wiki/$1' ] ); + $config = new HashConfig( [ MainConfigNames::ArticlePath => '/wiki/$1' ] ); // These should never occur in documents generated by either wikitext parser yield 'ShortUrl-null-string' => [ null, 'Foo', $config ]; @@ -97,7 +98,7 @@ class CommentUtilsTest extends IntegrationTestCase { public static function provideGetTitleFromUrl_ConfusingShortUrl() { // Super short URL that is confusing for the software but people use it anyway - $config = new HashConfig( [ 'ArticlePath' => '/$1' ] ); + $config = new HashConfig( [ MainConfigNames::ArticlePath => '/$1' ] ); // These should never occur in documents generated by either wikitext parser yield 'ConfusingShortUrl-null-string' => [ null, 'Foo', $config ]; @@ -127,7 +128,7 @@ class CommentUtilsTest extends IntegrationTestCase { public static function provideGetTitleFromUrl_NoShortUrl() { // No short URL configuration - $config = new HashConfig( [ 'ArticlePath' => '/wiki/index.php?title=$1' ] ); + $config = new HashConfig( [ MainConfigNames::ArticlePath => '/wiki/index.php?title=$1' ] ); // These should never occur in documents generated by either wikitext parser yield 'NoShortUrl-null-string' => [ null, 'Foo', $config ]; diff --git a/tests/phpunit/TestUtils.php b/tests/phpunit/TestUtils.php index a2cd96a6e..da811ea81 100644 --- a/tests/phpunit/TestUtils.php +++ b/tests/phpunit/TestUtils.php @@ -11,6 +11,7 @@ use MediaWiki\Extension\DiscussionTools\CommentParser; use MediaWiki\Interwiki\NullInterwikiLookup; use MediaWiki\Languages\LanguageConverterFactory; use MediaWiki\Languages\LanguageFactory; +use MediaWiki\MainConfigNames; use MediaWiki\MediaWikiServices; use MediaWiki\Title\MediaWikiTitleCodec; use MediaWiki\Title\NamespaceInfo; @@ -127,20 +128,19 @@ trait TestUtils { private static function prepareConfig( array $config, array $data ): array { return [ - 'LanguageCode' => $config['wgContentLanguage'], - 'ArticlePath' => $config['wgArticlePath'], + MainConfigNames::LanguageCode => $config['wgContentLanguage'], + MainConfigNames::ArticlePath => $config['wgArticlePath'], // TODO: Move this to $config - 'Localtimezone' => $data['localTimezone'], + MainConfigNames::Localtimezone => $data['localTimezone'], // Defaults for NamespaceInfo - 'CanonicalNamespaceNames' => NamespaceInfo::CANONICAL_NAMES, - 'CapitalLinkOverrides' => [], - 'CapitalLinks' => true, - 'ContentNamespaces' => [ NS_MAIN ], - 'ExtraNamespaces' => [], - 'ExtraSignatureNamespaces' => [], - 'NamespaceContentModels' => [], - 'NamespacesWithSubpages' => [ + MainConfigNames::CanonicalNamespaceNames => NamespaceInfo::CANONICAL_NAMES, + MainConfigNames::CapitalLinkOverrides => [], + MainConfigNames::CapitalLinks => true, + MainConfigNames::ContentNamespaces => [ NS_MAIN ], + MainConfigNames::ExtraSignatureNamespaces => [], + MainConfigNames::NamespaceContentModels => [], + MainConfigNames::NamespacesWithSubpages => [ NS_TALK => true, NS_USER => true, NS_USER_TALK => true, @@ -155,24 +155,25 @@ trait TestUtils { NS_HELP_TALK => true, NS_CATEGORY_TALK => true ], - 'NonincludableNamespaces' => [], + MainConfigNames::NonincludableNamespaces => [], // Defaults for LanguageFactory - 'DummyLanguageCodes' => [], + MainConfigNames::DummyLanguageCodes => [], // Defaults for LanguageConverterFactory - 'UsePigLatinVariant' => false, - 'DisableLangConversion' => false, - 'DisableTitleConversion' => false, + MainConfigNames::UsePigLatinVariant => false, + MainConfigNames::DisableLangConversion => false, + MainConfigNames::DisableTitleConversion => false, // Defaults for Language - 'ExtraGenderNamespaces' => [], + MainConfigNames::ExtraGenderNamespaces => [], // Overrides - 'ExtraNamespaces' => array_diff_key( $config['wgFormattedNamespaces'], NamespaceInfo::CANONICAL_NAMES ), - 'MetaNamespace' => strtr( $config['wgFormattedNamespaces'][NS_PROJECT], ' ', '_' ), - 'MetaNamespaceTalk' => strtr( $config['wgFormattedNamespaces'][NS_PROJECT_TALK], ' ', '_' ), - 'NamespaceAliases' => $config['wgNamespaceIds'], + MainConfigNames::ExtraNamespaces => array_diff_key( + $config['wgFormattedNamespaces'], NamespaceInfo::CANONICAL_NAMES ), + MainConfigNames::MetaNamespace => strtr( $config['wgFormattedNamespaces'][NS_PROJECT], ' ', '_' ), + MainConfigNames::MetaNamespaceTalk => strtr( $config['wgFormattedNamespaces'][NS_PROJECT_TALK], ' ', '_' ), + MainConfigNames::NamespaceAliases => $config['wgNamespaceIds'], ]; }