Merge "Add @var annotations to XmlTypeCheck class"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 3 Jul 2019 02:29:54 +0000 (02:29 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 3 Jul 2019 02:29:54 +0000 (02:29 +0000)
227 files changed:
HISTORY
RELEASE-NOTES-1.34
autoload.php
docs/hooks.txt
includes/GlobalFunctions.php
includes/Linker.php
includes/MediaWikiServices.php
includes/Rest/Router.php
includes/Title.php
includes/api/ApiBase.php
includes/api/ApiEditPage.php
includes/api/ApiQueryDeletedrevs.php
includes/api/i18n/fr.json
includes/api/i18n/hu.json
includes/api/i18n/pt-br.json
includes/api/i18n/zh-hans.json
includes/auth/LocalPasswordPrimaryAuthenticationProvider.php
includes/auth/TemporaryPasswordPrimaryAuthenticationProvider.php
includes/block/BlockManager.php
includes/changetags/ChangeTags.php
includes/deferred/UserEditCountUpdate.php
includes/filerepo/ForeignDBRepo.php
includes/htmlform/fields/HTMLInfoField.php
includes/import/ImportableOldRevisionImporter.php
includes/installer/i18n/de.json
includes/installer/i18n/es.json
includes/installer/i18n/ja.json
includes/libs/MultiHttpClient.php [deleted file]
includes/libs/filebackend/filejournal/FileJournal.php
includes/libs/http/MultiHttpClient.php [new file with mode: 0644]
includes/libs/lockmanager/NullLockManager.php
includes/libs/lockmanager/QuorumLockManager.php
includes/libs/mime/MimeAnalyzer.php
includes/libs/rdbms/database/Database.php
includes/libs/rdbms/database/DatabaseMysqlBase.php
includes/mail/EmailNotification.php
includes/mail/MailAddress.php
includes/mail/UserMailer.php
includes/objectcache/ObjectCache.php
includes/registration/ExtensionRegistry.php
includes/specialpage/ChangesListSpecialPage.php
includes/specials/SpecialChangeCredentials.php
includes/specials/SpecialMovepage.php
includes/specials/SpecialPageLanguage.php
includes/specials/pagers/BlockListPager.php
includes/user/User.php
languages/LanguageConverter.php
languages/i18n/ar.json
languages/i18n/az.json
languages/i18n/be-tarask.json
languages/i18n/ca.json
languages/i18n/diq.json
languages/i18n/es.json
languages/i18n/fa.json
languages/i18n/fr.json
languages/i18n/frp.json
languages/i18n/he.json
languages/i18n/hr.json
languages/i18n/hu.json
languages/i18n/ia.json
languages/i18n/id.json
languages/i18n/ja.json
languages/i18n/ka.json
languages/i18n/ko.json
languages/i18n/luz.json
languages/i18n/mai.json
languages/i18n/mk.json
languages/i18n/nb.json
languages/i18n/nl.json
languages/i18n/nqo.json
languages/i18n/pl.json
languages/i18n/pt-br.json
languages/i18n/qqq.json
languages/i18n/roa-tara.json
languages/i18n/ru.json
languages/i18n/sh.json
languages/i18n/sl.json
languages/i18n/sr-ec.json
languages/i18n/sr-el.json
languages/i18n/su.json
languages/i18n/tl.json
languages/i18n/uk.json
languages/i18n/yi.json
languages/i18n/zh-hans.json
languages/i18n/zh-hant.json
maintenance/importImages.php
maintenance/sqlite/archives/patch-pagelinks-fix-pk.sql
maintenance/sqlite/archives/patch-templatelinks-fix-pk.sql
phpunit.xml.dist
resources/Resources.php
resources/src/mediawiki.misc-authed-ooui/special.changecredentials.js [new file with mode: 0644]
resources/src/mediawiki.misc-authed-ooui/special.movePage.js [new file with mode: 0644]
resources/src/mediawiki.misc-authed-ooui/special.mute.js [new file with mode: 0644]
resources/src/mediawiki.misc-authed-ooui/special.pageLanguage.js [new file with mode: 0644]
resources/src/mediawiki.rcfilters/ui/FormWrapperWidget.js
resources/src/mediawiki.special.changecredentials.js [deleted file]
resources/src/mediawiki.special.movePage.js [deleted file]
resources/src/mediawiki.special.mute.js [deleted file]
resources/src/mediawiki.special.pageLanguage.js [deleted file]
tests/common/TestSetup.php
tests/common/TestsAutoLoader.php
tests/phpunit/MediaWikiGroupValidator.php [new file with mode: 0644]
tests/phpunit/MediaWikiIntegrationTestCase.php
tests/phpunit/MediaWikiUnitTestCase.php
tests/phpunit/bootstrap.php
tests/phpunit/documentation/ReleaseNotesTest.php
tests/phpunit/includes/FauxResponseTest.php [deleted file]
tests/phpunit/includes/FormOptionsInitializationTest.php [deleted file]
tests/phpunit/includes/FormOptionsTest.php [deleted file]
tests/phpunit/includes/LicensesTest.php [deleted file]
tests/phpunit/includes/MediaWikiVersionFetcherTest.php [deleted file]
tests/phpunit/includes/Rest/EntryPointTest.php [deleted file]
tests/phpunit/includes/Rest/Handler/HelloHandlerTest.php [deleted file]
tests/phpunit/includes/Rest/HeaderContainerTest.php [deleted file]
tests/phpunit/includes/Rest/PathTemplateMatcher/PathMatcherTest.php [deleted file]
tests/phpunit/includes/Rest/StringStreamTest.php [deleted file]
tests/phpunit/includes/Rest/testRoutes.json [deleted file]
tests/phpunit/includes/Revision/FallbackSlotRoleHandlerTest.php [deleted file]
tests/phpunit/includes/Revision/RevisionStoreFactoryTest.php [deleted file]
tests/phpunit/includes/Revision/SlotRoleHandlerTest.php [deleted file]
tests/phpunit/includes/ServiceWiringTest.php [deleted file]
tests/phpunit/includes/SiteConfigurationTest.php [deleted file]
tests/phpunit/includes/Storage/PreparedEditTest.php [deleted file]
tests/phpunit/includes/TitleTest.php
tests/phpunit/includes/XmlSelectTest.php [deleted file]
tests/phpunit/includes/api/ApiEditPageTest.php
tests/phpunit/includes/auth/AuthenticationResponseTest.php [deleted file]
tests/phpunit/includes/block/BlockManagerTest.php
tests/phpunit/includes/changes/ChangesListFilterGroupTest.php [deleted file]
tests/phpunit/includes/config/ConfigFactoryTest.php [deleted file]
tests/phpunit/includes/config/HashConfigTest.php [deleted file]
tests/phpunit/includes/config/MultiConfigTest.php [deleted file]
tests/phpunit/includes/config/ServiceOptionsTest.php [deleted file]
tests/phpunit/includes/content/JsonContentHandlerTest.php [deleted file]
tests/phpunit/includes/debug/DeprecationHelperTest.php
tests/phpunit/includes/debug/logger/MonologSpiTest.php [deleted file]
tests/phpunit/includes/debug/logger/monolog/AvroFormatterTest.php [deleted file]
tests/phpunit/includes/debug/logger/monolog/KafkaHandlerTest.php [deleted file]
tests/phpunit/includes/debug/logger/monolog/LineFormatterTest.php [deleted file]
tests/phpunit/includes/diff/ArrayDiffFormatterTest.php [deleted file]
tests/phpunit/includes/diff/DiffOpTest.php [deleted file]
tests/phpunit/includes/diff/DiffTest.php [deleted file]
tests/phpunit/includes/exception/MWExceptionHandlerTest.php [deleted file]
tests/phpunit/includes/installer/InstallDocFormatterTest.php [deleted file]
tests/phpunit/includes/installer/OracleInstallerTest.php [deleted file]
tests/phpunit/includes/interwiki/InterwikiLookupAdapterTest.php [deleted file]
tests/phpunit/includes/libs/objectcache/ReplicatedBagOStuffTest.php [deleted file]
tests/phpunit/includes/media/GIFMetadataExtractorTest.php [deleted file]
tests/phpunit/includes/media/IPTCTest.php [deleted file]
tests/phpunit/includes/media/MediaHandlerTest.php [deleted file]
tests/phpunit/includes/media/SVGMetadataExtractorTest.php [deleted file]
tests/phpunit/includes/objectcache/MemcachedBagOStuffTest.php [deleted file]
tests/phpunit/includes/objectcache/RESTBagOStuffTest.php [deleted file]
tests/phpunit/includes/parser/TidyTest.php [deleted file]
tests/phpunit/includes/password/PasswordTest.php [deleted file]
tests/phpunit/includes/preferences/FiltersTest.php [deleted file]
tests/phpunit/includes/registration/ExtensionProcessorTest.php [deleted file]
tests/phpunit/includes/search/SearchIndexFieldTest.php [deleted file]
tests/phpunit/includes/session/MetadataMergeExceptionTest.php [deleted file]
tests/phpunit/includes/session/SessionIdTest.php [deleted file]
tests/phpunit/includes/site/CachingSiteStoreTest.php [deleted file]
tests/phpunit/includes/site/HashSiteStoreTest.php [deleted file]
tests/phpunit/includes/skins/SkinFactoryTest.php [deleted file]
tests/phpunit/includes/title/ForeignTitleTest.php [deleted file]
tests/phpunit/includes/title/NamespaceAwareForeignTitleFactoryTest.php [deleted file]
tests/phpunit/includes/title/TitleValueTest.php [deleted file]
tests/phpunit/includes/user/UserArrayFromResultTest.php [deleted file]
tests/phpunit/includes/watcheditem/NoWriteWatchedItemStoreUnitTest.php [deleted file]
tests/phpunit/languages/SpecialPageAliasTest.php
tests/phpunit/unit/includes/FauxResponseTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/FormOptionsInitializationTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/FormOptionsTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/LicensesTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/MediaWikiVersionFetcherTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/Rest/EntryPointTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/Rest/Handler/HelloHandlerTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/Rest/HeaderContainerTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/Rest/PathTemplateMatcher/PathMatcherTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/Rest/StringStreamTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/Rest/testRoutes.json [new file with mode: 0644]
tests/phpunit/unit/includes/Revision/FallbackSlotRoleHandlerTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/Revision/RevisionStoreFactoryTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/Revision/SlotRoleHandlerTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/ServiceWiringTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/SiteConfigurationTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/Storage/PreparedEditTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/XmlSelectTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/auth/AuthenticationResponseTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/changes/ChangesListFilterGroupTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/config/ConfigFactoryTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/config/HashConfigTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/config/MultiConfigTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/config/ServiceOptionsTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/content/JsonContentHandlerTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/debug/logger/MonologSpiTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/debug/logger/monolog/AvroFormatterTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/debug/logger/monolog/KafkaHandlerTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/debug/logger/monolog/LineFormatterTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/diff/ArrayDiffFormatterTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/diff/DiffOpTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/diff/DiffTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/exception/MWExceptionHandlerTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/installer/InstallDocFormatterTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/installer/OracleInstallerTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/interwiki/InterwikiLookupAdapterTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/libs/objectcache/ReplicatedBagOStuffTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/media/GIFMetadataExtractorTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/media/IPTCTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/media/MediaHandlerTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/media/SVGMetadataExtractorTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/objectcache/MemcachedBagOStuffTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/objectcache/RESTBagOStuffTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/parser/TidyTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/password/PasswordTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/preferences/FiltersTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/registration/ExtensionProcessorTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/search/SearchIndexFieldTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/session/MetadataMergeExceptionTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/session/SessionIdTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/site/CachingSiteStoreTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/site/HashSiteStoreTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/skins/SkinFactoryTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/title/ForeignTitleTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/title/NamespaceAwareForeignTitleFactoryTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/title/TitleValueTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/user/UserArrayFromResultTest.php [new file with mode: 0644]
tests/phpunit/unit/includes/watcheditem/NoWriteWatchedItemStoreUnitTest.php [new file with mode: 0644]

diff --git a/HISTORY b/HISTORY
index 771d57e..ff4007e 100644 (file)
--- a/HISTORY
+++ b/HISTORY
@@ -1,7 +1,495 @@
 Change notes from older releases. For current info see RELEASE-NOTES-1.34.
 
+= MediaWiki 1.33 =
+
+=== Upgrading notes for 1.33 ===
+1.33 has several database changes since 1.32, and will not work without schema
+updates. Note that due to changes to some very large tables like the revision
+table, the schema update may take quite long (minutes on a medium sized site,
+many hours on a large site).
+
+Don't forget to always back up your database before upgrading!
+
+See the file UPGRADE for more detailed upgrade instructions, including
+important information when upgrading from versions prior to 1.11.
+
+Some specific notes for MediaWiki 1.33 upgrades are below:
+
+* Some external link searches will not work correctly until update.php (or
+  refreshExternallinksIndex.php) is run. These include searches for links using
+  IP addresses, internationalized domain names, and possibly mailto links.
+* If you ran migrateActors.php using an older version of MediaWiki and want to
+  run your wiki with $wgActorTableSchemaMigrationStage SCHEMA_COMPAT_READ_OLD,
+  note that log_search rows needed to find revision deletions by target user
+  were incorrectly deleted. See T215464 for details.
+* If revision deletions were performed when the wiki was configured with
+  $wgActorTableSchemaMigrationStage SCHEMA_COMPAT_WRITE_BOTH and without
+  migrateActors.php having been run, the log_search table may contain rows with
+  empty values for "target_author_actor" which will prevent log searches for
+  revision deletions by target user from finding those log entries. These rows
+  may be corrected by (re-)running migrateActors.php.
+
+For notes on 1.32.x and older releases, see HISTORY.
+
+== MediaWiki 1.33.0 ==
+
+=== Changes since MediaWiki 1.33.0-rc.0 ===
+* (T225558) Update installer link to PHP intl.
+* (T225901) Only attempt to deduplicate if there is data in archive and revision
+  tables.
+* (T225564) Fetch tag ID before calling undefineTag().
+* (T225496) Detect APC for MainCacheType in CLI installer.
+* Call unpack() with correct parameters in MimeAnalyzer.php for PHP 7.0 support.
+* (T212613) Style change tags correctly on Special:Newpages.
+* (T202211) Fix SQLite patch-(page|template)links-fix-pk.sql column order.
+
+== MediaWiki 1.33.0-rc.0 ==
+
+=== Configuration changes for system administrators in 1.33 ===
+==== New configuration ====
+* $wgEnablePartialBlocks – This enables the Partial Blocks feature, which gives
+  accounts with block permissions the ability to block users, IPs, and IP ranges
+  from editing specific pages, while allowing them to edit the rest of the wiki.
+  It is a temporary setting for gradual enablement, current default to `false`,
+  and will be set to `true` and then removed once initial development completes.
+
+==== Changed configuration ====
+* $wgChangeTagsSchemaMigrationStage (T193868) — This temporary setting, added in
+  MediaWiki 1.32, now defaults to MIGRATION_NEW instead of MIGRATION_WRITE_BOTH.
+* $wgPasswordPolicy – There is a new password policy to check that the account's
+  password is not in the large blacklist. This is enabled by default for the
+  built-in user groups bureaucrat, sysop, interface-admin, and bot. To configure
+  this for other user groups, set the `PasswordNotInLargeBlacklist` flag `true`.
+* $wgPasswordDefault – There is a new password type configuration using Argon2
+  password hashing (which requires PHP 7.2 and above). It's designed to resist
+  timing attacks, and (on systems with PHP 7.3+) GPU hacking; if you configure
+  argon2 to be used, by default, it will automatically choose the best available
+  algorithm depending on which version of PHP you have available. To use this,
+  you can set `$wgPasswordDefault = 'argon2';`.
+* $wgActorTableSchemaMigrationStage now defaults to reading the new schema.
+  update.php will back-populate the new database fields due to the changed
+  setting, which may take some time on large wikis. You can avoid downtime by
+  following a process like that described in T188327.
+
+==== Removed configuration ====
+* $wgTagStatisticsNewTable (T199334) — This temporary setting, added in
+  MediaWiki 1.32, has now been removed. When loading Special:Tags, MediaWiki
+  will now always use the `change_tag_def` instead of the `change_tag` table.
+* $wgUseTidy, $wgTidyBin, $wgTidyConf, $wgTidyOpts, $wgTidyInternal, and
+  $wgDebugTidy – These options, all deprecated since 1.26, have now all been
+  removed, as MediaWiki now always tidies user output. The $wgTidyConfig setting
+  remains only for experimental features and debugging, and should not be used.
+* $wgEnableParserCache – This setting has been deprecated since 1.26, has now
+  been removed. If you still desire to disable the parser cache, instead you can
+  set `$wgParserCacheType = CACHE_NONE;`.
+* $wgCommentTableSchemaMigrationStage – This temporary migration setting has now
+  been removed. Code finding it unset should treat it as being MIGRATION_NEW.
+* $wgAuth – This old setting, deprecated in 1.27, has been removed as part of
+  the removal of AuthPlugin.
+* $wgSitesCacheFile – This configuration was introduced in 1.25 with the intent
+  to allow sites to configure a file in which to cache the SiteStore database
+  table, but it was never used. SiteStore already caches its information by
+  default using BagOStuff (e.g. Memcached or APC).
+* $wgClockSkewFudge – This setting was used by User.php to let sites adjust by
+  how much MediaWiki would fudge when trying to minimize the chances of a
+  user.user_touched database update to the "current" timestamp being before the
+  value already there (e.g. due to clock skew between different servers). This
+  is no longer a problem, because the code now ensures the timestamp is always
+  higher than the previous one. The writes are guarded with CAS logic (check
+  and set), which prevents updates that would overlap.
+* $wgDBmysql5 (T196185) - This experimental setting, deprecated in 1.31, has
+  been removed.
+
+=== New user-facing features in 1.33 ===
+* (T96041) __EXPECTUNUSEDCATEGORY__ on a category page causes the category
+  to be hidden on Special:UnusedCategories.
+* (T210814) SVGs are now by default displayed in wiki language on image
+  pages.
+* Special:CreateAccount now warns the user if their chosen username has to be
+  normalized.
+* (T205040) Multilingual images are now be displayed in the current parse
+  language where available.
+* Special:ActiveUsers will no longer filter out users who became inactive since
+  the last time the active users query cache was updated.
+* (T215675) RecentChange and ManualLogEntry implement new Taggable interface.
+* (T215675) Added a hook, ManualLogEntryBeforePublish, to allow extensions
+  to modify (example: add tags) log entries.
+
+=== New developer features in 1.33 ===
+* The AuthManagerLoginAuthenticateAudit hook has a new parameter for
+  additional information about the authentication event.
+* TextContent::getText() was introduced as a replacement for
+  Content::getNativeData() for text-based content models.
+* (T214706) LinksUpdate::getAddedExternalLinks() and
+  LinksUpdate::getRemovedExternalLinks() were introduced.
+* (T213893) Added 'MaintenanceUpdateAddParams' hook
+* (T219655) The MarkPatrolled hook has a new parameter for the tags
+  associated with this entry in the patrol log.
+* (T212472) Extensions can now specify platform abilities they require to work,
+  limited to shell access for now.
+
+
+=== External library changes in 1.33 ===
+==== New external libraries ====
+* Added wikimedia/password-blacklist 0.1.4.
+* Added guzzlehttp/guzzle 6.3.3.
+
+==== Changed external libraries ====
+* Updated OOUI from v0.29.2 to v0.31.3.
+* Updated OOjs Router from pre-release to v0.2.0.
+* Updated moment from v2.19.3 to v2.24.0.
+* Updated wikimedia/xmp-reader from 0.6.0 to 0.6.2.
+* Updated wikimedia/scoped-callback from 2.0.0 to 3.0.0.
+* Updated jquery-client from 2.0.1 to 2.0.2.
+* Updated pear/net_smtp from 1.8.0 to 1.8.1.
+* Updated cssjanus/cssjanus from 1.2.0 to 1.3.0.
+* Updated wikimedia/php-session-serializer from 1.0.6 to 1.0.7.
+
+==== Removed external libraries ====
+* (T219403) jquery.ui.spinner, deprecated since 1.31, was removed.
+
+
+=== Developer library changes in 1.33 ===
+==== New developer libraries ====
+* Added jakub-onderka/php-console-highlighter 0.3.2 explicitly (dev-only).
+* Added mediawiki/mediawiki-phan-config 0.5.0 (dev-only).
+
+==== Changed developer libraries ====
+* Updated wikimedia/ip-set from 1.3.0 to 2.0.1.
+  * The deprecated IPSet\IPSet alias was removed, Wikimedia\IPSet must be
+    used instead.
+* Updated psy/psysh from 0.9.6 to 0.9.9 (dev-only).
+* Updated nikic/php-parser from 3.1.3 to 3.1.5 (dev-only).
+* Updated mediawiki/mediawiki-codesniffer from 22.0.0 to 25.0.0 (dev-only).
+* Updated qunitjs from 2.6.2 to 2.9.1.
+
+==== Removed developer libraries ====
+* The jetbrains/phpstorm-stubs repository was removed in favour of the minimal
+  stubs we need, which are kept in the new `.phan/internal_stubs` directory
+  (dev-only).
+
+
+=== Bug fixes in 1.33 ===
+* (T164211) Special:UserRights could sometimes fail with a
+  "conflict detected" error when there weren't any conflicts.
+* (T216029) Chrome redirects to Special:BadTitle after editing a section with
+  a non-Latin name on a page with non-Latin characters in title.
+* (T222385) resourceloader: Use AND instead of OR for upsert conds in
+  saveFileDependencies().
+
+=== Action API changes in 1.33 ===
+* (T198913) Added 'ApiOptions' hook.
+* The JSON formatversion=2 is no longer experimental.
+* Internal API errors (those with code beginning "internal_api_error") will
+  include the exception class name in a data field named "errorclass".
+  * Class names are not guaranteed to remain stable, and in particular database
+    exceptions will now include the "Wikimedia\Rdbms\" prefix in the class name.
+  * The code including an exception class name is deprecated. In the future,
+    all internal errors will use code "internal_api_error".
+* (T212356) When using action=delete on pages with many revisions, the module
+  may return a boolean-true 'scheduled' and no 'logid'. This signifies that the
+  deletion will be processed via the job queue.
+* action=setnotificationtimestamp will now update the watchlist asynchronously
+  if entirewatchlist is set, so updates may not be visible immediately
+* Block info will be added to "blocked" errors from more modules.
+* (T216245) Autoblocks will now be spread by action=edit and action=move.
+* action=query&meta=userinfo has a new uiprop, 'latestcontrib', that returns
+  the date of user's latest contribution.
+* (T25227) action=logout now requires to be posted and have a csrf token.
+
+=== Action API internal changes in 1.33 ===
+* A number of deprecated methods for API documentation, intended for overriding
+  by extensions, are no longer called by MediaWiki, and will emit deprecation
+  notices if your extension attempts to use them:
+  * ApiBase::getDescription() (deprecated in 1.25)
+  * ApiBase::getParamDescription() (deprecated in 1.25)
+  * ApiBase::getExamples() (deprecated in 1.25)
+  * ApiBase::getDescriptionMessage() (deprecated in 1.30)
+  Additionally, the  'APIGetDescription' and 'APIGetParamDescription' hooks have
+  been removed, as their only use was to let extensions override values returned
+  by getDescription() and getParamDescription(), respectively.
+* API error codes may only contain ASCII letters, numbers, underscore, and
+  hyphen. Methods such as ApiBase::dieWithError() and
+  ApiMessageTrait::setApiCode() will throw an InvalidArgumentException if
+  passed a bad code.
+* ApiBase::checkTitleUserPermissions() now takes an options array as its third
+  parameter. Passing a User object or null is deprecated.
+* The api-feature-usage log channel now has log context. The text message is
+  deprecated and will be removed in the future.
+
+=== Languages updated in 1.33 ===
+MediaWiki supports over 350 languages. Many localisations are updated regularly.
+Below only new and removed languages are listed, as well as changes to languages
+because of Phabricator reports.
+
+* (T203908) Added language support for Eastern Pwo (kjp).
+* (T213717) Fixed a translation error on Goan Konkani (gom-deva) translations
+  for NS_TEMPLATE.
+* (T212221) Added $digitTransformTable for Santali (sat).
+* (T216479) Added language support for Saisiyat (xsy).
+* (T219728) Added support for new Japanese era name "Reiwa"
+
+=== Breaking changes in 1.33 ===
+* The parameteter $lang in DifferenceEngine::setTextLanguage must be of type
+  Language. Other types are deprecated since 1.32.
+* Skin::doEditSectionLink requires type Language for the parameter $lang.
+  The parameters $tooltip and $lang are mandatory. Omitting the parameters is
+  deprecated since 1.32.
+* Language::truncate(), deprecated in 1.31, has been removed.
+* UtfNormal, deprecated in 1.25, was removed. Use UtfNormal\Validator directly
+  instead.
+* (T197179) In OOUI HTMLForm fields, the parameters 'notice', 'notice-messages',
+  and 'notice-message', which were deprecated in 1.32, were removed. Instead,
+  use 'help', 'help-message', and 'help-messages'.
+* (T197179) HTMLFormField::getNotices(), deprecated in 1.32, was removed.
+* The "Parsoid v1" compatibility mappings in ParsoidVirtualRESTService and
+  RestbaseVirtualRESTService, deprecated since 1.26, have been removed.
+  Use the RESTBase v1 or Parsoid v3 API instead.
+* ParserOptions defaults 'tidy' to true now, since the untidy modes of the
+  parser are being deprecated and ParserOptions::getCanonicalOverrides()
+  has always been true at any rate.
+* Support for disabling tidy and external tidy implementations has been removed.
+  This was deprecated in 1.32. The pure PHP Remex tidy implementation is now
+  used and no configuration is necessary.
+* A number of deprecated methods for API documentation, intended for overriding
+  by extensions, are no longer called by MediaWiki, and will emit deprecation
+  notices if your extension attempts to use them:
+  * ApiBase::getDescription() (deprecated in 1.25)
+  * ApiBase::getParamDescription() (deprecated in 1.25)
+  * ApiBase::getExamples() (deprecated in 1.25)
+  * ApiBase::getDescriptionMessage() (deprecated in 1.30)
+  Additionally, the  'APIGetDescription' and 'APIGetParamDescription' hooks have
+  been removed, as their only use was to let extensions override values returned
+  by getDescription() and getParamDescription(), respectively.
+* The authentication hooks 'AbortAutoAccount' 'AbortNewAccount', 'AbortLogin',
+  'LoginUserMigrated', 'UserCreateForm', and 'UserLoginForm', all deprecated by
+  the creation of AuthManager in 1.27, have been removed. This also means that
+  the FakeAuthTemplate and LoginForm classes are removed, that FakeAuthTemplate
+  is no longer passed into LoginSignupSpecialPage->getFieldDefinitions(), and
+  that LoginSignupSpecialPage->getBCFieldDefinitions() is removed.
+* The 'jquery.localize' module, deprecated in 1.32, has been removed. Instead,
+  use 'jquery.i18n'.
+* The hooks LanguageGetSpecialPageAliases and LanguageGetMagic, deprecated since
+  1.16, have now been removed. Instead, use $specialPageAliases or $magicWords
+  respectively in a $wgExtensionMessagesFiles file.
+* The following methods of the Preferences class, deprecated in 1.31, have been
+  removed:
+  * getSaveBlacklist()
+  * loadPreferenceValues()
+  * getOptionFromUser()
+  * profilePreferences()
+  * skinPreferences()
+  * filesPreferences()
+  * datetimePreferences()
+  * renderingPreferences()
+  * editingPreferences()
+  * rcPreferences()
+  * watchlistPreferences()
+  * searchPreferences()
+  * miscPreferences()
+  * generateSkinOptions()
+  * getDateOptions()
+  * getImageSizes()
+  * getThumbSizes()
+  * validateSignature()
+  * cleanSignature()
+  * getTimezoneOptions()
+  * filterIntval()
+  * filterTimezoneInput()
+  * getTimeZoneList()
+* mw.util.jsMessage(), deprecated in 1.20, was removed. Use mw.notify instead.
+* (T61113) User::EDIT_TOKEN_SUFFIX was removed. It was deprecated since 1.27.
+* The 'mediawiki.api' module aliases, deprecated in 1.32, have been removed.
+  Specifically: mediawiki.api.category, mediawiki.api.edit,
+  mediawiki.api.login, mediawiki.api.options, mediawiki.api.parse,
+  mediawiki.api.upload, mediawiki.api.user, mediawiki.api.watch,
+  mediawiki.api.messages, and mediawiki.api.rollback.
+* The 'jquery.byteLimit' module alias for 'jquery.lengthLimit',
+  deprecated in 1.31, was removed.
+* Revision::fetchRevision(), deprecated in 1.28, was removed.
+* Class SquidUpdate, deprecated in 1.27, was removed.
+* Title->getSquidURLs(), deprecated in 1.27, was removed. Instead, use
+  Title->getCdnUrls().
+* Title::escapeFragmentForURL(), deprecated in 1.30, was removed. Use
+  Sanitizer::escapeIdForLink() or escapeIdForExternalInterwiki() instead.
+* Title->canTalk(), deprecated in 1.30, was removed. Instead, use
+  Title->canHaveTalkPage().
+* Title's methods for site and user page related to CSS and JS, deprecated in
+  1.31, were removed:
+  * Title->isCssOrJsPage() — Use Title->isSiteConfigPage()
+  * Title->isCssJsSubpage() – Use Title->isUserConfigPage()
+  * Title->getSkinFromCssJsSubpage() – Use Title->getSkinFromConfigSubpage()
+  * Title->isCssSubpage() – Use Title->isUserCssConfigPage()
+  * Title->isJsSubpage() – Use Title->isUserJsConfigPage()
+* SiteSQLStore, deprecated in 1.27 and whose only method, ::newInstance(),
+  would return the global SiteStore instance, has been removed. You can get to
+  this via MediaWiki\MediaWikiServices::getInstance()->getSiteStore() directly.
+* Linker::formatSize, deprecated in 1.28, has been removed (with DummyLinker's).
+  Instead, use Language->formatSize() with the relevant Language object.
+* Linker::formatTemplates, deprecated in 1.28, has been removed (along with the
+  version in DummyLinker). You can use TemplatesOnThisPageFormatter directly.
+* EventRelayerGroup::singleton(), deprecated in 1.27, has been removed. You can
+  use MediaWikiServices::getInstance()->getEventRelayerGroup() directly.
+* LinkCache->addLink(), deprecated in 1.27, has been removed. It is thought to
+  be unused, and is distinct from OutputPage->addLink(), which remains.
+* JsonContent->getJsonData(), deprecated in 1.25, has been removed. Instead, use
+  JsonContent->getData().
+* MWExceptionHandler::getLogId(), deprecated in 1.27, has been removed, as the
+  exception ID is the same as the request ID, from WebRequest::getRequestId().
+* SearchEngine::getNearMatchResultSet(), deprecated in 1.27, has been removed.
+  You can use SearchEngine::getNearMatcher() instead.
+* EmailNotification::updateWatchlistTimestamp, deprecated in 1.27, has been
+  removed. Instead, use WatchedItemStore::updateNotificationTimestamp directly.
+* User::getGroupName() and ::getGroupMember(), both deprecated in 1.29, have
+  been removed. Instead, please use UserGroupMembership::getGroupName() and
+  UserGroupMembership::getGroupMemberName().
+* Backwards compatibility for setting wgSessionsInObjectCache to false or using
+  wgSessionHandler, both of which were deprecated in 1.27 with the introduction
+  of SessionManager, has been removed.
+* SessionManager::autoCreateUser, deprecated in 1.27, has been removed. Use
+  MediaWiki\Auth\AuthManager::autoCreateUser instead.
+* The mw.libs.jpegmeta property, deprecated in 1.31, was removed.
+  Use require( 'mediawiki.libs.jpegmeta' ) instead.
+* The mw.user.stickyRandomId() method, deprecated in 1.32, was removed.
+  Use mw.user.getPageviewToken() instead.
+* Removed deprecated class property WikiRevision::$importer.
+* ResourceLoaderFileModule::readStyleFiles() now requires its $context
+  parameter.
+* The ChangeList::insertArticleLink() method, that was deprecated in 1.27, has
+  been removed.
+* MessageBlobStore::__construct() now requires its $rl parameter.
+* Second parameter to Sanitizer::escapeIdReferenceList() (deprecated in 1.31)
+  has been removed.
+* The 'jquery.xmldom' module has been removed.
+* The 'jquery.mockjax' module has been removed.
+* The 'jquery.hidpi' module, deprecated in 1.32, has been removed.
+* AuthPlugin and related code, deprecated in 1.27, has been removed. Extensions
+  should instead use AuthManager. The following no longer exist:
+  * The AuthPlugin class itself and the related AuthPluginUser class and i18n
+  * The AuthPluginSetup and AuthPluginAutoCreate hooks
+  * The transitional wrapper classes AuthPluginPrimaryAuthenticationProvider,
+    AuthManagerAuthPlugin, and AuthManagerAuthPluginUser.
+  * The $wgAuth configuration setting and its use in Setup.php and unit tests
+* (T217772) The 'wgAvailableSkins' mw.config key in JavaScript, was removed.
+* Language::markNoConversion, deprecated in 1.32, has been removed. Use
+  LanguageConverter::markNoConversion instead.
+* BagOStuff::modifySimpleRelayEvent() method has been removed.
+* ParserOutput::getLegacyOptions, deprecated in 1.30, has been removed.
+  Use ParserOutput::allCacheVaryingOptions instead.
+* CdnCacheUpdate::newSimplePurge, deprecated in 1.27, has been removed.
+  Use CdnCacheUpdate::newFromTitles() instead.
+* Handling of multiple arguments by the Block constructor, deprecated in 1.26,
+  has been removed.
+* The translation of main page in Sardinian (sc) was changed from "Pàgina Base"
+  to "Pàgina printzipale". Existing wikis using this content language need to
+  move the main page or change the name through MediaWiki:Mainpage page.
+* wfSplitWikiID(), deprecated in 1.32, has been removed.
+* MessageBlobStore::getBlob(), deprecated in 1.27, has been removed.
+  Use ::getBlobs() instead.
+* The .background-size() LESS mixin, deprecated in 1.27, has been removed.
+* ReadOnlyMode::clearCache() and ConfiguredReadOnlyMode::clearCache() have been
+  removed. Use MediaWikiTestCase::overrideMwServices() instead.
+
+=== Deprecations in 1.33 ===
+* The configuration option $wgUseESI has been deprecated, and is expected
+  to be removed in a future release.
+* The configuration option $wgSquidPurgeUseHostHeader has been deprecated,
+  and is expected to be removed in a future release.
+* The configuration options $wgFixArabicUnicode and $wgFixMalayalamUnicode,
+  introduced in MW 1.17, have been deprecated.  These fixes will always be
+  applied for Arabic and Malayalam in the future.  Please enable these on
+  your local wiki (if you have them explicitly set to false) and run
+  maintenance/cleanupTitles.php to fix any existing page titles.
+* The LegacyHookPreAuthenticationProvider class, deprecated since its creation
+  in 1.27 as part of the AuthManager re-write, now emits deprecation warnings.
+  This will help identify the issue if you added it to $wgAuthManagerConfig.
+* wfSplitWikiId() is now deprecated. Cache key generation should have the wiki
+  domain ID as a key component and use makeGlobalKey().
+* (T202094) Title::getUserCaseDBKey() is deprecated; instead, please use
+  Title::getDBKey(), which doesn't vary case.
+* User::getPasswordValidity() is now deprecated. User::checkPasswordValidity()
+  returns the same information in a more useful format.
+* For Linker::generateTOC() and Linker::tocList(), passing strings or booleans
+  as the $lang parameter was deprecated. The same applies to DummyLinker.
+* The PasswordPolicy 'PasswordCannotBePopular' has been deprecated. To
+  follow best practices, it is reccommended to use 'PasswordNotInLargeBlacklist'
+  instead which blacklists 100,000 commonly used passwords.
+* (T208862) Action::requiresUnblock() is now called from
+  Title::getUserPermissionsErrors() and Title::userCan(). Previously, the method
+  was only called in Action::checkCanExecute(). Actions should ensure that their
+  requiresUnblock() returns the proper result (the default is `true`).
+* (T211608) The MediaWiki\Services namespace has been renamed to
+  Wikimedia\Services. The old name is still supported, but deprecated.
+* (T155582) Content::getNativeData has been deprecated. Please use model-
+  specific getters, such as TextContent::getText().
+* The class WebInstallerOutput is now marked as @private.
+* (T209699) The jquery.async module has been deprecated. JavaScript code that
+  needs asynchronous behaviour should use Promises.
+* Password::equals() is deprecated, use verify().
+* BaseTemplate::msgWiki() and QuickTemplate::msgWiki() will be removed. Use
+  other means to fetch a properly escaped message string or Message object.
+* (T126091) The 'ResourceLoaderTestModules' hook, which lets you declare QUnit
+  testing code for your JavaScript modules, is deprecated. Instead, you can now
+  use the new extension registration key 'QUnitTestModule'.
+* (T213426) The jquery.throttle-debounce module has been deprecated. JavaScript
+  code that needs this behaviour should use OO.ui.debounce/throttle.
+* The mw.language.specialCharacters property from the
+  'mediawiki.language.specialCharacters' module has been deprecated.
+  Use require( 'mediawiki.language.specialCharacters' ) instead.
+* ChangeTags::purgeTagUsageCache() has been deprecated, and is expected to be
+  removed in a future release.
+* Passing a User object or null as the third parameter to
+  ApiBase::checkTitleUserPermissions() has been deprecated. Pass an array
+  [ 'user' => $user ] instead.
+* (T211578) Block::prevents is deprecated. Use Block::isEmailBlocked,
+  Block::isCreateAccountBlocked and Block::isUsertalkEditAllowed to get and set
+  block properties; use Block::appliesToRight and Block::appliesToUsertalk to
+  check block behaviour.
+* The api-feature-usage log channel now has log context. The text message is
+  deprecated and will be removed in the future.
+* The FileBasedSiteLookup class has been deprecated. For a cacheable SiteLookup
+  implementation, use CachingSiteStore instead.
+* Language::viewPrevNext function is deprecated, use
+  SpecialPage::buildPrevNextNavigation instead
+* ManualLogEntry::setTags() is deprecated, use ManualLogEntry::addTags()
+  instead. The setTags() method was overriding the tags, addTags() doesn't
+  override, only adds new tags.
+* Block::isValid is deprecated, since it is no longer needed in core.
+* Calling Maintenance::hasArg() as well as Maintenance::getArg() with no
+  parameter has been deprecated. Please pass the argument number 0.
+* ResourceLoaderContext::expandModuleNames has been deprecated.
+  Use ResourceLoader::expandModuleNames instead.
+
+=== Other changes in 1.33 ===
+* (T201747) Html::openElement() warns if given an element name with a space
+  in it.
+* The implementation of buildStringCast() in Wikimedia\Rdbms\Database has
+  changed to explicitly cast. Subclasses relying on the base-class
+  implementation should check whether they need to override it now.
+* BagOStuff::add is now abstract and must explicitly be defined in subclasses.
+* LinksDeletionUpdate is now a subclass of LinksUpdate. As a consequence,
+  the following hooks will now be triggered upon page deletion in addition
+  to page updates: LinksUpdateConstructed, LinksUpdate, LinksUpdateComplete.
+  LinksUpdateAfterInsert is not triggered since deletions do not cause
+  insertions into links tables.
+* Category::newFromID( $id )->getID() will now return $id without any
+  validation, to avoid a mostly unnecessary DB query.
+* On Special:Version, the name for an extension can no longer be arbitrary
+  html when no link is specified.
+
+
 = MediaWiki 1.32 =
 
+== MediaWiki 1.32.3 ==
+
+This is a maintenance release of the MediaWiki 1.32 branch.
+
+=== Changes since MediaWiki 1.32.2 ===
+* (T225558) Update installer link to PHP intl.
+* (T225496) Detect APC for MainCacheType in CLI installer.
+* (T226766) Remove jetbrains/phpstorm-stubs from composer dev dependancies.
+* (T202211) Fix SQLite patch-(image|page|template)links-fix-pk.sql column order.
+
 == MediaWiki 1.32.2 ==
 
 This is a security and maintenance release of the MediaWiki 1.32 branch.
@@ -751,6 +1239,16 @@ because of Phabricator reports.
 
 = MediaWiki 1.31 =
 
+== MediaWiki 1.31.3 ==
+
+This is a maintenance release of the MediaWiki 1.31 branch.
+
+=== Changes since MediaWiki 1.31.2 ===
+* (T225558) Update installer link to PHP intl.
+* (T225496) Detect APC for MainCacheType in CLI installer.
+* (T226766) Remove jetbrains/phpstorm-stubs from composer dev dependancies.
+* (T202211) Fix SQLite patch-(image|page|template)links-fix-pk.sql column order.
+
 == MediaWiki 1.31.2 ==
 
 This is a security and maintenance release of the MediaWiki 1.31 branch.
index acd82d6..fdf2616 100644 (file)
@@ -252,6 +252,12 @@ because of Phabricator reports.
   protocol-relative URL, or full scheme URL), and will instead pass them to the
   client where they will likely 404. This usage was deprecated in 1.24.
 * Database::reportConnectionError, deprecated in 1.32, has been removed.
+* APIEditBeforeSave hook, deprecated in 1.28, has been removed. Please see
+  EditFilterMergedContent hook for an alternative way to use this feature.
+* API module methods getDescription(), getParamDescription(), & getExamples(),
+  all deprecated in 1.25 and ignored, have been removed.
+* The API module method getDescriptionMessage(), deprecated in 1.30, has been
+  removed.
 * …
 
 === Deprecations in 1.34 ===
index 6457747..5eadf79 100644 (file)
@@ -1009,7 +1009,7 @@ $wgAutoloadLocalClasses = [
        'MssqlInstaller' => __DIR__ . '/includes/installer/MssqlInstaller.php',
        'MssqlUpdater' => __DIR__ . '/includes/installer/MssqlUpdater.php',
        'MultiConfig' => __DIR__ . '/includes/config/MultiConfig.php',
-       'MultiHttpClient' => __DIR__ . '/includes/libs/MultiHttpClient.php',
+       'MultiHttpClient' => __DIR__ . '/includes/libs/http/MultiHttpClient.php',
        'MultiWriteBagOStuff' => __DIR__ . '/includes/libs/objectcache/MultiWriteBagOStuff.php',
        'MutableConfig' => __DIR__ . '/includes/config/MutableConfig.php',
        'MutableContext' => __DIR__ . '/includes/context/MutableContext.php',
index 4750560..1e5072f 100644 (file)
@@ -347,19 +347,6 @@ from ApiBase::addDeprecation().
 &$msgs: Message[] Messages to include in the help. Multiple messages will be
   joined with spaces.
 
-'APIEditBeforeSave': DEPRECATED since 1.28! Use EditFilterMergedContent instead.
-Before saving a page with api.php?action=edit, after
-processing request parameters. Return false to let the request fail, returning
-an error message or an <edit result="Failure"> tag if $resultArr was filled.
-Unlike for example 'EditFilterMergedContent' this also being run on undo.
-Since MediaWiki 1.25, 'EditFilterMergedContent' can also return error details
-for the API and it's recommended to use it instead of this hook.
-$editPage: the EditPage object
-$text: the text passed to the API. Note that this includes only the single
-  section for section edit, and is not necessarily the final text in case of
-  automatically resolved edit conflicts.
-&$resultArr: data in this array will be added to the API result
-
 'ApiFeedContributions::feedItem': Called to convert the result of ContribsPager
 into a FeedItem instance that ApiFeedContributions can consume. Implementors of
 this hook may cancel the hook to signal that the item is not viewable in the
index 05c4655..5f17ad8 100644 (file)
@@ -1037,9 +1037,18 @@ function wfLogDBError( $text, array $context = [] ) {
  * @param int $callerOffset How far up the call stack is the original
  *    caller. 2 = function that called the function that called
  *    wfDeprecated (Added in 1.20).
+ *
+ * @throws Exception If the MediaWiki version number is not a string or boolean.
  */
 function wfDeprecated( $function, $version = false, $component = false, $callerOffset = 2 ) {
-       MWDebug::deprecated( $function, $version, $component, $callerOffset + 1 );
+       if ( is_string( $version ) || is_bool( $version ) ) {
+               MWDebug::deprecated( $function, $version, $component, $callerOffset + 1 );
+       } else {
+               throw new Exception(
+                       "MediaWiki version must either be a string or a boolean. " .
+                       "Example valid version: '1.33'"
+               );
+       }
 }
 
 /**
index 01f695a..f3d492f 100644 (file)
@@ -1116,17 +1116,22 @@ class Linker {
         * @return string HTML
         */
        public static function revUserTools( $rev, $isPublic = false, $useParentheses = true ) {
-               if ( $rev->isDeleted( Revision::DELETED_USER ) && $isPublic ) {
-                       $link = wfMessage( 'rev-deleted-user' )->escaped();
-               } elseif ( $rev->userCan( Revision::DELETED_USER ) ) {
+               if ( $rev->userCan( Revision::DELETED_USER ) &&
+                       ( !$rev->isDeleted( Revision::DELETED_USER ) || !$isPublic )
+               ) {
                        $userId = $rev->getUser( Revision::FOR_THIS_USER );
                        $userText = $rev->getUserText( Revision::FOR_THIS_USER );
-                       $link = self::userLink( $userId, $userText )
-                               . self::userToolLinks( $userId, $userText, false, 0, null,
-                                       $useParentheses );
-               } else {
+                       if ( $userId && $userText ) {
+                               $link = self::userLink( $userId, $userText )
+                                       . self::userToolLinks( $userId, $userText, false, 0, null,
+                                               $useParentheses );
+                       }
+               }
+
+               if ( !isset( $link ) ) {
                        $link = wfMessage( 'rev-deleted-user' )->escaped();
                }
+
                if ( $rev->isDeleted( Revision::DELETED_USER ) ) {
                        return ' <span class="history-deleted mw-userlink">' . $link . '</span>';
                }
index a37e32e..7fda452 100644 (file)
@@ -33,9 +33,8 @@ use MediaWiki\Revision\RevisionStore;
 use OldRevisionImporter;
 use MediaWiki\Revision\RevisionStoreFactory;
 use UploadRevisionImporter;
-use Wikimedia\Rdbms\LBFactory;
+use Wikimedia\Rdbms\ILoadBalancer;
 use LinkCache;
-use Wikimedia\Rdbms\LoadBalancer;
 use MediaHandlerFactory;
 use MediaWiki\Config\ConfigRepository;
 use MediaWiki\Linker\LinkRenderer;
@@ -62,6 +61,7 @@ use SkinFactory;
 use TitleFormatter;
 use TitleParser;
 use VirtualRESTServiceClient;
+use Wikimedia\Rdbms\LBFactory;
 use Wikimedia\Services\SalvageableService;
 use Wikimedia\Services\ServiceContainer;
 use Wikimedia\Services\NoSuchServiceException;
@@ -549,7 +549,7 @@ class MediaWikiServices extends ServiceContainer {
 
        /**
         * @since 1.28
-        * @return LoadBalancer The main DB load balancer for the local wiki.
+        * @return ILoadBalancer The main DB load balancer for the local wiki.
         */
        public function getDBLoadBalancer() {
                return $this->getService( 'DBLoadBalancer' );
index 279c15e..5ba3d08 100644 (file)
@@ -233,7 +233,7 @@ class Router {
                        }
                }
 
-               $request->setPathParams( $match['params'] );
+               $request->setPathParams( array_map( 'rawurldecode', $match['params'] ) );
                $spec = $match['userData'];
                $objectFactorySpec = array_intersect_key( $spec,
                        [ 'factory' => true, 'class' => true, 'args' => true ] );
index f69f1a4..b27baa8 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 use MediaWiki\Permissions\PermissionManager;
+use Wikimedia\Assert\Assert;
 use Wikimedia\Rdbms\Database;
 use Wikimedia\Rdbms\IDatabase;
 use MediaWiki\Linker\LinkTarget;
@@ -851,7 +852,10 @@ class Title implements LinkTarget, IDBAccessObject {
        /**
         * Returns true if the title is valid, false if it is invalid.
         *
-        * Valid titles can be round-tripped via makeTitleSafe() and newFromText().
+        * Valid titles can be round-tripped via makeTitle() and newFromText().
+        * Their DB key can be used in the database, though it may not have the correct
+        * capitalization.
+        *
         * Invalid titles may get returned from makeTitle(), and it may be useful to
         * allow them to exist, e.g. in order to process log entries about pages in
         * namespaces that belong to extensions that are no longer installed.
@@ -870,10 +874,23 @@ class Title implements LinkTarget, IDBAccessObject {
 
                try {
                        $services->getTitleParser()->parseTitle( $this->mDbkeyform, $this->mNamespace );
-                       return true;
                } catch ( MalformedTitleException $ex ) {
                        return false;
                }
+
+               try {
+                       // Title value applies basic syntax checks. Should perhaps be moved elsewhere.
+                       new TitleValue(
+                               $this->mNamespace,
+                               $this->mDbkeyform,
+                               $this->mFragment,
+                               $this->mInterwiki
+                       );
+               } catch ( InvalidArgumentException $ex ) {
+                       return false;
+               }
+
+               return true;
        }
 
        /**
@@ -1728,6 +1745,9 @@ class Title implements LinkTarget, IDBAccessObject {
        /**
         * Get the root page name text without a namespace, i.e. the leftmost part before any slashes
         *
+        * @note the return value may contain trailing whitespace and is thus
+        * not safe for use with makeTitle or TitleValue.
+        *
         * @par Example:
         * @code
         * Title::newFromText('User:Foo/Bar/Baz')->getRootText();
@@ -1761,12 +1781,20 @@ class Title implements LinkTarget, IDBAccessObject {
         * @since 1.20
         */
        public function getRootTitle() {
-               return self::makeTitle( $this->mNamespace, $this->getRootText() );
+               $title = self::makeTitleSafe( $this->mNamespace, $this->getRootText() );
+               Assert::postcondition(
+                       $title !== null,
+                       'makeTitleSafe() should always return a Title for the text returned by getRootText().'
+               );
+               return $title;
        }
 
        /**
         * Get the base page name without a namespace, i.e. the part before the subpage name
         *
+        * @note the return value may contain trailing whitespace and is thus
+        * not safe for use with makeTitle or TitleValue.
+        *
         * @par Example:
         * @code
         * Title::newFromText('User:Foo/Bar/Baz')->getBaseText();
@@ -1794,7 +1822,7 @@ class Title implements LinkTarget, IDBAccessObject {
        }
 
        /**
-        * Get the base page name title, i.e. the part before the subpage name
+        * Get the base page name title, i.e. the part before the subpage name.
         *
         * @par Example:
         * @code
@@ -1806,7 +1834,12 @@ class Title implements LinkTarget, IDBAccessObject {
         * @since 1.20
         */
        public function getBaseTitle() {
-               return self::makeTitle( $this->mNamespace, $this->getBaseText() );
+               $title = self::makeTitleSafe( $this->mNamespace, $this->getBaseText() );
+               Assert::postcondition(
+                       $title !== null,
+                       'makeTitleSafe() should always return a Title for the text returned by getBaseText().'
+               );
+               return $title;
        }
 
        /**
index 5687f0f..e798414 100644 (file)
@@ -2629,81 +2629,6 @@ abstract class ApiBase extends ContextSource {
        }
 
        /**@}*/
-
-       /************************************************************************//**
-        * @name   Deprecated
-        * @{
-        */
-
-       /**
-        * Returns the description string for this module
-        *
-        * Ignored if an i18n message exists for
-        * "apihelp-{$this->getModulePath()}-description".
-        *
-        * @deprecated since 1.25
-        * @return Message|string|array|false
-        */
-       protected function getDescription() {
-               wfDeprecated( __METHOD__, '1.25' );
-               return false;
-       }
-
-       /**
-        * Returns an array of parameter descriptions.
-        *
-        * For each parameter, ignored if an i18n message exists for the parameter.
-        * By default that message is
-        * "apihelp-{$this->getModulePath()}-param-{$param}", but it may be
-        * overridden using ApiBase::PARAM_HELP_MSG in the data returned by
-        * self::getFinalParams().
-        *
-        * @deprecated since 1.25
-        * @return array|bool False on no parameter descriptions
-        */
-       protected function getParamDescription() {
-               wfDeprecated( __METHOD__, '1.25' );
-               return [];
-       }
-
-       /**
-        * Returns usage examples for this module.
-        *
-        * Return value as an array is either:
-        *  - numeric keys with partial URLs ("api.php?" plus a query string) as
-        *    values
-        *  - sequential numeric keys with even-numbered keys being display-text
-        *    and odd-numbered keys being partial urls
-        *  - partial URLs as keys with display-text (string or array-to-be-joined)
-        *    as values
-        * Return value as a string is the same as an array with a numeric key and
-        * that value, and boolean false means "no examples".
-        *
-        * @deprecated since 1.25, use getExamplesMessages() instead
-        * @return bool|string|array
-        */
-       protected function getExamples() {
-               wfDeprecated( __METHOD__, '1.25' );
-               return false;
-       }
-
-       /**
-        * Return the description message.
-        *
-        * This is additional text to display on the help page after the summary.
-        *
-        * @deprecated since 1.30
-        * @return string|array|Message
-        */
-       protected function getDescriptionMessage() {
-               wfDeprecated( __METHOD__, '1.30' );
-               return [ [
-                       "apihelp-{$this->getModulePath()}-description",
-                       "apihelp-{$this->getModulePath()}-summary",
-               ] ];
-       }
-
-       /**@}*/
 }
 
 /**
index d0a0523..96aea04 100644 (file)
@@ -367,21 +367,6 @@ class ApiEditPage extends ApiBase {
                $ep->importFormData( $req );
                $content = $ep->textbox1;
 
-               // Run hooks
-               // Handle APIEditBeforeSave parameters
-               $r = [];
-               // Deprecated in favour of EditFilterMergedContent
-               if ( !Hooks::run( 'APIEditBeforeSave', [ $ep, $content, &$r ], '1.28' ) ) {
-                       if ( count( $r ) ) {
-                               $r['result'] = 'Failure';
-                               $apiResult->addValue( null, $this->getModuleName(), $r );
-
-                               return;
-                       }
-
-                       $this->dieWithError( 'hookaborted' );
-               }
-
                // Do the actual save
                $oldRevId = $articleObject->getRevIdFetched();
                $result = null;
index 370a3fb..91d86b9 100644 (file)
@@ -59,10 +59,6 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
                $fld_token = isset( $prop['token'] );
                $fld_tags = isset( $prop['tags'] );
 
-               if ( isset( $prop['token'] ) ) {
-                       $p = $this->getModulePrefix();
-               }
-
                // If we're in a mode that breaks the same-origin policy, no tokens can
                // be obtained
                if ( $this->lacksSameOriginSecurity() ) {
index 8442213..640ddfa 100644 (file)
@@ -32,7 +32,8 @@
                        "KATRINE1992",
                        "Kenjiraw",
                        "Framawiki",
-                       "Epok"
+                       "Epok",
+                       "Derugon"
                ]
        },
        "apihelp-main-extended-description": "<div class=\"hlist plainlinks api-main-links\">\n* [[mw:Special:MyLanguage/API:Main_page|Documentation]]\n* [[mw:Special:MyLanguage/API:FAQ|FAQ]]\n* [https://lists.wikimedia.org/mailman/listinfo/mediawiki-api Liste de diffusion]\n* [https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce Annonces de l’API]\n* [https://phabricator.wikimedia.org/maniphest/query/GebfyV4uCaLd/#R Bogues et demandes]\n</div>\n<strong>État :</strong> L’API MediaWiki est une interface stable et mature qui est supportée et améliorée de façon active. Bien que nous essayions de l’éviter, nous pouvons avoir parfois besoin de faire des modifications impactantes ; inscrivez-vous à [https://lists.wikimedia.org/pipermail/mediawiki-api-announce/ la liste de diffusion mediawiki-api-announce] pour être informé des mises à jour.\n\n<strong>Requêtes erronées :</strong> Si des requêtes erronées sont envoyées à l’API, un entête HTTP sera renvoyé avec la clé « MediaWiki-API-Error ». La valeur de cet entête et le code d’erreur renvoyé prendront la même valeur. Pour plus d’information, voyez [[mw:Special:MyLanguage/API:Errors_and_warnings|API:Errors and warnings]].\n\n<p class=\"mw-apisandbox-link\"><strong>Test :</strong> Pour faciliter le test des requêtes à l’API, voyez [[Special:ApiSandbox]].</p>",
        "apihelp-query-param-indexpageids": "Inclure une section pageids supplémentaire listant tous les IDs de page renvoyés.",
        "apihelp-query-param-export": "Exporter les révisions actuelles de toutes les pages fournies ou générées.",
        "apihelp-query-param-exportnowrap": "Renvoyer le XML exporté sans l’inclure dans un résultat XML (même format que [[Special:Export]]). Utilisable uniquement avec $1export.",
+       "apihelp-query-param-exportschema": "Utiliser la version du format XML donnée en exportant. Peut être utilisé seulement avec <var>$1export</var>.",
        "apihelp-query-param-iwurl": "S’il faut obtenir l’URL complète si le titre est un lien interwiki.",
        "apihelp-query-param-rawcontinue": "Renvoyer les données <samp>query-continue</samp> brutes pour continuer.",
        "apihelp-query-example-revisions": "Récupérer [[Special:ApiHelp/query+siteinfo|l’info du site]] et [[Special:ApiHelp/query+revisions|les révisions]] de <kbd>Main Page</kbd>.",
        "api-help-param-templated-var-first": "<var>&#x7B;$1&#x7D;</var> dans le nom du paramètre doit être remplacé par des valeurs de <var>$2</var>",
        "api-help-param-templated-var": "<var>&#x7B;$1&#x7D;</var> par les valeurs de <var>$2</var>",
        "api-help-datatypes-header": "Type de données",
-       "api-help-datatypes": "Les entrées dans MédiaWiki doivent être en UTF-8 à la norme NFC. MédiaWiki peut tenter de convertir d’autres types d’entrée, mais cela peut faire échouer certaines opérations (comme les [[Special:ApiHelp/edit|modifications]] avec contrôles MD5) to fail.\n\nCertains types de paramètre dans les requêtes de l’API nécessitent plus d’explication :\n;boolean\n:Les paramètres booléens fonctionnent comme des cases à cocher HTML : si le paramètre est spécifié, quelle que soit sa valeur, il est considéré comme vrai. Pour une valeur fausse, enlever complètement le paramètre.\n;timestamp\n:Les horodatages peuvent être spécifiés sous différentes formes. Date et heure ISO 8601 est recommandé. Toutes les heures sont en UTC, tout fuseau horaire inclus est ignoré.\n:* Date et heure ISO 8601, <kbd><var>2001</var>-<var>01</var>-<var>15</var>T<var>14</var>:<var>56</var>:<var>00</var>Z</kbd> (la ponctuation et <kbd>Z</kbd> sont facultatifs)\n:* Date et heure ISO 8601 avec fractions de seconde (ignorées), <kbd><var>2001</var>-<var>01</var>-<var>15</var>T<var>14</var>:<var>56</var>:<var>00</var>.<var>00001</var>Z</kbd> (tirets, deux-points et <kbd>Z</kbd> sont facultatifs)\n:* Format MédiaWiki, <kbd><var>2001</var><var>01</var><var>15</var><var>14</var><var>56</var><var>00</var></kbd>\n:* Format numérique générique, <kbd><var>2001</var>-<var>01</var>-<var>15</var> <var>14</var>:<var>56</var>:<var>00</var></kbd> (fuseau horaire facultatif en <kbd>GMT</kbd>, <kbd>+<var>##</var></kbd>, ou <kbd>-<var>##</var></kbd> sont ignorés)\n:* Format EXIF, <kbd><var>2001</var>:<var>01</var>:<var>15</var> <var>14</var>:<var>56</var>:<var>00</var></kbd>\n:*Format RFC 2822 (le fuseau horaire est facultatif), <kbd><var>Mon</var>, <var>15</var> <var>Jan</var> <var>2001</var> <var>14</var>:<var>56</var>:<var>00</var></kbd>\n:* Format RFC 850 (le fuseau horaire est facultatif), <kbd><var>Monday</var>, <var>15</var>-<var>Jan</var>-<var>2001</var> <var>14</var>:<var>56</var>:<var>00</var></kbd>\n:* Format ctime C, <kbd><var>Mon</var> <var>Jan</var> <var>15</var> <var>14</var>:<var>56</var>:<var>00</var> <var>2001</var></kbd>\n:* Secondes depuis 1970-01-01T00:00:00Z sous forme d’entier de 1 à 13 chiffres (sans <kbd>0</kbd>)\n:* La chaîne <kbd>now</kbd>",
+       "api-help-datatypes": "Les entrées dans MédiaWiki doivent être en UTF-8 à la norme NFC. MédiaWiki peut tenter de convertir d’autres types d’entrées, mais cela peut faire échouer certaines opérations (comme les [[Special:ApiHelp/edit|modifications]] avec contrôles MD5).\n\nCertains types de paramètres dans les requêtes de l’API nécessitent plus d’explication&nbsp;:\n;boolean\n:Les paramètres booléens fonctionnent comme des cases à cocher HTML&nbsp;: si le paramètre est spécifié, quelle que soit sa valeur, il est considéré comme vrai. Pour une valeur fausse, enlever complètement le paramètre.\n;timestamp\n:Les horodatages peuvent être spécifiés sous différentes formes, voir [[mw:Special:MyLanguage/Timestamp|les formats d’entrées de la librairie Timestampdocumentés sur mediawiki.org]] pour plus de détails. La date et heure ISO 8601 est recommandée&nbsp;: <kbd><var>2001</var>-<var>01</var>-<var>15</var>T<var>14</var>:<var>56</var>:<var>00</var>Z</kbd>. De plus, la chaîne de caractères <kbd>now</kbd> peut être utilisée pour spécifier le fuseau horaire actuel.\n;séparateur multi-valeurs alternatif\n:Les paramètres prenant plusieurs valeurs sont normalement validés lorsque celles-ci sont séparées par le caractère «&nbsp;pipe&nbsp;» (|), ex. <kbd>paramètre=valeur1|valeur2</kbd> ou <kbd>paramètre=valeur1%7Cvaleur2</kbd>. Si une valeur doit contenir le caractère «&nbsp;pipe&nbsp;», utiliser U+001F (séparateur de sous-articles) comme séparateur ''et'' la préfixer de U+001F, ex. <kbd>paramètre=%1Fvaleur1%1Fvaleur2</kbd>.",
        "api-help-templatedparams-header": "Paramètres de modèle",
        "api-help-templatedparams": "Les paramètres de modèle supportent les cas où un module d’API a besoin d’une valeur pour chaque valeur d’un autre paramètre quelconque. Par exemple, s’il y avait un module d’API pour demander un fruit, il pourrait avoir un paramètre <var>fruits</var> pour spécifier quels fruits sont demandés et un paramètre de modèle <var>{fruit}-quantité</var> pour spécifier la quantité demandée de chaque fruit. Un client de l’API qui voudrait une pomme, cinq bananes et vingt fraises pourrait alors faire une requête comme <kbd>fruits=pommes|bananes|fraises&pommes-quantité=1&bananes-quantité=5&fraises-quantité=20</kbd>.",
        "api-help-param-type-limit": "Type : entier ou <kbd>max</kbd>",
index 530b7dd..7c98c7a 100644 (file)
        "api-help-param-integer-max": "Az {{PLURAL:$1|1=érték nem lehet nagyobb|2=értékek nem lehetnek nagyobbak}} mint $3.",
        "api-help-param-integer-minmax": "{{PLURAL:$1|1=Az értéknek $2 és $3 között kell lennie.|2=Az értékeknek $2 és $3 között kell lenniük.}}",
        "api-help-param-default": "Alapértelmezett: $1",
+       "api-help-param-default-empty": "Alapértelmezett: <span class=\"apihelp-empty\">(üres)</span>",
        "api-help-examples": "{{PLURAL:$1|Példa|Példák}}:",
        "apierror-timeout": "A kiszolgáló nem adott választ a várt időn belül."
 }
index 1e0d508..ef03a3d 100644 (file)
        "apihelp-query-param-indexpageids": "Inclua uma seção adicional de pageids listando todas as IDs de página retornadas.",
        "apihelp-query-param-export": "Exporte as revisões atuais de todas as páginas dadas ou geradas.",
        "apihelp-query-param-exportnowrap": "Retorna o XML de exportação sem envolvê-lo em um resultado XML (mesmo formato que [[Special:Export]]). Só pode ser usado com $1export.",
+       "apihelp-query-param-exportschema": "Segmente a versão fornecida do formato de dump XML ao exportar. Só pode ser usado com <var>$1export</var>.",
        "apihelp-query-param-iwurl": "Obter o URL completo se o título for um link interwiki.",
        "apihelp-query-param-rawcontinue": "Retorne os dados de <samp>query-continue</samp> para continuar.",
        "apihelp-query-example-revisions": "Obter [[Special:ApiHelp/query+siteinfo|site info]] e [[Special:ApiHelp/query+revisions|revisions]] da <kbd>Main Page</kbd>.",
index 13b22b1..cf80ac0 100644 (file)
@@ -28,7 +28,8 @@
                        "Wxyveronica",
                        "WhitePhosphorus",
                        "科劳",
-                       "SolidBlock"
+                       "SolidBlock",
+                       "神樂坂秀吉"
                ]
        },
        "apihelp-main-extended-description": "<div class=\"hlist plainlinks api-main-links\">\n* [[mw:Special:MyLanguage/API:Main_page|文档]]\n* [[mw:Special:MyLanguage/API:FAQ|常见问题]]\n* [https://lists.wikimedia.org/mailman/listinfo/mediawiki-api 邮件列表]\n* [https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce API公告]\n* [https://phabricator.wikimedia.org/maniphest/query/GebfyV4uCaLd/#R 程序错误与功能请求]\n</div>\n<strong>状态信息:</strong>MediaWiki API是一个成熟稳定的,不断受到支持和改进的界面。尽管我们尽力避免,但偶尔也需要作出重大更新;请订阅[https://lists.wikimedia.org/pipermail/mediawiki-api-announce/ mediawiki-api-announce 邮件列表]以便获得更新通知。\n\n<strong>错误请求:</strong>当API收到错误请求时,HTTP header将会返回一个包含\"MediaWiki-API-Error\"的值,随后header的值与error code将会送回并设置为相同的值。详细信息请参阅[[mw:Special:MyLanguage/API:Errors_and_warnings|API:错误与警告]]。\n\n<p class=\"mw-apisandbox-link\"><strong>测试中:</strong>测试API请求的易用性,请参见[[Special:ApiSandbox]]。</p>",
        "apihelp-opensearch-param-warningsaserror": "如果警告通过<kbd>format=json</kbd>提升,返回一个API错误而不是忽略它们。",
        "apihelp-opensearch-example-te": "查找以<kbd>Te</kbd>开头的页面。",
        "apihelp-options-summary": "更改当前用户的参数设置。",
-       "apihelp-options-extended-description": "只有注册在核心或者已安装扩展中的选项,或者具有<code>userjs-</code>键值前缀(旨在被用户脚本使用)的选项可被设置。",
+       "apihelp-options-extended-description": "只有注册在核心或者已安装扩展中的选项,或者具有<code>userjs-</code>键值前缀(旨在使用于用户脚本)的选项可设置。",
        "apihelp-options-param-reset": "将参数设置重置为网站默认值。",
        "apihelp-options-param-resetkinds": "当<var>$1reset</var>选项被设置时,要重置的选项类型列表。",
        "apihelp-options-param-change": "更改列表,以name=value格式化(例如skin=vector)。如果没提供值(甚至没有等号),例如optionname|otheroption|...,选项将重置为默认值。如果任何传递的值包含管道字符(<kbd>|</kbd>),请改用[[Special:ApiHelp/main#main/datatypes|替代多值分隔符]]以正确操作。",
index b646380..7d02a82 100644 (file)
@@ -199,7 +199,7 @@ class LocalPasswordPrimaryAuthenticationProvider
                list( $db, $options ) = \DBAccessObjectUtils::getDBOptions( $flags );
                return (bool)wfGetDB( $db )->selectField(
                        [ 'user' ],
-                       [ 'user_id' ],
+                       'user_id',
                        [ 'user_name' => $username ],
                        __METHOD__,
                        $options
index e129538..42a1c24 100644 (file)
@@ -206,7 +206,7 @@ class TemporaryPasswordPrimaryAuthenticationProvider
                list( $db, $options ) = \DBAccessObjectUtils::getDBOptions( $flags );
                return (bool)wfGetDB( $db )->selectField(
                        [ 'user' ],
-                       [ 'user_id' ],
+                       'user_id',
                        [ 'user_name' => $username ],
                        __METHOD__,
                        $options
index dc07364..c58537e 100644 (file)
@@ -21,6 +21,7 @@
 namespace MediaWiki\Block;
 
 use DateTime;
+use DeferredUpdates;
 use IP;
 use MediaWiki\User\UserIdentity;
 use MWCryptHash;
@@ -431,26 +432,38 @@ class BlockManager {
         * @param User $user
         */
        public function trackBlockWithCookie( User $user ) {
-               $block = $user->getBlock();
                $request = $user->getRequest();
-               $response = $request->response();
-               $isAnon = $user->isAnon();
-
-               if ( $block && $request->getCookie( 'BlockID' ) === null ) {
-                       if ( $block instanceof CompositeBlock ) {
-                               // TODO: Improve on simply tracking the first trackable block (T225654)
-                               foreach ( $block->getOriginalBlocks() as $originalBlock ) {
-                                       if ( $this->shouldTrackBlockWithCookie( $originalBlock, $isAnon ) ) {
-                                               $this->setBlockCookie( $originalBlock, $response );
-                                               return;
+               if ( $request->getCookie( 'BlockID' ) !== null ) {
+                       // User already has a block cookie
+                       return;
+               }
+
+               // Defer checks until the user has been fully loaded to avoid circular dependency
+               // of User on itself (T180050 and T226777)
+               DeferredUpdates::addCallableUpdate(
+                       function () use ( $user, $request ) {
+                               $block = $user->getBlock();
+                               $response = $request->response();
+                               $isAnon = $user->isAnon();
+
+                               if ( $block ) {
+                                       if ( $block instanceof CompositeBlock ) {
+                                               // TODO: Improve on simply tracking the first trackable block (T225654)
+                                               foreach ( $block->getOriginalBlocks() as $originalBlock ) {
+                                                       if ( $this->shouldTrackBlockWithCookie( $originalBlock, $isAnon ) ) {
+                                                               $this->setBlockCookie( $originalBlock, $response );
+                                                               return;
+                                                       }
+                                               }
+                                       } else {
+                                               if ( $this->shouldTrackBlockWithCookie( $block, $isAnon ) ) {
+                                                       $this->setBlockCookie( $block, $response );
+                                               }
                                        }
                                }
-                       } else {
-                               if ( $this->shouldTrackBlockWithCookie( $block, $isAnon ) ) {
-                                       $this->setBlockCookie( $block, $response );
-                               }
-                       }
-               }
+                       },
+                       DeferredUpdates::PRESEND
+               );
        }
 
        /**
index cf6ed17..14b53d3 100644 (file)
@@ -133,23 +133,23 @@ class ChangeTags {
        }
 
        /**
-        * Get a short description for a tag.
+        * Get the message object for the tag's short description.
         *
         * Checks if message key "mediawiki:tag-$tag" exists. If it does not,
-        * returns the HTML-escaped tag name. Uses the message if the message
-        * exists, provided it is not disabled. If the message is disabled,
-        * we consider the tag hidden, and return false.
+        * returns the tag name in a RawMessage. If the message exists, it is
+        * used, provided it is not disabled. If the message is disabled, we
+        * consider the tag hidden, and return false.
         *
+        * @since 1.34
         * @param string $tag
         * @param MessageLocalizer $context
-        * @return string|bool Tag description or false if tag is to be hidden.
-        * @since 1.25 Returns false if tag is to be hidden.
+        * @return Message|bool Tag description, or false if tag is to be hidden.
         */
-       public static function tagDescription( $tag, MessageLocalizer $context ) {
+       public static function tagShortDescriptionMessage( $tag, MessageLocalizer $context ) {
                $msg = $context->msg( "tag-$tag" );
                if ( !$msg->exists() ) {
-                       // No such message, so return the HTML-escaped tag name.
-                       return htmlspecialchars( $tag );
+                       // No such message
+                       return new RawMessage( '$1', [ Message::plaintextParam( $tag ) ] );
                }
                if ( $msg->isDisabled() ) {
                        // The message exists but is disabled, hide the tag.
@@ -157,7 +157,25 @@ class ChangeTags {
                }
 
                // Message exists and isn't disabled, use it.
-               return $msg->parse();
+               return $msg;
+       }
+
+       /**
+        * Get a short description for a tag.
+        *
+        * Checks if message key "mediawiki:tag-$tag" exists. If it does not,
+        * returns the HTML-escaped tag name. Uses the message if the message
+        * exists, provided it is not disabled. If the message is disabled,
+        * we consider the tag hidden, and return false.
+        *
+        * @param string $tag
+        * @param MessageLocalizer $context
+        * @return string|bool Tag description or false if tag is to be hidden.
+        * @since 1.25 Returns false if tag is to be hidden.
+        */
+       public static function tagDescription( $tag, MessageLocalizer $context ) {
+               $msg = self::tagShortDescriptionMessage( $tag, $context );
+               return $msg ? $msg->parse() : false;
        }
 
        /**
@@ -1468,6 +1486,7 @@ class ChangeTags {
                $cache->touchCheckKey( $cache->makeKey( 'active-tags' ) );
                $cache->touchCheckKey( $cache->makeKey( 'valid-tags-db' ) );
                $cache->touchCheckKey( $cache->makeKey( 'valid-tags-hook' ) );
+               $cache->touchCheckKey( $cache->makeKey( 'tags-usage-statistics' ) );
 
                MediaWikiServices::getInstance()->getChangeTagDefStore()->reloadMap();
        }
@@ -1479,21 +1498,35 @@ class ChangeTags {
         * @return array Array of string => int
         */
        public static function tagUsageStatistics() {
-               $dbr = wfGetDB( DB_REPLICA );
-               $res = $dbr->select(
-                       'change_tag_def',
-                       [ 'ctd_name', 'ctd_count' ],
-                       [],
-                       __METHOD__,
-                       [ 'ORDER BY' => 'ctd_count DESC' ]
-               );
+               $fname = __METHOD__;
 
-               $out = [];
-               foreach ( $res as $row ) {
-                       $out[$row->ctd_name] = $row->ctd_count;
-               }
+               $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
+               return $cache->getWithSetCallback(
+                       $cache->makeKey( 'tags-usage-statistics' ),
+                       WANObjectCache::TTL_MINUTE * 5,
+                       function ( $oldValue, &$ttl, array &$setOpts ) use ( $fname ) {
+                               $dbr = wfGetDB( DB_REPLICA );
+                               $res = $dbr->select(
+                                       'change_tag_def',
+                                       [ 'ctd_name', 'ctd_count' ],
+                                       [],
+                                       $fname,
+                                       [ 'ORDER BY' => 'ctd_count DESC' ]
+                               );
 
-               return $out;
+                               $out = [];
+                               foreach ( $res as $row ) {
+                                       $out[$row->ctd_name] = $row->ctd_count;
+                               }
+
+                               return $out;
+                       },
+                       [
+                               'checkKeys' => [ $cache->makeKey( 'tags-usage-statistics' ) ],
+                               'lockTSE' => WANObjectCache::TTL_MINUTE * 5,
+                               'pcTTL' => WANObjectCache::TTL_PROC_LONG
+                       ]
+               );
        }
 
        /**
index e9ebabb..ed7e00c 100644 (file)
@@ -82,20 +82,19 @@ class UserEditCountUpdate implements DeferrableUpdate, MergeableUpdate {
                                $affectedInstances = $info['instances'];
                                // Lazy initialization check...
                                if ( $dbw->affectedRows() == 0 ) {
-                                       // No rows will be "affected" if user_editcount is NULL.
-                                       // Check if the generic "replica" connection is not the master.
+                                       // The user_editcount is probably NULL (e.g. not initialized).
+                                       // Since this update runs after the new revisions were committed,
+                                       // wait for the replica DB to catch up so they will be counted.
                                        $dbr = $lb->getConnection( DB_REPLICA );
-                                       if ( $dbr !== $dbw ) {
-                                               // This method runs after the new revisions were committed.
-                                               // Wait for the replica to catch up so they will all be counted.
-                                               $dbr->flushSnapshot( $fname );
-                                               $lb->waitForMasterPos( $dbr );
-                                       }
-                                       $affectedInstances[0]->initEditCountInternal();
+                                       // If $dbr is actually the master DB, then clearing the snapshot is
+                                       // is harmless and waitForMasterPos() will just no-op.
+                                       $dbr->flushSnapshot( $fname );
+                                       $lb->waitForMasterPos( $dbr );
+                                       $affectedInstances[0]->initEditCountInternal( $dbr );
                                }
                                $newCount = (int)$dbw->selectField(
                                        'user',
-                                       [ 'user_editcount' ],
+                                       'user_editcount',
                                        [ 'user_id' => $userId ],
                                        $fname
                                );
index 4b33138..a44d3ed 100644 (file)
@@ -107,8 +107,7 @@ class ForeignDBRepo extends LocalRepo {
                        'password' => $this->dbPassword,
                        'dbname' => $this->dbName,
                        'flags' => $this->dbFlags,
-                       'tablePrefix' => $this->tablePrefix,
-                       'foreign' => true,
+                       'tablePrefix' => $this->tablePrefix
                ];
 
                return function ( $index ) use ( $type, $params ) {
index b4aab4a..ab59ff0 100644 (file)
@@ -76,15 +76,15 @@ class HTMLInfoField extends HTMLFormField {
        }
 
        /**
-        * @param mixed $value
+        * @param mixed $value If not FieldLayout or subclass has been deprecated.
         * @return OOUI\FieldLayout
         * @since 1.32
         */
        public function getOOUI( $value ) {
                if ( !empty( $this->mParams['rawrow'] ) ) {
                        if ( !( $value instanceof OOUI\FieldLayout ) ) {
-                               wfDeprecated( "'default' parameter as a string when using 'rawrow' " .
-                                       "(must be a FieldLayout or subclass)", '1.32' );
+                               wfDeprecated( __METHOD__ . ": 'default' parameter as a string when using" .
+                                       "'rawrow' (must be a FieldLayout or subclass)", '1.32' );
                        }
                        return $value;
                }
index 066a3ea..ad62e16 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 use Psr\Log\LoggerInterface;
-use Wikimedia\Rdbms\LoadBalancer;
+use Wikimedia\Rdbms\ILoadBalancer;
 
 /**
  * @since 1.31
@@ -19,19 +19,19 @@ class ImportableOldRevisionImporter implements OldRevisionImporter {
        private $doUpdates;
 
        /**
-        * @var LoadBalancer
+        * @var ILoadBalancer
         */
        private $loadBalancer;
 
        /**
         * @param bool $doUpdates
         * @param LoggerInterface $logger
-        * @param LoadBalancer $loadBalancer
+        * @param ILoadBalancer $loadBalancer
         */
        public function __construct(
                $doUpdates,
                LoggerInterface $logger,
-               LoadBalancer $loadBalancer
+               ILoadBalancer $loadBalancer
        ) {
                $this->doUpdates = $doUpdates;
                $this->logger = $logger;
index 5fcc4c9..6bf9921 100644 (file)
        "config-profile-help": "Wikis sind am nützlichsten, wenn so viele Menschen als möglich Bearbeitungen vornehmen können.\nMit MediaWiki ist es einfach die letzten Änderungen nachzuvollziehen und unbrauchbare Bearbeitungen, beispielsweise von unbedarften oder böswilligen Benutzern, rückgängig zu machen.\n\nAllerdings finden etliche Menschen Wikis auch mit anderen Bearbeitungskonzepten sinnvoll. Manchmal ist es zudem nicht einfach alle Beteiligten von den Vorteilen des „Wiki-Prinzips” zu überzeugen. Darum ist diese Auswahl möglich.\n\nDas Modell „'''{{int:config-profile-wiki}}'''“ ermöglicht es jedermann, sogar ohne über ein Benutzerkonto zu verfügen, Bearbeitungen vorzunehmen.\nEin Wiki bei dem die '''{{int:config-profile-no-anon}}''' ist, fordert von den Benutzern eine höhere Verantwortung für ihre Bearbeitungen ein, könnte allerdings Personen abschrecken, die nur gelegentlich Bearbeitungen vornehmen wollen. Ein Wiki für '''{{int:config-profile-fishbowl}}''' gestattet es nur bestimmten Benutzern, Bearbeitungen vorzunehmen. Allerdings kann dabei die Allgemeinheit die Seiten immer noch betrachten und Änderungen nachvollziehen. Ein '''{{int:config-profile-private}}''' gestattet es nur ausgewählten Benutzern, Seiten zu betrachten sowie zu bearbeiten.\n\nKomplexere Konzepte zur Zugriffssteuerung können erst nach abgeschlossenem Installationsvorgang eingerichtet werden. Hierzu gibt es weitere Informationen auf der Website mit der [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:User_rights entsprechenden Anleitung].",
        "config-license": "Lizenz:",
        "config-license-none": "Keine Lizenzangabe in der Fußzeile",
-       "config-license-cc-by-sa": "''Creative Commons'' „Namensnennung – Weitergabe unter gleichen Bedingungen“",
-       "config-license-cc-by": "''Creative Commons'' „Namensnennung“",
-       "config-license-cc-by-nc-sa": "''Creative Commons'' „Namensnennung – nicht kommerziell – Weitergabe unter gleichen Bedingungen“",
-       "config-license-cc-0": "''Creative Commons'' „Zero“ (Gemeinfreiheit)",
+       "config-license-cc-by-sa": "Creative Commons „Namensnennung – Weitergabe unter gleichen Bedingungen“",
+       "config-license-cc-by": "Creative Commons „Namensnennung“",
+       "config-license-cc-by-nc-sa": "Creative Commons „Namensnennung – nicht kommerziell – Weitergabe unter gleichen Bedingungen“",
+       "config-license-cc-0": "Creative Commons „Zero“ (Gemeinfreiheit)",
        "config-license-gfdl": "GNU-Lizenz für freie Dokumentation 1.3 oder höher",
        "config-license-pd": "Gemeinfreiheit",
        "config-license-cc-choose": "Eine andere Creative-Commons-Lizenz auswählen",
index feef335..6e1d5a2 100644 (file)
@@ -39,7 +39,8 @@
                        "Adjen",
                        "Dschultz",
                        "Carlosmg.dg",
-                       "Harvest"
+                       "Harvest",
+                       "Anarhistička Maca"
                ]
        },
        "config-desc": "El instalador de MediaWiki",
@@ -85,8 +86,8 @@
        "config-env-bad": "El entorno ha sido comprobado.\nNo puedes instalar MediaWiki.",
        "config-env-php": "PHP $1 está instalado.",
        "config-env-hhvm": "HHVM $1 está instalado.",
-       "config-unicode-using-intl": "Se utiliza la [https://pecl.php.net/intl extensión «intl» de PECL] para la normalización Unicode.",
-       "config-unicode-pure-php-warning": "<strong>Advertencia:</strong> la [https://pecl.php.net/intl extensión intl] no está disponible para efectuar la normalización Unicode. Se utilizará la implementación más lenta en PHP puro.\nSi tu web tiene mucho tráfico, te recomendamos leer acerca de la [https://www.mediawiki.org/wiki/Special:MyLanguage/Unicode_normalization_considerations normalización Unicode].",
+       "config-unicode-using-intl": "Se utiliza la [https://php.net/manual/en/book.intl.php PHP extensión «intl» de PECL] para la normalización Unicode.",
+       "config-unicode-pure-php-warning": "<strong>Advertencia:</strong> la [https://php.net/manual/en/book.intl.php PHP extensión intl] no está disponible para efectuar la normalización Unicode. Se utilizará la implementación más lenta en PHP puro.\nSi tu web tiene mucho tráfico, te recomendamos leer acerca [https://www.mediawiki.org/wiki/Special:MyLanguage/Unicode_normalization_considerations normalización Unicode].",
        "config-unicode-update-warning": "<strong>Atención:</strong> la versión instalada del contenedor de normalización de Unicode utiliza una versión anticuada de la biblioteca del [http://site.icu-project.org/ proyecto ICU].\nDeberías [https://www.mediawiki.org/wiki/Special:MyLanguage/Unicode_normalization_considerations modernizarla] si te interesa utilizar Unicode.",
        "config-no-db": "No se encontró un controlador adecuado para la base de datos. Necesitas instalar un controlador de base de datos para PHP.\n{{PLURAL:$2|Se admite el siguiente gestor de bases de datos|Se admiten los siguientes gestores de bases de datos}}: $1.\n\nSi compilaste PHP por tu cuenta, debes reconfigurarlo activando un cliente de base de datos, por ejemplo, mediante <code>./configure --with-mysqli</code>.\nSi instalaste PHP desde un paquete de Debian o Ubuntu, también debes instalar, por ejemplo, el paquete <code>php-mysql</code>.",
        "config-outdated-sqlite": "<strong>Advertencia:</strong> tienes SQLite $2, que es inferior a la mínima versión requerida: $1. SQLite no estará disponible.",
index ec17b0b..7f7c801 100644 (file)
        "config-invalid-db-server-oracle": "「$1」は無効なデータベース TNS です。\n「TNS 名」「Easy Connect」文字列のいずれかを使用してください ([http://docs.oracle.com/cd/E11882_01/network.112/e10836/naming.htm Oracle ネーミング メソッド])。",
        "config-invalid-db-name": "「$1」は無効なデータベース名です。\n半角の英数字 (a-z、A-Z、0-9)、アンダースコア (_)、ハイフン (-) のみを使用してください。",
        "config-invalid-db-prefix": "「$1」は無効なデータベース接頭辞です。\n半角の英数字 (a-z、A-Z、0-9)、アンダースコア (_)、ハイフン (-) のみを使用してください。",
-       "config-connection-error": "$1。\n\n以下のホスト名、ユーザー名、パスワードを確認してから再度試してください。",
+       "config-connection-error": "$1。\n\n以下のホスト名、ユーザー名、パスワードを確認してから再度試してください。データベースホストとして「localhost」を使用している場合は、代わりに 「127.0.0.1」を使用してください(またはその逆)。",
        "config-invalid-schema": "「$1」は MediaWiki のスキーマとして無効です。\n半角の英数字 (a-z、A-Z、0-9)、アンダースコア (_) のみを使用してください。",
        "config-db-sys-create-oracle": "インストーラーは、新規アカウント作成にはSYSDBAアカウントの利用のみをサポートしています。",
        "config-db-sys-user-exists-oracle": "利用者アカウント「$1」は既に存在します。SYSDBA は新しいアカウントの作成のみに使用できます!",
        "config-license-help": "多くの公開ウィキでは、すべての寄稿物が[https://freedomdefined.org/Definition フリーライセンス]のもとに置かれています。\nこうすることにより、コミュニティによる共有の感覚が生まれ、長期的な寄稿が促されます。\n私的ウィキや企業のウィキでは、通常、フリーライセンスにする必要はありません。\n\nウィキペディアにあるテキストをあなたのウィキで利用し、逆にあなたのウィキにあるテキストをウィキペディアに複製することを許可したい場合には、<strong>{{int:config-license-cc-by-sa}}</strong>を選択するべきです。\n\nウィキペディアは以前、GNUフリー文書利用許諾契約書(GFDL)を使用していました。\nGFDLは有効なライセンスですが、内容を理解するのは困難です。\nまた、GFDLのもとに置かれているコンテンツの再利用も困難です。",
        "config-email-settings": "メールの設定",
        "config-enable-email": "メール送信を有効にする",
-       "config-enable-email-help": "メールを使用したい場合は、[Config-dbsupport-oracle/manual/en/mail.configuration.php PHP のメール設定]が正しく設定されている必要があります。\nメールの機能を使用しない場合は、ここで無効にすることができます。",
+       "config-enable-email-help": "メールを使用したい場合は、[https://www.php.net/manual/en/mail.configuration.php PHP のメール設定]が正しく設定されている必要があります。\nメールの機能を使用しない場合は、ここで無効にすることができます。",
        "config-email-user": "利用者間のメールを有効にする",
        "config-email-user-help": "設定で有効になっている場合、すべてのユーザーがお互いにメールのやりとりを行うことを許可する。",
        "config-email-usertalk": "利用者のトークページでの通知を有効にする",
        "config-install-done": "<strong>おめでとうございます!</strong>\nMediaWikiのインストールに成功しました。\n\n<code>LocalSettings.php</code>ファイルが生成されました。\nこのファイルはすべての設定を含んでいます。\n\nこれをダウンロードして、ウィキをインストールした基準ディレクトリ (index.phpと同じディレクトリ) に設置する必要があります。ダウンロードは自動的に開始されるはずです。\n\nダウンロードが開始されていない場合、またはダウンロードをキャンセルした場合は、下記のリンクをクリックしてダウンロードを再開できます:\n\n$3\n\n<strong>注意:</strong> この生成された設定ファイルをダウンロードせずにインストールを終了すると、このファイルは利用できなくなります。\n\n上記の作業が完了すると、<strong>[$2 ウィキに入る]</strong>ことができます。",
        "config-install-done-path": "<strong>おめでとうございます!</strong>\nMediaWikiのインストールに成功しました。\n\n<code>LocalSettings.php</code>ファイルが生成されました。\nこのファイルはすべての設定を含んでいます。\n\nこれをダウンロードして、<code>$4</code> に設置する必要があります。ダウンロードは自動的に開始されるはずです。\n\nダウンロードが開始されていない場合、またはダウンロードをキャンセルした場合は、下記のリンクをクリックしてダウンロードを再開できます:\n\n$3\n\n<strong>注意:</strong> この生成された設定ファイルをダウンロードせずにインストールを終了すると、このファイルは利用できなくなります。\n\n上記の作業が完了すると、<strong>[$2 ウィキに入る]</strong>ことができます。",
        "config-install-success": "MediaWikiが正常にインストールされました。\n今すぐ<$1$2>にアクセスしてあなたのwikiを表示できます。\nご質問がある場合は、よくある質問リストをご覧ください:\n<https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ>または\nそのページにリンクされているサポートフォーラム",
+       "config-install-db-success": "データベースは正常にセットアップされました",
        "config-download-localsettings": "<code>LocalSettings.php</code> をダウンロード",
        "config-help": "ヘルプ",
        "config-help-tooltip": "クリックで展開",
diff --git a/includes/libs/MultiHttpClient.php b/includes/libs/MultiHttpClient.php
deleted file mode 100644 (file)
index a6135ae..0000000
+++ /dev/null
@@ -1,609 +0,0 @@
-<?php
-/**
- * HTTP service client
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- */
-
-use Psr\Log\LoggerAwareInterface;
-use Psr\Log\LoggerInterface;
-use Psr\Log\NullLogger;
-use MediaWiki\MediaWikiServices;
-
-/**
- * Class to handle multiple HTTP requests
- *
- * If curl is available, requests will be made concurrently.
- * Otherwise, they will be made serially.
- *
- * HTTP request maps are arrays that use the following format:
- *   - method   : GET/HEAD/PUT/POST/DELETE
- *   - url      : HTTP/HTTPS URL
- *   - query    : <query parameter field/value associative array> (uses RFC 3986)
- *   - headers  : <header name/value associative array>
- *   - body     : source to get the HTTP request body from;
- *                this can simply be a string (always), a resource for
- *                PUT requests, and a field/value array for POST request;
- *                array bodies are encoded as multipart/form-data and strings
- *                use application/x-www-form-urlencoded (headers sent automatically)
- *   - stream   : resource to stream the HTTP response body to
- *   - proxy    : HTTP proxy to use
- *   - flags    : map of boolean flags which supports:
- *                  - relayResponseHeaders : write out header via header()
- * Request maps can use integer index 0 instead of 'method' and 1 instead of 'url'.
- *
- * @since 1.23
- */
-class MultiHttpClient implements LoggerAwareInterface {
-       /** @var resource */
-       protected $multiHandle = null; // curl_multi handle
-       /** @var string|null SSL certificates path */
-       protected $caBundlePath;
-       /** @var float */
-       protected $connTimeout = 10;
-       /** @var float */
-       protected $reqTimeout = 300;
-       /** @var bool */
-       protected $usePipelining = false;
-       /** @var int */
-       protected $maxConnsPerHost = 50;
-       /** @var string|null proxy */
-       protected $proxy;
-       /** @var string */
-       protected $userAgent = 'wikimedia/multi-http-client v1.0';
-       /** @var LoggerInterface */
-       protected $logger;
-
-       // In PHP 7 due to https://bugs.php.net/bug.php?id=76480 the request/connect
-       // timeouts are periodically polled instead of being accurately respected.
-       // The select timeout is set to the minimum timeout multiplied by this factor.
-       const TIMEOUT_ACCURACY_FACTOR = 0.1;
-
-       /**
-        * @param array $options
-        *   - connTimeout     : default connection timeout (seconds)
-        *   - reqTimeout      : default request timeout (seconds)
-        *   - proxy           : HTTP proxy to use
-        *   - usePipelining   : whether to use HTTP pipelining if possible (for all hosts)
-        *   - maxConnsPerHost : maximum number of concurrent connections (per host)
-        *   - userAgent       : The User-Agent header value to send
-        *   - logger          : a \Psr\Log\LoggerInterface instance for debug logging
-        *   - caBundlePath    : path to specific Certificate Authority bundle (if any)
-        * @throws Exception
-        */
-       public function __construct( array $options ) {
-               if ( isset( $options['caBundlePath'] ) ) {
-                       $this->caBundlePath = $options['caBundlePath'];
-                       if ( !file_exists( $this->caBundlePath ) ) {
-                               throw new Exception( "Cannot find CA bundle: " . $this->caBundlePath );
-                       }
-               }
-               static $opts = [
-                       'connTimeout', 'reqTimeout', 'usePipelining', 'maxConnsPerHost',
-                       'proxy', 'userAgent', 'logger'
-               ];
-               foreach ( $opts as $key ) {
-                       if ( isset( $options[$key] ) ) {
-                               $this->$key = $options[$key];
-                       }
-               }
-               if ( $this->logger === null ) {
-                       $this->logger = new NullLogger;
-               }
-       }
-
-       /**
-        * Execute an HTTP(S) request
-        *
-        * This method returns a response map of:
-        *   - code    : HTTP response code or 0 if there was a serious error
-        *   - reason  : HTTP response reason (empty if there was a serious error)
-        *   - headers : <header name/value associative array>
-        *   - body    : HTTP response body or resource (if "stream" was set)
-        *   - error     : Any error string
-        * The map also stores integer-indexed copies of these values. This lets callers do:
-        * @code
-        *              list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $http->run( $req );
-        * @endcode
-        * @param array $req HTTP request array
-        * @param array $opts
-        *   - connTimeout    : connection timeout per request (seconds)
-        *   - reqTimeout     : post-connection timeout per request (seconds)
-        * @return array Response array for request
-        */
-       public function run( array $req, array $opts = [] ) {
-               return $this->runMulti( [ $req ], $opts )[0]['response'];
-       }
-
-       /**
-        * Execute a set of HTTP(S) requests.
-        *
-        * If curl is available, requests will be made concurrently.
-        * Otherwise, they will be made serially.
-        *
-        * The maps are returned by this method with the 'response' field set to a map of:
-        *   - code    : HTTP response code or 0 if there was a serious error
-        *   - reason  : HTTP response reason (empty if there was a serious error)
-        *   - headers : <header name/value associative array>
-        *   - body    : HTTP response body or resource (if "stream" was set)
-        *   - error   : Any error string
-        * The map also stores integer-indexed copies of these values. This lets callers do:
-        * @code
-        *        list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $req['response'];
-        * @endcode
-        * All headers in the 'headers' field are normalized to use lower case names.
-        * This is true for the request headers and the response headers. Integer-indexed
-        * method/URL entries will also be changed to use the corresponding string keys.
-        *
-        * @param array $reqs Map of HTTP request arrays
-        * @param array $opts
-        *   - connTimeout     : connection timeout per request (seconds)
-        *   - reqTimeout      : post-connection timeout per request (seconds)
-        *   - usePipelining   : whether to use HTTP pipelining if possible
-        *   - maxConnsPerHost : maximum number of concurrent connections (per host)
-        * @return array $reqs With response array populated for each
-        * @throws Exception
-        */
-       public function runMulti( array $reqs, array $opts = [] ) {
-               $this->normalizeRequests( $reqs );
-               if ( $this->isCurlEnabled() ) {
-                       return $this->runMultiCurl( $reqs, $opts );
-               } else {
-                       return $this->runMultiHttp( $reqs, $opts );
-               }
-       }
-
-       /**
-        * Determines if the curl extension is available
-        *
-        * @return bool true if curl is available, false otherwise.
-        */
-       protected function isCurlEnabled() {
-               return extension_loaded( 'curl' );
-       }
-
-       /**
-        * Execute a set of HTTP(S) requests concurrently
-        *
-        * @see MultiHttpClient::runMulti()
-        *
-        * @param array $reqs Map of HTTP request arrays
-        * @param array $opts
-        *   - connTimeout     : connection timeout per request (seconds)
-        *   - reqTimeout      : post-connection timeout per request (seconds)
-        *   - usePipelining   : whether to use HTTP pipelining if possible
-        *   - maxConnsPerHost : maximum number of concurrent connections (per host)
-        * @return array $reqs With response array populated for each
-        * @throws Exception
-        */
-       private function runMultiCurl( array $reqs, array $opts = [] ) {
-               $chm = $this->getCurlMulti();
-
-               $selectTimeout = $this->getSelectTimeout( $opts );
-
-               // Add all of the required cURL handles...
-               $handles = [];
-               foreach ( $reqs as $index => &$req ) {
-                       $handles[$index] = $this->getCurlHandle( $req, $opts );
-                       if ( count( $reqs ) > 1 ) {
-                               // https://github.com/guzzle/guzzle/issues/349
-                               curl_setopt( $handles[$index], CURLOPT_FORBID_REUSE, true );
-                       }
-               }
-               unset( $req ); // don't assign over this by accident
-
-               $indexes = array_keys( $reqs );
-               if ( isset( $opts['usePipelining'] ) ) {
-                       curl_multi_setopt( $chm, CURLMOPT_PIPELINING, (int)$opts['usePipelining'] );
-               }
-               if ( isset( $opts['maxConnsPerHost'] ) ) {
-                       // Keep these sockets around as they may be needed later in the request
-                       curl_multi_setopt( $chm, CURLMOPT_MAXCONNECTS, (int)$opts['maxConnsPerHost'] );
-               }
-
-               // @TODO: use a per-host rolling handle window (e.g. CURLMOPT_MAX_HOST_CONNECTIONS)
-               $batches = array_chunk( $indexes, $this->maxConnsPerHost );
-               $infos = [];
-
-               foreach ( $batches as $batch ) {
-                       // Attach all cURL handles for this batch
-                       foreach ( $batch as $index ) {
-                               curl_multi_add_handle( $chm, $handles[$index] );
-                       }
-                       // Execute the cURL handles concurrently...
-                       $active = null; // handles still being processed
-                       do {
-                               // Do any available work...
-                               do {
-                                       $mrc = curl_multi_exec( $chm, $active );
-                                       $info = curl_multi_info_read( $chm );
-                                       if ( $info !== false ) {
-                                               $infos[(int)$info['handle']] = $info;
-                                       }
-                               } while ( $mrc == CURLM_CALL_MULTI_PERFORM );
-                               // Wait (if possible) for available work...
-                               if ( $active > 0 && $mrc == CURLM_OK && curl_multi_select( $chm, $selectTimeout ) == -1 ) {
-                                       // PHP bug 63411; https://curl.haxx.se/libcurl/c/curl_multi_fdset.html
-                                       usleep( 5000 ); // 5ms
-                               }
-                       } while ( $active > 0 && $mrc == CURLM_OK );
-               }
-
-               // Remove all of the added cURL handles and check for errors...
-               foreach ( $reqs as $index => &$req ) {
-                       $ch = $handles[$index];
-                       curl_multi_remove_handle( $chm, $ch );
-
-                       if ( isset( $infos[(int)$ch] ) ) {
-                               $info = $infos[(int)$ch];
-                               $errno = $info['result'];
-                               if ( $errno !== 0 ) {
-                                       $req['response']['error'] = "(curl error: $errno)";
-                                       if ( function_exists( 'curl_strerror' ) ) {
-                                               $req['response']['error'] .= " " . curl_strerror( $errno );
-                                       }
-                                       $this->logger->warning( "Error fetching URL \"{$req['url']}\": " .
-                                               $req['response']['error'] );
-                               }
-                       } else {
-                               $req['response']['error'] = "(curl error: no status set)";
-                       }
-
-                       // For convenience with the list() operator
-                       $req['response'][0] = $req['response']['code'];
-                       $req['response'][1] = $req['response']['reason'];
-                       $req['response'][2] = $req['response']['headers'];
-                       $req['response'][3] = $req['response']['body'];
-                       $req['response'][4] = $req['response']['error'];
-                       curl_close( $ch );
-                       // Close any string wrapper file handles
-                       if ( isset( $req['_closeHandle'] ) ) {
-                               fclose( $req['_closeHandle'] );
-                               unset( $req['_closeHandle'] );
-                       }
-               }
-               unset( $req ); // don't assign over this by accident
-
-               // Restore the default settings
-               curl_multi_setopt( $chm, CURLMOPT_PIPELINING, (int)$this->usePipelining );
-               curl_multi_setopt( $chm, CURLMOPT_MAXCONNECTS, (int)$this->maxConnsPerHost );
-
-               return $reqs;
-       }
-
-       /**
-        * @param array &$req HTTP request map
-        * @param array $opts
-        *   - connTimeout    : default connection timeout
-        *   - reqTimeout     : default request timeout
-        * @return resource
-        * @throws Exception
-        */
-       protected function getCurlHandle( array &$req, array $opts = [] ) {
-               $ch = curl_init();
-
-               curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT_MS,
-                       ( $opts['connTimeout'] ?? $this->connTimeout ) * 1000 );
-               curl_setopt( $ch, CURLOPT_PROXY, $req['proxy'] ?? $this->proxy );
-               curl_setopt( $ch, CURLOPT_TIMEOUT_MS,
-                       ( $opts['reqTimeout'] ?? $this->reqTimeout ) * 1000 );
-               curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 );
-               curl_setopt( $ch, CURLOPT_MAXREDIRS, 4 );
-               curl_setopt( $ch, CURLOPT_HEADER, 0 );
-               if ( !is_null( $this->caBundlePath ) ) {
-                       curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, true );
-                       curl_setopt( $ch, CURLOPT_CAINFO, $this->caBundlePath );
-               }
-               curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
-
-               $url = $req['url'];
-               $query = http_build_query( $req['query'], '', '&', PHP_QUERY_RFC3986 );
-               if ( $query != '' ) {
-                       $url .= strpos( $req['url'], '?' ) === false ? "?$query" : "&$query";
-               }
-               curl_setopt( $ch, CURLOPT_URL, $url );
-
-               curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, $req['method'] );
-               if ( $req['method'] === 'HEAD' ) {
-                       curl_setopt( $ch, CURLOPT_NOBODY, 1 );
-               }
-
-               if ( $req['method'] === 'PUT' ) {
-                       curl_setopt( $ch, CURLOPT_PUT, 1 );
-                       if ( is_resource( $req['body'] ) ) {
-                               curl_setopt( $ch, CURLOPT_INFILE, $req['body'] );
-                               if ( isset( $req['headers']['content-length'] ) ) {
-                                       curl_setopt( $ch, CURLOPT_INFILESIZE, $req['headers']['content-length'] );
-                               } elseif ( isset( $req['headers']['transfer-encoding'] ) &&
-                                       $req['headers']['transfer-encoding'] === 'chunks'
-                               ) {
-                                       curl_setopt( $ch, CURLOPT_UPLOAD, true );
-                               } else {
-                                       throw new Exception( "Missing 'Content-Length' or 'Transfer-Encoding' header." );
-                               }
-                       } elseif ( $req['body'] !== '' ) {
-                               $fp = fopen( "php://temp", "wb+" );
-                               fwrite( $fp, $req['body'], strlen( $req['body'] ) );
-                               rewind( $fp );
-                               curl_setopt( $ch, CURLOPT_INFILE, $fp );
-                               curl_setopt( $ch, CURLOPT_INFILESIZE, strlen( $req['body'] ) );
-                               $req['_closeHandle'] = $fp; // remember to close this later
-                       } else {
-                               curl_setopt( $ch, CURLOPT_INFILESIZE, 0 );
-                       }
-                       curl_setopt( $ch, CURLOPT_READFUNCTION,
-                               function ( $ch, $fd, $length ) {
-                                       $data = fread( $fd, $length );
-                                       $len = strlen( $data );
-                                       return $data;
-                               }
-                       );
-               } elseif ( $req['method'] === 'POST' ) {
-                       curl_setopt( $ch, CURLOPT_POST, 1 );
-                       // Don't interpret POST parameters starting with '@' as file uploads, because this
-                       // makes it impossible to POST plain values starting with '@' (and causes security
-                       // issues potentially exposing the contents of local files).
-                       curl_setopt( $ch, CURLOPT_SAFE_UPLOAD, true );
-                       curl_setopt( $ch, CURLOPT_POSTFIELDS, $req['body'] );
-               } else {
-                       if ( is_resource( $req['body'] ) || $req['body'] !== '' ) {
-                               throw new Exception( "HTTP body specified for a non PUT/POST request." );
-                       }
-                       $req['headers']['content-length'] = 0;
-               }
-
-               if ( !isset( $req['headers']['user-agent'] ) ) {
-                       $req['headers']['user-agent'] = $this->userAgent;
-               }
-
-               $headers = [];
-               foreach ( $req['headers'] as $name => $value ) {
-                       if ( strpos( $name, ': ' ) ) {
-                               throw new Exception( "Headers cannot have ':' in the name." );
-                       }
-                       $headers[] = $name . ': ' . trim( $value );
-               }
-               curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
-
-               curl_setopt( $ch, CURLOPT_HEADERFUNCTION,
-                       function ( $ch, $header ) use ( &$req ) {
-                               if ( !empty( $req['flags']['relayResponseHeaders'] ) && trim( $header ) !== '' ) {
-                                       header( $header );
-                               }
-                               $length = strlen( $header );
-                               $matches = [];
-                               if ( preg_match( "/^(HTTP\/1\.[01]) (\d{3}) (.*)/", $header, $matches ) ) {
-                                       $req['response']['code'] = (int)$matches[2];
-                                       $req['response']['reason'] = trim( $matches[3] );
-                                       return $length;
-                               }
-                               if ( strpos( $header, ":" ) === false ) {
-                                       return $length;
-                               }
-                               list( $name, $value ) = explode( ":", $header, 2 );
-                               $name = strtolower( $name );
-                               $value = trim( $value );
-                               if ( isset( $req['response']['headers'][$name] ) ) {
-                                       $req['response']['headers'][$name] .= ', ' . $value;
-                               } else {
-                                       $req['response']['headers'][$name] = $value;
-                               }
-                               return $length;
-                       }
-               );
-
-               if ( isset( $req['stream'] ) ) {
-                       // Don't just use CURLOPT_FILE as that might give:
-                       // curl_setopt(): cannot represent a stream of type Output as a STDIO FILE*
-                       // The callback here handles both normal files and php://temp handles.
-                       curl_setopt( $ch, CURLOPT_WRITEFUNCTION,
-                               function ( $ch, $data ) use ( &$req ) {
-                                       return fwrite( $req['stream'], $data );
-                               }
-                       );
-               } else {
-                       curl_setopt( $ch, CURLOPT_WRITEFUNCTION,
-                               function ( $ch, $data ) use ( &$req ) {
-                                       $req['response']['body'] .= $data;
-                                       return strlen( $data );
-                               }
-                       );
-               }
-
-               return $ch;
-       }
-
-       /**
-        * @return resource
-        * @throws Exception
-        */
-       protected function getCurlMulti() {
-               if ( !$this->multiHandle ) {
-                       if ( !function_exists( 'curl_multi_init' ) ) {
-                               throw new Exception( "PHP cURL function curl_multi_init missing. " .
-                                       "Check https://www.mediawiki.org/wiki/Manual:CURL" );
-                       }
-                       $cmh = curl_multi_init();
-                       curl_multi_setopt( $cmh, CURLMOPT_PIPELINING, (int)$this->usePipelining );
-                       curl_multi_setopt( $cmh, CURLMOPT_MAXCONNECTS, (int)$this->maxConnsPerHost );
-                       $this->multiHandle = $cmh;
-               }
-               return $this->multiHandle;
-       }
-
-       /**
-        * Execute a set of HTTP(S) requests sequentially.
-        *
-        * @see MultiHttpClient::runMulti()
-        * @todo Remove dependency on MediaWikiServices: use a separate HTTP client
-        *  library or copy code from PhpHttpRequest
-        * @param array $reqs Map of HTTP request arrays
-        * @param array $opts
-        *   - connTimeout     : connection timeout per request (seconds)
-        *   - reqTimeout      : post-connection timeout per request (seconds)
-        * @return array $reqs With response array populated for each
-        * @throws Exception
-        */
-       private function runMultiHttp( array $reqs, array $opts = [] ) {
-               $httpOptions = [
-                       'timeout' => $opts['reqTimeout'] ?? $this->reqTimeout,
-                       'connectTimeout' => $opts['connTimeout'] ?? $this->connTimeout,
-                       'logger' => $this->logger,
-                       'caInfo' => $this->caBundlePath,
-               ];
-               foreach ( $reqs as &$req ) {
-                       $reqOptions = $httpOptions + [
-                               'method' => $req['method'],
-                               'proxy' => $req['proxy'] ?? $this->proxy,
-                               'userAgent' => $req['headers']['user-agent'] ?? $this->userAgent,
-                               'postData' => $req['body'],
-                       ];
-
-                       $url = $req['url'];
-                       $query = http_build_query( $req['query'], '', '&', PHP_QUERY_RFC3986 );
-                       if ( $query != '' ) {
-                               $url .= strpos( $req['url'], '?' ) === false ? "?$query" : "&$query";
-                       }
-
-                       $httpRequest = MediaWikiServices::getInstance()->getHttpRequestFactory()->create(
-                               $url, $reqOptions );
-                       $sv = $httpRequest->execute()->getStatusValue();
-
-                       $respHeaders = array_map(
-                               function ( $v ) {
-                                       return implode( ', ', $v );
-                               },
-                               $httpRequest->getResponseHeaders() );
-
-                       $req['response'] = [
-                               'code' => $httpRequest->getStatus(),
-                               'reason' => '',
-                               'headers' => $respHeaders,
-                               'body' => $httpRequest->getContent(),
-                               'error' => '',
-                       ];
-
-                       if ( !$sv->isOk() ) {
-                               $svErrors = $sv->getErrors();
-                               if ( isset( $svErrors[0] ) ) {
-                                       $req['response']['error'] = $svErrors[0]['message'];
-
-                                       // param values vary per failure type (ex. unknown host vs unknown page)
-                                       if ( isset( $svErrors[0]['params'][0] ) ) {
-                                               if ( is_numeric( $svErrors[0]['params'][0] ) ) {
-                                                       if ( isset( $svErrors[0]['params'][1] ) ) {
-                                                               $req['response']['reason'] = $svErrors[0]['params'][1];
-                                                       }
-                                               } else {
-                                                       $req['response']['reason'] = $svErrors[0]['params'][0];
-                                               }
-                                       }
-                               }
-                       }
-
-                       $req['response'][0] = $req['response']['code'];
-                       $req['response'][1] = $req['response']['reason'];
-                       $req['response'][2] = $req['response']['headers'];
-                       $req['response'][3] = $req['response']['body'];
-                       $req['response'][4] = $req['response']['error'];
-               }
-
-               return $reqs;
-       }
-
-       /**
-        * Normalize request information
-        *
-        * @param array $reqs the requests to normalize
-        */
-       private function normalizeRequests( array &$reqs ) {
-               foreach ( $reqs as &$req ) {
-                       $req['response'] = [
-                               'code'     => 0,
-                               'reason'   => '',
-                               'headers'  => [],
-                               'body'     => '',
-                               'error'    => ''
-                       ];
-                       if ( isset( $req[0] ) ) {
-                               $req['method'] = $req[0]; // short-form
-                               unset( $req[0] );
-                       }
-                       if ( isset( $req[1] ) ) {
-                               $req['url'] = $req[1]; // short-form
-                               unset( $req[1] );
-                       }
-                       if ( !isset( $req['method'] ) ) {
-                               throw new Exception( "Request has no 'method' field set." );
-                       } elseif ( !isset( $req['url'] ) ) {
-                               throw new Exception( "Request has no 'url' field set." );
-                       }
-                       $this->logger->debug( "{$req['method']}: {$req['url']}" );
-                       $req['query'] = $req['query'] ?? [];
-                       $headers = []; // normalized headers
-                       if ( isset( $req['headers'] ) ) {
-                               foreach ( $req['headers'] as $name => $value ) {
-                                       $headers[strtolower( $name )] = $value;
-                               }
-                       }
-                       $req['headers'] = $headers;
-                       if ( !isset( $req['body'] ) ) {
-                               $req['body'] = '';
-                               $req['headers']['content-length'] = 0;
-                       }
-                       $req['flags'] = $req['flags'] ?? [];
-               }
-       }
-
-       /**
-        * Get a suitable select timeout for the given options.
-        *
-        * @param array $opts
-        * @return float
-        */
-       private function getSelectTimeout( $opts ) {
-               $connTimeout = $opts['connTimeout'] ?? $this->connTimeout;
-               $reqTimeout = $opts['reqTimeout'] ?? $this->reqTimeout;
-               $timeouts = array_filter( [ $connTimeout, $reqTimeout ] );
-               if ( count( $timeouts ) === 0 ) {
-                       return 1;
-               }
-
-               $selectTimeout = min( $timeouts ) * self::TIMEOUT_ACCURACY_FACTOR;
-               // Minimum 10us for sanity
-               if ( $selectTimeout < 10e-6 ) {
-                       $selectTimeout = 10e-6;
-               }
-               return $selectTimeout;
-       }
-
-       /**
-        * Register a logger
-        *
-        * @param LoggerInterface $logger
-        */
-       public function setLogger( LoggerInterface $logger ) {
-               $this->logger = $logger;
-       }
-
-       function __destruct() {
-               if ( $this->multiHandle ) {
-                       curl_multi_close( $this->multiHandle );
-               }
-       }
-}
index 999594b..dc007a0 100644 (file)
@@ -26,6 +26,8 @@
  * @ingroup FileJournal
  */
 
+use Wikimedia\Timestamp\ConvertibleTimestamp;
+
 /**
  * @brief Class for handling file operation journaling.
  *
@@ -37,7 +39,6 @@
 abstract class FileJournal {
        /** @var string */
        protected $backend;
-
        /** @var int */
        protected $ttlDays;
 
@@ -63,7 +64,7 @@ abstract class FileJournal {
                $class = $config['class'];
                $jrn = new $class( $config );
                if ( !$jrn instanceof self ) {
-                       throw new InvalidArgumentException( "Class given is not an instance of FileJournal." );
+                       throw new InvalidArgumentException( "$class is not an instance of " . __CLASS__ );
                }
                $jrn->backend = $backend;
 
@@ -82,7 +83,9 @@ abstract class FileJournal {
                }
                $s = Wikimedia\base_convert( sha1( $s ), 16, 36, 31 );
 
-               return substr( Wikimedia\base_convert( wfTimestamp( TS_MW ), 10, 36, 9 ) . $s, 0, 31 );
+               $timestamp = ConvertibleTimestamp::convert( TS_MW, time() );
+
+               return substr( Wikimedia\base_convert( $timestamp, 10, 36, 9 ) . $s, 0, 31 );
        }
 
        /**
diff --git a/includes/libs/http/MultiHttpClient.php b/includes/libs/http/MultiHttpClient.php
new file mode 100644 (file)
index 0000000..a6135ae
--- /dev/null
@@ -0,0 +1,609 @@
+<?php
+/**
+ * HTTP service client
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ */
+
+use Psr\Log\LoggerAwareInterface;
+use Psr\Log\LoggerInterface;
+use Psr\Log\NullLogger;
+use MediaWiki\MediaWikiServices;
+
+/**
+ * Class to handle multiple HTTP requests
+ *
+ * If curl is available, requests will be made concurrently.
+ * Otherwise, they will be made serially.
+ *
+ * HTTP request maps are arrays that use the following format:
+ *   - method   : GET/HEAD/PUT/POST/DELETE
+ *   - url      : HTTP/HTTPS URL
+ *   - query    : <query parameter field/value associative array> (uses RFC 3986)
+ *   - headers  : <header name/value associative array>
+ *   - body     : source to get the HTTP request body from;
+ *                this can simply be a string (always), a resource for
+ *                PUT requests, and a field/value array for POST request;
+ *                array bodies are encoded as multipart/form-data and strings
+ *                use application/x-www-form-urlencoded (headers sent automatically)
+ *   - stream   : resource to stream the HTTP response body to
+ *   - proxy    : HTTP proxy to use
+ *   - flags    : map of boolean flags which supports:
+ *                  - relayResponseHeaders : write out header via header()
+ * Request maps can use integer index 0 instead of 'method' and 1 instead of 'url'.
+ *
+ * @since 1.23
+ */
+class MultiHttpClient implements LoggerAwareInterface {
+       /** @var resource */
+       protected $multiHandle = null; // curl_multi handle
+       /** @var string|null SSL certificates path */
+       protected $caBundlePath;
+       /** @var float */
+       protected $connTimeout = 10;
+       /** @var float */
+       protected $reqTimeout = 300;
+       /** @var bool */
+       protected $usePipelining = false;
+       /** @var int */
+       protected $maxConnsPerHost = 50;
+       /** @var string|null proxy */
+       protected $proxy;
+       /** @var string */
+       protected $userAgent = 'wikimedia/multi-http-client v1.0';
+       /** @var LoggerInterface */
+       protected $logger;
+
+       // In PHP 7 due to https://bugs.php.net/bug.php?id=76480 the request/connect
+       // timeouts are periodically polled instead of being accurately respected.
+       // The select timeout is set to the minimum timeout multiplied by this factor.
+       const TIMEOUT_ACCURACY_FACTOR = 0.1;
+
+       /**
+        * @param array $options
+        *   - connTimeout     : default connection timeout (seconds)
+        *   - reqTimeout      : default request timeout (seconds)
+        *   - proxy           : HTTP proxy to use
+        *   - usePipelining   : whether to use HTTP pipelining if possible (for all hosts)
+        *   - maxConnsPerHost : maximum number of concurrent connections (per host)
+        *   - userAgent       : The User-Agent header value to send
+        *   - logger          : a \Psr\Log\LoggerInterface instance for debug logging
+        *   - caBundlePath    : path to specific Certificate Authority bundle (if any)
+        * @throws Exception
+        */
+       public function __construct( array $options ) {
+               if ( isset( $options['caBundlePath'] ) ) {
+                       $this->caBundlePath = $options['caBundlePath'];
+                       if ( !file_exists( $this->caBundlePath ) ) {
+                               throw new Exception( "Cannot find CA bundle: " . $this->caBundlePath );
+                       }
+               }
+               static $opts = [
+                       'connTimeout', 'reqTimeout', 'usePipelining', 'maxConnsPerHost',
+                       'proxy', 'userAgent', 'logger'
+               ];
+               foreach ( $opts as $key ) {
+                       if ( isset( $options[$key] ) ) {
+                               $this->$key = $options[$key];
+                       }
+               }
+               if ( $this->logger === null ) {
+                       $this->logger = new NullLogger;
+               }
+       }
+
+       /**
+        * Execute an HTTP(S) request
+        *
+        * This method returns a response map of:
+        *   - code    : HTTP response code or 0 if there was a serious error
+        *   - reason  : HTTP response reason (empty if there was a serious error)
+        *   - headers : <header name/value associative array>
+        *   - body    : HTTP response body or resource (if "stream" was set)
+        *   - error     : Any error string
+        * The map also stores integer-indexed copies of these values. This lets callers do:
+        * @code
+        *              list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $http->run( $req );
+        * @endcode
+        * @param array $req HTTP request array
+        * @param array $opts
+        *   - connTimeout    : connection timeout per request (seconds)
+        *   - reqTimeout     : post-connection timeout per request (seconds)
+        * @return array Response array for request
+        */
+       public function run( array $req, array $opts = [] ) {
+               return $this->runMulti( [ $req ], $opts )[0]['response'];
+       }
+
+       /**
+        * Execute a set of HTTP(S) requests.
+        *
+        * If curl is available, requests will be made concurrently.
+        * Otherwise, they will be made serially.
+        *
+        * The maps are returned by this method with the 'response' field set to a map of:
+        *   - code    : HTTP response code or 0 if there was a serious error
+        *   - reason  : HTTP response reason (empty if there was a serious error)
+        *   - headers : <header name/value associative array>
+        *   - body    : HTTP response body or resource (if "stream" was set)
+        *   - error   : Any error string
+        * The map also stores integer-indexed copies of these values. This lets callers do:
+        * @code
+        *        list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $req['response'];
+        * @endcode
+        * All headers in the 'headers' field are normalized to use lower case names.
+        * This is true for the request headers and the response headers. Integer-indexed
+        * method/URL entries will also be changed to use the corresponding string keys.
+        *
+        * @param array $reqs Map of HTTP request arrays
+        * @param array $opts
+        *   - connTimeout     : connection timeout per request (seconds)
+        *   - reqTimeout      : post-connection timeout per request (seconds)
+        *   - usePipelining   : whether to use HTTP pipelining if possible
+        *   - maxConnsPerHost : maximum number of concurrent connections (per host)
+        * @return array $reqs With response array populated for each
+        * @throws Exception
+        */
+       public function runMulti( array $reqs, array $opts = [] ) {
+               $this->normalizeRequests( $reqs );
+               if ( $this->isCurlEnabled() ) {
+                       return $this->runMultiCurl( $reqs, $opts );
+               } else {
+                       return $this->runMultiHttp( $reqs, $opts );
+               }
+       }
+
+       /**
+        * Determines if the curl extension is available
+        *
+        * @return bool true if curl is available, false otherwise.
+        */
+       protected function isCurlEnabled() {
+               return extension_loaded( 'curl' );
+       }
+
+       /**
+        * Execute a set of HTTP(S) requests concurrently
+        *
+        * @see MultiHttpClient::runMulti()
+        *
+        * @param array $reqs Map of HTTP request arrays
+        * @param array $opts
+        *   - connTimeout     : connection timeout per request (seconds)
+        *   - reqTimeout      : post-connection timeout per request (seconds)
+        *   - usePipelining   : whether to use HTTP pipelining if possible
+        *   - maxConnsPerHost : maximum number of concurrent connections (per host)
+        * @return array $reqs With response array populated for each
+        * @throws Exception
+        */
+       private function runMultiCurl( array $reqs, array $opts = [] ) {
+               $chm = $this->getCurlMulti();
+
+               $selectTimeout = $this->getSelectTimeout( $opts );
+
+               // Add all of the required cURL handles...
+               $handles = [];
+               foreach ( $reqs as $index => &$req ) {
+                       $handles[$index] = $this->getCurlHandle( $req, $opts );
+                       if ( count( $reqs ) > 1 ) {
+                               // https://github.com/guzzle/guzzle/issues/349
+                               curl_setopt( $handles[$index], CURLOPT_FORBID_REUSE, true );
+                       }
+               }
+               unset( $req ); // don't assign over this by accident
+
+               $indexes = array_keys( $reqs );
+               if ( isset( $opts['usePipelining'] ) ) {
+                       curl_multi_setopt( $chm, CURLMOPT_PIPELINING, (int)$opts['usePipelining'] );
+               }
+               if ( isset( $opts['maxConnsPerHost'] ) ) {
+                       // Keep these sockets around as they may be needed later in the request
+                       curl_multi_setopt( $chm, CURLMOPT_MAXCONNECTS, (int)$opts['maxConnsPerHost'] );
+               }
+
+               // @TODO: use a per-host rolling handle window (e.g. CURLMOPT_MAX_HOST_CONNECTIONS)
+               $batches = array_chunk( $indexes, $this->maxConnsPerHost );
+               $infos = [];
+
+               foreach ( $batches as $batch ) {
+                       // Attach all cURL handles for this batch
+                       foreach ( $batch as $index ) {
+                               curl_multi_add_handle( $chm, $handles[$index] );
+                       }
+                       // Execute the cURL handles concurrently...
+                       $active = null; // handles still being processed
+                       do {
+                               // Do any available work...
+                               do {
+                                       $mrc = curl_multi_exec( $chm, $active );
+                                       $info = curl_multi_info_read( $chm );
+                                       if ( $info !== false ) {
+                                               $infos[(int)$info['handle']] = $info;
+                                       }
+                               } while ( $mrc == CURLM_CALL_MULTI_PERFORM );
+                               // Wait (if possible) for available work...
+                               if ( $active > 0 && $mrc == CURLM_OK && curl_multi_select( $chm, $selectTimeout ) == -1 ) {
+                                       // PHP bug 63411; https://curl.haxx.se/libcurl/c/curl_multi_fdset.html
+                                       usleep( 5000 ); // 5ms
+                               }
+                       } while ( $active > 0 && $mrc == CURLM_OK );
+               }
+
+               // Remove all of the added cURL handles and check for errors...
+               foreach ( $reqs as $index => &$req ) {
+                       $ch = $handles[$index];
+                       curl_multi_remove_handle( $chm, $ch );
+
+                       if ( isset( $infos[(int)$ch] ) ) {
+                               $info = $infos[(int)$ch];
+                               $errno = $info['result'];
+                               if ( $errno !== 0 ) {
+                                       $req['response']['error'] = "(curl error: $errno)";
+                                       if ( function_exists( 'curl_strerror' ) ) {
+                                               $req['response']['error'] .= " " . curl_strerror( $errno );
+                                       }
+                                       $this->logger->warning( "Error fetching URL \"{$req['url']}\": " .
+                                               $req['response']['error'] );
+                               }
+                       } else {
+                               $req['response']['error'] = "(curl error: no status set)";
+                       }
+
+                       // For convenience with the list() operator
+                       $req['response'][0] = $req['response']['code'];
+                       $req['response'][1] = $req['response']['reason'];
+                       $req['response'][2] = $req['response']['headers'];
+                       $req['response'][3] = $req['response']['body'];
+                       $req['response'][4] = $req['response']['error'];
+                       curl_close( $ch );
+                       // Close any string wrapper file handles
+                       if ( isset( $req['_closeHandle'] ) ) {
+                               fclose( $req['_closeHandle'] );
+                               unset( $req['_closeHandle'] );
+                       }
+               }
+               unset( $req ); // don't assign over this by accident
+
+               // Restore the default settings
+               curl_multi_setopt( $chm, CURLMOPT_PIPELINING, (int)$this->usePipelining );
+               curl_multi_setopt( $chm, CURLMOPT_MAXCONNECTS, (int)$this->maxConnsPerHost );
+
+               return $reqs;
+       }
+
+       /**
+        * @param array &$req HTTP request map
+        * @param array $opts
+        *   - connTimeout    : default connection timeout
+        *   - reqTimeout     : default request timeout
+        * @return resource
+        * @throws Exception
+        */
+       protected function getCurlHandle( array &$req, array $opts = [] ) {
+               $ch = curl_init();
+
+               curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT_MS,
+                       ( $opts['connTimeout'] ?? $this->connTimeout ) * 1000 );
+               curl_setopt( $ch, CURLOPT_PROXY, $req['proxy'] ?? $this->proxy );
+               curl_setopt( $ch, CURLOPT_TIMEOUT_MS,
+                       ( $opts['reqTimeout'] ?? $this->reqTimeout ) * 1000 );
+               curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 );
+               curl_setopt( $ch, CURLOPT_MAXREDIRS, 4 );
+               curl_setopt( $ch, CURLOPT_HEADER, 0 );
+               if ( !is_null( $this->caBundlePath ) ) {
+                       curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, true );
+                       curl_setopt( $ch, CURLOPT_CAINFO, $this->caBundlePath );
+               }
+               curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
+
+               $url = $req['url'];
+               $query = http_build_query( $req['query'], '', '&', PHP_QUERY_RFC3986 );
+               if ( $query != '' ) {
+                       $url .= strpos( $req['url'], '?' ) === false ? "?$query" : "&$query";
+               }
+               curl_setopt( $ch, CURLOPT_URL, $url );
+
+               curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, $req['method'] );
+               if ( $req['method'] === 'HEAD' ) {
+                       curl_setopt( $ch, CURLOPT_NOBODY, 1 );
+               }
+
+               if ( $req['method'] === 'PUT' ) {
+                       curl_setopt( $ch, CURLOPT_PUT, 1 );
+                       if ( is_resource( $req['body'] ) ) {
+                               curl_setopt( $ch, CURLOPT_INFILE, $req['body'] );
+                               if ( isset( $req['headers']['content-length'] ) ) {
+                                       curl_setopt( $ch, CURLOPT_INFILESIZE, $req['headers']['content-length'] );
+                               } elseif ( isset( $req['headers']['transfer-encoding'] ) &&
+                                       $req['headers']['transfer-encoding'] === 'chunks'
+                               ) {
+                                       curl_setopt( $ch, CURLOPT_UPLOAD, true );
+                               } else {
+                                       throw new Exception( "Missing 'Content-Length' or 'Transfer-Encoding' header." );
+                               }
+                       } elseif ( $req['body'] !== '' ) {
+                               $fp = fopen( "php://temp", "wb+" );
+                               fwrite( $fp, $req['body'], strlen( $req['body'] ) );
+                               rewind( $fp );
+                               curl_setopt( $ch, CURLOPT_INFILE, $fp );
+                               curl_setopt( $ch, CURLOPT_INFILESIZE, strlen( $req['body'] ) );
+                               $req['_closeHandle'] = $fp; // remember to close this later
+                       } else {
+                               curl_setopt( $ch, CURLOPT_INFILESIZE, 0 );
+                       }
+                       curl_setopt( $ch, CURLOPT_READFUNCTION,
+                               function ( $ch, $fd, $length ) {
+                                       $data = fread( $fd, $length );
+                                       $len = strlen( $data );
+                                       return $data;
+                               }
+                       );
+               } elseif ( $req['method'] === 'POST' ) {
+                       curl_setopt( $ch, CURLOPT_POST, 1 );
+                       // Don't interpret POST parameters starting with '@' as file uploads, because this
+                       // makes it impossible to POST plain values starting with '@' (and causes security
+                       // issues potentially exposing the contents of local files).
+                       curl_setopt( $ch, CURLOPT_SAFE_UPLOAD, true );
+                       curl_setopt( $ch, CURLOPT_POSTFIELDS, $req['body'] );
+               } else {
+                       if ( is_resource( $req['body'] ) || $req['body'] !== '' ) {
+                               throw new Exception( "HTTP body specified for a non PUT/POST request." );
+                       }
+                       $req['headers']['content-length'] = 0;
+               }
+
+               if ( !isset( $req['headers']['user-agent'] ) ) {
+                       $req['headers']['user-agent'] = $this->userAgent;
+               }
+
+               $headers = [];
+               foreach ( $req['headers'] as $name => $value ) {
+                       if ( strpos( $name, ': ' ) ) {
+                               throw new Exception( "Headers cannot have ':' in the name." );
+                       }
+                       $headers[] = $name . ': ' . trim( $value );
+               }
+               curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
+
+               curl_setopt( $ch, CURLOPT_HEADERFUNCTION,
+                       function ( $ch, $header ) use ( &$req ) {
+                               if ( !empty( $req['flags']['relayResponseHeaders'] ) && trim( $header ) !== '' ) {
+                                       header( $header );
+                               }
+                               $length = strlen( $header );
+                               $matches = [];
+                               if ( preg_match( "/^(HTTP\/1\.[01]) (\d{3}) (.*)/", $header, $matches ) ) {
+                                       $req['response']['code'] = (int)$matches[2];
+                                       $req['response']['reason'] = trim( $matches[3] );
+                                       return $length;
+                               }
+                               if ( strpos( $header, ":" ) === false ) {
+                                       return $length;
+                               }
+                               list( $name, $value ) = explode( ":", $header, 2 );
+                               $name = strtolower( $name );
+                               $value = trim( $value );
+                               if ( isset( $req['response']['headers'][$name] ) ) {
+                                       $req['response']['headers'][$name] .= ', ' . $value;
+                               } else {
+                                       $req['response']['headers'][$name] = $value;
+                               }
+                               return $length;
+                       }
+               );
+
+               if ( isset( $req['stream'] ) ) {
+                       // Don't just use CURLOPT_FILE as that might give:
+                       // curl_setopt(): cannot represent a stream of type Output as a STDIO FILE*
+                       // The callback here handles both normal files and php://temp handles.
+                       curl_setopt( $ch, CURLOPT_WRITEFUNCTION,
+                               function ( $ch, $data ) use ( &$req ) {
+                                       return fwrite( $req['stream'], $data );
+                               }
+                       );
+               } else {
+                       curl_setopt( $ch, CURLOPT_WRITEFUNCTION,
+                               function ( $ch, $data ) use ( &$req ) {
+                                       $req['response']['body'] .= $data;
+                                       return strlen( $data );
+                               }
+                       );
+               }
+
+               return $ch;
+       }
+
+       /**
+        * @return resource
+        * @throws Exception
+        */
+       protected function getCurlMulti() {
+               if ( !$this->multiHandle ) {
+                       if ( !function_exists( 'curl_multi_init' ) ) {
+                               throw new Exception( "PHP cURL function curl_multi_init missing. " .
+                                       "Check https://www.mediawiki.org/wiki/Manual:CURL" );
+                       }
+                       $cmh = curl_multi_init();
+                       curl_multi_setopt( $cmh, CURLMOPT_PIPELINING, (int)$this->usePipelining );
+                       curl_multi_setopt( $cmh, CURLMOPT_MAXCONNECTS, (int)$this->maxConnsPerHost );
+                       $this->multiHandle = $cmh;
+               }
+               return $this->multiHandle;
+       }
+
+       /**
+        * Execute a set of HTTP(S) requests sequentially.
+        *
+        * @see MultiHttpClient::runMulti()
+        * @todo Remove dependency on MediaWikiServices: use a separate HTTP client
+        *  library or copy code from PhpHttpRequest
+        * @param array $reqs Map of HTTP request arrays
+        * @param array $opts
+        *   - connTimeout     : connection timeout per request (seconds)
+        *   - reqTimeout      : post-connection timeout per request (seconds)
+        * @return array $reqs With response array populated for each
+        * @throws Exception
+        */
+       private function runMultiHttp( array $reqs, array $opts = [] ) {
+               $httpOptions = [
+                       'timeout' => $opts['reqTimeout'] ?? $this->reqTimeout,
+                       'connectTimeout' => $opts['connTimeout'] ?? $this->connTimeout,
+                       'logger' => $this->logger,
+                       'caInfo' => $this->caBundlePath,
+               ];
+               foreach ( $reqs as &$req ) {
+                       $reqOptions = $httpOptions + [
+                               'method' => $req['method'],
+                               'proxy' => $req['proxy'] ?? $this->proxy,
+                               'userAgent' => $req['headers']['user-agent'] ?? $this->userAgent,
+                               'postData' => $req['body'],
+                       ];
+
+                       $url = $req['url'];
+                       $query = http_build_query( $req['query'], '', '&', PHP_QUERY_RFC3986 );
+                       if ( $query != '' ) {
+                               $url .= strpos( $req['url'], '?' ) === false ? "?$query" : "&$query";
+                       }
+
+                       $httpRequest = MediaWikiServices::getInstance()->getHttpRequestFactory()->create(
+                               $url, $reqOptions );
+                       $sv = $httpRequest->execute()->getStatusValue();
+
+                       $respHeaders = array_map(
+                               function ( $v ) {
+                                       return implode( ', ', $v );
+                               },
+                               $httpRequest->getResponseHeaders() );
+
+                       $req['response'] = [
+                               'code' => $httpRequest->getStatus(),
+                               'reason' => '',
+                               'headers' => $respHeaders,
+                               'body' => $httpRequest->getContent(),
+                               'error' => '',
+                       ];
+
+                       if ( !$sv->isOk() ) {
+                               $svErrors = $sv->getErrors();
+                               if ( isset( $svErrors[0] ) ) {
+                                       $req['response']['error'] = $svErrors[0]['message'];
+
+                                       // param values vary per failure type (ex. unknown host vs unknown page)
+                                       if ( isset( $svErrors[0]['params'][0] ) ) {
+                                               if ( is_numeric( $svErrors[0]['params'][0] ) ) {
+                                                       if ( isset( $svErrors[0]['params'][1] ) ) {
+                                                               $req['response']['reason'] = $svErrors[0]['params'][1];
+                                                       }
+                                               } else {
+                                                       $req['response']['reason'] = $svErrors[0]['params'][0];
+                                               }
+                                       }
+                               }
+                       }
+
+                       $req['response'][0] = $req['response']['code'];
+                       $req['response'][1] = $req['response']['reason'];
+                       $req['response'][2] = $req['response']['headers'];
+                       $req['response'][3] = $req['response']['body'];
+                       $req['response'][4] = $req['response']['error'];
+               }
+
+               return $reqs;
+       }
+
+       /**
+        * Normalize request information
+        *
+        * @param array $reqs the requests to normalize
+        */
+       private function normalizeRequests( array &$reqs ) {
+               foreach ( $reqs as &$req ) {
+                       $req['response'] = [
+                               'code'     => 0,
+                               'reason'   => '',
+                               'headers'  => [],
+                               'body'     => '',
+                               'error'    => ''
+                       ];
+                       if ( isset( $req[0] ) ) {
+                               $req['method'] = $req[0]; // short-form
+                               unset( $req[0] );
+                       }
+                       if ( isset( $req[1] ) ) {
+                               $req['url'] = $req[1]; // short-form
+                               unset( $req[1] );
+                       }
+                       if ( !isset( $req['method'] ) ) {
+                               throw new Exception( "Request has no 'method' field set." );
+                       } elseif ( !isset( $req['url'] ) ) {
+                               throw new Exception( "Request has no 'url' field set." );
+                       }
+                       $this->logger->debug( "{$req['method']}: {$req['url']}" );
+                       $req['query'] = $req['query'] ?? [];
+                       $headers = []; // normalized headers
+                       if ( isset( $req['headers'] ) ) {
+                               foreach ( $req['headers'] as $name => $value ) {
+                                       $headers[strtolower( $name )] = $value;
+                               }
+                       }
+                       $req['headers'] = $headers;
+                       if ( !isset( $req['body'] ) ) {
+                               $req['body'] = '';
+                               $req['headers']['content-length'] = 0;
+                       }
+                       $req['flags'] = $req['flags'] ?? [];
+               }
+       }
+
+       /**
+        * Get a suitable select timeout for the given options.
+        *
+        * @param array $opts
+        * @return float
+        */
+       private function getSelectTimeout( $opts ) {
+               $connTimeout = $opts['connTimeout'] ?? $this->connTimeout;
+               $reqTimeout = $opts['reqTimeout'] ?? $this->reqTimeout;
+               $timeouts = array_filter( [ $connTimeout, $reqTimeout ] );
+               if ( count( $timeouts ) === 0 ) {
+                       return 1;
+               }
+
+               $selectTimeout = min( $timeouts ) * self::TIMEOUT_ACCURACY_FACTOR;
+               // Minimum 10us for sanity
+               if ( $selectTimeout < 10e-6 ) {
+                       $selectTimeout = 10e-6;
+               }
+               return $selectTimeout;
+       }
+
+       /**
+        * Register a logger
+        *
+        * @param LoggerInterface $logger
+        */
+       public function setLogger( LoggerInterface $logger ) {
+               $this->logger = $logger;
+       }
+
+       function __destruct() {
+               if ( $this->multiHandle ) {
+                       curl_multi_close( $this->multiHandle );
+               }
+       }
+}
index b83462c..339a7ee 100644 (file)
  */
 
 /**
- * Simple version of LockManager that does nothing
+ * Simple version of LockManager that only does lock reference counting
  * @since 1.19
  */
 class NullLockManager extends LockManager {
        protected function doLock( array $paths, $type ) {
+               foreach ( $paths as $path ) {
+                       if ( isset( $this->locksHeld[$path][$type] ) ) {
+                               ++$this->locksHeld[$path][$type];
+                       } else {
+                               $this->locksHeld[$path][$type] = 1;
+                       }
+               }
+
                return StatusValue::newGood();
        }
 
        protected function doUnlock( array $paths, $type ) {
-               return StatusValue::newGood();
+               $status = StatusValue::newGood();
+
+               foreach ( $paths as $path ) {
+                       if ( isset( $this->locksHeld[$path][$type] ) ) {
+                               if ( --$this->locksHeld[$path][$type] <= 0 ) {
+                                       unset( $this->locksHeld[$path][$type] );
+                                       if ( !$this->locksHeld[$path] ) {
+                                               unset( $this->locksHeld[$path] ); // clean up
+                                       }
+                               }
+                       } else {
+                               $status->warning( 'lockmanager-notlocked', $path );
+                       }
+               }
+
+               return $status;
        }
 }
index 1ef4642..950b283 100644 (file)
@@ -35,15 +35,7 @@ abstract class QuorumLockManager extends LockManager {
        /** @var array Map of degraded buckets */
        protected $degradedBuckets = []; // (bucket index => UNIX timestamp)
 
-       final protected function doLock( array $paths, $type ) {
-               return $this->doLockByType( [ $type => $paths ] );
-       }
-
-       final protected function doUnlock( array $paths, $type ) {
-               return $this->doUnlockByType( [ $type => $paths ] );
-       }
-
-       protected function doLockByType( array $pathsByType ) {
+       final protected function doLockByType( array $pathsByType ) {
                $status = StatusValue::newGood();
 
                $pathsToLock = []; // (bucket => type => paths)
@@ -278,4 +270,12 @@ abstract class QuorumLockManager extends LockManager {
         * @return StatusValue
         */
        abstract protected function releaseAllLocks();
+
+       final protected function doLock( array $paths, $type ) {
+               throw new LogicException( __METHOD__ . ': proxy class does not need this method.' );
+       }
+
+       final protected function doUnlock( array $paths, $type ) {
+               throw new LogicException( __METHOD__ . ': proxy class does not need this method.' );
+       }
 }
index e7dc926..f493769 100644 (file)
@@ -755,7 +755,9 @@ EOT;
                /**
                 * look for XML formats (XHTML and SVG)
                 */
+               Wikimedia\suppressWarnings();
                $xml = new XmlTypeCheck( $file );
+               Wikimedia\restoreWarnings();
                if ( $xml->wellFormed ) {
                        $xmlTypes = $this->xmlTypes;
                        return $xmlTypes[$xml->getRootElement()] ?? 'application/xml';
index 760d137..dfad922 100644 (file)
@@ -1068,7 +1068,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
        protected function isTransactableQuery( $sql ) {
                return !in_array(
                        $this->getQueryVerb( $sql ),
-                       [ 'BEGIN', 'ROLLBACK', 'COMMIT', 'SET', 'SHOW', 'CREATE', 'ALTER', 'USE' ],
+                       [ 'BEGIN', 'ROLLBACK', 'COMMIT', 'SET', 'SHOW', 'CREATE', 'ALTER', 'USE', 'SHOW' ],
                        true
                );
        }
@@ -3626,7 +3626,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
         * Actually run any "atomic section cancel" callbacks.
         *
         * @param int $trigger IDatabase::TRIGGER_* constant
-        * @param AtomicSectionIdentifier[]|null $sectionId Section IDs to cancel,
+        * @param AtomicSectionIdentifier[]|null $sectionIds Section IDs to cancel,
         *  null on transaction rollback
         */
        private function runOnAtomicSectionCancelCallbacks(
index e3c2268..b3af8ad 100644 (file)
@@ -601,7 +601,8 @@ abstract class DatabaseMysqlBase extends Database {
         */
        public function fieldInfo( $table, $field ) {
                $table = $this->tableName( $table );
-               $res = $this->query( "SELECT * FROM $table LIMIT 1", __METHOD__, true );
+               $flags = self::QUERY_SILENCE_ERRORS;
+               $res = $this->query( "SELECT * FROM $table LIMIT 1", __METHOD__, $flags );
                if ( !$res ) {
                        return false;
                }
@@ -722,7 +723,8 @@ abstract class DatabaseMysqlBase extends Database {
         * @return bool|int
         */
        protected function getLagFromSlaveStatus() {
-               $res = $this->query( 'SHOW SLAVE STATUS', __METHOD__ );
+               $flags = self::QUERY_SILENCE_ERRORS | self::QUERY_IGNORE_DBO_TRX;
+               $res = $this->query( 'SHOW SLAVE STATUS', __METHOD__, $flags );
                $row = $res ? $res->fetchObject() : false;
                // If the server is not replicating, there will be no row
                if ( $row && strval( $row->Seconds_Behind_Master ) !== '' ) {
@@ -824,7 +826,8 @@ abstract class DatabaseMysqlBase extends Database {
 
                                // Connect to and query the master; catch errors to avoid outages
                                try {
-                                       $res = $conn->query( 'SELECT @@server_id AS id', $fname );
+                                       $flags = self::QUERY_SILENCE_ERRORS | self::QUERY_IGNORE_DBO_TRX;
+                                       $res = $conn->query( 'SELECT @@server_id AS id', $fname, $flags );
                                        $row = $res ? $res->fetchObject() : false;
                                        $id = $row ? (int)$row->id : 0;
                                } catch ( DBError $e ) {
@@ -854,7 +857,8 @@ abstract class DatabaseMysqlBase extends Database {
                        // percision field is not supported in MySQL <= 5.5.
                        $res = $this->query(
                                "SELECT ts FROM heartbeat.heartbeat WHERE $whereSQL ORDER BY ts DESC LIMIT 1",
-                               __METHOD__
+                               __METHOD__,
+                               self::QUERY_SILENCE_ERRORS | self::QUERY_IGNORE_DBO_TRX
                        );
                        $row = $res ? $res->fetchObject() : false;
                } finally {
@@ -1032,7 +1036,9 @@ abstract class DatabaseMysqlBase extends Database {
                        $this->srvCache->makeGlobalKey( 'mysql-server-id', $this->getServer() ),
                        self::SERVER_ID_CACHE_TTL,
                        function () use ( $fname ) {
-                               $res = $this->query( "SELECT @@server_id AS id", $fname );
+                               $flags = self::QUERY_IGNORE_DBO_TRX;
+                               $res = $this->query( "SELECT @@server_id AS id", $fname, $flags );
+
                                return intval( $this->fetchObject( $res )->id );
                        }
                );
@@ -1042,11 +1048,13 @@ abstract class DatabaseMysqlBase extends Database {
         * @return string|null
         */
        protected function getServerUUID() {
+               $fname = __METHOD__;
                return $this->srvCache->getWithSetCallback(
                        $this->srvCache->makeGlobalKey( 'mysql-server-uuid', $this->getServer() ),
                        self::SERVER_ID_CACHE_TTL,
-                       function () {
-                               $res = $this->query( "SHOW GLOBAL VARIABLES LIKE 'server_uuid'" );
+                       function () use ( $fname ) {
+                               $flags = self::QUERY_IGNORE_DBO_TRX;
+                               $res = $this->query( "SHOW GLOBAL VARIABLES LIKE 'server_uuid'", $fname, $flags );
                                $row = $this->fetchObject( $res );
 
                                return $row ? $row->Value : null;
@@ -1060,13 +1068,15 @@ abstract class DatabaseMysqlBase extends Database {
         */
        protected function getServerGTIDs( $fname = __METHOD__ ) {
                $map = [];
+
+               $flags = self::QUERY_IGNORE_DBO_TRX;
                // Get global-only variables like gtid_executed
-               $res = $this->query( "SHOW GLOBAL VARIABLES LIKE 'gtid_%'", $fname );
+               $res = $this->query( "SHOW GLOBAL VARIABLES LIKE 'gtid_%'", $fname, $flags );
                foreach ( $res as $row ) {
                        $map[$row->Variable_name] = $row->Value;
                }
                // Get session-specific (e.g. gtid_domain_id since that is were writes will log)
-               $res = $this->query( "SHOW SESSION VARIABLES LIKE 'gtid_%'", $fname );
+               $res = $this->query( "SHOW SESSION VARIABLES LIKE 'gtid_%'", $fname, $flags );
                foreach ( $res as $row ) {
                        $map[$row->Variable_name] = $row->Value;
                }
@@ -1080,11 +1090,14 @@ abstract class DatabaseMysqlBase extends Database {
         * @return string[] Latest available server status row
         */
        protected function getServerRoleStatus( $role, $fname = __METHOD__ ) {
-               return $this->query( "SHOW $role STATUS", $fname )->fetchRow() ?: [];
+               $flags = self::QUERY_IGNORE_DBO_TRX;
+
+               return $this->query( "SHOW $role STATUS", $fname, $flags )->fetchRow() ?: [];
        }
 
        public function serverIsReadOnly() {
-               $res = $this->query( "SHOW GLOBAL VARIABLES LIKE 'read_only'", __METHOD__ );
+               $flags = self::QUERY_IGNORE_DBO_TRX;
+               $res = $this->query( "SHOW GLOBAL VARIABLES LIKE 'read_only'", __METHOD__, $flags );
                $row = $this->fetchObject( $res );
 
                return $row ? ( strtolower( $row->Value ) === 'on' ) : false;
@@ -1149,9 +1162,10 @@ abstract class DatabaseMysqlBase extends Database {
         */
        public function setSessionOptions( array $options ) {
                if ( isset( $options['connTimeout'] ) ) {
+                       $flags = self::QUERY_IGNORE_DBO_TRX;
                        $timeout = (int)$options['connTimeout'];
-                       $this->query( "SET net_read_timeout=$timeout" );
-                       $this->query( "SET net_write_timeout=$timeout" );
+                       $this->query( "SET net_read_timeout=$timeout", __METHOD__, $flags );
+                       $this->query( "SET net_write_timeout=$timeout", __METHOD__, $flags );
                }
        }
 
@@ -1184,8 +1198,10 @@ abstract class DatabaseMysqlBase extends Database {
                }
 
                $encName = $this->addQuotes( $this->makeLockName( $lockName ) );
-               $result = $this->query( "SELECT IS_FREE_LOCK($encName) AS lockstatus", $method );
-               $row = $this->fetchObject( $result );
+
+               $flags = self::QUERY_IGNORE_DBO_TRX;
+               $res = $this->query( "SELECT IS_FREE_LOCK($encName) AS lockstatus", $method, $flags );
+               $row = $this->fetchObject( $res );
 
                return ( $row->lockstatus == 1 );
        }
@@ -1198,8 +1214,10 @@ abstract class DatabaseMysqlBase extends Database {
         */
        public function lock( $lockName, $method, $timeout = 5 ) {
                $encName = $this->addQuotes( $this->makeLockName( $lockName ) );
-               $result = $this->query( "SELECT GET_LOCK($encName, $timeout) AS lockstatus", $method );
-               $row = $this->fetchObject( $result );
+
+               $flags = self::QUERY_IGNORE_DBO_TRX;
+               $res = $this->query( "SELECT GET_LOCK($encName, $timeout) AS lockstatus", $method, $flags );
+               $row = $this->fetchObject( $res );
 
                if ( $row->lockstatus == 1 ) {
                        parent::lock( $lockName, $method, $timeout ); // record
@@ -1221,8 +1239,10 @@ abstract class DatabaseMysqlBase extends Database {
         */
        public function unlock( $lockName, $method ) {
                $encName = $this->addQuotes( $this->makeLockName( $lockName ) );
-               $result = $this->query( "SELECT RELEASE_LOCK($encName) as lockstatus", $method );
-               $row = $this->fetchObject( $result );
+
+               $flags = self::QUERY_IGNORE_DBO_TRX;
+               $res = $this->query( "SELECT RELEASE_LOCK($encName) as lockstatus", $method, $flags );
+               $row = $this->fetchObject( $res );
 
                if ( $row->lockstatus == 1 ) {
                        parent::unlock( $lockName, $method ); // record
@@ -1258,13 +1278,13 @@ abstract class DatabaseMysqlBase extends Database {
                }
 
                $sql = "LOCK TABLES " . implode( ',', $items );
-               $this->query( $sql, $method );
+               $this->query( $sql, $method, self::QUERY_IGNORE_DBO_TRX );
 
                return true;
        }
 
        protected function doUnlockTables( $method ) {
-               $this->query( "UNLOCK TABLES", $method );
+               $this->query( "UNLOCK TABLES", $method, self::QUERY_IGNORE_DBO_TRX );
 
                return true;
        }
@@ -1285,7 +1305,7 @@ abstract class DatabaseMysqlBase extends Database {
                                (bool)$this->selectField( false, '@@sql_big_selects', '', __METHOD__ );
                }
                $encValue = $value ? '1' : '0';
-               $this->query( "SET sql_big_selects=$encValue", __METHOD__ );
+               $this->query( "SET sql_big_selects=$encValue", __METHOD__, self::QUERY_IGNORE_DBO_TRX );
        }
 
        /**
@@ -1468,7 +1488,8 @@ abstract class DatabaseMysqlBase extends Database {
         * @return array
         */
        private function getMysqlStatus( $which = "%" ) {
-               $res = $this->query( "SHOW STATUS LIKE '{$which}'" );
+               $flags = self::QUERY_IGNORE_DBO_TRX;
+               $res = $this->query( "SHOW STATUS LIKE '{$which}'", __METHOD__, $flags );
                $status = [];
 
                foreach ( $res as $row ) {
index 0b77651..7361032 100644 (file)
@@ -407,7 +407,7 @@ class EmailNotification {
         * @param User $user
         * @param string $source
         */
-       function compose( $user, $source ) {
+       private function compose( $user, $source ) {
                global $wgEnotifImpersonal;
 
                if ( !$this->composed_common ) {
@@ -424,7 +424,7 @@ class EmailNotification {
        /**
         * Send any queued mails
         */
-       function sendMails() {
+       private function sendMails() {
                global $wgEnotifImpersonal;
                if ( $wgEnotifImpersonal ) {
                        $this->sendImpersonal( $this->mailTargets );
@@ -440,9 +440,8 @@ class EmailNotification {
         * @param User $watchingUser
         * @param string $source
         * @return Status
-        * @private
         */
-       function sendPersonalised( $watchingUser, $source ) {
+       private function sendPersonalised( $watchingUser, $source ) {
                global $wgEnotifUseRealName;
                // From the PHP manual:
                //   Note: The to parameter cannot be an address in the form of
@@ -481,7 +480,7 @@ class EmailNotification {
         * @param MailAddress[] $addresses
         * @return Status|null
         */
-       function sendImpersonal( $addresses ) {
+       private function sendImpersonal( $addresses ) {
                if ( empty( $addresses ) ) {
                        return null;
                }
index 63a114d..1a5d08a 100644 (file)
@@ -71,7 +71,7 @@ class MailAddress {
         * Return formatted and quoted address to insert into SMTP headers
         * @return string
         */
-       function toString() {
+       public function toString() {
                if ( !$this->address ) {
                        return '';
                }
@@ -94,7 +94,7 @@ class MailAddress {
                return "$quoted <{$this->address}>";
        }
 
-       function __toString() {
+       public function __toString() {
                return $this->toString();
        }
 }
index 5d7030b..47fa16f 100644 (file)
@@ -64,7 +64,7 @@ class UserMailer {
         *
         * @return string
         */
-       static function arrayToHeaderString( $headers, $endl = PHP_EOL ) {
+       private static function arrayToHeaderString( $headers, $endl = PHP_EOL ) {
                $strings = [];
                foreach ( $headers as $name => $value ) {
                        // Prevent header injection by stripping newlines from value
@@ -79,7 +79,7 @@ class UserMailer {
         *
         * @return string
         */
-       static function makeMsgId() {
+       private static function makeMsgId() {
                global $wgSMTP, $wgServer;
 
                $domainId = WikiMap::getCurrentWikiDbDomain()->getId();
@@ -465,7 +465,7 @@ class UserMailer {
         * @param int $code Error number
         * @param string $string Error message
         */
-       static function errorHandler( $code, $string ) {
+       private static function errorHandler( $code, $string ) {
                self::$mErrorString = preg_replace( '/^mail\(\)(\s*\[.*?\])?: /', '', $string );
        }
 
index c0adb51..e9853b1 100644 (file)
@@ -382,6 +382,7 @@ class ObjectCache {
         * @deprecated Since 1.28 Use MediaWikiServices::getInstance()->getMainObjectStash()
         */
        public static function getMainStashInstance() {
+               wfDeprecated( __METHOD__, '1.28' );
                return MediaWikiServices::getInstance()->getMainObjectStash();
        }
 
index 768b488..9cae73c 100644 (file)
@@ -300,6 +300,13 @@ class ExtensionRegistry {
                        }
 
                        $dir = dirname( $path );
+                       self::exportAutoloadClassesAndNamespaces(
+                               $dir,
+                               $info,
+                               $autoloadClasses,
+                               $autoloadNamespaces
+                       );
+
                        if ( isset( $info['AutoloadClasses'] ) ) {
                                $autoload = $this->processAutoLoader( $dir, $info['AutoloadClasses'] );
                                $GLOBALS['wgAutoloadClasses'] += $autoload;
@@ -347,6 +354,28 @@ class ExtensionRegistry {
                return $data;
        }
 
+       /**
+        * Export autoload classes and namespaces for a given directory and parsed JSON info file.
+        *
+        * @param string $dir
+        * @param array $info
+        * @param array &$autoloadClasses
+        * @param array &$autoloadNamespaces
+        */
+       public static function exportAutoloadClassesAndNamespaces(
+               $dir, $info, &$autoloadClasses = [], &$autoloadNamespaces = []
+       ) {
+               if ( isset( $info['AutoloadClasses'] ) ) {
+                       $autoload = self::processAutoLoader( $dir, $info['AutoloadClasses'] );
+                       $GLOBALS['wgAutoloadClasses'] += $autoload;
+                       $autoloadClasses += $autoload;
+               }
+               if ( isset( $info['AutoloadNamespaces'] ) ) {
+                       $autoloadNamespaces += self::processAutoLoader( $dir, $info['AutoloadNamespaces'] );
+                       AutoLoader::$psr4Namespaces += $autoloadNamespaces;
+               }
+       }
+
        protected function exportExtractedData( array $info ) {
                foreach ( $info['globals'] as $key => $val ) {
                        // If a merge strategy is set, read it and remove it from the value
@@ -511,7 +540,7 @@ class ExtensionRegistry {
         * @param array $files
         * @return array
         */
-       protected function processAutoLoader( $dir, array $files ) {
+       protected static function processAutoLoader( $dir, array $files ) {
                // Make paths absolute, relative to the JSON file
                foreach ( $files as &$file ) {
                        $file = "$dir/$file";
index 3c9abb2..f9b4542 100644 (file)
@@ -824,9 +824,27 @@ abstract class ChangesListSpecialPage extends SpecialPage {
                }
        }
 
+       /**
+        * Get essential data about getRcFiltersConfigVars() for change detection.
+        *
+        * @internal For use by Resources.php only.
+        * @see ResourceLoaderModule::getDefinitionSummary() and ResourceLoaderModule::getVersionHash()
+        * @param ResourceLoaderContext $context
+        * @return array
+        */
+       public static function getRcFiltersConfigSummary( ResourceLoaderContext $context ) {
+               return [
+                       // Reduce version computation by avoiding Message parsing
+                       'RCFiltersChangeTags' => self::getChangeTagListSummary( $context ),
+                       'StructuredChangeFiltersEditWatchlistUrl' =>
+                               SpecialPage::getTitleFor( 'EditWatchlist' )->getLocalURL()
+               ];
+       }
+
        /**
         * Get config vars to export with the mediawiki.rcfilters.filters.ui module.
         *
+        * @internal For use by Resources.php only.
         * @param ResourceLoaderContext $context
         * @return array
         */
@@ -839,70 +857,105 @@ abstract class ChangesListSpecialPage extends SpecialPage {
        }
 
        /**
-        * Fetch the change tags list for the front end
+        * Get (cheap to compute) information about change tags.
+        *
+        * Returns an array of associative arrays with information about each tag:
+        * - name: Tag name (string)
+        * - labelMsg: Short description message (Message object)
+        * - descriptionMsg: Long description message (Message object)
+        * - cssClass: CSS class to use for RC entries with this tag
+        * - hits: Number of RC entries that have this tag
         *
         * @param ResourceLoaderContext $context
-        * @return array Tag data
+        * @return array[] Information about each tag
         */
-       protected static function getChangeTagList( ResourceLoaderContext $context ) {
-               $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
-               return $cache->getWithSetCallback(
-                       $cache->makeKey( 'changeslistspecialpage-changetags', $context->getLanguage() ),
-                       $cache::TTL_MINUTE * 10,
-                       function () use ( $context ) {
-                               $explicitlyDefinedTags = array_fill_keys( ChangeTags::listExplicitlyDefinedTags(), 0 );
-                               $softwareActivatedTags = array_fill_keys( ChangeTags::listSoftwareActivatedTags(), 0 );
-
-                               $tagStats = ChangeTags::tagUsageStatistics();
-                               $tagHitCounts = array_merge( $explicitlyDefinedTags, $softwareActivatedTags, $tagStats );
-
-                               // Sort by hits (disabled for now)
-                               //arsort( $tagHitCounts );
-
-                               // HACK work around ChangeTags::truncateTagDescription() requiring a RequestContext
-                               $fakeContext = RequestContext::newExtraneousContext( Title::newFromText( 'Dwimmerlaik' ) );
-                               $fakeContext->setLanguage( Language::factory( $context->getLanguage() ) );
-
-                               // Build the list and data
-                               $result = [];
-                               foreach ( $tagHitCounts as $tagName => $hits ) {
-                                       if (
-                                               (
-                                                       // Only get active tags
-                                                       isset( $explicitlyDefinedTags[ $tagName ] ) ||
-                                                       isset( $softwareActivatedTags[ $tagName ] )
-                                               ) &&
-                                               // Only get tags with more than 0 hits
-                                               $hits > 0
-                                       ) {
-                                               $result[] = [
-                                                       'name' => $tagName,
-                                                       'label' => Sanitizer::stripAllTags(
-                                                               ChangeTags::tagDescription( $tagName, $context )
-                                                       ),
-                                                       'description' =>
-                                                               ChangeTags::truncateTagDescription(
-                                                                       $tagName,
-                                                                       self::TAG_DESC_CHARACTER_LIMIT,
-                                                                       $fakeContext
-                                                               ),
-                                                       'cssClass' => Sanitizer::escapeClass( 'mw-tag-' . $tagName ),
-                                                       'hits' => $hits,
-                                               ];
-                                       }
+       protected static function getChangeTagInfo( ResourceLoaderContext $context ) {
+               $explicitlyDefinedTags = array_fill_keys( ChangeTags::listExplicitlyDefinedTags(), 0 );
+               $softwareActivatedTags = array_fill_keys( ChangeTags::listSoftwareActivatedTags(), 0 );
+
+               $tagStats = ChangeTags::tagUsageStatistics();
+               $tagHitCounts = array_merge( $explicitlyDefinedTags, $softwareActivatedTags, $tagStats );
+
+               $result = [];
+               foreach ( $tagHitCounts as $tagName => $hits ) {
+                       if (
+                               (
+                                       // Only get active tags
+                                       isset( $explicitlyDefinedTags[ $tagName ] ) ||
+                                       isset( $softwareActivatedTags[ $tagName ] )
+                               ) &&
+                               // Only get tags with more than 0 hits
+                               $hits > 0
+                       ) {
+                               $labelMsg = ChangeTags::tagShortDescriptionMessage( $tagName, $context );
+                               if ( $labelMsg === false ) {
+                                       // Tag is hidden, skip it
+                                       continue;
                                }
+                               $result[] = [
+                                       'name' => $tagName,
+                                       // 'label' and 'description' filled in by getChangeTagList()
+                                       'labelMsg' => $labelMsg,
+                                       'descriptionMsg' => ChangeTags::tagLongDescriptionMessage( $tagName, $context ),
+                                       'cssClass' => Sanitizer::escapeClass( 'mw-tag-' . $tagName ),
+                                       'hits' => $hits,
+                               ];
+                       }
+               }
+               return $result;
+       }
 
-                               // Instead of sorting by hit count (disabled, see above), sort by display name
-                               usort( $result, function ( $a, $b ) {
-                                       return strcasecmp( $a['label'], $b['label'] );
-                               } );
+       /**
+        * Get information about change tags for use in getRcFiltersConfigSummary().
+        *
+        * This expands labelMsg and descriptionMsg to the raw values of each message, which captures
+        * changes in the messages but avoids the expensive step of parsing them.
+        *
+        * @param ResourceLoaderContext $context
+        * @return array[] Result of getChangeTagInfo(), with messages expanded to raw contents
+        */
+       protected static function getChangeTagListSummary( ResourceLoaderContext $context ) {
+               $tags = self::getChangeTagInfo( $context );
+               foreach ( $tags as &$tagInfo ) {
+                       $tagInfo['labelMsg'] = $tagInfo['labelMsg']->plain();
+                       if ( $tagInfo['descriptionMsg'] ) {
+                               $tagInfo['descriptionMsg'] = $tagInfo['descriptionMsg']->plain();
+                       }
+               }
+               return $tags;
+       }
 
-                               return $result;
-                       },
-                       [
-                               'lockTSE' => 30
-                       ]
-               );
+       /**
+        * Get information about change tags to export to JS via getRcFiltersConfigVars().
+        *
+        * This removes labelMsg and descriptionMsg, and adds label and description, which are parsed,
+        * stripped and (in the case of description) truncated versions of these messages. Message
+        * parsing is expensive, so to detect whether the tag list has changed, use
+        * getChangeTagListSummary() instead.
+        *
+        * @param ResourceLoaderContext $context
+        * @return array[] Result of getChangeTagInfo(), with messages parsed, stripped and truncated
+        */
+       protected static function getChangeTagList( ResourceLoaderContext $context ) {
+               $tags = self::getChangeTagInfo( $context );
+               $language = Language::factory( $context->getLanguage() );
+               foreach ( $tags as &$tagInfo ) {
+                       $tagInfo['label'] = Sanitizer::stripAllTags( $tagInfo['labelMsg']->parse() );
+                       $tagInfo['description'] = $tagInfo['descriptionMsg'] ?
+                               $language->truncateForVisual(
+                                       Sanitizer::stripAllTags( $tagInfo['descriptionMsg']->parse() ),
+                                       self::TAG_DESC_CHARACTER_LIMIT
+                               ) :
+                               '';
+                       unset( $tagInfo['labelMsg'] );
+                       unset( $tagInfo['descriptionMsg'] );
+               }
+
+               // Instead of sorting by hit count (disabled for now), sort by display name
+               usort( $tags, function ( $a, $b ) {
+                       return strcasecmp( $a['label'], $b['label'] );
+               } );
+               return $tags;
        }
 
        /**
index 1d0ff21..f899d76 100644 (file)
@@ -141,9 +141,7 @@ class SpecialChangeCredentials extends AuthManagerSpecialPage {
                        }
 
                        if ( $any ) {
-                               $this->getOutput()->addModules( [
-                                       'mediawiki.special.changecredentials.js'
-                               ] );
+                               $this->getOutput()->addModules( 'mediawiki.misc-authed-ooui' );
                        }
 
                        return $descriptor;
index 252df5b..ecbbc25 100644 (file)
@@ -147,7 +147,7 @@ class MovePageForm extends UnlistedSpecialPage {
                $out = $this->getOutput();
                $out->setPageTitle( $this->msg( 'move-page', $this->oldTitle->getPrefixedText() ) );
                $out->addModuleStyles( 'mediawiki.special' );
-               $out->addModules( 'mediawiki.special.movePage' );
+               $out->addModules( 'mediawiki.misc-authed-ooui' );
                $this->addHelpLink( 'Help:Moving a page' );
 
                $out->addWikiMsg( $this->getConfig()->get( 'FixDoubleRedirects' ) ?
index 7e41305..c0f004f 100644 (file)
@@ -43,7 +43,7 @@ class SpecialPageLanguage extends FormSpecialPage {
        }
 
        protected function preText() {
-               $this->getOutput()->addModules( 'mediawiki.special.pageLanguage' );
+               $this->getOutput()->addModules( 'mediawiki.misc-authed-ooui' );
                return parent::preText();
        }
 
index f7ad80c..01aed22 100644 (file)
@@ -365,7 +365,7 @@ class BlockListPager extends TablePager {
        function getTotalAutoblocks() {
                $dbr = $this->getDatabase();
                $res = $dbr->selectField( 'ipblocks',
-                       [ 'COUNT(*) AS totalautoblocks' ],
+                       'COUNT(*)',
                        [
                                'ipb_auto' => '1',
                                'ipb_expiry >= ' . $dbr->addQuotes( $dbr->timestamp() ),
index 97d4702..d0d8351 100644 (file)
@@ -1280,12 +1280,11 @@ class User implements IDBAccessObject, UserIdentity {
                $user = $session->getUser();
                if ( $user->isLoggedIn() ) {
                        $this->loadFromUserObject( $user );
-                       if ( $user->getBlock() ) {
-                               // If this user is autoblocked, set a cookie to track the block. This has to be done on
-                               // every session load, because an autoblocked editor might not edit again from the same
-                               // IP address after being blocked.
-                               MediaWikiServices::getInstance()->getBlockManager()->trackBlockWithCookie( $this );
-                       }
+
+                       // If this user is autoblocked, set a cookie to track the block. This has to be done on
+                       // every session load, because an autoblocked editor might not edit again from the same
+                       // IP address after being blocked.
+                       MediaWikiServices::getInstance()->getBlockManager()->trackBlockWithCookie( $this );
 
                        // Other code expects these to be set in the session, so set them.
                        $session->set( 'wsUserID', $this->getId() );
@@ -3464,7 +3463,7 @@ class User implements IDBAccessObject, UserIdentity {
 
                        if ( $count === null ) {
                                // it has not been initialized. do so.
-                               $count = $this->initEditCountInternal();
+                               $count = $this->initEditCountInternal( $dbr );
                        }
                        $this->mEditCount = $count;
                }
@@ -5024,14 +5023,13 @@ class User implements IDBAccessObject, UserIdentity {
        /**
         * Initialize user_editcount from data out of the revision table
         *
-        * This method should not be called outside User/UserEditCountUpdate
-        *
+        * @internal This method should not be called outside User/UserEditCountUpdate
+        * @param IDatabase $dbr Replica database
         * @return int Number of edits
         */
-       public function initEditCountInternal() {
+       public function initEditCountInternal( IDatabase $dbr ) {
                // Pull from a replica DB to be less cruel to servers
                // Accuracy isn't the point anyway here
-               $dbr = wfGetDB( DB_REPLICA );
                $actorWhere = ActorMigration::newMigration()->getWhere( $dbr, 'rev_user', $this );
                $count = (int)$dbr->selectField(
                        [ 'revision' ] + $actorWhere['tables'],
index c5ff9d6..9fc7d73 100644 (file)
@@ -391,27 +391,30 @@ class LanguageConverter {
                   IMPORTANT: Beware of failure from pcre.backtrack_limit (T124404).
                   Minimize use of backtracking where possible.
                */
-               $marker = '|' . Parser::MARKER_PREFIX . '[^\x7f]++\x7f';
-
-               // this one is needed when the text is inside an HTML markup
-               $htmlfix = '|<[^>\004]++(?=\004$)|^[^<>]*+>';
-
-               // Optimize for the common case where these tags have
-               // few or no children. Thus try and possesively get as much as
-               // possible, and only engage in backtracking when we hit a '<'.
-
-               // disable convert to variants between <code> tags
-               $codefix = '<code>[^<]*+(?:(?:(?!<\/code>).)[^<]*+)*+<\/code>|';
-               // disable conversion of <script> tags
-               $scriptfix = '<script[^>]*+>[^<]*+(?:(?:(?!<\/script>).)[^<]*+)*+<\/script>|';
-               // disable conversion of <pre> tags
-               $prefix = '<pre[^>]*+>[^<]*+(?:(?:(?!<\/pre>).)[^<]*+)*+<\/pre>|';
-               // The "|.*+)" at the end, is in case we missed some part of html syntax,
-               // we will fail securely (hopefully) by matching the rest of the string.
-               $htmlFullTag = '<(?:[^>=]*+(?>[^>=]*+=\s*+(?:"[^"]*"|\'[^\']*\'|[^\'">\s]*+))*+[^>=]*+>|.*+)|';
-
-               $reg = '/' . $codefix . $scriptfix . $prefix . $htmlFullTag .
-                       '&[a-zA-Z#][a-z0-9]++;' . $marker . $htmlfix . '|\004$/s';
+               static $reg;
+               if ( $reg === null ) {
+                       $marker = '|' . Parser::MARKER_PREFIX . '[^\x7f]++\x7f';
+
+                       // this one is needed when the text is inside an HTML markup
+                       $htmlfix = '|<[^>\004]++(?=\004$)|^[^<>]*+>';
+
+                       // Optimize for the common case where these tags have
+                       // few or no children. Thus try and possesively get as much as
+                       // possible, and only engage in backtracking when we hit a '<'.
+
+                       // disable convert to variants between <code> tags
+                       $codefix = '<code>[^<]*+(?:(?:(?!<\/code>).)[^<]*+)*+<\/code>|';
+                       // disable conversion of <script> tags
+                       $scriptfix = '<script[^>]*+>[^<]*+(?:(?:(?!<\/script>).)[^<]*+)*+<\/script>|';
+                       // disable conversion of <pre> tags
+                       $prefix = '<pre[^>]*+>[^<]*+(?:(?:(?!<\/pre>).)[^<]*+)*+<\/pre>|';
+                       // The "|.*+)" at the end, is in case we missed some part of html syntax,
+                       // we will fail securely (hopefully) by matching the rest of the string.
+                       $htmlFullTag = '<(?:[^>=]*+(?>[^>=]*+=\s*+(?:"[^"]*"|\'[^\']*\'|[^\'">\s]*+))*+[^>=]*+>|.*+)|';
+
+                       $reg = '/' . $codefix . $scriptfix . $prefix . $htmlFullTag .
+                                '&[a-zA-Z#][a-z0-9]++;' . $marker . $htmlfix . '|\004$/s';
+               }
                $startPos = 0;
                $sourceBlob = '';
                $literalBlob = '';
@@ -426,8 +429,9 @@ class LanguageConverter {
 
                // We add a marker (\004) at the end of text, to ensure we always match the
                // entire text (Otherwise, pcre.backtrack_limit might cause silent failure)
+               $textWithMarker = $text . "\004";
                while ( $startPos < strlen( $text ) ) {
-                       if ( preg_match( $reg, $text . "\004", $markupMatches, PREG_OFFSET_CAPTURE, $startPos ) ) {
+                       if ( preg_match( $reg, $textWithMarker, $markupMatches, PREG_OFFSET_CAPTURE, $startPos ) ) {
                                $elementPos = $markupMatches[0][1];
                                $element = $markupMatches[0][0];
                                if ( $element === "\004" ) {
index 30b511d..2d2d3f1 100644 (file)
        "specialmute-error-invalid-user": "لا يمكن العثور على اسم المستخدم المطلوب.",
        "specialmute-error-email-blacklist-disabled": "لم يتم تمكين كتم المستخدمين من إرسال رسائل البريد الإلكتروني إليك.",
        "specialmute-error-email-preferences": "يجب تأكيد عنوان بريدك الإلكتروني قبل أن تتمكن من كتم صوت المستخدم، يمكنك القيام بذلك من [[Special:Preferences]].",
-       "specialmute-email-footer": "[$1 إدارة تفضيلات البريد الإلكتروني لـ{{BIDI:$2}}.]",
+       "specialmute-email-footer": "لإدارة تفضيلات البريد الإلكتروني لـ{{BIDI:$2}}؛ تُرجَى زيارة <$1>",
        "specialmute-login-required": "يُرجَى تسجيل الدخول لتغيير تفضيلات الصمت الخاصة بك.",
        "revid": "المراجعة $1",
        "pageid": "معرف الصفحة $1",
index 07496b9..21151e5 100644 (file)
        "nmembers": "$1 {{PLURAL:$1|üzv|üzv}}",
        "nmemberschanged": "$1 → $2 {{PLURAL:$2|üzv|üzvlər}}",
        "nrevisions": "$1 dəyişiklik",
-       "nimagelinks": "$1 səhifədə istifadə olunmur",
+       "nimagelinks": "$1 səhifədə istifadə olunur",
        "ntransclusions": "$1 səhifədə istifadə olunur",
        "specialpage-empty": "Bu səhifə boşdur.",
        "lonelypages": "Yetim səhifələr",
index ae5f2cb..30aecf1 100644 (file)
        "specialmute": "Заглушаныя ўдзельнікі",
        "specialmute-success": "Вашыя налады заглушэньня былі пасьпяхова абноўленыя. Глядзіце ўсіх заглушаных удзельнікаў на старонцы [[Special:Preferences]].",
        "specialmute-submit": "Пацьвердзіць",
+       "specialmute-label-mute-email": "Заглушыць лісты электроннай пошты ад гэтага ўдзельніка",
+       "specialmute-header": "Калі ласка, абярыце вашыя налады заглушэньня для {{BIDI:[[User:$1]]}}.",
+       "specialmute-error-invalid-user": "Запытанае імя ўдзельніка ня можа быць знойдзенае.",
        "revid": "вэрсія $1",
        "pageid": "Ідэнтыфікатар старонкі $1",
        "interfaceadmin-info": "$1\n\nДазволы на рэдагаваньне агульнасайтавых CSS/JS/JSON-файлаў былі нядаўна вылучаныя з права <code>editinterface</code>. Калі вы не разумееце, чаму атрымліваеце гэтую памылку, глядзіце [[mw:MediaWiki_1.32/interface-admin]].",
index 765e5f0..faa4581 100644 (file)
        "createacct-another-submit": "Crea un compte",
        "createacct-continue-submit": "Continua amb la creació del compte",
        "createacct-another-continue-submit": "Continua amb la creació del compte",
-       "createacct-benefit-heading": "{{SITENAME}} és feta per gent com tu.",
+       "createacct-benefit-heading": "Gent com vós fa possible {{SITENAME}}.",
        "createacct-benefit-body1": "{{PLURAL:$1|edició|edicions}}",
        "createacct-benefit-body2": "{{PLURAL:$1|pàgina|pàgines}}",
        "createacct-benefit-body3": "{{PLURAL:$1|col·laborador recent|col·laboradors recents}}",
index 42a92d9..7b58d71 100644 (file)
@@ -32,7 +32,8 @@
                        "Archaeodontosaurus",
                        "Fitoschido",
                        "ديفيد",
-                       "Orbot707"
+                       "Orbot707",
+                       "Shirayuki"
                ]
        },
        "tog-underline": "Bınê gırey de xete bance:",
        "hidetoc": "bınımne",
        "collapsible-collapse": "Teng ke",
        "collapsible-expand": "Hera kerê",
-       "confirmable-confirm": "{{GENDER:$1|Şıma}} pêbawerê?",
+       "confirmable-confirm": "{{GENDER:$1|Şıma}} bêgumanê?",
        "confirmable-yes": "Eya",
        "confirmable-no": "Nê",
        "thisisdeleted": "Bıvêne ya zi $1 peyser biya?",
        "virus-scanfailed": "cıgerayiş tamam nêbı (kod $1)",
        "virus-unknownscanner": "antiviruso ke nêzanyeno:",
        "logouttext": "'''Henda şıma hesab ra veciyay.'''\n\nDiqat kerê ke tayê perri şenê hewna zey şıma kewtê ra cı bıasê, heta şıma ver-virê şanekerê (browserê) xo besterê.",
+       "logout-failed": "Enewke ronıştışo nêracneyêno:$1",
        "cannotlogoutnow-title": "Enewke ronıştışo nêracneyêno",
        "cannotlogoutnow-text": "Gurenayışê $1i de veciyayış mımkın niyo.",
        "welcomeuser": "Heyr amey, $1!",
        "post-expand-template-argument-warning": "Tembe: No per de tewr tay yew şablono herayi esto.Nê vurnayeni ser çebyay",
        "post-expand-template-argument-category": "Pelê ke şablonê eyi qebul niye",
        "parser-template-loop-warning": "Gıreyê şabloni ca biyo: [[$1]]",
+       "template-loop-category": "dordorekê şabloniya peri",
        "parser-template-recursion-depth-warning": "limitê şablonê newekerdışi biyo de ($1)",
        "language-converter-depth-warning": "xoritiya çarnekarê zıwanan viyarnê ra ($1)",
        "node-count-exceeded-category": "Pela ra hetê kotya amardışê cı ravêrya",
        "revdelete-no-file": "Dosya diyarkerdiye çıniya.",
        "revdelete-show-file-confirm": "Şıma eminê ke wazenê çımraviyarnayışê esterıtey na dosya \"<nowiki>$1</nowiki>\" $2 ra $3 de bıvênê?",
        "revdelete-show-file-submit": "Eya",
+       "revdelete-selected-text": "Qandê [[:$2]]  {{PLURAL:$1|weçinaye revizyon|weçinaye revizyoni}}:",
        "logdelete-selected": "{{PLURAL:$1|Qeydbiyayışo weçinıte|Qeydbiyayışê weçinıtey}}:",
        "revdelete-confirm": "Ma rica keno testiq bike ti ena hereket keno u ti zano neticeyanê herketanê xo u ti ena hereket pê ena [[{{MediaWiki:Policy-url}}|polici]] ra keno.",
        "revdelete-suppress-text": "Wedardış gani '''tenya''' nê halanê cêrênan de bıxebıtiyo:\n* Melumatê kıfırio mıhtemel\n* Melumatê şexio bêmınasıb\n*: ''adresa keyey u numreyê têlefoni, numreyê siğorta sosyale, uêb.''",
        "action-applychangetags": "Vurnayışana piya etiket kerdışi zi dezge fi",
        "action-deletechangetags": "etitikan danegeh ra bestere",
        "action-purge": "Ane perer newe ke",
+       "action-blockemail": "Yew karberi rıştena e-maili ra bloke bıke",
+       "action-bot": "Yew karo otomatik deyne muamele bıkerê",
        "action-editprotected": "\"{{int:protect-level-sysop}}\" şeveknaye pêlan de vırnayış bıkerê",
        "action-editsemiprotected": "\"{{int:protect-level-autoconfirmed}}\" deyne şeveknaye pelan dê vurnayış bıkerê",
        "action-editinterface": "miyanriyê karberi bıvurne",
        "metadata-expand": "Detayan bımotné",
        "metadata-collapse": "melumati bınımne",
        "metadata-fields": "Resımê meydanê metadataê ke na pele de benê lista, pela resımmocnaene de ke tabloê metadata gına waro, gureniyenê.\nÊ bini zey sayekerdoğan nımiyenê.\n* make\n* model\n* datetimeoriginal\n* exposuretime\n* fnumber\n* isospeedratings\n* focallength\n* artist\n* copyright\n* imagedescription\n* gpslatitude\n* gpslongitude\n* gpsaltitude",
-       "metadata-langitem": "'''$2:''' $1",
+       "metadata-langitem": "<strong>$2:</strong> $1",
        "metadata-langitem-default": "$1",
        "namespacesall": "pêro",
        "monthsall": "pêro",
        "confirmemail_body_set": "Jew ten, muhtemelen şıma no IP-adresi $1 ra,\nkeye pelê {{SITENAME}}i de pê no $2 e-postayi hesab kerda.\n\nEke raşta no e-posta eyê şıma yo şıma gani tesdiq bıkerî,\nqey tesdiq kerdışi gani karê e-postayê keyepeli {{SITENAME}} aktif bıbo, qey aktif kerdışi gıreyê cêrıni bıtıkne:\n\n$3\n\neke şıma hesab *nêakerdo*, qey ibtalê tesdiq kerdışê adresa e-postayi gıreyê cêrêni bıtıknê:\n\n$5\n\nkodê tesdiqi heta ıney tarixi $4 meqbul o.",
        "confirmemail_invalidated": "Konfermasyonê adres ê emaîlî iptal biy",
        "invalidateemail": "confirmasyonê e-maili iptal bik",
+       "notificationemail_subject_changed": "Site da {{SITENAME}} dı qeydın adresê eposta vurneya",
        "scarytranscludedisabled": "[Transcludê înterwîkîyî nihebityeno]",
        "scarytranscludefailed": "[Qe $1 fetch kerdişî nihebitiyeno]",
        "scarytranscludefailed-httpstatus": "[Qande $1 şablon nêşa bıgêriyo: HTTP $2]",
        "logentry-block-unblock": "$1, {{GENDER:$4|$3}} {{GENDER:$2|men kerdış wedarna}}",
        "logentry-partialblock-block-page": "{{PLURAL:$1|pele|peli}} $2",
        "logentry-partialblock-block-ns": "{{PLURAL:$1|cayê nameyi|cayê nameyan}} $2",
+       "logentry-import-upload": "$1 {{GENDER:$2|zere kerdışa }} $3'i Dosya kerd bar.",
        "logentry-move-move": "$1, pela $3 ra {{GENDER:$2|kırışt}} pela $4",
        "logentry-move-move-noredirect": "$1, pera $3'i bêhetenayış {{GENDER:$2|kırışt}} pera $4`i",
        "logentry-move-move_redir": "$1 {{GENDER:$2|kırışna}} riperr $3 be $4 weçarnayış sera.",
        "mw-widgets-abandonedit": "Qeydkerdışi ra ravêr, şıma qayılê peyser şêrê asayışo vêrên?",
        "mw-widgets-abandonedit-discard": "Vurnayışan vece",
        "mw-widgets-abandonedit-keep": "Vurnayışi rê dewam ke",
-       "mw-widgets-abandonedit-title": "Vac welay?",
+       "mw-widgets-abandonedit-title": "Şıma bêgumanê?",
        "mw-widgets-copytextlayout-copy": "Kopya",
        "mw-widgets-dateinput-no-date": "Tarix nêweçiniya",
        "mw-widgets-dateinput-placeholder-day": "SSSS-AA-RR",
index 234c7d9..87bee6d 100644 (file)
        "log-action-filter-managetags-deactivate": "Desactivación de etiquetas",
        "log-action-filter-move-move": "Traslado sin sobrescritura de redirecciones",
        "log-action-filter-move-move_redir": "Traslado con sobrescritura de redirecciones",
-       "log-action-filter-newusers-create": "La creación por usuario anónimo",
-       "log-action-filter-newusers-create2": "La creación por usuario registrado",
+       "log-action-filter-newusers-create": "Creación por usuario anónimo",
+       "log-action-filter-newusers-create2": "Creación por usuario registrado",
        "log-action-filter-newusers-autocreate": "Creación automática",
        "log-action-filter-newusers-byemail": "Creación con la contraseña enviada por correo",
        "log-action-filter-patrol-patrol": "Verificación manual",
        "edit-error-long": "Errores:\n\n$1",
        "specialmute": "Silenciar",
        "specialmute-submit": "Confirmar",
+       "specialmute-label-mute-email": "Silenciar los correos electrónicos de este usuario",
        "specialmute-error-invalid-user": "No se encontró el nombre de usuario solicitado.",
+       "specialmute-error-email-preferences": "Debes confirmar tu dirección de correo electrónico antes de que puedas silenciar a un usuario. Puedes hacerlo desde [[Special:Preferences|tus preferencias]].",
        "revid": "revisión $1",
        "pageid": "ID de página $1",
        "interfaceadmin-info": "$1\n\nLos permisos para editar los archivos con formato CSS, JS y JSON en todo el sitio han sido recientemente separados del permiso <code>editinterface</code>. Si no comprendes por qué recibes este error, por favor lee [[mw:MediaWiki_1.32/interface-admin]].",
index f0b6aea..5f0f2c9 100644 (file)
        "grant-createaccount": "ایجاد حساب‌های کاربری",
        "grant-createeditmovepage": "ایجاد، ویرایش و انتقال صفحات",
        "grant-delete": "حذف صفحات، نسخه‌های ویرایش و سیاهه ورودی",
-       "grant-editinterface": "ویرایش صفحه‌های جی‌سان کاربری یا سراسری و فضای نام مدیاویکی",
+       "grant-editinterface": "ویرایش فضای نام مدیاویکی و JSONهای کاربری/وب‌گاه‌مبنا",
        "grant-editmycssjs": "ویرایش  CSS /جاوااسکریپت/JSON  کاربری",
        "grant-editmyoptions": "اولویت‌های کاربری و پیکربندی JSON را ویرایش کنید",
        "grant-editmywatchlist": "ویرایش فهرست پی‌گیری‌هایتان",
-       "grant-editsiteconfig": "ویرایش گسترده CSS/JS کاربر",
+       "grant-editsiteconfig": "ویرایش CSS/JS کاربری و وب‌گاه‌مبنا",
        "grant-editpage": "ویرایش صفحات موجود",
        "grant-editprotected": "ویرایش صفحه محافظت شده",
        "grant-highvolume": "ویرایش با حجم بالا",
        "timezone-local": "محلی",
        "duplicate-defaultsort": "هشدار: ترتیب پیش‌فرض «$2» ترتیب پیش‌فرض قبلی «$1» را باطل می‌کند.",
        "duplicate-displaytitle": "<strong>هشدار:</strong> نمایش عنوان \" $2 \"باعث ابطال پیش نمایش عنوان\" $1 \" می‌شود.",
-       "restricted-displaytitle": "<strong>هشدار:</strong> از آنجايي که عنوان نمایشی «$1» با عنوان اصلی صفحه یکی نبود، مورد اغماز قرار گرفت.",
+       "restricted-displaytitle": "<strong>هشدار:</strong> از آنجایی که عنوان نمایشی «$1» با عنوان اصلی صفحه یکی نبود، نادیده گرفته شد.",
        "invalid-indicator-name": "<strong>خطا:</strong>ویژگی های شاخص‌های وضعیت صفحهٔ <code>name</code> نباید خالی باشند.",
        "version": "نسخه",
        "version-extensions": "افزونه‌های نصب‌شده",
index e1ea96c..862e281 100644 (file)
        "action-override-export-depth": "exporter les pages en incluant les pages liées jusqu’à une profondeur de 5 niveaux",
        "action-suppressredirect": "ne pas créer de redirections depuis les pages sources lors du renommage",
        "nchanges": "$1 modification{{PLURAL:$1||s}}",
+       "ntimes": "$1×",
        "enhancedrc-since-last-visit": "$1 {{PLURAL:$1|depuis la dernière visite}}",
        "enhancedrc-history": "historique",
        "recentchanges": "Modifications récentes",
        "listgrouprights-rights": "Droits associés",
        "listgrouprights-helppage": "Help:Droits de groupes",
        "listgrouprights-members": "(liste des membres)",
+       "listgrouprights-right-display": "<span class=\"listgrouprights-granted\">$1 <code>($2)</code></span>",
+       "listgrouprights-right-revoked": "<span class=\"listgrouprights-revoked\">$1 <code>($2)</code></span>",
        "listgrouprights-addgroup": "Ajouter des membres {{PLURAL:$2|au groupe|aux groupes}} : $1",
        "listgrouprights-removegroup": "Retirer des membres {{PLURAL:$2|du groupe|des groupes}} : $1",
        "listgrouprights-addgroup-all": "Ajouter des membres à tous les groupes",
        "protect-fallback": "Autoriser uniquement les utilisateurs avec le droit « $1 »",
        "protect-level-autoconfirmed": "Autoriser uniquement les utilisateurs autoconfirmés",
        "protect-level-sysop": "Autoriser uniquement les administrateurs",
+       "protect-summary-desc": "[$1=$2] ($3)",
        "protect-summary-cascade": "protection en cascade",
        "protect-expiring": "expire le $1 (UTC)",
        "protect-expiring-local": "expire le $1",
        "undelete-error-long": "Des erreurs ont été rencontrées lors de la restauration du fichier :\n\n$1",
        "undelete-show-file-confirm": "Êtes-vous sûr{{GENDER:||e}} de vouloir consulter une version supprimée du fichier « <nowiki>$1</nowiki> » datant du $2 à $3 ?",
        "undelete-show-file-submit": "Oui",
+       "undelete-revision-row2": "$1 ($2) $3 . . $4 $5 $6 $7 $8",
        "namespace": "Espace de noms :",
        "invert": "Inverser la sélection",
        "tooltip-invert": "Cochez cette case pour cacher les modifications des pages dans l'espace de noms sélectionné (et l'espace de noms associé si coché)",
        "ip_range_toolow": "Les intervalles d'adresses IP ne sont effectivement pas autorisés.",
        "proxyblocker": "Bloqueur de serveurs mandataires",
        "proxyblockreason": "Votre adresse IP a été bloquée car c'est celle d’un serveur mandataire ouvert.\nVeuillez contacter votre fournisseur d’accès à Internet ou votre service d’assistance technique et l’informer de ce sérieux problème de sécurité.",
+       "sorbs": "DNSBL",
        "sorbsreason": "Votre adresse IP est listée comme mandataire ouvert dans le DNSBL utilisé par {{SITENAME}}.",
        "sorbs_create_account_reason": "Votre adresse IP est listée comme mandataire ouvert dans le DNSBL utilisé par {{SITENAME}}.\nVous ne pouvez pas créer un compte.",
        "softblockrangesreason": "Les contributions anonymes ne sont pas autorisées à partir de votre adresse IP ($1). Veuillez vous connecter.",
        "pageinfo-few-watchers": "Moins de $1 {{PLURAL:$1|observateur|observateurs}}",
        "pageinfo-few-visiting-watchers": "Il peut ou non y avoir un observateur regardant les modifications récentes",
        "pageinfo-redirects-name": "Nombre de redirections vers cette page",
+       "pageinfo-redirects-value": "$1",
        "pageinfo-subpages-name": "Nombre de sous-pages de cette page",
        "pageinfo-subpages-value": "$1 ($2 {{PLURAL:$2|redirection|redirections}}; $3 {{PLURAL:$3|non-redirection|non-redirections}})",
        "pageinfo-firstuser": "Créateur de la page",
        "metadata-expand": "Afficher les informations détaillées",
        "metadata-collapse": "Masquer les informations détaillées",
        "metadata-fields": "Les champs de métadonnées d'image listés dans ce message seront inclus dans la page de description de l'image quand la table de métadonnées sera réduite. Les autres champs seront cachés par défaut.\n* make\n* model\n* datetimeoriginal\n* exposuretime\n* fnumber\n* isospeedratings\n* focallength\n* artist\n* copyright\n* imagedescription\n* gpslatitude\n* gpslongitude\n* gpsaltitude",
-       "metadata-langitem": "'''$2&nbsp;:''' $1",
+       "metadata-langitem": "<strong>$2&nbsp;:</strong> $1",
+       "metadata-langitem-default": "$1",
        "namespacesall": "Tous",
        "monthsall": "tous",
        "confirmemail": "Confirmer l’adresse de courriel",
        "confirmrecreate": "L’utilisat{{GENDER:$1|eur|rice}} [[User:$1|$1]] ([[User talk:$1|Discussion]]) a supprimé cette page, alors que vous aviez commencé à la modifier, pour le motif suivant :\n: <em>$2</em>\nVeuillez confirmer que vous désirez réellement recréer cette page.",
        "confirmrecreate-noreason": "L’utilisat{{GENDER:$1|eur|rice}} [[User:$1|$1]] ([[User talk:$1|Discussion]]) a supprimé cette page, alors que vous aviez commencé à la modifier. Veuillez confirmer que vous désirez réellement recréer cette page.",
        "recreate": "Recréer",
+       "unit-pixel": "px",
        "confirm-purge-title": "Purger cette page",
        "confirm_purge_button": "Confirmer",
        "confirm-purge-top": "Voulez-vous rafraîchir cette page (purger le cache) ?",
        "mcrundo-parse-failed": "Echec dans l'analyse de la nouvelle version : $1",
        "semicolon-separator": "&nbsp;;&#32;",
        "colon-separator": "&nbsp;:&#32;",
+       "ellipsis": "…",
        "percent": "$1&#160;%",
+       "parentheses": "($1)",
+       "parentheses-start": "(",
+       "parentheses-end": ")",
+       "brackets": "[$1]",
        "quotation-marks": "« $1 »",
        "imgmultipageprev": "← page précédente",
        "imgmultipagenext": "page suivante →",
        "imgmultigo": "Accéder !",
        "imgmultigoto": "Aller à la page $1",
+       "img-lang-opt": "$2 ($1)",
        "img-lang-default": "(langue par défaut)",
        "img-lang-info": "Afficher cette image en $1 $2.",
        "img-lang-go": "Lancer",
        "size-exabytes": "$1 Eio",
        "size-zetabytes": "$1&nbsp;Zio",
        "size-yottabytes": "$1 Yio",
+       "size-pixel": "$1 {{PLURAL:$1|pixel|pixels}}",
        "bitrate-bits": "$1&nbsp;bps",
        "bitrate-kilobits": "$1&nbsp;kbps",
        "bitrate-megabits": "$1&nbsp;Mbps",
        "version-variables": "Variables",
        "version-editors": "Éditeurs",
        "version-antispam": "Prévention du pollupostage",
+       "version-api": "API",
        "version-other": "Divers",
        "version-mediahandlers": "Manipulateurs de médias",
        "version-hooks": "Greffons",
        "limitreport-walltime": "Temps réel d’utilisation",
        "limitreport-walltime-value": "$1 {{PLURAL:$1|seconde|secondes}}",
        "limitreport-ppvisitednodes": "Nombre de nœuds de préprocesseur visités",
+       "limitreport-ppvisitednodes-value": "$1/$2",
        "limitreport-ppgeneratednodes": "Nombre de nœuds de préprocesseur générés",
+       "limitreport-ppgeneratednodes-value": "$1/$2",
        "limitreport-postexpandincludesize": "Taille d’inclusion après expansion",
        "limitreport-postexpandincludesize-value": "$1/$2 {{PLURAL:$2|octet|octets}}",
        "limitreport-templateargumentsize": "Taille de l’argument du modèle",
        "limitreport-templateargumentsize-value": "$1/$2 {{PLURAL:$2|octet|octets}}",
        "limitreport-expansiondepth": "Profondeur d’expansion maximale",
+       "limitreport-expansiondepth-value": "$1/$2",
        "limitreport-expensivefunctioncount": "Nombre de fonctions d’analyse coûteuses",
+       "limitreport-expensivefunctioncount-value": "$1/$2",
        "limitreport-unstrip-depth": "Profondeur de récursion de développement",
        "limitreport-unstrip-depth-value": "$1/$2",
        "limitreport-unstrip-size": "Taille de développement après expansion",
        "mediastatistics-header-text": "Textuel",
        "mediastatistics-header-executable": "Exécutables",
        "mediastatistics-header-archive": "Formats compressés",
+       "mediastatistics-header-3d": "3D",
        "mediastatistics-header-total": "Tous les fichiers",
        "json-warn-trailing-comma": "$1 {{PLURAL:$1|virgule finale a été supprimée|virgules finales ont été supprimées}} du JSON",
        "json-error-unknown": "Il y a eu un problème avec le JSON. Erreur : $1",
        "authmanager-provider-password-domain": "Authentification par mot de passe et domaine",
        "authmanager-provider-temporarypassword": "Mot de passe temporaire",
        "authprovider-confirmlink-message": "D’après vos dernières tentatives de connexion, les comptes suivants peuvent être liés à votre compte wiki. Les lier vous permettra de se connecter via ces comptes. Veuillez sélectionner lesquels doivent être liés.",
+       "authprovider-confirmlink-option": "$1 ($2)",
        "authprovider-confirmlink-request-label": "Comptes qui doivent être liés",
        "authprovider-confirmlink-success-line": "$1 : Liés avec succès.",
        "authprovider-confirmlink-failed-line": "$1 : $2",
        "edit-error-short": "Erreur : $1",
        "edit-error-long": "Erreurs :\n\n$1",
        "specialmute": "Muet",
+       "specialmute-success": "Vos préférences de mise en sourdine on bien été mises à jour. Voyez tous les utilisateurs impliqués dans [[Special:Preferences]].",
        "specialmute-submit": "Confirmer",
-       "specialmute-error-invalid-user": "Le nom d'utilisateur demandé n'a pu être trouvé.",
+       "specialmute-label-mute-email": "Mettre en sourdine les courriels de cet utilisateur",
+       "specialmute-header": "Veuillez sélectionner vos préférences de mise en sourdine pour {{BIDI:[[User:$1]]}}.",
+       "specialmute-error-invalid-user": "Le nom d’utilisateur demandé n’a pu être trouvé.",
+       "specialmute-error-email-blacklist-disabled": "La mise en sourdine des utilisateurs pour vous envoyer des courriels n’est pas activée.",
+       "specialmute-error-email-preferences": "Vous devez confirmer votre adresse courriel avant de pouvoir mettre en sourdine un utilisateur. Vous pouvez le faire depuis [[Special:Preferences]].",
+       "specialmute-email-footer": "Veuillez voir <$1> pour gérer les préférences courriel pour {{BIDI:$2}}.",
+       "specialmute-login-required": "Veuillez vous connecter pour mettre-à-jour vos préférences de mise en sourdine d’utilisateurs.",
        "revid": "version $1",
        "pageid": "ID de page $1",
        "interfaceadmin-info": "$1\n\nLes droits pour modifier les fichiers CSS/JS/JSON globaux au site ont été récemment séparés du droit <code>editinterface</code>. Si vous ne comprenez pas pourquoi vous avez cette erreur, voyez [[mw:MediaWiki_1.32/interface-admin]].",
        "passwordpolicies-summary": "Voici une liste des politiques des mots de passe effectifs pour les groupes d'utilisateurs de ce wiki.",
        "passwordpolicies-group": "Groupe",
        "passwordpolicies-policies": "Politiques",
+       "passwordpolicies-policy-display": "<span class=\"passwordpolicies-policy\">$1 <code>($2)</code></span>",
+       "passwordpolicies-policy-displaywithflags": "<span class=\"passwordpolicies-policy\">$1 <code>($2)</code></span> <span class=\"passwordpolicies-policy-flags\">($3)</span>",
        "passwordpolicies-policy-minimalpasswordlength": "Les mots de passe doivent avoir au moins $1 caractère{{PLURAL:$1||s}} de long",
        "passwordpolicies-policy-minimumpasswordlengthtologin": "Les mots de passe doivent avoir au moins $1 caractère{{PLURAL:$1||s}} de long pour autoriser la connextion",
        "passwordpolicies-policy-passwordcannotmatchusername": "Le mot de passe ne peut pas être le même que le nom d'utilisateur",
index 6cfd81b..2dd9452 100644 (file)
@@ -10,7 +10,8 @@
                        "Macofe",
                        "Matma Rex",
                        "Fitoschido",
-                       "Vlad5250"
+                       "Vlad5250",
+                       "Wladek92"
                ]
        },
        "tog-underline": "Solegnér los lims :",
        "metadata-expand": "Montrar los dètalys de més",
        "metadata-collapse": "Cachiér los dètalys de més",
        "metadata-fields": "Los champs de mètabalyês d’émâge listâs dens cél mèssâjo seront rapondus dedens la pâge de dèscripcion de l’émâge quand la trâbla de mètabalyês serat rèduita.\nLos ôtros champs seront cachiês per dèfôt.\n* make\n* model\n* datetimeoriginal\n* exposuretime\n* fnumber\n* isospeedratings\n* focallength\n* artist\n* copyright\n* imagedescription\n* gpslatitude\n* gpslongitude\n* gpsaltitude",
-       "metadata-langitem": "'''$2 :''' $1",
+       "metadata-langitem": "<strong>$2 :</strong> $1",
        "namespacesall": "Tôs",
        "monthsall": "tôs",
        "confirmemail": "Confirmar l’adrèce èlèctronica",
index 86526a1..5389289 100644 (file)
        "pt-createaccount": "יצירת חשבון",
        "pt-userlogout": "יציאה מהחשבון",
        "php-mail-error-unknown": "שגיאה לא ידועה בפונקציה mail()‎ של PHP.",
-       "user-mail-no-addy": "× ×\99ס×\99×\95×\9f ×\9cש×\9c×\95×\97 ×\93×\95×\90\"×\9c ×\9c×\9c×\90 ×\9bת×\95×\91ת ×\93×\95×\90\"ל.",
+       "user-mail-no-addy": "×\94ת×\91צע × ×\99ס×\99×\95×\9f ×\9cש×\9c×\99×\97ת ×\94×\95×\93×¢×\94 ×\9c×\9c×\90 ×\9bת×\95×\91ת ×\93×\95×\90×´ל.",
        "user-mail-no-body": "ניסיון לשלוח דוא\"ל עם תוכן ריק או קצר מאוד.",
        "changepassword": "שינוי סיסמה",
        "resetpass_announce": "כדי לסיים את הכניסה לחשבון, יש להגדיר סיסמה חדשה.",
        "gender-male": "הוא עורך דפים בוויקי",
        "gender-female": "היא עורכת דפים בוויקי",
        "prefs-help-gender": "לא חובה למלא העדפה זו.\nהמערכת משתמשת במידע הזה כדי לפנות אליך/אלייך ולציין את שם המשתמש שלך במין הדקדוקי הנכון.\nהמידע יהיה ציבורי.",
-       "email": "דוא\"ל",
+       "email": "דוא״ל",
        "prefs-help-realname": "לא חובה למלא את השם האמיתי.\nאם סופק, הוא עשוי לשמש כדי לייחס לך את עבודתך.",
        "prefs-help-email": "כתובת דואר אלקטרוני היא אופציונלית, אבל היא חיונית לאיפוס הסיסמה במקרה ש{{GENDER:|תשכח|תשכחי}} אותה.",
        "prefs-help-email-others": "באפשרותך גם לאפשר למשתמשים ליצור איתך קשר באמצעות דוא\"ל דרך קישור בדף המשתמש או בדף השיחה שלך.\nכתובת הדוא\"ל שלך לא תיחשף כשמשתמשים יצרו איתך קשר.",
        "authmanager-password-help": "הסיסמה לאימות.",
        "authmanager-domain-help": "שם מתחם לאימות חיצוני.",
        "authmanager-retype-help": "חזרה על הסיסמה.",
-       "authmanager-email-label": "דוא\"ל",
+       "authmanager-email-label": "דוא״ל",
        "authmanager-email-help": "כתובת דוא\"ל",
        "authmanager-realname-label": "שם אמיתי",
        "authmanager-realname-help": "השם האמיתי של המשתמש",
        "restrictionsfield-help": "כתובת IP אחת או טווח CIDR אחד בשורה. כדי לאפשר את הכול, ניתן להשתמש ב:<pre>0.0.0.0/0\n::/0</pre>",
        "edit-error-short": "שגיאה: $1",
        "edit-error-long": "שגיאות:\n\n$1",
+       "specialmute": "השתקה",
        "revid": "גרסה $1",
        "pageid": "מזהה דף $1",
        "interfaceadmin-info": "$1\n\nההרשאות לעריכת קובצי CSS/JS/JSON של האתר כולו הופרדו לאחרונה מההרשאה <code>editinterface</code>. אם לא ברור לך מדוע קיבלת את הודעת השגיאה הזאת, ר' [[mw:MediaWiki_1.32/interface-admin]].",
index a6d9c48..3a4ed91 100644 (file)
@@ -41,7 +41,9 @@
                        "Hamster",
                        "BadDog",
                        "Vlad5250",
-                       "Zeljko.filipin"
+                       "Zeljko.filipin",
+                       "Anarhistička Maca",
+                       "Astrind"
                ]
        },
        "tog-underline": "Podcrtavanje poveznica",
        "history": "Povijest stranice",
        "history_short": "Stare izmjene",
        "history_small": "povijest",
-       "updatedmarker": "Obnovljeno od posljednjeg posjeta",
+       "updatedmarker": "obnovljeno od posljednjeg posjeta",
        "printableversion": "Inačica za ispis",
        "permalink": "Trajna poveznica",
        "print": "Ispiši",
        "logentry-pagelang-pagelang": "$1 {{GENDER:$2|promijenio|promijenila}} je jezik stranice $3 iz $4 u $5.",
        "mediastatistics": "Statistika datoteka",
        "mediastatistics-summary": "Slijede statistike postavljenih datoteka koje pokazuju zadnju inačicu datoteke. Starije ili izbrisane inačice nisu prikazane.",
-       "mediastatistics-nfiles": "$1 ($2 %)",
+       "mediastatistics-nfiles": "$1 ($2%)",
        "mediastatistics-nbytes": "{{PLURAL:$1|$1 bajt|$1 bajta|$1 bajtova}} ($2; $3 %)",
        "mediastatistics-bytespertype": "Ukupna veličina datoteka za ovaj odlomak: {{PLURAL:$1|$1 bajt|$1 bajta|$1 bajtova}} ($2; $3%).",
        "mediastatistics-allbytes": "Ukupna veličina svih datoteka: {{PLURAL:$1|$1 bajt|$1 bajta|$1 bajtova}} ($2).",
        "removecredentials-submit": "Ukloni vjerodajnice",
        "credentialsform-provider": "Vrsta vjerodajnica:",
        "credentialsform-account": "Suradnički račun:",
+       "specialmute": "Isključi zvuk",
+       "specialmute-success": "Vaše postavke utišavanja su uspješno ažurirane. Vidite sve utišane korisnike ovdje: [[Special:Preferences]].",
+       "specialmute-submit": "Potvrdi",
+       "specialmute-error-invalid-user": "Korisničko ime koje ste tražili nije moguće pronaći.",
+       "specialmute-error-email-preferences": "Morate potvrditi svoju email adresu prije nego što možete utišati ovoga korisnika. To možete učiniti putem [[Special:Preferences]].",
+       "specialmute-login-required": "Molimo Vas prijavite se da biste promijenili postavke.",
        "gotointerwiki": "Napuštate projekt {{SITENAME}}",
        "gotointerwiki-invalid": "Navedeni naslov nije valjan.",
        "gotointerwiki-external": "Napuštate projekt {{SITENAME}} da biste posjetili zasebno mrežno mjesto [[$2]].\n\n<strong>[$1 Nastavljate na $1]</strong>",
index 2d675bf..9cd104b 100644 (file)
        "history": "Laptörténet",
        "history_short": "Laptörténet",
        "history_small": "laptörténet",
-       "updatedmarker": "az utolsó látogatásom óta frissítették",
+       "updatedmarker": "utolsó látogatásod óta frissítve",
        "printableversion": "Nyomtatható változat",
        "permalink": "Hivatkozás erre a változatra",
        "print": "Nyomtatás",
index 5dec6c7..851afba 100644 (file)
        "listgrouprights-rights": "Derectos",
        "listgrouprights-helppage": "Help:Derectos de gruppos",
        "listgrouprights-members": "(lista de membros)",
-       "listgrouprights-addgroup": "Pote adder {{PLURAL:$2|gruppo|gruppos}}: $1",
-       "listgrouprights-removegroup": "Pote remover {{PLURAL:$2|gruppo|gruppos}}: $1",
+       "listgrouprights-addgroup": "Pote adder membros al {{PLURAL:$2|gruppo|gruppos}}: $1",
+       "listgrouprights-removegroup": "Pote remover membros del {{PLURAL:$2|gruppo|gruppos}}: $1",
        "listgrouprights-addgroup-all": "Pote adder tote le gruppos",
        "listgrouprights-removegroup-all": "Pote eliminar tote le gruppos",
        "listgrouprights-addgroup-self": "Pote adder {{PLURAL:$2|gruppo|gruppos}} al proprie conto: $1",
        "specialmute-error-invalid-user": "Le nomine de usator que tu requestava non pote esser trovate.",
        "specialmute-error-email-blacklist-disabled": "Le silentiamento de usatores pro inviar te e-mail non ha essite activate.",
        "specialmute-error-email-preferences": "Tu debe confirmar tu adresse de e-mail ante de poter silentiar un usator. Face isto in [[Special:Preferences]].",
-       "specialmute-email-footer": "[$1 Gerer preferentias de e-mail pro {{BIDI:$2}}.]",
+       "specialmute-email-footer": "Pro gerer le preferentias de e-mail pro {{BIDI:$2}}, visita <$1>.",
        "specialmute-login-required": "Es necessari aperir session pro cambiar le preferentias de silentio.",
        "revid": "version $1",
        "pageid": "ID de pagina $1",
index 9785ce2..27d9569 100644 (file)
@@ -64,7 +64,8 @@
                        "Bagas Chrisara",
                        "Pebaryan",
                        "Veracious",
-                       "Mnam23"
+                       "Mnam23",
+                       "Shirayuki"
                ]
        },
        "tog-underline": "Garis bawahi pranala:",
        "metadata-expand": "Tampilkan rincian tambahan",
        "metadata-collapse": "Sembunyikan rincian tambahan",
        "metadata-fields": "Bidang metadata gambar yang tercantum dalam pesan ini akan dimasukkan pada tampilan halaman gambar ketika tabel metadata diciutkan.\nData lain akan disembunyikan secara bawaan.\n* make\n* model\n* datetimeoriginal\n* exposuretime\n* fnumber\n* isospeedratings\n* focallength\n* artist\n* copyright\n* imagedescription\n* gpslatitude\n* gpslongitude\n* gpsaltitude",
-       "metadata-langitem": "'''$2:''' $1",
+       "metadata-langitem": "<strong>$2:</strong> $1",
        "metadata-langitem-default": "$1",
        "namespacesall": "semua",
        "monthsall": "semua",
index e27a850..0276645 100644 (file)
@@ -95,7 +95,8 @@
                        "Suyama",
                        "고솜",
                        "Wat",
-                       "Puntti ja"
+                       "Puntti ja",
+                       "マツムシ"
                ]
        },
        "tog-underline": "リンクの下線:",
        "autoblockedtext": "このIPアドレスは、$1によりブロックされた利用者によって使用されたため、自動的にブロックされています。\n理由は次の通りです。\n\n:<em>$2</em>\n\n* ブロック開始日時: $8\n* ブロック解除予定: $6\n* ブロック対象: $7\n\n$1または他の[[{{MediaWiki:Grouppage-sysop}}|管理者]]にこのブロックについて問い合わせることができます。\n\nただし、[[Special:Preferences|個人設定]]に正しいメールアドレスが登録されていない場合、またはメール送信がブロックされている場合、「{{int:emailuser}}」機能を使用できないことに注意してください。\n\n現在ご使用中のIPアドレスは$3 、このブロックIDは#$5です。\nお問い合わせの際は、上記の情報を必ず書いてください。",
        "systemblockedtext": "あなたの利用者名またはIPアドレスはMediaWikiによって自動的にブロックされています。\n理由は次の通りです。\n\n:<em>$2</em>\n\n* ブロック開始日時: $8\n* ブロック解除予定: $6\n* ブロック対象: $7\n\nあなたの現在のIPアドレスは $3 です。\nお問い合わせの際は、上記の詳細情報をすべて含めてください。",
        "blockednoreason": "理由が設定されていません",
+       "blockedtext-composite": "<strong>あなたのアカウントまたはIPアドレスはブロックされています</strong>\n\n理由:\n\n:<em>$2</em>.\n\n* ブロック開始日: $8\n* ブロックの有効期限: $6\n\nあなたの現在のIPアドレスは$3です。\n上記の詳細は,ご質問にお答えください。",
+       "blockedtext-composite-reason": "アカウントまたはIPアドレスに対して複数のブロックが存在します",
        "whitelistedittext": "このページを編集するには$1してください。",
        "confirmedittext": "ページの編集を始める前にメールアドレスの確認をする必要があります。\n[[Special:Preferences|個人設定]]でメールアドレスを設定し、確認を行ってください。",
        "nosuchsectiontitle": "節が見つかりません",
        "restrictionsfield-help": "一行につき、単一の IP アドレス、もしくは CIDR による範囲。全帯域からの接続を許可する場合: <pre>0.0.0.0/0\n::/0</pre>",
        "edit-error-short": "エラー: $1",
        "edit-error-long": "エラー:\n\n\n\n$1",
+       "specialmute": "ミュート",
+       "specialmute-label-mute-email": "この利用者からのウィキメールをミュートする",
+       "specialmute-error-invalid-user": "あなたが要求した利用者名は見つかりませんでした。",
        "revid": "版 $1",
        "pageid": "ページID $1",
        "interfaceadmin-info": "$1\n\nサイト全体のCSS/JavaScriptの編集権限は、最近<code>editinterface</code> 権限から分離されました。なぜこのエラーが表示されたのかわからない場合は、[[mw:MediaWiki_1.32/interface-admin]]をご覧ください。",
index e8c3520..264e0c9 100644 (file)
@@ -31,7 +31,8 @@
                        "OpusDEI",
                        "Fitoschido",
                        "Mehman97",
-                       "Vlad5250"
+                       "Vlad5250",
+                       "Shirayuki"
                ]
        },
        "tog-underline": "ბმულების ხაზგასმა:",
        "metadata-expand": "დამატებითი ინფორმაციის ჩვენება",
        "metadata-collapse": "დამატებითი ინფორმაციის დამალვა",
        "metadata-fields": "მეტამონაცემების ჩამონათვალი ამ შეტყობინებაში დამატებული იქნება სურათის გვერდზე, როცა მეტამონაცემების ცხრილი გახსნილია.\nსხვები უპირობოდ დამალული იქნება.\n* make\n* model\n* datetimeoriginal\n* exposuretime\n* fnumber\n* isospeedratings\n* focallength\n* artist\n* copyright\n* imagedescription\n* gpslatitude\n* gpslongitude\n* gpsaltitude",
-       "metadata-langitem": "'''$2:''' $1",
+       "metadata-langitem": "<strong>$2:</strong> $1",
        "metadata-langitem-default": "$1",
        "namespacesall": "ყველა",
        "monthsall": "ყველა",
index 94249e8..da07dd6 100644 (file)
        "specialmute-error-invalid-user": "요청한 사용자 이름을 찾을 수 없습니다.",
        "specialmute-error-email-blacklist-disabled": "이메일 보내기로부터 사용자 알림 미표시가 활성화되어 있지 않습니다.",
        "specialmute-error-email-preferences": "사용자의 알림을 미표시 처리하기 전에 이메일 주소를 확인해야 합니다. [[Special:Preferences]]에서 이 작업을 할 수 있습니다.",
-       "specialmute-email-footer": "[$1 {{BIDI:$2}}의 이메일 환경 설정을 관리합니다.]",
+       "specialmute-email-footer": "{{BIDI:$2}}의 이메일 환경 설정을 관리하려면 <$1>을(를) 방문해 주십시오.",
        "specialmute-login-required": "알림 미표시 환경 설정을 변경하려면 로그인해 주십시오.",
        "revid": "$1 판",
        "pageid": "페이지 ID $1",
index 9b65424..8a37844 100644 (file)
        "searcharticle": "رۉ",
        "history": "ڤیرگار ھ بألگە",
        "history_short": "ڤیرگار",
-       "updatedmarker": "بروز وابی تا موقع آخرین سیل کردن مو",
+       "updatedmarker": "بهروز وابی تا موقع آخرین سیل کردن مو",
        "printableversion": "ڤیرژین سی چاپ",
        "permalink": "لینکل دائمی",
        "print": "چاپ",
        "logentry-newusers-create": "حسآۉ کارڤأر $1 ڤابیە {{GENDER:$2|راس ڤیدھ }}",
        "logentry-upload-upload": "$1 {{GENDER:$2|بلم گیر کردھ ۉابی}} $3",
        "searchsuggest-search": "جۉستأن",
+       "specialmute": "بی‌صدا",
        "userlogout-continue": "ایخیت برِیِتو وَدَر"
 }
index 640d2ae..1120141 100644 (file)
@@ -25,7 +25,8 @@
                        "Macofe",
                        "राम प्रसाद जोशी",
                        "Fitoschido",
-                       "Haribanshi"
+                       "Haribanshi",
+                       "Shirayuki"
                ]
        },
        "tog-underline": "लिङ्कके रेखाङ्कित करी:",
        "metadata-expand": "बढ़ाओल विवरण देखाउ।",
        "metadata-collapse": "विस्तृत विवरण नुकाउ",
        "metadata-fields": "चित्र प्रदत्तांश क्षेत्र सभ जे ई सन्देशमे सङ्कलित अछि चित्र पन्ना प्रदर्शनमे लेल जाएत जखन प्रदत्तांश सारणी क्षतिग्रस्त हएत।  \nआन सभ पूर्वनिधारित रूपेँ नुका जाएत।\n* make\n* model\n* datetimeoriginal\n* exposuretime\n* fnumber\n* isospeedratings\n* focallength\n* artist\n* copyright\n* imagedescription\n* gpslatitude\n* gpslongitude\n* gpsaltitude",
-       "metadata-langitem": "'''$2:''' $1",
+       "metadata-langitem": "<strong>$2:</strong> $1",
        "metadata-langitem-default": "$1",
        "namespacesall": "सभटा",
        "monthsall": "सभ",
index eb80f11..5609e33 100644 (file)
        "page_first": "прв",
        "page_last": "последен",
        "histlegend": "Разлика помеѓу преработките: Означете ги преработките што сакате да ги споредите и притиснете на Enter или копчето на дното од страницата.<br />\nЛегенда: '''({{int:cur}})''' = разлика со последна преработка, '''({{int:last}})''' = разлика со претходна преработка, '''{{int:minoreditletter}}''' = ситна промена.",
-       "history-fieldset-title": "ФилÑ\82Ñ\80иÑ\80аÑ\98 преработки",
+       "history-fieldset-title": "ФилÑ\82Ñ\80иÑ\80аÑ\9aе Ð½Ð° преработки",
        "history-show-deleted": "Само избришани преработки",
        "histfirst": "најстари",
        "histlast": "најнови",
index 3c8f618..fb5a296 100644 (file)
        "history": "Sidehistorikk",
        "history_short": "Historikk",
        "history_small": "historikk",
-       "updatedmarker": "oppdatert siden mitt forrige besøk",
+       "updatedmarker": "oppdatert siden ditt forrige besøk",
        "printableversion": "Utskriftsvennlig versjon",
        "permalink": "Permanent lenke",
        "print": "Skriv ut",
        "autoblockedtext": "Din IP-adresse har blitt automatisk blokkert fordi den ble brukt av en annen bruker som ble blokkert av $1.\nDen oppgitte grunnen var:\n\n:'''$2'''\n\n* Blokkeringen begynte: $8\n* Blokkeringen utgår: $6\n* Blokkeringen er ment for: $7\n\nDu kan kontakte $1 eller en av de andre [[{{MediaWiki:Grouppage-sysop}}|administratorene]] for å diskutere blokkeringen.\n\nMerk at du ikke kan bruke «{{int:emailuser}}»-funksjonen med mindre du har registrert en gyldig e-postadresse i [[Special:Preferences|innstillingene dine]].\n\nDin IP-adresse er $3, og blokkerings-ID-en er #$5.\nVennligst ta med all denne informasjonen ved henvendelser.",
        "systemblockedtext": "Ditt brukernavn eller IP-adresse har blitt blokkert automatisk av MediaWiki.\n\nBlokkeringen grunnes:\n\n:<em>$2</em>\n\n* Blokkeringen startet: $8\n* Blokkeringen gjelder til: $6\n* Blokkeringen er ment for: $7\n\nDin nåværende IP-adresse er $3.\nVennligst inkluder informasjonen over i alle spørsmål du spør angående dette.",
        "blockednoreason": "ingen grunn gitt",
+       "blockedtext-composite": "<strong>Brukernavnet ditt eller IP-adressa di har blitt blokkert.</strong>\n\nBlokkeringen grunnes:\n\n:<em>$2</em>\n\n* Blokkeringen startet: $8\n* Blokkeringen løper ut: $6\n\nIP-adressa di er $3.\nVennligst inkluder alle detaljene ovenfor i spørsmål du måtte ha angående dette.",
+       "blockedtext-composite-reason": "Det foreligger flere blokkeringer på din konto og/eller IP-adresse",
        "whitelistedittext": "Du må $1 for å redigere artikler.",
        "confirmedittext": "Du må bekrefte e-postadressen din før du kan redigere sider. Vennligst oppgi og bekreft e-postadressen din via [[Special:Preferences|innstillingene dine]].",
        "nosuchsectiontitle": "Finner ikke avsnittet",
        "mw-widgets-abandonedit-discard": "Forkast endringene",
        "mw-widgets-abandonedit-keep": "Fortsett å redigere",
        "mw-widgets-abandonedit-title": "Er du sikker?",
+       "mw-widgets-copytextlayout-copy": "Kopier",
+       "mw-widgets-copytextlayout-copy-fail": "Kunne ikke kopiere til utklippstavlen.",
+       "mw-widgets-copytextlayout-copy-success": "Kopiert til utklippstavlen.",
        "mw-widgets-dateinput-no-date": "Ingen dato valgt",
        "mw-widgets-dateinput-placeholder-day": "ÅÅÅÅ-MM-DD",
        "mw-widgets-dateinput-placeholder-month": "ÅÅÅÅ-MM",
        "restrictionsfield-help": "Én IP-adresse eller CIDR-intervall per linje. For å slå på alt, bruk: <pre>0.0.0.0/0\n::/0</pre>",
        "edit-error-short": "Feil: $1",
        "edit-error-long": "Feil:\n\n$1",
+       "specialmute": "Demp",
+       "specialmute-success": "Dempingsinnstillingene dine har blitt oppdatert. Se alle dempede brukere i [[Special:Preferences|innstillingene]].",
+       "specialmute-submit": "Bekreft",
+       "specialmute-label-mute-email": "Demp eposter fra denne brukeren",
+       "specialmute-header": "Velg dempingsinnstillenger som gjelder {{BIDI:[[User:$1|$1]]}}.",
+       "specialmute-error-invalid-user": "Det forespurte brukernavnet ble ikke funnet.",
+       "specialmute-error-email-blacklist-disabled": "Muligheten for å hindre enkeltbrukere fra å sende deg epost er ikke slått på.",
+       "specialmute-error-email-preferences": "Du må bekrefte epostadressa di før du kan dempe en bruker. Du kan gjøre det fra [[Special:Preferences|innstillingene]].",
+       "specialmute-email-footer": "Besøk <$1> for å behandle epostinnstillingene som gjelder {{BIDI:$2}}.",
+       "specialmute-login-required": "Logg inn for å endre dempingsinnstillingene dine.",
        "revid": "revisjon $1",
        "pageid": "side-ID $1",
        "interfaceadmin-info": "$1\n\nTillatelse til å redigere CSS, JavaScript og JSON som gjelder hele nettstedet ble nylig utskilt til rettigheten <code>editinterface</code>. Om du ikke forstår hvorfor du får denne feilmeldingen, se [[mw:MediaWiki_1.32/interface-admin]].",
        "passwordpolicies-policyflag-suggestchangeonlogin": "foreslå endring ved innlogging",
        "easydeflate-invaliddeflate": "Det gitte innholdet er ikke riktig komprimert",
        "unprotected-js": "Av sikkerhetsårsaker kan ikke JavaScript lastes fra ubeskyttede sider. Bare skap JavaScript i MediaWiki-navnerommet eller som en brukerunderside",
-       "userlogout-continue": "Hvis du ønsker å logge ut, [$1 fortsett til utloggingssiden]."
+       "userlogout-continue": "Ønsker du å logge ut?"
 }
index 8d3c9be..23daede 100644 (file)
        "specialmute-error-invalid-user": "De ingevoerde gebruikersnaam kon niet worden gevonden.",
        "specialmute-error-email-blacklist-disabled": "Het negeren van e-mails verstuurd door andere gebruikers is niet ingeschakeld.",
        "specialmute-error-email-preferences": "U moet uw e-mailadres bevestigen voordat u een gebruiker kunt negeren. U kunt dit doen in [[Special:Preferences|uw voorkeuren]].",
-       "specialmute-email-footer": "[$1 E-mail voorkeuren beheren voor {{BIDI:$2}}.]",
+       "specialmute-email-footer": "Om uw e-mailvoorkeuren voor {{BIDI:$2}} te beheren gaat u naar <$1>.",
        "specialmute-login-required": "U moet aanmelden om voorkeuren voor het negeren van gebruikers in te stellen.",
        "revid": "versie $1",
        "pageid": "Pagina-ID $1",
index 3dad188..9f70b67 100644 (file)
        "template-protected": "(ߊ߬ ߡߊߞߊ߲ߞߊ߲ߣߍ߲߫ ߠߋ߬)",
        "template-semiprotected": "(ߟߊ߬ߞߊ߲߬ߘߊ߬ߟߌ-ߝߊ߲߬ߞߋ߬ߟߋ߲߬ߡߊ)",
        "hiddencategories": "ߞߐߜߍ ߣߌ߲߬ ߦߋ߫ ߢߌ߲߬ ߠߎ߫ ߛߌ߲߬ߝߏ߲ ߠߋ߬ ߘߌ߫{{PLURAL:$1|}}",
+       "nocreate-loggedin": "ߞߐߜߍ߫ ߞߎߘߊ߫ ߛߌ߲ߘߌ߫ ߞߏ ߟߊߘߌ߬ߢߍ߬ߣߍ߲߬ ߕߴߌ ߦߋ߫.",
        "sectioneditnotsupported-text": "ߛߌ߰ߘߊ ߡߊߦߟߍ߬ߡߊ߲߬ߠߌ߲ ߠߊߘߤߊ߬ߣߍ߲߬ ߕߍ߫ ߞߐߜߍ ߣߌ߲߬ ߠߊ߫ ߕߊ߲߬.",
        "permissionserrors": "ߝߌ߬ߟߌ߫ ߘߌ߬ߢߍ߬ߒߧߋ",
        "permissionserrorstext": "ߌ ߟߊߘߌ߬ߢߍ߬ߣߍ߲߬ ߕߍ߫ ߞߵߏ߬ ߞߍ߫߸ ߣߌ߲߬ ߠߊ߫ {{PLURAL:$1|ߛߊߓߎ|ߛߊߓߎ ߟߎ߬}}:",
        "rcfilters-savedqueries-already-saved": "ߛߍ߲ߛߍ߲ߟߊ߲ ߣߌ߲߬ ߓߘߊ߫ ߓߊ߲߫ ߠߊߞߎ߲߬ߘߎ߬ ߟߊ߫.ߌ ߟߊ߫ ߟߊ߬ߓߍ߲߬ߢߐ߲߰ߡߊ ߡߊߝߊ߬ߟߋ߲߬ ߞߊ߬ ߛߍ߲ߛߍ߲ߟߊ߲߫ ߟߊߞߎ߲߬ߘߎ߬ߣߍ߲ ߘߏ߫ ߛߌ߲ߘߌ߫.",
        "rcfilters-clear-all-filters": "ߛߍ߲ߛߍ߲ߟߊ߲ ߓߍ߯ ߛߊߣߌ߲ߧߊ߫",
        "rcfilters-show-new-changes": "ߡߊ߬ߦߟߍ߬ߡߊ߲߬ߠߌ߲߬ ߞߎߘߊ ߟߎ߬ ߦߋ߫ ߞߊ߬ߦߌ߯ $1",
+       "rcfilters-invalid-filter": "ߛߍ߲ߛߍ߲ߟߊ߲ ߓߍ߲߬ߓߊߟߌ",
+       "rcfilters-filterlist-title": "ߛߍ߲ߛߍ߲ߟߊ߲",
        "rcfilters-filterlist-whatsthis": "ߣߌ߲߬ ߦߋ߫ ߓߊ߯ߙߊ߫ ߟߊ߫ ߘߌ߬؟",
+       "rcfilters-filterlist-feedbacklink": "ߌ ߤߊߞߟߌߣߊ߲ ߝߐ߫ ߊ߲ ߧߋ߫ ߞߊ߬ ߓߍ߲߬ ߛߍ߲ߛߍ߲ߟߊ߲ ߖߐ߯ߙߊ߲ ߠߊ߫ ߞߏ ߡߊ߬.",
        "rcfilters-highlightbutton-title": "ߞߐߝߟߌ߫ ߡߊߦߋߙߋ߲ߣߍ߲ ߠߎ߬",
        "rcfilters-highlightmenu-title": "ߞߐ߬ߟߐ ߘߏ߫ ߓߊߓߌ߬ߟߊ߬",
        "rcfilters-filter-editsbyself-label": "ߡߍ߲ ߠߎ߬ ߡߊߦߟߍ߬ߡߊ߲߬ߣߍ߲߬ ߌ ߓߟߏ߫",
        "rcfilters-filter-user-experience-level-unregistered-label": "ߕߐ߯ߛߓߍߓߊߟߌ",
        "rcfilters-filter-user-experience-level-unregistered-description": "ߡߊ߬ߦߟߍ߬ߡߊ߲߬ߠߊ ߡߍ߲ ߜߊ߲߬ߞߎ߲߬ߣߍ߲߬ ߕߍ߫.",
        "rcfilters-filter-user-experience-level-learner-label": "ߞߊ߬ߙߊ߲߬ߠߊ ߟߎ߬",
+       "rcfilters-filter-user-experience-level-experienced-description": "ߟߊ߬ߓߊ߰ߙߊ߬ߟߊ߬ ߕߐ߯ߛߓߍߣߍ߲ ߡߍ߲ ߠߊ߫ ߡߊ߬ߦߟߍ߬ߡߊ߲߬ߠߌ߲ ߓߘߊ߫ ߕߊ߬ߡߌ߲߬ ߅߀߀ ߞߊ߲߬ ߕߟߋ߬ ߃߀ ߓߊ߯ߙߊ߫ ߣߐ.",
        "rcfilters-filter-bots-label": "ߓߏߕ",
        "rcfilters-filter-bots-description": "ߡߊ߬ߦߟߍ߬ߡߊ߲߬ߠߌ߲ ߡߍ߲ ߠߎ߬ ߛߌ߲ߘߌߣߍ߲߫ ߞߍߒߖߘߍߦߋ߫ ߖߐ߯ߙߊ߲ ߠߎ߬ ߘߐ߫.",
        "rcfilters-filter-humans-label": "ߡߐ߱ (ߓߏߕ  ߕߍ߫)",
        "rcfilters-filter-newpages-label": "ߞߐߜߍ ߛߌ߲ߘߟߌ",
        "rcfilters-filter-newpages-description": "ߡߊ߬ߦߟߍ߬ߡߊ߲߬ߠߌ߲ ߡߍ߲ ߠߎ߬ ߦߋ߫ ߞߐߜߍ߫ ߞߎߘߊ߫ ߟߊߘߊ߲߫ ߠߊ߫.",
        "rcfilters-filter-categorization-label": "ߦߌߟߡߊ߫ ߡߊߦߟߍߡߊ߲",
+       "rcfilters-filtergroup-lastrevision": "ߡߊ߬ߛߊ߬ߦߌ߲߬ߠߌ߲ ߕߊ߬ߡߌ߲߬ߣߍ߲",
+       "rcfilters-filter-lastrevision-label": "ߡߊ߬ߛߊ߬ߦߌ߲߬ߠߌ߲ ߕߊ߬ߡߌ߲߬ߣߍ߲",
+       "rcfilters-filter-lastrevision-description": "ߡߊ߬ߦߟߍ߬ߡߊ߲߬ߠߌ߲߬ ߞߎ߲ߓߊ ߟߎ߬ ߘߐߙߐ߲߫ ߦߋ߫ ߞߍ߫ ߞߐߜߍ ߘߐ߫.",
+       "rcfilters-filter-previousrevision-label": "ߡߊ߬ߦߟߍ߬ߡߊ߲߬ߠߌ߲߬ ߞߐ߯ߟߕߊ ߝߋ߲߫ ߕߍ߫",
+       "rcfilters-filter-previousrevision-description": "ߡߊ߬ߦߟߍ߬ߡߊ߲߬ߠߌ߲ ߠߎ߬ ߓߍ߯ ߡߍ߲ ߠߎ߬ ߕߍ߫ \"ߟߢߊ߬ߟߌ߬ ߞߐ߯ߟߕߊ߫\" ߘߌ߫.",
+       "rcfilters-filter-excluded": "ߊ߬ ߓߘߊ߫ ߟߊߘߏ߲߬ ߊ߬ ߘߐ߫",
+       "rcfilters-tag-prefix-namespace-inverted": "<strong>:ߍ߲߬ߍ߲߫</strong> $1",
        "rcfilters-target-page-placeholder": "ߞߐߜߍ ߕߐ߮ ߟߊߘߏ߲߬ (ߥߟߊ߫ ߦߌߟߡߊ)",
        "rcnotefrom": "ߘߎ߰ߟߊ ߘߐ߫ {{PLURAL:$5|is the change|are the changes}} ߞߊ߬ߦߌ߯ <strong>$3, $4</strong> (up to <strong>$1</strong> shown).",
        "rclistfromreset": "ߞߐߜߍ ߓߊߕߐߡߐ߲ߠߌ߲ ߡߊߦߟߍ߬ߡߊ߲߫",
        "reuploaddesc": "ߟߊ߬ߦߟߍ߬ߟߌ ߘߐߛߊ߬ ߊ߬ ߣߌ߫ ߞߵߌ ߞߐߛߊ߬ߦߌ߬ ߟߊ߬ߦߟߍ߬ߟߌ ߖߙߎߡߎ߲ ߘߐ߫",
        "uploadnologin": "ߌ ߜߊ߲߬ߞߎ߲߬ߣߍ߲߬ ߕߍ߫",
        "uploadnologintext": "ߖߊ߰ߣߌ߲߫ $1 ߞߊ߬ ߞߐߕߐ߮ ߟߎ߬ ߟߊߦߟߍ߬.",
+       "uploaderror": "ߟߊ߬ߦߟߍ߬ߟߌ ߝߎ߬ߕߎ߲߬ߕߌ",
+       "upload-recreate-warning": "<strong>ߖߊ߬ߛߙߋ߬ߡߊ߬ߟߊ: ߞߐߕߐ߮ ߡߍ߲ ߕߘߍ߬ ߦߋ߫ ߕߐ߮ ߏ߬ ߟߊ߫߸ ߏ߬ ߓߘߊ߫ ߖߏ߬ߛߌ߬ ߥߟߊ߫ ߞߵߊ߬ ߛߋ߲߬ߓߐ߫.</strong>\n\nߞߐߜߍ ߣߌ߲߬ ߖߏ߰ߛߌ߬ߟߌ ߣߴߊ߬ ߛߋ߲߬ߓߐ߬ߟߌ ߟߎ߬ ߡߊߛߐߣߍ߲߫ ߦߋ߫ ߦߊ߲߬ ߟߊ߬ߘߐ߰ߦߊ߬ߟߌ ߟߋ߬ ߞߏߛߐ߲߬:",
+       "uploadtext": "ߘߎ߰ߟߊ߬ߘߐ߫ ߖߙߎߡߎ߲ ߣߌ߲߬ ߠߊߓߊ߯ߙߊ߫ ߞߊ߬ ߞߐߕߐ߮ ߟߎ߬ ߟߊߦߟߍ߬.\nߖߐ߲߬ߛߊ߫ ߞߐߕߐ߯ ߟߊߦߟߍ߬ߣߍ߲߬ ߞߎߘߊ ߟߎ߬ ߦߋ߫ ߥߟߊ߫ ߞߵߊ߬ ߢߌߣߌ߲߫߸ ߕߊ߯ ߓߐ߫  [[Special:FileList|list of uploaded files]]߸ ߞߐߕߐ߯ ߟߊߛߊ߬ߦߌ߲߬ߣߍ߲ ߠߎ߬ ߝߣߊ߫ ߟߊߦߟߍ߬ߣߍ߲߬ ߦߋ߫ [[Special:Log/upload|upload log]] ߘߐ߫߸ ߖߏ߰ߛߌ߬ߟߌ ߦߋ߫ [[Special:Log/delete|deletion log]] ߟߋ߬ ߘߐ߫.\n\nߖߐ߲߬ߛߊ߫ ߞߊ߬ ߞߐߕߐ߮ ߟߊߘߏ߲߬ ߞߐߜߍ ߘߏ߫ ߘߐ߫߸ ߛߘߌ߬ߜߋ߲ ߖߙߎߡߎ߲ ߢߌ߲߬ ߠߎ߬ ߘߏ߫ ߟߊߓߊ߯ߙߊ߫: \n* <strong><code><nowiki>[[</nowiki>{{ns:file}}<nowiki>:File.jpg]]</nowiki></code></strong> ߖߐ߲߬ߛߊ߫ ߌ ߘߌ߫ ߞߐߕߐ߮ ߦߌߟߡߊ ߘߝߊߣߍ߲ ߠߊߓߊ߯ߙߊ߫.\n* <strong><code><nowiki>[[</nowiki>{{ns:file}}<nowiki>:File.png|200px|thumb|left|alt text]]</nowiki></code></strong> ߖߐ߲߬ߛߊ߫ ߌ ߘߌ߫ ߖߌ߬ߦߊ߬ߘߊ߲ߕߊ ߂߀߀ ߞߣߍ ߦߟߍ߬ߡߊ߲߬ߠߌ߲ ߞߏ߲߬ߘߏ߬ ߞߋߟߋ߲߫ ߘߐ߫ ߣߎߡߊ߲߫ ߝߍ߫ ߓߌߟߊߢߐ߲߮ߡߊ ߘߐ߫߸ alt ߛߓߍߟߌ ߘߌ߫ ߞߊ߲߬ߛߓߍߟߌ ߘߐ߫. \n* <strong><code><nowiki>[[</nowiki>{{ns:media}}<nowiki>:File.ogg]]</nowiki></code></strong> ߛߘߌ߬ߜߋ߲ ߞߎ߲߬ߕߋ߬ߟߋ߲߬ߡߊ ߟߥߊ ߞߐߕߐ߯ ߘߐ߫ ߞߵߊ߬ ߕߘߍ߬ ߞߐߕߐ߮ ߡߊ߫ ߦߋ߫.",
+       "upload-permitted": "ߞߐߕߐ߯ ߟߊߘߌ߬ߢߍ߬ߣߍ߲ {{PLURAL:$2|ߛߎ߮ߦߊ|ߛߎ߮ߦߊ ߟߎ߬}}: $1.",
+       "upload-preferred": "ߞߐߕߐ߯ ߝߌ߬ߛߊ߬ߡߊ߲߬ߕߋ {{PLURAL:$2|ߛߎ߮ߦߊ|ߛߎ߯ߦߊ ߟߎ߬}}: $1.",
+       "upload-prohibited": "ߞߐߕߐ߯ ߟߊߕߐ߲ߣߍ߲ {{PLURAL:$2|ߛߎ߮ߦߊ|ߛߎ߮ߦߊ ߟߎ߬}}: $1.",
        "uploadlogpage": "ߜߊ߲߬ߞߎ߲߬ߠߌ߲ ߘߏ߫ ߟߊߦߟߍ߬",
+       "uploadlogpagetext": "ߘߎ߰ߟߊ߬߬ߘߐ߬ߟߊ ߣߌ߲߬ ߦߋ߫ ߞߐߕߐ߯ ߢߊ߬ߕߣߐ߬ߡߊ߬ ߟߊߦߟߍ߬ߣߍ߲߬ ߞߎߘߊ ߟߎ߬ ߛߙߍߘߍ ߟߋ߬ ߘߌ߫.\nߣߌ߲߬ ߦߋ߫ [[Special:NewFiles|gallery of new files]] ߦߋߢߐ߲߯ߝߍ߫ ߦߋߟߌ߫ ߜߘߍ߫ ߞߏ ߘߐ߫.",
        "filename": "ߞߐߕߐ߮ ߕߐ߮",
        "filedesc": "ߟߊߘߛߏߣߍ߲",
        "fileuploadsummary": "ߟߊ߬ߘߛߏ߬ߟߌ:",
        "filereuploadsummary": "ߞߐߕߐ߮ ߡߊߦߟߍ߬ߡߊ߲:",
+       "filestatus": "ߓߊߦߟߍߡߊ߲ߠߌ߲ ߤߊߞߍ ߟߌ߬ߤߟߊ:",
        "filesource": "ߛߎ߲:",
+       "ignorewarning": "ߖߊ߬ߛߙߋ߬ߡߊ߬ߟߊ ߡߊߓߌ߬ߟߊ߬ ߞߊ߬ ߞߐߕߐ߮ ߟߊߞߎ߲߬ߘߎ߬ ߢߊ ߓߍ߯ ߡߊ߬.",
+       "ignorewarnings": "ߖߊ߬ߛߙߋ߬ߡߊ߬ߟߊ ߓߍ߯ ߡߊߓߌ߬ߟߊ߬",
+       "minlength1": "ߞߐߕߐ߮ ߕߐ߮ ߞߊߞߊ߲߫ ߞߊ߬ ߞߍ߫ ߞߟߏߘߋ߲߫ ߞߋߟߋ߲ ߛߊ߲ߘߐ߫.",
+       "illegalfilename": "ߞߟߏ ߘߏ߫ ߦߋ߫ ߞߐߕߐ߮ ߕߐ߮  \"$1\" ߘߐ߫ ߡߍ߲ ߠߊߘߤߊ߬ߣߍ߲߬ ߕߍ߫ ߞߐߜߍ ߞߎ߲߬ߕߐ߰ ߞߏ ߘߐ߫. \nߕߐ߯ ߜߘߍ߫ ߟߊ߫ ߞߐߕߐ߮ ߟߊ߫ ߖߊ߰ߣߌ߲߬ ߞߣߊ߬ ߕߴߊ߬ ߟߊߦߟߍ߬ߟߌ ߡߊߝߍߣߍ߲߫ ߠߊ߫ ߕߎ߲߯.",
+       "filename-toolong": "ߞߐߕߐ߮ ߕߐ߮ ߡߊ߲ߞߊ߲߫ ߞߊ߬ ߕߊ߬ߡߌ߲߬ ߝߙߐ߬ߢߐ ߂߀߀ ߞߊ߲߬.",
+       "badfilename": "ߞߐߕߐ߮ ߕߐ߮ ߓߘߊ߫ ߦߟߍ߬ߡߊ߲߫ ߞߵߊ߬ ߞߍ߫ \"$1\" ߘߌ߫",
        "empty-file": "ߌ ߣߊ߬ ߞߐߕߐ߮ ߡߍ߲ ߞߙߊߓߊ߫ ߟߊ߫߸ ߊ߬ ߘߐߞߏߟߏ߲ ߠߋ߬ ߕߘߍ߬.",
        "file-too-large": "ߌ ߟߊ߫ ߞߐߕߐ߮ ߞߙߊߓߊߣߍ߲ ߓߏ߲߬ߓߊ߫ ߕߘߍ߬ ߞߏߖߎ߰߹",
        "filename-tooshort": "ߞߐߕߐ߮ ߕߐ߮ ߛߘߎ߬ߡߊ߲߬ ߞߏߖߎ߰.",
        "verification-error": "ߞߐߕߐ߮ ߣߌ߲߬ ߡߊ߫ ߕߊ߬ߡߌ߲߬ ߞߐߕߐ߮ ߝߛߍ߬ߝߛߍ߬ ߦߌߟߊ.",
        "hookaborted": "ߌ ߕߘߍ߬ ߦߋ߫ ߡߊ߬ߦߟߍ߬ߡߊ߲߬ߠߌ߲ ߡߍ߲ ߞߍ߫ ߞߏ ߘߐ߫߸ ߊ߬ ߘߐߛߊ߬ߣߍ߲߬ ߦߋ߫ ߘߐ߬ߥߙߊ߬ߟߌ ߟߋ߬ ߓߟߏ߫.",
        "illegal-filename": "ߞߐߕߐ߮ ߕߐ߮ ߟߊߘߌ߬ߢߍ߬ߣߍ߲߬ ߕߍ߫.",
+       "unknown-error": "ߝߎ߬ߕߎ߲߬ߕߌ߬ ߡߊߟߐ߲ߓߊߟߌ ߘߏ߫ ߓߘߊ߫ ߓߌ߬ߟߵߊ߬ ߘߐ߫.",
+       "tmp-create-error": "ߊ߬ ߕߍ߫ ߣߊ߬ ߥߊ߯ߕߌ߫ ߟߊߕߊߡߌ߲߫ ߞߐߕߐ߮ ߛߌ߲ߘߌ߫ ߟߊ߫.",
        "uploadwarning": "ߟߊ߬ߦߟߍ߬ߟߌ ߖߊ߬ߛߙߋ߬ߡߊ߬ߟߊ",
        "uploadwarning-text": "ߞߐߕߐ߮ ߘߎ߰ߟߊ߬ߘߐ߫ ߞߊ߲ߛߓߍߟߌ ߡߊ߬ߦߟߍ߬ߡߊ߲߫ ߖߊ߰ߣߌ߲߬߸ ߞߵߊ߬ ߡߊߝߍߣߍ߲߫ ߕߎ߲߯.",
        "savefile": "ߞߐߕߐ߮ ߟߊߞߎ߲߬ߘߎ߬",
        "upload-form-label-own-work-message-generic-local": "ߒ ߧߴߊ߬ ߟߊߛߙߋߦߊ߫ ߟߊ߫ ߞߏ߫ ߒ ߧߋ߫ ߞߐߕߐ߮ ߣߌ߲߬ ߠߊߦߟߍ߬ ߞߊ߲߬ ߞߊ߬ ߓߍ߲߬ ߗߋߘߊ ߛߙߊߕߌ ߣߌ߫ ߕߌ߰ߦߊ ߤߊߞߍ ߡߊ߬ {{SITENAME}} ߞߊ߲߬",
        "backend-fail-delete": "ߞߐߕߐ߮ ߕߴߛߋ߫ ߖߏ߰ߛߌ߬ ߟߊ߫  \"$1\".",
        "backend-fail-describe": "ߡߋߕߊߘߕߊ ߞߐߕߐ߮ ߕߴߛߋ߫ ߡߊߦߟߍ߬ߡߊ߲߫ ߠߊ߫  \"$1\".",
+       "backend-fail-alreadyexists": "ߞߐߕߐ߮  \"$1\" ߦߋ߫ ߦߋ߲߬ ߞߘߐ߬ߡߊ߲߬.",
        "backend-fail-store": "ߞߐߕߐ߮  \"$1\" ߕߍ߫ ߛߐ߲߬ ߟߊߡߙߊ߬ ߟߊ߫ ߦߊ߲߬  \"$2\"",
        "backend-fail-copy": "ߊ߬ ߕߍ߫ ߣߊ߬ ߛߐ߲߬ ߠߊ߫ ߞߐߕߐ߮  \"$1\" ߓߊߦߟߍ߬ߡߊ߲߬ ߠߊ߫ ߦߊ߲߬  \"$2\".",
+       "backend-fail-move": "ߊ߬ ߕߍ߫ ߣߊ߬ ߛߐ߲߬ ߠߊ߫ ߞߐߕߐ߮  \"$1\" ߓߊߦߟߍ߬ߡߊ߲߬ ߠߊ߫ ߦߊ߲߬  \"$2\".",
+       "backend-fail-opentemp": "ߊ߬ ߕߍ߫ ߣߊ߬ ߥߊ߯ߕߌ߫ ߟߊߕߊߡߌ߲߫ ߞߐߕߐ߮ ߛߌ߲ߘߌ߫ ߟߊ߫.",
+       "backend-fail-writetemp": "ߊ߬ ߕߍ߫ ߣߊ߬ ߥߊ߯ߕߌ߫ ߟߊߕߊߡߌ߲߫ ߞߐߕߐ߮ ߛߓߍ߫ ߟߊ߫.",
+       "backend-fail-closetemp": "ߊ߬ ߕߍ߫ ߣߊ߬ ߥߊ߯ߕߌ߫ ߟߊߕߊߡߌ߲߫ ߞߐߕߐ߮ ߘߊߕߎ߲߯ ߠߊ߫.",
+       "backend-fail-read": "ߞߐߕߐ߮ ߕߴߛߋ߫ ߘߐߞߊ߬ߙߊ߲߬ ߠߊ߫   \"$1\".",
+       "backend-fail-create": "ߊ߬ ߕߍ߫ ߣߊ߬ ߛߐ߲߬ ߠߊ߫ ߞߐߕߐ߮  \"$1\" ߛߓߍ߫ ߟߊ߫.",
+       "backend-fail-maxsize": "ߊ߫ ߕߍ߫ ߣߊ߬ ߞߐߕߐ߮  \"$1\" ߛߓߍ߫ ߟߊ߫߸ ߓߊߏ߬ ߊ߬ ߓߏ߲߬ߓߊ߫ ߞߊ߬ ߕߊ߬ߡߌ߲߬ {{PLURAL:$2|ߝߙߐ߬ߢߐ߬ ߞߋߟߋ߲߫|ߝߙߐ߬ߢߐ ߟߎ߬ $2}}.",
        "img-auth-nofile": "ߞߐߕߐ߮  \"$1\" ߕߍ߫ ߦߋ߲߬.",
        "http-request-error": "HTTP ߡߊ߬ߢߌ߬ߣߌ߲߬ߠߌ߲ ߓߘߊ߫ ߗߌߙߏ߲߫ ߝߎ߬ߕߎ߲߬ߕߌ߬ ߡߊߟߐ߲ߓߊߟߌ ߘߏ߫ ߞߏߛߐ߲߬.",
        "http-read-error": "HTTP ߘߐ߬ߞߊ߬ߙߊ߲߬ߠߌ߲ ߝߎ߬ߕߎ߲߬ߕߌ.",
        "http-bad-status": "ߝߙߋߞߋ ߕߘߍ߬ ߦߋ߫ ߦߋ߲߬ HTTP ߡߊߢߌߣߌ߲ߠߌ߲: $1 $2 ߘߐ߫",
        "http-internal-error": "HTTP ߞߣߐߟߊ ߘߐ߫ ߝߎߕߎ߲ߕߌ.",
        "upload-curl-error6": "ߌ ߕߍ߫ ߣߊ߬ URL ߡߊߛߐ߬ߘߐ߲߬ ߠߊ߫",
+       "upload-curl-error28": "ߟߊ߬ߦߟߍ߬ߟߌ ߕߎ߬ߡߊ ߓߘߊ߫ ߕߊ߬ߡߌ߲߬",
        "license": "ߟߊ߬ߘߌ߬ߢߍ߬ߟߌ ߦߴߌ ߘߐ߫:",
        "license-header": "ߟߊ߬ߘߌ߬ߢߍ߬ߟߌ ߦߴߌ ߘߐ߫",
+       "nolicense": "ߊ߬ ߡߊ߫ ߓߊߕߐ߬ߡߐ߲߬",
+       "listfiles-delete": "ߊ߬ ߖߏ߬ߛߌ߬",
        "imgfile": "ߞߐߕߐ߮",
        "listfiles": "ߞߐߕߐ߮ ߛߙߍߘߍ",
+       "listfiles_thumb": "ߞߝߊ߬ߟߋ߲ߛߋ߲",
+       "listfiles_date": "ߕߎ߬ߡߊ߬ߘߊ",
+       "listfiles_name": "ߕߐ߮",
+       "listfiles_user": "ߟߊ߬ߓߊ߰ߙߊ߬ߟߊ",
+       "listfiles_size": "ߢߊ߲ߞߊ߲",
+       "listfiles_description": "ߞߊ߲߬ߛߓߍߟߌ",
+       "listfiles_count": "ߦߌߟߡߊ",
+       "listfiles-latestversion-yes": "ߐ߲߬ߐ߲߬ߐ߲߫",
+       "listfiles-latestversion-no": "ߊ߬ߦߌ߫",
        "file-anchor-link": "ߞߐߕߐ߮",
        "filehist": "ߞߐߕߐ߮ ߟߊ߫ ߘߐ߬ߝߐ",
        "filehist-help": "ߕߎ߬ߡߊ߬ߘߊ/ߕߎ߬ߡߊ ߛߐ߲߬ߞߌ߲߬ ߓߊ߫߸ ߞߊ߬ ߕߎ߬ߡߊ߬ߘߊ ߞߐߕߐ߮ ߟߎ߬ ߦߋ߫.",
+       "filehist-deleteall": "ߊ߬ ߓߍ߯ ߖߏ߰ߛߌ߬",
+       "filehist-deleteone": "ߊ߬ ߖߏ߬ߛߌ߬",
        "filehist-revert": "ߊ߬ ߟߊߢߊ߬",
        "filehist-current": "ߞߍߛߊ߲ߞߏ",
        "filehist-datetime": "ߕߎ߬ߡߊ߬ߘߊ/ߕߎ߬ߡߊ߬ߟߊ߲",
        "filehist-nothumb": "ߖߌ߬ߦߊ߬ ߘߐ߯ߡߊ߲߫ ߕߴߦߋ߲߬",
        "filehist-user": "ߟߊ߬ߓߊ߰ߙߊ߬ߟߊ",
        "filehist-dimensions": "ߛߎߡߊ߲ߘߐ",
+       "filehist-filesize": "ߞߐߕߐ߮ ߢߊ߲ߞߊ߲",
        "filehist-comment": "ߞߊ߲߬ߝߐߟߌ",
        "imagelinks": "ߞߐߕߐ߮ ߟߊߓߊ߯ߙߊߟߌ",
        "linkstoimage": "ߞߐߕߐ߮ ߣߌ߲߬ {{PLURAL:$1|ߞߐߜߍ ߟߎ߬|$1 ߞߐߜߍ ߟߎ߬}}:",
index 6cac408..9c1de7e 100644 (file)
        "specialmute-error-invalid-user": "Pożądana nazwa użytkownika nie została odnaleziona.",
        "specialmute-error-email-blacklist-disabled": "Ignorowanie e-maili od użytkowników nie jest włączone.",
        "specialmute-error-email-preferences": "Musisz potwierdzić swój adres e-mail zanim będziesz {{GENDER:|mógł|mogła}} ignorować użytkownika. Możesz to zrobić w [[Special:Preferences|preferencjach]].",
-       "specialmute-email-footer": "[$1 Zarządzaj preferencjami ignorowania dla {{BIDI:$2}}.]",
+       "specialmute-email-footer": "Aby zarządzać preferencjami ignorowania dla {{BIDI:$2}} odwiedź <$1>.",
        "specialmute-login-required": "Zaloguj się, aby zmienić swoje preferencje wyignorowania.",
        "revid": "wersja $1",
        "pageid": "ID strony: $1",
index 175e0b4..639063b 100644 (file)
        "specialmute-error-invalid-user": "O nome de usuário solicitado não foi encontrado.",
        "specialmute-error-email-blacklist-disabled": "O silenciamento de usuários do envio de e-mails não está ativado.",
        "specialmute-error-email-preferences": "Você deve confirmar seu endereço de e-mail antes de poder silenciar um usuário. Você pode fazer isso de [[Special:Preferences]].",
-       "specialmute-email-footer": "[$1 Gerenciar preferências de email para {{BIDI:$2}}.]",
+       "specialmute-email-footer": "Para gerenciar as preferências de e-mail para {{BIDI:$2}} por favor visite <$1>.",
        "specialmute-login-required": "Por favor, entre para alterar suas preferências de mudo.",
        "revid": "revisão $1",
        "pageid": "ID da página $1",
index 63ff375..a300f02 100644 (file)
        "listgrouprights-members": "Used on [[Special:ListGroupRights]] and [[Special:Statistics]] as a link to [[Special:ListUsers|Special:ListUsers/\"group\"]], a list of members in that group.",
        "listgrouprights-right-display": "{{optional}}\nParameters:\n* $1 - the text from the \"right-...\" messages, i.e. {{msg-mw|Right-edit}}\n* $2 - the codename of this right",
        "listgrouprights-right-revoked": "{{optional}}\nParameters:\n* $1 - the text from the \"right-...\" messages, i.e. {{msg-mw|Right-edit}}\n* $2 - the codename of this right",
-       "listgrouprights-addgroup": "This is an individual right for groups, used on [[Special:ListGroupRights]].\n* $1 - an enumeration of group names\n* $2 - the number of group names in $1\nSee also:\n* {{msg-mw|listgrouprights-removegroup}}\n{{Related|Listgrouprights}}",
+       "listgrouprights-addgroup": "This is the individual right to add users to groups, used on [[Special:ListGroupRights]].\n* $1 - an enumeration of group names\n* $2 - the number of group names in $1\nSee also:\n* {{msg-mw|listgrouprights-removegroup}}\n{{Related|Listgrouprights}}",
        "listgrouprights-removegroup": "This is an individual right for groups, used on [[Special:ListGroupRights]].\n* $1 - an enumeration of group names\n* $2 - the number of group names in $1\nSee also:\n* {{msg-mw|listgrouprights-addgroup}}",
        "listgrouprights-addgroup-all": "Used on [[Special:ListGroupRights]].\n{{Related|Listgrouprights}}",
        "listgrouprights-removegroup-all": "Used on [[Special:ListGroupRights]].\n{{Related|Listgrouprights}}",
        "contributions": "Display name for the 'User contributions', shown in the sidebar menu of all user pages and user talk pages.\n\nAlso the page name of the target page.\n\nThe target page shows an overview of the most recent contributions by a user.\n\nParameters:\n* $1 - username\n\nSee also:\n* {{msg-mw|Contributions}}\n* {{msg-mw|Accesskey-t-contributions}}\n* {{msg-mw|Tooltip-t-contributions}}",
        "contributions-summary": "{{doc-specialpagesummary|contributions}}",
        "contributions-title": "{{Gender}}\nThe page title in your browser bar, but not the page title.\n\nParameters:\n* $1 - the username\nSee also:\n* {{msg-mw|Contributions}}",
-       "mycontris": "In the personal urls page section - right upper corner.\n\nSee also:\n* {{msg-mw|Mycontris}}\n* {{msg-mw|Accesskey-pt-mycontris}}\n* {{msg-mw|Tooltip-pt-mycontris}}\n{{Identical|Contribution}}",
+       "mycontris": "Link to the current user's own contributions, in the personal account links area, at the upper right corner of the page.\n\nSee also:\n* {{msg-mw|Mycontris}}\n* {{msg-mw|Accesskey-pt-mycontris}}\n* {{msg-mw|Tooltip-pt-mycontris}}\n{{Identical|Contribution}}",
        "anoncontribs": "Same as {{msg-mw|mycontris}} but used for non-logged-in users.\n\nSee also:\n* {{msg-mw|Accesskey-pt-anoncontribs}}\n* {{msg-mw|Tooltip-pt-anoncontribs}}\n{{Identical|Contribution}}",
        "contribsub2": "Contributions for \"user\" (links). Parameters:\n* $1 is an IP address or a username, with a link which points to the user page (if registered user).\n* $2 is list of tool links. The list contains a link which has text {{msg-mw|Sp-contributions-talk}}.\n* $3 is a plain text username used for GENDER.\n{{Identical|For $1}}",
        "contributions-subtitle": "Successor to {{msg-mw|contribsub2}}. Contributions for \"user\". Parameters:\n* $1 is an IP address or a username, with a link which points to the user page (if registered user).",
index cdf5c9c..14aaa08 100644 (file)
@@ -12,7 +12,8 @@
                        "Fitoschido",
                        "Ruthven",
                        "Matěj Suchánek",
-                       "Vlad5250"
+                       "Vlad5250",
+                       "Shirayuki"
                ]
        },
        "tog-underline": "Collegaminde sottolinèate:",
        "metadata-expand": "Fa vedè le dettaglie estese",
        "metadata-collapse": "Scunne le dettaglie estese",
        "metadata-fields": "Le cambe de le immaggine metadata elengate jndr'à stu messagge onna essere mise sus a 'na pàgene de immaggine quanne 'a taggella de metadata jè collassate.\nOtre avènene scunnute pe defolt.\n* make\n* model\n* datetimeoriginal\n* exposuretime\n* fnumber\n* isospeedratings\n* focallength\n* artist\n* copyright\n* imagedescription\n* gpslatitude\n* gpslongitude\n* gpsaltitude",
-       "metadata-langitem": "'''$2:''' $1",
+       "metadata-langitem": "<strong>$2:</strong> $1",
        "metadata-langitem-default": "$1",
        "namespacesall": "tutte",
        "monthsall": "tutte",
index 7136fb7..8cd4eac 100644 (file)
                        "Diralik",
                        "1233qwer1234qwer4",
                        "Саша Волохов",
-                       "Serhio Magpie"
+                       "Serhio Magpie",
+                       "ЛингвоЧел"
                ]
        },
        "tog-underline": "Подчёркивание ссылок:",
        "specialmute-header": "Пожалуйста, выберите настройки уведомлений от {{BIDI:[[User:$1]]}}.",
        "specialmute-error-invalid-user": "Указанное вами имя участника не может быть найдено.",
        "specialmute-error-email-preferences": "Вы должны подтвердить вашу электронную почту, прежде чем отключить уведомление от других. Это можно сделать на странице [[Special:Preferences]].",
-       "specialmute-email-footer": "[$1 Управление настройками эл. почты для {{BIDI:$2}}.]",
+       "specialmute-email-footer": "Для управления настройками эл. почты для {{BIDI:$2}}, пожалуйста, посмотрите <$1>.",
        "specialmute-login-required": "Пожалуйста, войдите, чтобы совершить изменения.",
        "revid": "версия $1",
        "pageid": "ID страницы $1",
index 48fcb81..58a0bbc 100644 (file)
        "history": "Historija stranice",
        "history_short": "Historija",
        "history_small": "historija",
-       "updatedmarker": "promjene od moje zadnje posjete",
+       "updatedmarker": "obnovljeno od vaše posljednje posjete",
        "printableversion": "Verzija za ispis",
        "permalink": "Trajni link",
        "print": "Štampa",
index da11bf7..ae6455d 100644 (file)
        "restrictionsfield-help": "En IP-naslov ali CIDR-območje na vrstico. Da omogočite vse, uporabite:\n<pre>0.0.0.0/0\n::/0</pre>",
        "edit-error-short": "Napaka: $1",
        "edit-error-long": "Napake:\n\n$1",
+       "specialmute": "Utišaj",
+       "specialmute-success": "Vaše nastavitve utišanja smo uspešno posodobili. Oglejte si vse utišane uporabnike na strani [[Special:Preferences]].",
+       "specialmute-submit": "Potrdi",
+       "specialmute-label-mute-email": "Utišaj e-pošto tega uporabnika",
+       "specialmute-header": "Prosimo, izberite svoje nastavitve utišanja za uporabnika {{BIDI:[[User:$1]]}}.",
+       "specialmute-error-invalid-user": "Navedenega uporabniškega imena ni bilo mogoče najti.",
+       "specialmute-error-email-blacklist-disabled": "Utišanje uporabnikov pred pošiljanjem e-pošte ni omogočeno.",
+       "specialmute-error-email-preferences": "Preden lahko utišate uporabnika morate potrditi svoj e-poštni naslov. To lahko storite na strani [[Special:Preferences]].",
+       "specialmute-email-footer": "Za upravljanje e-poštnih nastavitev za uporabnika {{BIDI:$2}} obiščite <$1>.",
+       "specialmute-login-required": "Prosimo, prijavite se, da spremenite svoje nastavitve utišanja.",
        "revid": "redakcija $1",
        "pageid": "ID strani $1",
        "interfaceadmin-info": "$1\n\nDovoljenja za urejanje datotek CSS/JS/JSON spletišča smo nedavno ločili od dovoljenja <code>editinterface</code>. Če ne razumete, zakaj smo vam izpisali to napako, si oglejte [[mw:MediaWiki_1.32/interface-admin]].",
index 6872a0f..33ff4f3 100644 (file)
@@ -41,7 +41,8 @@
                        "Fitoschido",
                        "Stalker",
                        "Vlad5250",
-                       "Петар Петковић"
+                       "Петар Петковић",
+                       "Shirayuki"
                ]
        },
        "tog-underline": "Подвлачење веза:",
        "metadata-expand": "Прикажи детаље",
        "metadata-collapse": "Сакриј додатне детаље",
        "metadata-fields": "Поља за метаподатке слике наведена у овој поруци ће бити укључена на страници за слике када се скупи табела метаподатака. Остала поља ће бити сакривена по подразумеваним поставкама.\n* make\n* model\n* datetimeoriginal\n* exposuretime\n* fnumber\n* isospeedratings\n* focallength\n* artist\n* copyright\n* imagedescription\n* gpslatitude\n* gpslongitude\n* gpsaltitude",
-       "metadata-langitem": "'''$2:''' $1",
+       "metadata-langitem": "<strong>$2:</strong> $1",
        "metadata-langitem-default": "$1",
        "namespacesall": "сви",
        "monthsall": "све",
index 071b97e..4dd4165 100644 (file)
@@ -32,7 +32,8 @@
                        "Acamicamacaraca",
                        "Fitoschido",
                        "BadDog",
-                       "Vlad5250"
+                       "Vlad5250",
+                       "Shirayuki"
                ]
        },
        "tog-underline": "Podvlačenje veza:",
        "metadata-expand": "Prikaži detalje",
        "metadata-collapse": "Sakrij dodatne detalje",
        "metadata-fields": "Polja za metapodatke slike navedena u ovoj poruci će biti uključena na stranici za slike kada se skupi tabela metapodataka. Ostala polja će biti sakrivena po podrazumevanim postavkama.\n* make\n* model\n* datetimeoriginal\n* exposuretime\n* fnumber\n* isospeedratings\n* focallength\n* artist\n* copyright\n* imagedescription\n* gpslatitude\n* gpslongitude\n* gpsaltitude",
-       "metadata-langitem": "'''$2:''' $1",
+       "metadata-langitem": "<strong>$2:</strong> $1",
        "metadata-langitem-default": "$1",
        "namespacesall": "svi",
        "monthsall": "sve",
index 54dd8bc..61b5c18 100644 (file)
        "ipb-disableusertalk": "Cegah ieu pamaké pikeun ngédit kaca obrolan manéhns sorangan nalika dipeunpeuk",
        "ipb-change-block": "Peungpeuk deui pamaké kalawan sét konfigurasi ieu",
        "ipb-confirm": "Konfirmasi peungpeuk",
+       "ipb-partial": "Wawaréhan",
        "badipaddress": "Alamat IP teu sah",
        "blockipsuccesssub": "Meungpeuk geus hasil",
        "blockipsuccesstext": "[[Special:Contributions/$1|$1]] geus dipeungpeuk.<br />\nTempo [[Special:BlockList|daptar peungpeukan]] pikeun niténan deui pameungpeukan.",
        "blocklist-userblocks": "Sumputkeun peungpeukan akun",
        "blocklist-tempblocks": "Sumputkeun peungpeukan saheulaanan",
        "blocklist-addressblocks": "Sumputkeun pameungpeukan IP tunggal",
+       "blocklist-type": "Jinis:",
+       "blocklist-type-opt-all": "Sakumna",
+       "blocklist-type-opt-partial": "Wawaréhan",
        "blocklist-rangeblocks": "Nyumputkeun hontalan peungpeuk",
        "blocklist-timestamp": "Cap titimangsa",
        "blocklist-target": "Udagan",
        "createaccountblock": "nyieun akun ditumpurkeun",
        "emailblock": "surélek di peungpeuk",
        "blocklist-nousertalk": "teu bisa ngarobah kaca obrolan sorangan",
+       "blocklist-editing": "pangéditan",
+       "blocklist-editing-page": "kaca",
+       "blocklist-editing-ns": "ngaranspasi",
        "ipblocklist-empty": "Daptar peungpeuk kosong.",
-       "ipblocklist-no-results": "Alamat IP atawa sandiasma nu dipundut teu dipeungpeuk.",
+       "ipblocklist-no-results": "Taya peungpeukan nu cocog jeung alamat IP atawa sandiasma nu dipundut.",
        "blocklink": "blokir",
        "unblocklink": "buka blokir",
        "change-blocklink": "Robah status blokir",
        "pageinfo-display-title": "Judul pidangan",
        "pageinfo-default-sort": "Konci susun baku",
        "pageinfo-length": "Panjang kaca (dina bit)",
+       "pageinfo-namespace": "Ngaranspasi",
        "pageinfo-article-id": "ID kaca",
        "pageinfo-language": "Basa eusi kaca",
        "pageinfo-language-change": "robah",
        "version-specialpages": "Kaca husus",
        "version-parserhooks": "Kait parser",
        "version-variables": "Variabel",
+       "version-editors": "Éditor",
        "version-antispam": "Panyegahan spam",
        "version-other": "Séjén",
        "version-mediahandlers": "Pananganan média",
        "tag-filter-submit": "Saring",
        "tag-list-wrapper": "[[Special:Tags|{{PLURAL:$1|Tag}}]]: $2",
        "tag-mw-contentmodelchange": "parobahan modél kontén",
+       "tag-mw-new-redirect": "Alihan anyar",
+       "tag-mw-removed-redirect": "Mupus alihan",
+       "tag-mw-blank": "Ngosongkeun",
+       "tag-mw-replace": "Gagantian",
+       "tag-mw-undo": "Bedo",
        "tags-title": "Tag",
        "tags-intro": "Ieu kaca ngandung daptar tag nu bisa ditandaan ku pakakas lemes kana hiji éditan di handap hartina.",
        "tags-tag": "Ngaran tag",
        "limitreport-templateargumentsize": "Ukuran argumén citakan",
        "limitreport-templateargumentsize-value": "$1/$2 {{PLURAL:$2|sabita|bita}}",
        "expandtemplates": "Mekarkeun citakan",
-       "expand_templates_input": "Téks input:",
+       "expand_templates_input": "Asupkeun tékswiki:",
        "expand_templates_output": "Hasil:",
        "expand_templates_xml_output": "Output XML",
        "expand_templates_html_output": "Kaluaran HTML atah",
        "special-characters-title-endash": "gurat en",
        "special-characters-title-emdash": "gurat em",
        "special-characters-title-minus": "tanda kurang",
+       "mw-widgets-abandonedit-discard": "Piceun éditan",
+       "mw-widgets-abandonedit-title": "Anjeun yakin?",
+       "mw-widgets-copytextlayout-copy": "Tiron",
+       "mw-widgets-copytextlayout-copy-fail": "Gagal nironkeun kana papanklip.",
+       "mw-widgets-copytextlayout-copy-success": "Ditiron kana papanklip.",
        "mw-widgets-dateinput-no-date": "Euweuh tanggal pinilih",
        "mw-widgets-mediasearch-input-placeholder": "Paluruh média",
        "mw-widgets-mediasearch-noresults": "Euweuh hasil nu kapanggih.",
        "mw-widgets-titleinput-description-redirect": "ngalihkeun ka $1",
        "mw-widgets-categoryselector-add-category-placeholder": "Tambahkeun kategori...",
        "mw-widgets-usersmultiselect-placeholder": "Tambahkeun leuwih loba...",
+       "mw-widgets-titlesmultiselect-placeholder": "Tambahkeun leuwih loba...",
        "date-range-from": "Ti ping:",
        "date-range-to": "Nepi ping:",
        "sessionprovider-generic": "sési $1",
        "log-action-filter-suppress-block": "Parusiahan pamaké dumasar peungpeukan",
        "log-action-filter-upload-upload": "Unjalan anyar",
        "log-action-filter-upload-overwrite": "Unjal deui",
+       "log-action-filter-upload-revert": "Balikkeun",
        "authmanager-create-disabled": "Panyieunan akun ditumpurkeun",
        "authmanager-create-from-login": "Pikeun nyieun akun, mangga eusi ieu kolom di handap.",
        "authmanager-autocreate-noperm": "Panyieunan akun otomatis teu diidinan.",
        "restrictionsfield-badip": "Alamat IP atawa pantengan IP teu sah: $1",
        "restrictionsfield-label": "Pantengan IP nu diheugbaékeun:",
        "restrictionsfield-help": "Hiji alamat IP atawa pantengan CIDR per baris. Pikeun ngahurungkeun sakumna, paké:\n<pre>0.0.0.0/0\n::/0</pre>",
+       "specialmute": "Pireu",
+       "specialmute-submit": "Konfirmasi",
        "revid": "révisi $1",
        "pageid": "ID kaca $1",
        "rawhtml-notallowed": "Tag &lt;html&gt; teu bisa dipaké di luar kaca normal.",
        "undelete-cantedit": "Anjeun teu bisa ngabolaykeun pamupusan ieu kaca lantaran anjeun teu bisa ngédit ieu kaca.",
        "pagedata-title": "Data kaca",
        "pagedata-not-acceptable": "Teu kapanggih format nu luyu. Jinis MIME nu dirojong: $1",
-       "pagedata-bad-title": "Judul teu sah: $1."
+       "pagedata-bad-title": "Judul teu sah: $1.",
+       "passwordpolicies-group": "Jumplukan",
+       "passwordpolicies-policies": "Kawijakan",
+       "passwordpolicies-policyflag-forcechange": "kudu ganti pas asup log",
+       "passwordpolicies-policyflag-suggestchangeonlogin": "sarankeun gagantian asup log",
+       "userlogout-continue": "Yakin rék kaluar log?"
 }
index 215c2de..4c6d5df 100644 (file)
@@ -24,7 +24,8 @@
                        "Blakegripling ph",
                        "LR Guanzon",
                        "Fitoschido",
-                       "Vlad5250"
+                       "Vlad5250",
+                       "Shirayuki"
                ]
        },
        "tog-underline": "Pagsasalungguhit ng kawing:",
        "metadata-expand": "Ipakita ang karugtong na mga detalye",
        "metadata-collapse": "Itago ang karugtong na mga detalye",
        "metadata-fields": "Ang mga hanay ng pook ng metadatos ng larawan na nakatala sa mensaheng ito ay masasama sa ipinapakitang pahina ng larawan kapag tumiklop ang tabla ng metadatos.\nLikas na nakatakdang itago ang iba pa.\n* make\n* model\n* datetimeoriginal\n* exposuretime\n* fnumber\n* isospeedratings\n* focallength\n* artist\n* copyright\n* imagedescription\n* gpslatitude\n* gpslongitude\n* gpsaltitude",
-       "metadata-langitem": "'''$2:''' $1",
+       "metadata-langitem": "<strong>$2:</strong> $1",
        "metadata-langitem-default": "$1",
        "namespacesall": "lahat",
        "monthsall": "lahat",
index dc556f2..f9eeb8e 100644 (file)
@@ -79,7 +79,8 @@
                        "Esk78",
                        "Vlad5250",
                        "Олександр М.",
-                       "Gzhegozh"
+                       "Gzhegozh",
+                       "Shirayuki"
                ]
        },
        "tog-underline": "Підкреслювання посилань:",
        "metadata-expand": "Показати додаткові дані",
        "metadata-collapse": "Приховати додаткові дані",
        "metadata-fields": "Поля метаданих зображення, перелічені в наступному списку, будуть відображатись на сторінці опису зображення при згорнутій таблиці метаданих. Решта полів будуть приховані за замовчуванням.\n* make\n* model\n* datetimeoriginal\n* exposuretime\n* fnumber\n* isospeedratings\n* focallength\n* artist\n* copyright\n* imagedescription\n* gpslatitude\n* gpslongitude\n* gpsaltitude",
-       "metadata-langitem": "'''$2:''' $1",
+       "metadata-langitem": "<strong>$2:</strong> $1",
        "metadata-langitem-default": "$1",
        "namespacesall": "всі",
        "monthsall": "всі",
index 7adbe7b..08c6c10 100644 (file)
        "history": "בלאט היסטאריע",
        "history_short": "היסטאָריע",
        "history_small": "היסטאריע",
-       "updatedmarker": "×\93ער×\94×\99×\99× ×\98×\99×\92×\98 ×\96×\99× ×\98 ×\9e×\99×\99×\9f ×\9cעצ×\98×¢ וויזיט",
+       "updatedmarker": "×\93ער×\94×\99×\99× ×\98×\99×\92×\98 ×\96×\99× ×\98 ×\90×\99×\99ער ×\9cעצ×\98×\9f וויזיט",
        "printableversion": "דרוק ווערסיע",
        "permalink": "שטענדיגער לינק",
        "print": "דרוק",
        "virus-scanfailed": "איבערקוקן נישט געראטן (קאד: $1)",
        "virus-unknownscanner": "אומבאוואוסטער אנטי־ווירוס:",
        "logouttext": "'''איר האָט זיך ארויסלאָגירט.'''\n\nבאמערקט אז געוויסע בלעטער קענען זיך ווייטער ארויסשטעלן אזוי ווי ווען איר זענט אריינלאגירט, ביז איר וועט אויסליידיגן דעם בלעטערער זאפאס.",
+       "logging-out-notify": "איר ווערט ארויסלאגירט. זייט אזוי גוט און ווארט.",
+       "logout-failed": "קען נישט ארויסלאגירן אצינד: $1",
        "cannotlogoutnow-title": "קען נישט ארויסלאגירן אצינד",
        "cannotlogoutnow-text": "ארויסלאגירן נישט מעגלעך ווען מען ניצט $1.",
        "welcomeuser": "ברוך הבא, $1!",
        "ipb-blocklist": "זעט עקזיסטירנדע בלאקירונגען",
        "ipb-blocklist-contribs": "בײַשטײַערונגען פֿון {{GENDER:$1|$1}}",
        "ipb-blocklist-duration-left": "נאך $1",
+       "block-actions": "פעולות צו ווערן בלאקירט:",
        "block-expiry": "אויסגיין:",
        "block-reason": "אורזאַך:",
        "block-target": "באניצער־נאמען אדער IP-אדרעס:",
        "blocklogpage": "בלאקירן לאג",
        "blocklog-showlog": "{{GENDER:$1|דער באַניצער|די באַניצערין}} איז שוין געווארן פֿאַרשפאַרט אַמאָל.\nדער בלאקירונג לאג איז צוגעשטעלט אונטן:",
        "blocklog-showsuppresslog": "{{GENDER:$1|דער באַניצער|די באַניצערין}} איז שוין געווארן פֿאַרשפאַרט און פֿאַרבארגט אַמאָל.\nדער פֿאַרשטיקונג לאג איז צוגעשטעלט אונטן:",
-       "blocklogentry": "בלאקירט \"[[$1]]\" אויף אַ תקופה פון $2 $3",
+       "blocklogentry": "×\94×\90×\98 ×\91×\9c×\90ק×\99ר×\98 \"[[$1]]\" ×\90×\95×\99×£ ×\90Ö· ×ª×§×\95פ×\94 ×¤×\95×\9f $2 $3",
        "reblock-logentry": "גענדערט די בלאקירונג דעפיניציעס פון [[$1]] מיטן צייט אפלויף פון $2 $3",
        "blocklogtext": "דאס איז א לאג בוך פון אלע בלאקירונגען און באפרייונגען פֿון באניצער.\nאיי פי אדרעסן וואס זענען בלאקירט אויטאמאטיש ווערן נישט אויסגערעכענט דא.\nזעט די איצטיקע [[Special:BlockList|ליסטע פון בלאקירטע באניצער]].",
        "unblocklogentry": "אומבלאקירט $1",
        "revdelete-uname-unhid": "באַניצער נאָמען ארויסגעגעבן",
        "revdelete-restricted": "צוגעלייגט באגרעניצונגען פאר סיסאפן",
        "revdelete-unrestricted": "אוועקגענומען באגרעניצונגען פאר סיסאפן",
+       "logentry-block-block": "$1 {{GENDER:$2|האט בלאקירט}} {{GENDER:$4|$3}} מיט אן אויסלאז צייט פון $5 $6",
+       "logentry-partialblock-block": "$1 {{GENDER:$2|האט בלאקירט}} {{GENDER:$4|$3}} פֿון רעדאקטירן $7 מיט אן אויסלאז צייט פון $5 $6",
        "logentry-suppress-block": "$1 {{GENDER:$2|האט בלאקירט}} {{GENDER:$4|$3}} מיט אן אויסלאז צייט פון $5 $6",
        "logentry-move-move": "$1 {{GENDER:$2|האט באוועגט}} בלאט $3 צו $4",
        "logentry-move-move-noredirect": "$1 {{GENDER:$2|האט באוועגט}} בלאט $3 צו $4 אן לאזן א ווייטערפירונג",
index c872c4b..4ea707f 100644 (file)
        "confirmable-no": "否",
        "thisisdeleted": "查看或还原$1?",
        "viewdeleted": "查看$1?",
-       "restorelink": "$1个已删除的编辑",
+       "restorelink": "$1个已删除的编辑",
        "feedlinks": "源:",
        "feed-invalid": "无效的订阅feed类型。",
        "feed-unavailable": "不提供联合feed",
        "systemblockedtext": "您的用户名或IP地址已被MediaWiki自动封禁。封禁原因:\n\n:<em>$2</em>\n\n* 开始时间:$8\n* 到期时间:$6\n* 目标用户:$7\n\n您当前的IP地址是$3。请在您做出的任何查询中包含所有上述详情。",
        "blockednoreason": "未给出原因",
        "blockedtext-composite": "您的用户名或IP地址已被封禁。封禁原因:\n\n:<em>$2</em>\n\n* 开始时间:$8\n* 到期时间:$6\n\n您当前的IP地址是$3。请在您做出的任何查询中包含所有上述详情。",
+       "blockedtext-composite-reason": "有多个封禁目标为您的账户和/或IP地址",
        "whitelistedittext": "请$1以编辑页面。",
        "confirmedittext": "您必须确认您的电子邮件地址才能编辑页面。请通过[[Special:Preferences|系统设置]]设置并确认您的电子邮件地址。",
        "nosuchsectiontitle": "没有这个段落",
        "prefs-help-watchlist-token2": "这是您的监视列表的网络feed密钥。任何拥有者均可以浏览您的监视列表,因此不要公开该密钥。如果有需要,[[Special:ResetTokens|您可以重置密钥]]。",
        "prefs-help-tokenmanagement": "您可以查看并重置您账户的密钥,它用来访问您监视列表的Web订阅源。任何知道密钥的人都将可以阅读您的监视列表,所以不要分享它。",
        "savedprefs": "您的系统设置已保存。",
-       "savedrights": "{{GENDER:$1|$1}}的用户组已保存。",
+       "savedrights": "{{GENDER:$1|$1}}的用户组已保存。",
        "timezonelegend": "时区:",
        "localtime": "当地时间:",
        "timezoneuseserverdefault": "使用wiki默认值($1)",
        "img-auth-nofile": "文件“$1”不存在。",
        "img-auth-isdir": "您正试图访问目录“$1”。您只能访问文件。",
        "img-auth-streaming": "流式化“$1”中。",
-       "img-auth-public": "img_auth.phpç\9a\84å\8a\9fè\83½æ\98¯ä»\8eé\9d\9eå\85¬å¼\80wikiè¾\93å\87ºæ\96\87件ã\80\82æ\9c¬wiki已被设置为å\85¬å¼\80ã\80\82为äº\86æ\9c\80ä½³å®\89å\85¨ç\8a¶å\86µï¼\8cimg_auth.phpå·²å\81\9cç\94¨ã\80\82",
+       "img-auth-public": "img_auth.php的功能是从非公开wiki输出文件。本wiki已设置为公开。为了最佳安全状况,img_auth.php已停用。",
        "img-auth-noread": "用户无权读取“$1”。",
        "http-invalid-url": "无效URL:$1",
        "http-invalid-scheme": "带“$1”方案的URL不受支持。",
        "undeleteinvert": "反向选择",
        "undeletecomment": "原因:",
        "cannotundelete": "部分或全部还原删除失败:$1",
-       "undeletedpage": "<strong>$1å·²ç»\8f被è¿\98å\8e\9f</strong>\n\næ\9c\80è¿\91ç\9a\84å\88 é\99¤å\92\8cè¿\98å\8e\9fè®°å½\95请è§\81[[Special:Log/delete|å\88 é\99¤æ\97¥å¿\97]]ã\80\82",
+       "undeletedpage": "<strong>$1已经还原</strong>\n\n最近的删除和还原记录请见[[Special:Log/delete|删除日志]]。",
        "undelete-header": "如要查询最近的记录请参阅[[Special:Log/delete|删除日志]]。",
        "undelete-search-title": "搜索已删除页面",
        "undelete-search-box": "搜索已删除页面",
        "unblockiptext": "使用下列表单来恢复之前被封禁的IP地址或用户名的写权限。",
        "ipusubmit": "解除此封禁",
        "unblocked": "[[User:$1|$1]]已经被解封",
-       "unblocked-range": "$1已被解å°\81",
+       "unblocked-range": "$1已解å°\81ã\80\82",
        "unblocked-id": "封禁$1已被解除",
        "unblocked-ip": "[[Special:Contributions/$1|$1]]已解封。",
        "blocklist": "被封禁用户",
        "anonymous": "{{SITENAME}}匿名{{PLURAL:$1|用户}}",
        "siteuser": "{{SITENAME}}用户$1",
        "anonuser": "{{SITENAME}}匿名用户$1",
-       "lastmodifiedatby": "本页面$3最后编辑于$1 $2。",
+       "lastmodifiedatby": "本页面$3最后编辑于$1 $2。",
        "othercontribs": "基于$1的劳动成果。",
        "others": "其他",
        "siteusers": "{{SITENAME}}{{PLURAL:$2|{{GENDER:$1|用户}}}}$1",
        "edit-error-long": "错误:\n\n$1",
        "specialmute": "屏蔽",
        "specialmute-submit": "确认",
+       "specialmute-label-mute-email": "屏蔽该用户的邮件",
+       "specialmute-error-invalid-user": "未找到您请求的用户名。",
        "revid": "修订版本$1",
        "pageid": "页面ID$1",
        "interfaceadmin-info": "$1\n\n编辑全站CSS/JS/JSON文件的权限刚刚从<code>editinterface</code>权限中拆分。如果您不知道为何收到此错误,请参见[[mw:MediaWiki_1.32/interface-admin]]。",
index 39d9be7..966c9d3 100644 (file)
        "history": "頁面歷史",
        "history_short": "歷史",
        "history_small": "歷史",
-       "updatedmarker": "è\87ªæ\88\91上次瀏覽之後的更新",
+       "updatedmarker": "è\87ªæ\82¨上次瀏覽之後的更新",
        "printableversion": "可列印版",
        "permalink": "靜態連結",
        "print": "列印",
        "restrictionsfield-help": "一個 IP 位址或 CIDR 範圍一行,要開啟所有範圍可使用:<pre>0.0.0.0/0\n::/0</pre>",
        "edit-error-short": "錯誤:$1",
        "edit-error-long": "錯誤:\n\n$1",
+       "specialmute-submit": "確認",
+       "specialmute-error-invalid-user": "無法找到請求的使用者名稱。",
        "revid": "修訂 $1",
        "pageid": "頁面 ID $1",
        "interfaceadmin-info": "$1\n\n編輯全站 CSS/JS/JSON 檔案的權限,近期已從 <code>editinterface</code> 權限裡拆分。若您不清楚為何會收到此錯誤,請查看 [[mw:MediaWiki_1.32/interface-admin]]。",
index 381926a..f5d9359 100644 (file)
@@ -129,7 +129,7 @@ class ImportImages extends Maintenance {
 
                $processed = $added = $ignored = $skipped = $overwritten = $failed = 0;
 
-               $this->output( "Import Images\n\n" );
+               $this->output( "Importing Files\n\n" );
 
                $dir = $this->getArg( 0 );
 
index 0e84586..40fd51f 100644 (file)
@@ -13,8 +13,8 @@ CREATE TABLE /*_*/pagelinks_tmp (
   PRIMARY KEY (pl_from,pl_namespace,pl_title)
 ) /*$wgDBTableOptions*/;
 
-INSERT INTO /*_*/pagelinks_tmp
-       SELECT * FROM /*_*/pagelinks;
+INSERT INTO /*_*/pagelinks_tmp (pl_from, pl_from_namespace, pl_namespace, pl_title)
+       SELECT pl_from, pl_from_namespace, pl_namespace, pl_title FROM /*_*/pagelinks;
 
 DROP TABLE /*_*/pagelinks;
 
index 5f09f60..e9bbab8 100644 (file)
@@ -13,8 +13,8 @@ CREATE TABLE /*_*/templatelinks_tmp (
   PRIMARY KEY (tl_from,tl_namespace,tl_title)
 ) /*$wgDBTableOptions*/;
 
-INSERT INTO /*_*/templatelinks_tmp
-       SELECT * FROM /*_*/templatelinks;
+INSERT INTO /*_*/templatelinks_tmp (tl_from, tl_from_namespace, tl_namespace, tl_title)
+       SELECT tl_from, tl_from_namespace, tl_namespace, tl_title FROM /*_*/templatelinks;
 
 DROP TABLE /*_*/templatelinks;
 
index e160f3b..159adbc 100644 (file)
        <testsuites>
                <testsuite name="unit">
                        <directory>tests/phpunit/unit</directory>
+                       <directory>**/**/tests/phpunit/unit</directory>
                </testsuite>
                <testsuite name="integration">
                        <directory>tests/phpunit/integration</directory>
+                       <directory>**/**/tests/phpunit/integration</directory>
                </testsuite>
        </testsuites>
        <groups>
index b228b96..92b4fd4 100644 (file)
@@ -1819,7 +1819,10 @@ return [
                        'ui/RclTargetPageWidget.js',
                        'ui/RclToOrFromWidget.js',
                        'ui/WatchlistTopSectionWidget.js',
-                       [ 'name' => 'config.json', 'callback' => 'ChangesListSpecialPage::getRcFiltersConfigVars' ],
+                       [ 'name' => 'config.json',
+                               'versionCallback' => 'ChangesListSpecialPage::getRcFiltersConfigSummary',
+                               'callback' => 'ChangesListSpecialPage::getRcFiltersConfigVars',
+                       ],
                ],
                'styles' => [
                        'styles/mw.rcfilters.mixins.less',
@@ -2089,11 +2092,27 @@ return [
                ],
                'targets' => [ 'desktop', 'mobile' ],
        ],
-       'mediawiki.special.changecredentials.js' => [
-               'scripts' => 'resources/src/mediawiki.special.changecredentials.js',
+       // This bundles various small (under 5 KB?) JavaScript files that:
+       // - .. are not loaded on when viewing or editing wiki pages.
+       // - .. are used by logged-in users only.
+       // - .. depend on oojs-ui-core.
+       // - .. contain UI intialisation code (e.g. no public module exports, because
+       //      requiring or depending on this bundle is awkard)
+       'mediawiki.misc-authed-ooui' => [
+               'localBasePath' => "$IP/resources/src/mediawiki.misc-authed-ooui",
+               'remoteBasePath' => "$wgResourceBasePath/resources/src/mediawiki.misc-authed-ooui",
+               'scripts' => [
+                       'special.changecredentials.js',
+                       'special.movePage.js',
+                       'special.mute.js',
+                       'special.pageLanguage.js',
+               ],
                'dependencies' => [
-                       'mediawiki.api',
-                       'mediawiki.htmlform.ooui'
+                       'mediawiki.api', // Used by special.changecredentials.js
+                       'mediawiki.htmlform.ooui', // Used by special.changecredentials.js
+                       'mediawiki.widgets.visibleLengthLimit', // Used by special.movePage.js
+                       'mediawiki.widgets', // Used by special.movePage.js
+                       'oojs-ui-core', // Used by special.pageLanguage.js
                ],
                'targets' => [ 'desktop', 'mobile' ],
        ],
@@ -2142,22 +2161,6 @@ return [
        'mediawiki.special.import' => [
                'scripts' => 'resources/src/mediawiki.special.import.js',
        ],
-       'mediawiki.special.movePage' => [
-               'scripts' => 'resources/src/mediawiki.special.movePage.js',
-               'dependencies' => [
-                       'mediawiki.widgets.visibleLengthLimit',
-                       'mediawiki.widgets',
-               ],
-       ],
-       'mediawiki.special.pageLanguage' => [
-               'scripts' => [
-                       'resources/src/mediawiki.special.mute.js',
-                       'resources/src/mediawiki.special.pageLanguage.js'
-               ],
-               'dependencies' => [
-                       'oojs-ui-core',
-               ],
-       ],
        'mediawiki.special.preferences.ooui' => [
                'targets' => [ 'desktop', 'mobile' ],
                'scripts' => [
diff --git a/resources/src/mediawiki.misc-authed-ooui/special.changecredentials.js b/resources/src/mediawiki.misc-authed-ooui/special.changecredentials.js
new file mode 100644 (file)
index 0000000..36ad252
--- /dev/null
@@ -0,0 +1,55 @@
+/*!
+ * JavaScript for change credentials form.
+ */
+( function () {
+       mw.hook( 'htmlform.enhance' ).add( function ( $root ) {
+               var api = new mw.Api();
+
+               $root.find( '.mw-changecredentials-validate-password.oo-ui-fieldLayout' ).each( function () {
+                       var currentApiPromise,
+                               self = OO.ui.FieldLayout.static.infuse( $( this ) );
+
+                       self.getField().setValidation( function ( password ) {
+                               var d;
+
+                               if ( currentApiPromise ) {
+                                       currentApiPromise.abort();
+                                       currentApiPromise = undefined;
+                               }
+
+                               password = password.trim();
+
+                               if ( password === '' ) {
+                                       self.setErrors( [] );
+                                       return true;
+                               }
+
+                               d = $.Deferred();
+                               currentApiPromise = api.post( {
+                                       action: 'validatepassword',
+                                       password: password,
+                                       formatversion: 2,
+                                       errorformat: 'html',
+                                       errorsuselocal: true,
+                                       uselang: mw.config.get( 'wgUserLanguage' )
+                               } ).done( function ( resp ) {
+                                       var pwinfo = resp.validatepassword,
+                                               good = pwinfo.validity === 'Good',
+                                               errors = [];
+
+                                       currentApiPromise = undefined;
+
+                                       if ( !good ) {
+                                               pwinfo.validitymessages.map( function ( m ) {
+                                                       errors.push( new OO.ui.HtmlSnippet( m.html ) );
+                                               } );
+                                       }
+                                       self.setErrors( errors );
+                                       d.resolve( good );
+                               } ).fail( d.reject );
+
+                               return d.promise( { abort: currentApiPromise.abort } );
+                       } );
+               } );
+       } );
+}() );
diff --git a/resources/src/mediawiki.misc-authed-ooui/special.movePage.js b/resources/src/mediawiki.misc-authed-ooui/special.movePage.js
new file mode 100644 (file)
index 0000000..8004a44
--- /dev/null
@@ -0,0 +1,19 @@
+/*!
+ * JavaScript for Special:MovePage
+ */
+( function () {
+       $( function () {
+               var summaryCodePointLimit = mw.config.get( 'wgCommentCodePointLimit' ),
+                       summaryByteLimit = mw.config.get( 'wgCommentByteLimit' ),
+                       wpReason = OO.ui.infuse( $( '#wpReason' ) );
+
+               // Infuse for pretty dropdown
+               OO.ui.infuse( $( '#wpNewTitle' ) );
+               // Limit to bytes or UTF-8 codepoints, depending on MediaWiki's configuration
+               if ( summaryCodePointLimit ) {
+                       mw.widgets.visibleCodePointLimit( wpReason, summaryCodePointLimit );
+               } else if ( summaryByteLimit ) {
+                       mw.widgets.visibleByteLimit( wpReason, summaryByteLimit );
+               }
+       } );
+}() );
diff --git a/resources/src/mediawiki.misc-authed-ooui/special.mute.js b/resources/src/mediawiki.misc-authed-ooui/special.mute.js
new file mode 100644 (file)
index 0000000..b9dcc21
--- /dev/null
@@ -0,0 +1,23 @@
+( function () {
+       'use strict';
+
+       $( function () {
+               var $inputs = $( '#mw-specialmute-form input[type="checkbox"]' ),
+                       saveButton, $saveButton = $( '#save' );
+
+               function isFormChanged() {
+                       return $inputs.is( function () {
+                               return this.checked !== this.defaultChecked;
+                       } );
+               }
+
+               if ( $saveButton.length ) {
+                       saveButton = OO.ui.infuse( $saveButton );
+                       saveButton.setDisabled( !isFormChanged() );
+
+                       $inputs.on( 'change', function () {
+                               saveButton.setDisabled( !isFormChanged() );
+                       } );
+               }
+       } );
+}() );
diff --git a/resources/src/mediawiki.misc-authed-ooui/special.pageLanguage.js b/resources/src/mediawiki.misc-authed-ooui/special.pageLanguage.js
new file mode 100644 (file)
index 0000000..8538e95
--- /dev/null
@@ -0,0 +1,13 @@
+/*!
+ * JavaScript module used on Special:PageLanguage
+ */
+( function () {
+       $( function () {
+               // Select the 'Language select' option if user is trying to select language
+               if ( $( '#mw-pl-languageselector' ).length ) {
+                       OO.ui.infuse( $( '#mw-pl-languageselector' ) ).on( 'change', function () {
+                               OO.ui.infuse( $( '#mw-pl-options' ) ).setValue( '2' );
+                       } );
+               }
+       } );
+}() );
index 7d69fb6..5d6eaef 100644 (file)
@@ -71,7 +71,7 @@ FormWrapperWidget.prototype.onFormSubmit = function ( e ) {
        $( e.target ).find( 'input:not([type="hidden"],[type="submit"]), select' ).each( function () {
                var value = '';
 
-               if ( !$( this ).is( ':checkbox' ) || $( this ).is( ':checked' ) ) {
+               if ( !$( this ).is( '[type="checkbox"]' ) || $( this ).is( ':checked' ) ) {
                        value = $( this ).val();
                }
 
diff --git a/resources/src/mediawiki.special.changecredentials.js b/resources/src/mediawiki.special.changecredentials.js
deleted file mode 100644 (file)
index 36ad252..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*!
- * JavaScript for change credentials form.
- */
-( function () {
-       mw.hook( 'htmlform.enhance' ).add( function ( $root ) {
-               var api = new mw.Api();
-
-               $root.find( '.mw-changecredentials-validate-password.oo-ui-fieldLayout' ).each( function () {
-                       var currentApiPromise,
-                               self = OO.ui.FieldLayout.static.infuse( $( this ) );
-
-                       self.getField().setValidation( function ( password ) {
-                               var d;
-
-                               if ( currentApiPromise ) {
-                                       currentApiPromise.abort();
-                                       currentApiPromise = undefined;
-                               }
-
-                               password = password.trim();
-
-                               if ( password === '' ) {
-                                       self.setErrors( [] );
-                                       return true;
-                               }
-
-                               d = $.Deferred();
-                               currentApiPromise = api.post( {
-                                       action: 'validatepassword',
-                                       password: password,
-                                       formatversion: 2,
-                                       errorformat: 'html',
-                                       errorsuselocal: true,
-                                       uselang: mw.config.get( 'wgUserLanguage' )
-                               } ).done( function ( resp ) {
-                                       var pwinfo = resp.validatepassword,
-                                               good = pwinfo.validity === 'Good',
-                                               errors = [];
-
-                                       currentApiPromise = undefined;
-
-                                       if ( !good ) {
-                                               pwinfo.validitymessages.map( function ( m ) {
-                                                       errors.push( new OO.ui.HtmlSnippet( m.html ) );
-                                               } );
-                                       }
-                                       self.setErrors( errors );
-                                       d.resolve( good );
-                               } ).fail( d.reject );
-
-                               return d.promise( { abort: currentApiPromise.abort } );
-                       } );
-               } );
-       } );
-}() );
diff --git a/resources/src/mediawiki.special.movePage.js b/resources/src/mediawiki.special.movePage.js
deleted file mode 100644 (file)
index 8004a44..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/*!
- * JavaScript for Special:MovePage
- */
-( function () {
-       $( function () {
-               var summaryCodePointLimit = mw.config.get( 'wgCommentCodePointLimit' ),
-                       summaryByteLimit = mw.config.get( 'wgCommentByteLimit' ),
-                       wpReason = OO.ui.infuse( $( '#wpReason' ) );
-
-               // Infuse for pretty dropdown
-               OO.ui.infuse( $( '#wpNewTitle' ) );
-               // Limit to bytes or UTF-8 codepoints, depending on MediaWiki's configuration
-               if ( summaryCodePointLimit ) {
-                       mw.widgets.visibleCodePointLimit( wpReason, summaryCodePointLimit );
-               } else if ( summaryByteLimit ) {
-                       mw.widgets.visibleByteLimit( wpReason, summaryByteLimit );
-               }
-       } );
-}() );
diff --git a/resources/src/mediawiki.special.mute.js b/resources/src/mediawiki.special.mute.js
deleted file mode 100644 (file)
index 3d494d0..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-( function () {
-       'use strict';
-
-       $( function () {
-               var $inputs = $( '#mw-specialmute-form input:checkbox' ),
-                       saveButton, $saveButton = $( '#save' );
-
-               function isFormChanged() {
-                       return $inputs.is( function () {
-                               return this.checked !== this.defaultChecked;
-                       } );
-               }
-
-               if ( $saveButton.length ) {
-                       saveButton = OO.ui.infuse( $saveButton );
-                       saveButton.setDisabled( !isFormChanged() );
-
-                       $inputs.on( 'change', function () {
-                               saveButton.setDisabled( !isFormChanged() );
-                       } );
-               }
-       } );
-}() );
diff --git a/resources/src/mediawiki.special.pageLanguage.js b/resources/src/mediawiki.special.pageLanguage.js
deleted file mode 100644 (file)
index 8538e95..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/*!
- * JavaScript module used on Special:PageLanguage
- */
-( function () {
-       $( function () {
-               // Select the 'Language select' option if user is trying to select language
-               if ( $( '#mw-pl-languageselector' ).length ) {
-                       OO.ui.infuse( $( '#mw-pl-languageselector' ) ).on( 'change', function () {
-                               OO.ui.infuse( $( '#mw-pl-options' ) ).setValue( '2' );
-                       } );
-               }
-       } );
-}() );
index e24c4c5..a42f573 100644 (file)
@@ -18,6 +18,9 @@ class TestSetup {
                global $wgSessionProviders, $wgSessionPbkdf2Iterations;
                global $wgJobTypeConf;
                global $wgAuthManagerConfig;
+               global $wgShowExceptionDetails;
+
+               $wgShowExceptionDetails = true;
 
                // wfWarn should cause tests to fail
                $wgDevelopmentWarnings = true;
index e1dde22..c35e80f 100644 (file)
@@ -54,6 +54,7 @@ $wgAutoloadClasses += [
        'HamcrestPHPUnitIntegration' => "$testDir/phpunit/HamcrestPHPUnitIntegration.php",
        'LessFileCompilationTest' => "$testDir/phpunit/LessFileCompilationTest.php",
        'MediaWikiCoversValidator' => "$testDir/phpunit/MediaWikiCoversValidator.php",
+       'MediaWikiGroupValidator' => "$testDir/phpunit/MediaWikiGroupValidator.php",
        'MediaWikiLangTestCase' => "$testDir/phpunit/MediaWikiLangTestCase.php",
        'MediaWikiLoggerPHPUnitTestListener' => "$testDir/phpunit/MediaWikiLoggerPHPUnitTestListener.php",
        'MediaWikiPHPUnitCommand' => "$testDir/phpunit/MediaWikiPHPUnitCommand.php",
diff --git a/tests/phpunit/MediaWikiGroupValidator.php b/tests/phpunit/MediaWikiGroupValidator.php
new file mode 100644 (file)
index 0000000..4daff34
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+/**
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup Testing
+ */
+
+/**
+ * Trait that provides methods to check if group annotations are valid.
+ */
+trait MediaWikiGroupValidator {
+
+       /**
+        * @return bool
+        * @throws ReflectionException
+        * @since 1.34
+        */
+       public function isTestInDatabaseGroup() {
+               // If the test class says it belongs to the Database group, it needs the database.
+               // NOTE: This ONLY checks for the group in the class level doc comment.
+               $rc = new ReflectionClass( $this );
+               return (bool)preg_match( '/@group +Database/im', $rc->getDocComment() );
+       }
+}
index a5c9ab1..536de24 100644 (file)
@@ -24,6 +24,7 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase {
 
        use MediaWikiCoversValidator;
        use PHPUnit4And6Compat;
+       use MediaWikiGroupValidator;
 
        /**
         * The original service locator. This is overridden during setUp().
@@ -180,7 +181,6 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase {
 
        public static function setUpBeforeClass() {
                parent::setUpBeforeClass();
-               \PHPUnit\Framework\Assert::assertFileExists( 'LocalSettings.php' );
                self::initializeForStandardPhpunitEntrypointIfNeeded();
 
                // Get the original service locator
@@ -1319,17 +1319,6 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase {
                return $this->tablesUsed || $this->isTestInDatabaseGroup();
        }
 
-       /**
-        * @return bool
-        * @since 1.32
-        */
-       protected function isTestInDatabaseGroup() {
-               // If the test class says it belongs to the Database group, it needs the database.
-               // NOTE: This ONLY checks for the group in the class level doc comment.
-               $rc = new ReflectionClass( $this );
-               return (bool)preg_match( '/@group +Database/im', $rc->getDocComment() );
-       }
-
        /**
         * Insert a new page.
         *
index 06f0c9c..1065c2f 100644 (file)
@@ -30,4 +30,5 @@ use PHPUnit\Framework\TestCase;
 abstract class MediaWikiUnitTestCase extends TestCase {
        use PHPUnit4And6Compat;
        use MediaWikiCoversValidator;
+
 }
index 258c822..10348d4 100644 (file)
@@ -65,3 +65,24 @@ require_once "$IP/tests/common/TestSetup.php";
 
 wfRequireOnceInGlobalScope( "$IP/includes/AutoLoader.php" );
 wfRequireOnceInGlobalScope( "$IP/tests/common/TestsAutoLoader.php" );
+wfRequireOnceInGlobalScope( "$IP/includes/Defines.php" );
+wfRequireOnceInGlobalScope( "$IP/includes/DefaultSettings.php" );
+
+// Load extensions/skins present in filesystem so that classes can be discovered.
+$directoryToJsonMap = [
+       'extensions' => [ 'extension.json', 'extension-wip.json' ],
+       'skins' => [ 'skin.json', 'skin-wip.json' ]
+];
+foreach ( $directoryToJsonMap as $directory => $jsonFile ) {
+       foreach ( new DirectoryIterator( __DIR__ . '/../../' . $directory ) as $iterator ) {
+               foreach ( $jsonFile as $file ) {
+                       $jsonPath = $iterator->getPathname() . '/' . $file;
+                       if ( file_exists( $jsonPath ) ) {
+                               $json = file_get_contents( $jsonPath );
+                               $info = json_decode( $json, true );
+                               $dir = dirname( $jsonPath );
+                               ExtensionRegistry::exportAutoloadClassesAndNamespaces( $dir, $info );
+                       }
+               }
+       }
+}
index d20fcff..acbb04a 100644 (file)
@@ -32,38 +32,60 @@ class ReleaseNotesTest extends MediaWikiTestCase {
                foreach ( $notesFiles as $index => $fileName ) {
                        $this->assertFileLength( "Release Notes", $fileName );
                }
+       }
+
+       public static function provideFilesAtRoot() {
+               global $IP;
 
-               // Also test the README and similar files
-               $otherFiles = [
-                       "$IP/COPYING",
-                       "$IP/FAQ",
-                       "$IP/HISTORY",
-                       "$IP/INSTALL",
-                       "$IP/README",
-                       "$IP/SECURITY"
+               $rootFiles = [
+                       "COPYING",
+                       "FAQ",
+                       "HISTORY",
+                       "INSTALL",
+                       "README",
+                       "SECURITY",
                ];
 
-               foreach ( $otherFiles as $index => $fileName ) {
-                       $this->assertFileLength( "Help", $fileName );
+               foreach ( $rootFiles as $rootFile ) {
+                       yield "$rootFile file" => [ "$IP/$rootFile" ];
                }
        }
 
+       /**
+        * @dataProvider provideFilesAtRoot
+        * @coversNothing
+        */
+       public function testRootFilesHaveProperLineLength( $fileName ) {
+               $this->assertFileLength( "Help", $fileName );
+       }
+
        private function assertFileLength( $type, $fileName ) {
-               $file = file( $fileName, FILE_IGNORE_NEW_LINES );
+               $lines = file( $fileName, FILE_IGNORE_NEW_LINES );
 
-               $this->assertFalse(
-                       !$file,
+               $this->assertNotFalse(
+                       $lines,
                        "$type file '$fileName' is inaccessible."
                );
 
-               foreach ( $file as $i => $line ) {
+               $errors = [];
+               foreach ( $lines as $i => $line ) {
                        $num = $i + 1;
-                       $this->assertLessThanOrEqual(
-                               // FILE_IGNORE_NEW_LINES drops the \n at the EOL, so max length is 80 not 81.
-                               80,
-                               mb_strlen( $line ),
-                               "$type file '$fileName' line $num, is longer than 80 chars:\n\t'$line'"
-                       );
+
+                       // FILE_IGNORE_NEW_LINES drops the \n at the EOL, so max length is 80 not 81.
+                       $max_length = 80;
+
+                       $length = mb_strlen( $line );
+                       if ( $length <= $max_length ) {
+                               continue;
+                       }
+                       $errors[] = "line $num: length $length > $max_length:\n$line";
                }
+               # Use assertSame() instead of assertEqual(), to show the full line in the diff
+               $this->assertSame(
+                       [],
+                       $errors,
+                       "$type file '$fileName' lines " .
+                       "have at most $max_length characters"
+               );
        }
 }
diff --git a/tests/phpunit/includes/FauxResponseTest.php b/tests/phpunit/includes/FauxResponseTest.php
deleted file mode 100644 (file)
index 8085bc7..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-<?php
-/**
- * Copyright @ 2011 Alexandre Emsenhuber
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- */
-
-class FauxResponseTest extends MediaWikiTestCase {
-       /** @var FauxResponse */
-       protected $response;
-
-       protected function setUp() {
-               parent::setUp();
-               $this->response = new FauxResponse;
-       }
-
-       /**
-        * @covers FauxResponse::setCookie
-        * @covers FauxResponse::getCookie
-        * @covers FauxResponse::getCookieData
-        * @covers FauxResponse::getCookies
-        */
-       public function testCookie() {
-               $expire = time() + 100;
-               $cookie = [
-                       'value' => 'val',
-                       'path' => '/path',
-                       'domain' => 'domain',
-                       'secure' => true,
-                       'httpOnly' => false,
-                       'raw' => false,
-                       'expire' => $expire,
-               ];
-
-               $this->assertEquals( null, $this->response->getCookie( 'xkey' ), 'Non-existing cookie' );
-               $this->response->setCookie( 'key', 'val', $expire, [
-                       'prefix' => 'x',
-                       'path' => '/path',
-                       'domain' => 'domain',
-                       'secure' => 1,
-                       'httpOnly' => 0,
-               ] );
-               $this->assertEquals( 'val', $this->response->getCookie( 'xkey' ), 'Existing cookie' );
-               $this->assertEquals( $cookie, $this->response->getCookieData( 'xkey' ),
-                       'Existing cookie (data)' );
-               $this->assertEquals( [ 'xkey' => $cookie ], $this->response->getCookies(),
-                       'Existing cookies' );
-       }
-
-       /**
-        * @covers FauxResponse::getheader
-        * @covers FauxResponse::header
-        */
-       public function testHeader() {
-               $this->assertEquals( null, $this->response->getHeader( 'Location' ), 'Non-existing header' );
-
-               $this->response->header( 'Location: http://localhost/' );
-               $this->assertEquals(
-                       'http://localhost/',
-                       $this->response->getHeader( 'Location' ),
-                       'Set header'
-               );
-
-               $this->response->header( 'Location: http://127.0.0.1/' );
-               $this->assertEquals(
-                       'http://127.0.0.1/',
-                       $this->response->getHeader( 'Location' ),
-                       'Same header'
-               );
-
-               $this->response->header( 'Location: http://127.0.0.2/', false );
-               $this->assertEquals(
-                       'http://127.0.0.1/',
-                       $this->response->getHeader( 'Location' ),
-                       'Same header with override disabled'
-               );
-
-               $this->response->header( 'Location: http://localhost/' );
-               $this->assertEquals(
-                       'http://localhost/',
-                       $this->response->getHeader( 'LOCATION' ),
-                       'Get header case insensitive'
-               );
-       }
-
-       /**
-        * @covers FauxResponse::getStatusCode
-        */
-       public function testResponseCode() {
-               $this->response->header( 'HTTP/1.1 200' );
-               $this->assertEquals( 200, $this->response->getStatusCode(), 'Header with no message' );
-
-               $this->response->header( 'HTTP/1.x 201' );
-               $this->assertEquals(
-                       201,
-                       $this->response->getStatusCode(),
-                       'Header with no message and protocol 1.x'
-               );
-
-               $this->response->header( 'HTTP/1.1 202 OK' );
-               $this->assertEquals( 202, $this->response->getStatusCode(), 'Normal header' );
-
-               $this->response->header( 'HTTP/1.x 203 OK' );
-               $this->assertEquals(
-                       203,
-                       $this->response->getStatusCode(),
-                       'Normal header with no message and protocol 1.x'
-               );
-
-               $this->response->header( 'HTTP/1.x 204 OK', false, 205 );
-               $this->assertEquals(
-                       205,
-                       $this->response->getStatusCode(),
-                       'Third parameter overrides the HTTP/... header'
-               );
-
-               $this->response->statusHeader( 210 );
-               $this->assertEquals(
-                       210,
-                       $this->response->getStatusCode(),
-                       'Handle statusHeader method'
-               );
-
-               $this->response->header( 'Location: http://localhost/', false, 206 );
-               $this->assertEquals(
-                       206,
-                       $this->response->getStatusCode(),
-                       'Third parameter with another header'
-               );
-       }
-}
diff --git a/tests/phpunit/includes/FormOptionsInitializationTest.php b/tests/phpunit/includes/FormOptionsInitializationTest.php
deleted file mode 100644 (file)
index 2c78618..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-<?php
-
-use Wikimedia\TestingAccessWrapper;
-
-/**
- * Test class for FormOptions initialization
- * Ensure the FormOptions::add() does what we want it to do.
- *
- * Copyright © 2011, Antoine Musso
- *
- * @author Antoine Musso
- */
-class FormOptionsInitializationTest extends MediaWikiTestCase {
-       /**
-        * @var FormOptions
-        */
-       protected $object;
-
-       /**
-        * A new fresh and empty FormOptions object to test initialization
-        * with.
-        */
-       protected function setUp() {
-               parent::setUp();
-               $this->object = TestingAccessWrapper::newFromObject( new FormOptions() );
-       }
-
-       /**
-        * @covers FormOptions::add
-        */
-       public function testAddStringOption() {
-               $this->object->add( 'foo', 'string value' );
-               $this->assertEquals(
-                       [
-                               'foo' => [
-                                       'default' => 'string value',
-                                       'consumed' => false,
-                                       'type' => FormOptions::STRING,
-                                       'value' => null,
-                               ]
-                       ],
-                       $this->object->options
-               );
-       }
-
-       /**
-        * @covers FormOptions::add
-        */
-       public function testAddIntegers() {
-               $this->object->add( 'one', 1 );
-               $this->object->add( 'negone', -1 );
-               $this->assertEquals(
-                       [
-                               'negone' => [
-                                       'default' => -1,
-                                       'value' => null,
-                                       'consumed' => false,
-                                       'type' => FormOptions::INT,
-                               ],
-                               'one' => [
-                                       'default' => 1,
-                                       'value' => null,
-                                       'consumed' => false,
-                                       'type' => FormOptions::INT,
-                               ]
-                       ],
-                       $this->object->options
-               );
-       }
-}
diff --git a/tests/phpunit/includes/FormOptionsTest.php b/tests/phpunit/includes/FormOptionsTest.php
deleted file mode 100644 (file)
index da08670..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-<?php
-/**
- * This file host two test case classes for the MediaWiki FormOptions class:
- *  - FormOptionsInitializationTest : tests initialization of the class.
- *  - FormOptionsTest : tests methods an on instance
- *
- * The split let us take advantage of setting up a fixture for the methods
- * tests.
- */
-
-/**
- * Test class for FormOptions methods.
- *
- * Copyright © 2011, Antoine Musso
- *
- * @author Antoine Musso
- */
-class FormOptionsTest extends MediaWikiTestCase {
-       /**
-        * @var FormOptions
-        */
-       protected $object;
-
-       /**
-        * Instanciates a FormOptions object to play with.
-        * FormOptions::add() is tested by the class FormOptionsInitializationTest
-        * so we assume the function is well tested already an use it to create
-        * the fixture.
-        */
-       protected function setUp() {
-               parent::setUp();
-               $this->object = new FormOptions;
-               $this->object->add( 'string1', 'string one' );
-               $this->object->add( 'string2', 'string two' );
-               $this->object->add( 'integer', 0 );
-               $this->object->add( 'float', 0.0 );
-               $this->object->add( 'intnull', 0, FormOptions::INTNULL );
-       }
-
-       /** Helpers for testGuessType() */
-       /* @{ */
-       private function assertGuessBoolean( $data ) {
-               $this->guess( FormOptions::BOOL, $data );
-       }
-
-       private function assertGuessInt( $data ) {
-               $this->guess( FormOptions::INT, $data );
-       }
-
-       private function assertGuessFloat( $data ) {
-               $this->guess( FormOptions::FLOAT, $data );
-       }
-
-       private function assertGuessString( $data ) {
-               $this->guess( FormOptions::STRING, $data );
-       }
-
-       private function assertGuessArray( $data ) {
-               $this->guess( FormOptions::ARR, $data );
-       }
-
-       /** Generic helper */
-       private function guess( $expected, $data ) {
-               $this->assertEquals(
-                       $expected,
-                       FormOptions::guessType( $data )
-               );
-       }
-
-       /* @} */
-
-       /**
-        * Reuse helpers above assertGuessBoolean assertGuessInt assertGuessString
-        * @covers FormOptions::guessType
-        */
-       public function testGuessTypeDetection() {
-               $this->assertGuessBoolean( true );
-               $this->assertGuessBoolean( false );
-
-               $this->assertGuessInt( 0 );
-               $this->assertGuessInt( -5 );
-               $this->assertGuessInt( 5 );
-               $this->assertGuessInt( 0x0F );
-
-               $this->assertGuessFloat( 0.0 );
-               $this->assertGuessFloat( 1.5 );
-               $this->assertGuessFloat( 1e3 );
-
-               $this->assertGuessString( 'true' );
-               $this->assertGuessString( 'false' );
-               $this->assertGuessString( '5' );
-               $this->assertGuessString( '0' );
-               $this->assertGuessString( '1.5' );
-
-               $this->assertGuessArray( [ 'foo' ] );
-       }
-
-       /**
-        * @expectedException MWException
-        * @covers FormOptions::guessType
-        */
-       public function testGuessTypeOnNullThrowException() {
-               $this->object->guessType( null );
-       }
-}
diff --git a/tests/phpunit/includes/LicensesTest.php b/tests/phpunit/includes/LicensesTest.php
deleted file mode 100644 (file)
index 0e96bf4..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php
-
-/**
- * @covers Licenses
- */
-class LicensesTest extends MediaWikiTestCase {
-
-       public function testLicenses() {
-               $str = "
-* Free licenses:
-** GFDL|Debian disagrees
-";
-
-               $lc = new Licenses( [
-                       'fieldname' => 'FooField',
-                       'type' => 'select',
-                       'section' => 'description',
-                       'id' => 'wpLicense',
-                       'label' => 'A label text', # Note can't test label-message because $wgOut is not defined
-                       'name' => 'AnotherName',
-                       'licenses' => $str,
-               ] );
-               $this->assertThat( $lc, $this->isInstanceOf( Licenses::class ) );
-       }
-}
diff --git a/tests/phpunit/includes/MediaWikiVersionFetcherTest.php b/tests/phpunit/includes/MediaWikiVersionFetcherTest.php
deleted file mode 100644 (file)
index 9803081..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<?php
-
-/**
- * Note: this is not a unit test, as it touches the file system and reads an actual file.
- * If unit tests are added for MediaWikiVersionFetcher, this should be done in a distinct test case.
- *
- * @covers MediaWikiVersionFetcher
- *
- * @group ComposerHooks
- *
- * @author Jeroen De Dauw < jeroendedauw@gmail.com >
- */
-class MediaWikiVersionFetcherTest extends MediaWikiTestCase {
-
-       public function testReturnsResult() {
-               global $wgVersion;
-               $versionFetcher = new MediaWikiVersionFetcher();
-               $this->assertSame( $wgVersion, $versionFetcher->fetchVersion() );
-       }
-
-}
diff --git a/tests/phpunit/includes/Rest/EntryPointTest.php b/tests/phpunit/includes/Rest/EntryPointTest.php
deleted file mode 100644 (file)
index 4f87a70..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-<?php
-
-namespace MediaWiki\Tests\Rest;
-
-use EmptyBagOStuff;
-use GuzzleHttp\Psr7\Uri;
-use GuzzleHttp\Psr7\Stream;
-use MediaWiki\Rest\Handler;
-use MediaWikiTestCase;
-use MediaWiki\Rest\EntryPoint;
-use MediaWiki\Rest\RequestData;
-use MediaWiki\Rest\ResponseFactory;
-use MediaWiki\Rest\Router;
-use WebResponse;
-
-/**
- * @covers \MediaWiki\Rest\EntryPoint
- * @covers \MediaWiki\Rest\Router
- */
-class EntryPointTest extends MediaWikiTestCase {
-       private static $mockHandler;
-
-       private function createRouter() {
-               return new Router(
-                       [ __DIR__ . '/testRoutes.json' ],
-                       [],
-                       '/rest',
-                       new EmptyBagOStuff(),
-                       new ResponseFactory() );
-       }
-
-       private function createWebResponse() {
-               return $this->getMockBuilder( WebResponse::class )
-                       ->setMethods( [ 'header' ] )
-                       ->getMock();
-       }
-
-       public static function mockHandlerHeader() {
-               return new class extends Handler {
-                       public function execute() {
-                               $response = $this->getResponseFactory()->create();
-                               $response->setHeader( 'Foo', 'Bar' );
-                               return $response;
-                       }
-               };
-       }
-
-       public function testHeader() {
-               $webResponse = $this->createWebResponse();
-               $webResponse->expects( $this->any() )
-                       ->method( 'header' )
-                       ->withConsecutive(
-                               [ 'HTTP/1.1 200 OK', true, null ],
-                               [ 'Foo: Bar', true, null ]
-                       );
-
-               $entryPoint = new EntryPoint(
-                       new RequestData( [ 'uri' => new Uri( '/rest/mock/EntryPoint/header' ) ] ),
-                       $webResponse,
-                       $this->createRouter() );
-               $entryPoint->execute();
-               $this->assertTrue( true );
-       }
-
-       public static function mockHandlerBodyRewind() {
-               return new class extends Handler {
-                       public function execute() {
-                               $response = $this->getResponseFactory()->create();
-                               $stream = new Stream( fopen( 'php://memory', 'w+' ) );
-                               $stream->write( 'hello' );
-                               $response->setBody( $stream );
-                               return $response;
-                       }
-               };
-       }
-
-       /**
-        * Make sure EntryPoint rewinds a seekable body stream before reading.
-        */
-       public function testBodyRewind() {
-               $entryPoint = new EntryPoint(
-                       new RequestData( [ 'uri' => new Uri( '/rest/mock/EntryPoint/bodyRewind' ) ] ),
-                       $this->createWebResponse(),
-                       $this->createRouter() );
-               ob_start();
-               $entryPoint->execute();
-               $this->assertSame( 'hello', ob_get_clean() );
-       }
-
-}
diff --git a/tests/phpunit/includes/Rest/Handler/HelloHandlerTest.php b/tests/phpunit/includes/Rest/Handler/HelloHandlerTest.php
deleted file mode 100644 (file)
index afbaafb..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-<?php
-
-namespace MediaWiki\Tests\Rest\Handler;
-
-use EmptyBagOStuff;
-use GuzzleHttp\Psr7\Uri;
-use MediaWiki\Rest\RequestData;
-use MediaWiki\Rest\ResponseFactory;
-use MediaWiki\Rest\Router;
-use MediaWikiTestCase;
-
-/**
- * @covers \MediaWiki\Rest\Handler\HelloHandler
- */
-class HelloHandlerTest extends MediaWikiTestCase {
-       public static function provideTestViaRouter() {
-               return [
-                       'normal' => [
-                               [
-                                       'method' => 'GET',
-                                       'uri' => self::makeUri( '/user/Tim/hello' ),
-                               ],
-                               [
-                                       'statusCode' => 200,
-                                       'reasonPhrase' => 'OK',
-                                       'protocolVersion' => '1.1',
-                                       'body' => '{"message":"Hello, Tim!"}',
-                               ],
-                       ],
-                       'method not allowed' => [
-                               [
-                                       'method' => 'POST',
-                                       'uri' => self::makeUri( '/user/Tim/hello' ),
-                               ],
-                               [
-                                       'statusCode' => 405,
-                                       'reasonPhrase' => 'Method Not Allowed',
-                                       'protocolVersion' => '1.1',
-                                       'body' => '{"httpCode":405,"httpReason":"Method Not Allowed"}',
-                               ],
-                       ],
-               ];
-       }
-
-       private static function makeUri( $path ) {
-               return new Uri( "http://www.example.com/rest$path" );
-       }
-
-       /** @dataProvider provideTestViaRouter */
-       public function testViaRouter( $requestInfo, $responseInfo ) {
-               $router = new Router(
-                       [ __DIR__ . '/../testRoutes.json' ],
-                       [],
-                       '/rest',
-                       new EmptyBagOStuff(),
-                       new ResponseFactory() );
-               $request = new RequestData( $requestInfo );
-               $response = $router->execute( $request );
-               if ( isset( $responseInfo['statusCode'] ) ) {
-                       $this->assertSame( $responseInfo['statusCode'], $response->getStatusCode() );
-               }
-               if ( isset( $responseInfo['reasonPhrase'] ) ) {
-                       $this->assertSame( $responseInfo['reasonPhrase'], $response->getReasonPhrase() );
-               }
-               if ( isset( $responseInfo['protocolVersion'] ) ) {
-                       $this->assertSame( $responseInfo['protocolVersion'], $response->getProtocolVersion() );
-               }
-               if ( isset( $responseInfo['body'] ) ) {
-                       $this->assertSame( $responseInfo['body'], $response->getBody()->getContents() );
-               }
-               $this->assertSame(
-                       [],
-                       array_diff( array_keys( $responseInfo ), [
-                               'statusCode',
-                               'reasonPhrase',
-                               'protocolVersion',
-                               'body'
-                       ] ),
-                       '$responseInfo may not contain unknown keys' );
-       }
-}
diff --git a/tests/phpunit/includes/Rest/HeaderContainerTest.php b/tests/phpunit/includes/Rest/HeaderContainerTest.php
deleted file mode 100644 (file)
index e0dbfdf..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-<?php
-
-namespace MediaWiki\Tests\Rest;
-
-use MediaWikiTestCase;
-use MediaWiki\Rest\HeaderContainer;
-
-/**
- * @covers \MediaWiki\Rest\HeaderContainer
- */
-class HeaderContainerTest extends MediaWikiTestCase {
-       public static function provideSetHeader() {
-               return [
-                       'simple' => [
-                               [
-                                       [ 'Test', 'foo' ]
-                               ],
-                               [ 'Test' => [ 'foo' ] ],
-                               [ 'Test' => 'foo' ]
-                       ],
-                       'replace' => [
-                               [
-                                       [ 'Test', 'foo' ],
-                                       [ 'Test', 'bar' ],
-                               ],
-                               [ 'Test' => [ 'bar' ] ],
-                               [ 'Test' => 'bar' ],
-                       ],
-                       'array value' => [
-                               [
-                                       [ 'Test', [ '1', '2' ] ],
-                                       [ 'Test', [ '3', '4' ] ],
-                               ],
-                               [ 'Test' => [ '3', '4' ] ],
-                               [ 'Test' => '3, 4' ]
-                       ],
-                       'preserve most recent case' => [
-                               [
-                                       [ 'test', 'foo' ],
-                                       [ 'tesT', 'bar' ],
-                               ],
-                               [ 'tesT' => [ 'bar' ] ],
-                               [ 'tesT' => 'bar' ]
-                       ],
-                       'empty' => [ [], [], [] ],
-               ];
-       }
-
-       /** @dataProvider provideSetHeader */
-       public function testSetHeader( $setOps, $headers, $lines ) {
-               $hc = new HeaderContainer;
-               foreach ( $setOps as list( $name, $value ) ) {
-                       $hc->setHeader( $name, $value );
-               }
-               $this->assertSame( $headers, $hc->getHeaders() );
-               $this->assertSame( $lines, $hc->getHeaderLines() );
-       }
-
-       public static function provideAddHeader() {
-               return [
-                       'simple' => [
-                               [
-                                       [ 'Test', 'foo' ]
-                               ],
-                               [ 'Test' => [ 'foo' ] ],
-                               [ 'Test' => 'foo' ]
-                       ],
-                       'add' => [
-                               [
-                                       [ 'Test', 'foo' ],
-                                       [ 'Test', 'bar' ],
-                               ],
-                               [ 'Test' => [ 'foo', 'bar' ] ],
-                               [ 'Test' => 'foo, bar' ],
-                       ],
-                       'array value' => [
-                               [
-                                       [ 'Test', [ '1', '2' ] ],
-                                       [ 'Test', [ '3', '4' ] ],
-                               ],
-                               [ 'Test' => [ '1', '2', '3', '4' ] ],
-                               [ 'Test' => '1, 2, 3, 4' ]
-                       ],
-                       'preserve original case' => [
-                               [
-                                       [ 'Test', 'foo' ],
-                                       [ 'tesT', 'bar' ],
-                               ],
-                               [ 'Test' => [ 'foo', 'bar' ] ],
-                               [ 'Test' => 'foo, bar' ]
-                       ],
-               ];
-       }
-
-       /** @dataProvider provideAddHeader */
-       public function testAddHeader( $addOps, $headers, $lines ) {
-               $hc = new HeaderContainer;
-               foreach ( $addOps as list( $name, $value ) ) {
-                       $hc->addHeader( $name, $value );
-               }
-               $this->assertSame( $headers, $hc->getHeaders() );
-               $this->assertSame( $lines, $hc->getHeaderLines() );
-       }
-
-       public static function provideRemoveHeader() {
-               return [
-                       'simple' => [
-                               [ [ 'Test', 'foo' ] ],
-                               [ 'Test' ],
-                               [],
-                               []
-                       ],
-                       'case mismatch' => [
-                               [ [ 'Test', 'foo' ] ],
-                               [ 'tesT' ],
-                               [],
-                               []
-                       ],
-                       'remove nonexistent' => [
-                               [ [ 'A', '1' ] ],
-                               [ 'B' ],
-                               [ 'A' => [ '1' ] ],
-                               [ 'A' => '1' ]
-                       ],
-               ];
-       }
-
-       /** @dataProvider provideRemoveHeader */
-       public function testRemoveHeader( $addOps, $removeOps, $headers, $lines ) {
-               $hc = new HeaderContainer;
-               foreach ( $addOps as list( $name, $value ) ) {
-                       $hc->addHeader( $name, $value );
-               }
-               foreach ( $removeOps as $name ) {
-                       $hc->removeHeader( $name );
-               }
-               $this->assertSame( $headers, $hc->getHeaders() );
-               $this->assertSame( $lines, $hc->getHeaderLines() );
-       }
-
-       public function testHasHeader() {
-               $hc = new HeaderContainer;
-               $hc->addHeader( 'A', '1' );
-               $hc->addHeader( 'B', '2' );
-               $hc->addHeader( 'C', '3' );
-               $hc->removeHeader( 'B' );
-               $hc->removeHeader( 'c' );
-               $this->assertTrue( $hc->hasHeader( 'A' ) );
-               $this->assertTrue( $hc->hasHeader( 'a' ) );
-               $this->assertFalse( $hc->hasHeader( 'B' ) );
-               $this->assertFalse( $hc->hasHeader( 'c' ) );
-               $this->assertFalse( $hc->hasHeader( 'C' ) );
-       }
-
-       public function testGetRawHeaderLines() {
-               $hc = new HeaderContainer;
-               $hc->addHeader( 'A', '1' );
-               $hc->addHeader( 'a', '2' );
-               $hc->addHeader( 'b', '3' );
-               $hc->addHeader( 'Set-Cookie', 'x' );
-               $hc->addHeader( 'SET-cookie', 'y' );
-               $this->assertSame(
-                       [
-                               'A: 1, 2',
-                               'b: 3',
-                               'Set-Cookie: x',
-                               'Set-Cookie: y',
-                       ],
-                       $hc->getRawHeaderLines()
-               );
-       }
-}
diff --git a/tests/phpunit/includes/Rest/PathTemplateMatcher/PathMatcherTest.php b/tests/phpunit/includes/Rest/PathTemplateMatcher/PathMatcherTest.php
deleted file mode 100644 (file)
index 935cec1..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-<?php
-
-namespace MediaWiki\Tests\Rest\PathTemplateMatcher;
-
-use MediaWiki\Rest\PathTemplateMatcher\PathConflict;
-use MediaWiki\Rest\PathTemplateMatcher\PathMatcher;
-use MediaWikiTestCase;
-
-/**
- * @covers \MediaWiki\Rest\PathTemplateMatcher\PathMatcher
- * @covers \MediaWiki\Rest\PathTemplateMatcher\PathConflict
- */
-class PathMatcherTest extends MediaWikiTestCase {
-       private static $normalRoutes = [
-               '/a/b',
-               '/b/{x}',
-               '/c/{x}/d',
-               '/c/{x}/e',
-               '/c/{x}/{y}/d',
-       ];
-
-       public static function provideConflictingRoutes() {
-               return [
-                       [ '/a/b', 0, '/a/b' ],
-                       [ '/a/{x}', 0, '/a/b' ],
-                       [ '/{x}/c', 1, '/b/{x}' ],
-                       [ '/b/a', 1, '/b/{x}' ],
-                       [ '/b/{x}', 1, '/b/{x}' ],
-                       [ '/{x}/{y}/d', 2, '/c/{x}/d' ],
-               ];
-       }
-
-       public static function provideMatch() {
-               return [
-                       [ '', false ],
-                       [ '/a/b', [ 'params' => [], 'userData' => 0 ] ],
-                       [ '/b', false ],
-                       [ '/b/1', [ 'params' => [ 'x' => '1' ], 'userData' => 1 ] ],
-                       [ '/c/1/d', [ 'params' => [ 'x' => '1' ], 'userData' => 2 ] ],
-                       [ '/c/1/e', [ 'params' => [ 'x' => '1' ], 'userData' => 3 ] ],
-                       [ '/c/000/e', [ 'params' => [ 'x' => '000' ], 'userData' => 3 ] ],
-                       [ '/c/1/f', false ],
-                       [ '/c//e', [ 'params' => [ 'x' => '' ], 'userData' => 3 ] ],
-                       [ '/c///e', false ],
-               ];
-       }
-
-       public function createNormalRouter() {
-               $pm = new PathMatcher;
-               foreach ( self::$normalRoutes as $i => $route ) {
-                       $pm->add( $route, $i );
-               }
-               return $pm;
-       }
-
-       /** @dataProvider provideConflictingRoutes */
-       public function testAddConflict( $attempt, $expectedUserData, $expectedTemplate ) {
-               $pm = $this->createNormalRouter();
-               $actualTemplate = null;
-               $actualUserData = null;
-               try {
-                       $pm->add( $attempt, 'conflict' );
-               } catch ( PathConflict $pc ) {
-                       $actualTemplate = $pc->existingTemplate;
-                       $actualUserData = $pc->existingUserData;
-               }
-               $this->assertSame( $expectedUserData, $actualUserData );
-               $this->assertSame( $expectedTemplate, $actualTemplate );
-       }
-
-       /** @dataProvider provideMatch */
-       public function testMatch( $path, $expectedResult ) {
-               $pm = $this->createNormalRouter();
-               $result = $pm->match( $path );
-               $this->assertSame( $expectedResult, $result );
-       }
-}
diff --git a/tests/phpunit/includes/Rest/StringStreamTest.php b/tests/phpunit/includes/Rest/StringStreamTest.php
deleted file mode 100644 (file)
index f474643..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-<?php
-
-namespace MediaWiki\Tests\Rest;
-
-use MediaWiki\Rest\StringStream;
-use MediaWikiTestCase;
-
-/** @covers \MediaWiki\Rest\StringStream */
-class StringStreamTest extends MediaWikiTestCase {
-       public static function provideSeekGetContents() {
-               return [
-                       [ 'abcde', 0, SEEK_SET, 'abcde' ],
-                       [ 'abcde', 1, SEEK_SET, 'bcde' ],
-                       [ 'abcde', 5, SEEK_SET, '' ],
-                       [ 'abcde', 1, SEEK_CUR, 'cde' ],
-                       [ 'abcde', 0, SEEK_END, '' ],
-               ];
-       }
-
-       /** @dataProvider provideSeekGetContents */
-       public function testCopyToStream( $input, $offset, $whence, $expected ) {
-               $ss = new StringStream;
-               $ss->write( $input );
-               $ss->seek( 1 );
-               $ss->seek( $offset, $whence );
-               $destStream = fopen( 'php://memory', 'w+' );
-               $ss->copyToStream( $destStream );
-               fseek( $destStream, 0 );
-               $result = stream_get_contents( $destStream );
-               $this->assertSame( $expected, $result );
-       }
-
-       public function testGetSize() {
-               $ss = new StringStream;
-               $this->assertSame( 0, $ss->getSize() );
-               $ss->write( "hello" );
-               $this->assertSame( 5, $ss->getSize() );
-               $ss->rewind();
-               $this->assertSame( 5, $ss->getSize() );
-       }
-
-       public function testTell() {
-               $ss = new StringStream;
-               $this->assertSame( $ss->tell(), 0 );
-               $ss->write( "abc" );
-               $this->assertSame( $ss->tell(), 3 );
-               $ss->seek( 0 );
-               $ss->read( 1 );
-               $this->assertSame( $ss->tell(), 1 );
-       }
-
-       public function testEof() {
-               $ss = new StringStream( 'abc' );
-               $this->assertFalse( $ss->eof() );
-               $ss->read( 1 );
-               $this->assertFalse( $ss->eof() );
-               $ss->read( 1 );
-               $this->assertFalse( $ss->eof() );
-               $ss->read( 1 );
-               $this->assertTrue( $ss->eof() );
-               $ss->rewind();
-               $this->assertFalse( $ss->eof() );
-       }
-
-       public function testIsSeekable() {
-               $ss = new StringStream;
-               $this->assertTrue( $ss->isSeekable() );
-       }
-
-       public function testIsReadable() {
-               $ss = new StringStream;
-               $this->assertTrue( $ss->isReadable() );
-       }
-
-       public function testIsWritable() {
-               $ss = new StringStream;
-               $this->assertTrue( $ss->isWritable() );
-       }
-
-       public function testSeekWrite() {
-               $ss = new StringStream;
-               $this->assertSame( '', (string)$ss );
-               $ss->write( 'a' );
-               $this->assertSame( 'a', (string)$ss );
-               $ss->write( 'b' );
-               $this->assertSame( 'ab', (string)$ss );
-               $ss->seek( 1 );
-               $ss->write( 'c' );
-               $this->assertSame( 'ac', (string)$ss );
-       }
-
-       /** @dataProvider provideSeekGetContents */
-       public function testSeekGetContents( $input, $offset, $whence, $expected ) {
-               $ss = new StringStream( $input );
-               $ss->seek( 1 );
-               $ss->seek( $offset, $whence );
-               $this->assertSame( $expected, $ss->getContents() );
-       }
-
-       public static function provideSeekRead() {
-               return [
-                       [ 'abcde', 0, SEEK_SET, 1, 'a' ],
-                       [ 'abcde', 0, SEEK_SET, 2, 'ab' ],
-                       [ 'abcde', 4, SEEK_SET, 2, 'e' ],
-                       [ 'abcde', 5, SEEK_SET, 1, '' ],
-                       [ 'abcde', 1, SEEK_CUR, 1, 'c' ],
-                       [ 'abcde', 0, SEEK_END, 1, '' ],
-                       [ 'abcde', -1, SEEK_END, 1, 'e' ],
-               ];
-       }
-
-       /** @dataProvider provideSeekRead */
-       public function testSeekRead( $input, $offset, $whence, $length, $expected ) {
-               $ss = new StringStream( $input );
-               $ss->seek( 1 );
-               $ss->seek( $offset, $whence );
-               $this->assertSame( $expected, $ss->read( $length ) );
-       }
-
-       /** @expectedException \InvalidArgumentException */
-       public function testReadBeyondEnd() {
-               $ss = new StringStream( 'abc' );
-               $ss->seek( 1, SEEK_END );
-       }
-
-       /** @expectedException \InvalidArgumentException */
-       public function testReadBeforeStart() {
-               $ss = new StringStream( 'abc' );
-               $ss->seek( -1 );
-       }
-}
diff --git a/tests/phpunit/includes/Rest/testRoutes.json b/tests/phpunit/includes/Rest/testRoutes.json
deleted file mode 100644 (file)
index 7e43bb0..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-[
-       {
-               "path": "/user/{name}/hello",
-               "class": "MediaWiki\\Rest\\Handler\\HelloHandler"
-       },
-       {
-               "path": "/mock/EntryPoint/header",
-               "factory": "MediaWiki\\Tests\\Rest\\EntryPointTest::mockHandlerHeader"
-       },
-       {
-               "path": "/mock/EntryPoint/bodyRewind",
-               "factory": "MediaWiki\\Tests\\Rest\\EntryPointTest::mockHandlerBodyRewind"
-       }
-]
diff --git a/tests/phpunit/includes/Revision/FallbackSlotRoleHandlerTest.php b/tests/phpunit/includes/Revision/FallbackSlotRoleHandlerTest.php
deleted file mode 100644 (file)
index 898a35f..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-<?php
-
-namespace MediaWiki\Tests\Revision;
-
-use MediaWiki\Revision\FallbackSlotRoleHandler;
-use MediaWikiTestCase;
-use Title;
-
-/**
- * @covers \MediaWiki\Revision\FallbackSlotRoleHandler
- */
-class FallbackSlotRoleHandlerTest extends MediaWikiTestCase {
-
-       /**
-        * @return Title
-        */
-       private function makeBlankTitleObject() {
-               return $this->createMock( Title::class );
-       }
-
-       /**
-        * @covers \MediaWiki\Revision\FallbackSlotRoleHandler::__construct
-        * @covers \MediaWiki\Revision\FallbackSlotRoleHandler::getRole()
-        * @covers \MediaWiki\Revision\FallbackSlotRoleHandler::getNameMessageKey()
-        * @covers \MediaWiki\Revision\FallbackSlotRoleHandler::getDefaultModel()
-        * @covers \MediaWiki\Revision\FallbackSlotRoleHandler::getOutputLayoutHints()
-        */
-       public function testConstruction() {
-               $handler = new FallbackSlotRoleHandler( 'foo' );
-               $this->assertSame( 'foo', $handler->getRole() );
-               $this->assertSame( 'slot-name-foo', $handler->getNameMessageKey() );
-
-               $title = $this->makeBlankTitleObject();
-               $this->assertSame( CONTENT_MODEL_TEXT, $handler->getDefaultModel( $title ) );
-
-               $hints = $handler->getOutputLayoutHints();
-               $this->assertArrayHasKey( 'display', $hints );
-               $this->assertArrayHasKey( 'region', $hints );
-               $this->assertArrayHasKey( 'placement', $hints );
-       }
-
-       /**
-        * @covers \MediaWiki\Revision\FallbackSlotRoleHandler::isAllowedModel()
-        */
-       public function testIsAllowedModel() {
-               $handler = new FallbackSlotRoleHandler( 'foo', 'FooModel' );
-
-               // For the fallback handler, no models are allowed
-               $title = $this->makeBlankTitleObject();
-               $this->assertFalse( $handler->isAllowedModel( 'FooModel', $title ) );
-               $this->assertFalse( $handler->isAllowedModel( 'QuaxModel', $title ) );
-       }
-
-       /**
-        * @covers \MediaWiki\Revision\SlotRoleHandler::isAllowedModel()
-        */
-       public function testIsAllowedOn() {
-               $handler = new FallbackSlotRoleHandler( 'foo', 'FooModel' );
-
-               $title = $this->makeBlankTitleObject();
-               $this->assertFalse( $handler->isAllowedOn( $title ) );
-       }
-
-       /**
-        * @covers \MediaWiki\Revision\FallbackSlotRoleHandler::supportsArticleCount()
-        */
-       public function testSupportsArticleCount() {
-               $handler = new FallbackSlotRoleHandler( 'foo', 'FooModel' );
-
-               $this->assertFalse( $handler->supportsArticleCount() );
-       }
-
-}
diff --git a/tests/phpunit/includes/Revision/RevisionStoreFactoryTest.php b/tests/phpunit/includes/Revision/RevisionStoreFactoryTest.php
deleted file mode 100644 (file)
index 84c815d..0000000
+++ /dev/null
@@ -1,194 +0,0 @@
-<?php
-
-namespace MediaWiki\Tests\Revision;
-
-use ActorMigration;
-use CommentStore;
-use MediaWiki\Logger\Spi as LoggerSpi;
-use MediaWiki\Revision\RevisionStore;
-use MediaWiki\Revision\RevisionStoreFactory;
-use MediaWiki\Revision\SlotRoleRegistry;
-use MediaWiki\Storage\BlobStore;
-use MediaWiki\Storage\BlobStoreFactory;
-use MediaWiki\Storage\NameTableStore;
-use MediaWiki\Storage\NameTableStoreFactory;
-use MediaWiki\Storage\SqlBlobStore;
-use MediaWikiTestCase;
-use Psr\Log\LoggerInterface;
-use Psr\Log\NullLogger;
-use WANObjectCache;
-use Wikimedia\Rdbms\ILBFactory;
-use Wikimedia\Rdbms\ILoadBalancer;
-use Wikimedia\TestingAccessWrapper;
-
-class RevisionStoreFactoryTest extends MediaWikiTestCase {
-
-       /**
-        * @covers \MediaWiki\Revision\RevisionStoreFactory::__construct
-        */
-       public function testValidConstruction_doesntCauseErrors() {
-               new RevisionStoreFactory(
-                       $this->getMockLoadBalancerFactory(),
-                       $this->getMockBlobStoreFactory(),
-                       $this->getNameTableStoreFactory(),
-                       $this->getMockSlotRoleRegistry(),
-                       $this->getHashWANObjectCache(),
-                       $this->getMockCommentStore(),
-                       ActorMigration::newMigration(),
-                       MIGRATION_OLD,
-                       $this->getMockLoggerSpi(),
-                       true
-               );
-               $this->assertTrue( true );
-       }
-
-       public function provideWikiIds() {
-               yield [ true ];
-               yield [ false ];
-               yield [ 'somewiki' ];
-               yield [ 'somewiki', MIGRATION_OLD , false ];
-               yield [ 'somewiki', MIGRATION_NEW , true ];
-       }
-
-       /**
-        * @dataProvider provideWikiIds
-        * @covers \MediaWiki\Revision\RevisionStoreFactory::getRevisionStore
-        */
-       public function testGetRevisionStore(
-               $dbDomain,
-               $mcrMigrationStage = MIGRATION_OLD,
-               $contentHandlerUseDb = true
-       ) {
-               $lbFactory = $this->getMockLoadBalancerFactory();
-               $blobStoreFactory = $this->getMockBlobStoreFactory();
-               $nameTableStoreFactory = $this->getNameTableStoreFactory();
-               $slotRoleRegistry = $this->getMockSlotRoleRegistry();
-               $cache = $this->getHashWANObjectCache();
-               $commentStore = $this->getMockCommentStore();
-               $actorMigration = ActorMigration::newMigration();
-               $loggerProvider = $this->getMockLoggerSpi();
-
-               $factory = new RevisionStoreFactory(
-                       $lbFactory,
-                       $blobStoreFactory,
-                       $nameTableStoreFactory,
-                       $slotRoleRegistry,
-                       $cache,
-                       $commentStore,
-                       $actorMigration,
-                       $mcrMigrationStage,
-                       $loggerProvider,
-                       $contentHandlerUseDb
-               );
-
-               $store = $factory->getRevisionStore( $dbDomain );
-               $wrapper = TestingAccessWrapper::newFromObject( $store );
-
-               // ensure the correct object type is returned
-               $this->assertInstanceOf( RevisionStore::class, $store );
-
-               // ensure the RevisionStore is for the given wikiId
-               $this->assertSame( $dbDomain, $wrapper->dbDomain );
-
-               // ensure all other required services are correctly set
-               $this->assertSame( $cache, $wrapper->cache );
-               $this->assertSame( $commentStore, $wrapper->commentStore );
-               $this->assertSame( $mcrMigrationStage, $wrapper->mcrMigrationStage );
-               $this->assertSame( $actorMigration, $wrapper->actorMigration );
-               $this->assertSame( $contentHandlerUseDb, $store->getContentHandlerUseDB() );
-
-               $this->assertInstanceOf( ILoadBalancer::class, $wrapper->loadBalancer );
-               $this->assertInstanceOf( BlobStore::class, $wrapper->blobStore );
-               $this->assertInstanceOf( NameTableStore::class, $wrapper->contentModelStore );
-               $this->assertInstanceOf( NameTableStore::class, $wrapper->slotRoleStore );
-               $this->assertInstanceOf( LoggerInterface::class, $wrapper->logger );
-       }
-
-       /**
-        * @return \PHPUnit_Framework_MockObject_MockObject|ILoadBalancer
-        */
-       private function getMockLoadBalancer() {
-               return $this->getMockBuilder( ILoadBalancer::class )
-                       ->disableOriginalConstructor()->getMock();
-       }
-
-       /**
-        * @return \PHPUnit_Framework_MockObject_MockObject|ILBFactory
-        */
-       private function getMockLoadBalancerFactory() {
-               $mock = $this->getMockBuilder( ILBFactory::class )
-                       ->disableOriginalConstructor()->getMock();
-
-               $mock->method( 'getMainLB' )
-                       ->willReturnCallback( function () {
-                               return $this->getMockLoadBalancer();
-                       } );
-
-               return $mock;
-       }
-
-       /**
-        * @return \PHPUnit_Framework_MockObject_MockObject|SqlBlobStore
-        */
-       private function getMockSqlBlobStore() {
-               return $this->getMockBuilder( SqlBlobStore::class )
-                       ->disableOriginalConstructor()->getMock();
-       }
-
-       /**
-        * @return \PHPUnit_Framework_MockObject_MockObject|BlobStoreFactory
-        */
-       private function getMockBlobStoreFactory() {
-               $mock = $this->getMockBuilder( BlobStoreFactory::class )
-                       ->disableOriginalConstructor()->getMock();
-
-               $mock->method( 'newSqlBlobStore' )
-                       ->willReturnCallback( function () {
-                               return $this->getMockSqlBlobStore();
-                       } );
-
-               return $mock;
-       }
-
-       /**
-        * @return SlotRoleRegistry
-        */
-       private function getMockSlotRoleRegistry() {
-               return $this->createMock( SlotRoleRegistry::class );
-       }
-
-       /**
-        * @return NameTableStoreFactory
-        */
-       private function getNameTableStoreFactory() {
-               return new NameTableStoreFactory(
-                       $this->getMockLoadBalancerFactory(),
-                       $this->getHashWANObjectCache(),
-                       new NullLogger() );
-       }
-
-       /**
-        * @return \PHPUnit_Framework_MockObject_MockObject|CommentStore
-        */
-       private function getMockCommentStore() {
-               return $this->getMockBuilder( CommentStore::class )
-                       ->disableOriginalConstructor()->getMock();
-       }
-
-       private function getHashWANObjectCache() {
-               return new WANObjectCache( [ 'cache' => new \HashBagOStuff() ] );
-       }
-
-       /**
-        * @return \PHPUnit_Framework_MockObject_MockObject|LoggerSpi
-        */
-       private function getMockLoggerSpi() {
-               $mock = $this->getMock( LoggerSpi::class );
-
-               $mock->method( 'getLogger' )
-                       ->willReturn( new NullLogger() );
-
-               return $mock;
-       }
-
-}
diff --git a/tests/phpunit/includes/Revision/SlotRoleHandlerTest.php b/tests/phpunit/includes/Revision/SlotRoleHandlerTest.php
deleted file mode 100644 (file)
index 372a879..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-<?php
-
-namespace MediaWiki\Tests\Revision;
-
-use MediaWiki\Revision\SlotRoleHandler;
-use MediaWikiTestCase;
-use Title;
-
-/**
- * @covers \MediaWiki\Revision\SlotRoleHandler
- */
-class SlotRoleHandlerTest extends MediaWikiTestCase {
-
-       /**
-        * @return Title
-        */
-       private function makeBlankTitleObject() {
-               return $this->createMock( Title::class );
-       }
-
-       /**
-        * @covers \MediaWiki\Revision\SlotRoleHandler::__construct
-        * @covers \MediaWiki\Revision\SlotRoleHandler::getRole()
-        * @covers \MediaWiki\Revision\SlotRoleHandler::getNameMessageKey()
-        * @covers \MediaWiki\Revision\SlotRoleHandler::getDefaultModel()
-        * @covers \MediaWiki\Revision\SlotRoleHandler::getOutputLayoutHints()
-        */
-       public function testConstruction() {
-               $handler = new SlotRoleHandler( 'foo', 'FooModel', [ 'frob' => 'niz' ] );
-               $this->assertSame( 'foo', $handler->getRole() );
-               $this->assertSame( 'slot-name-foo', $handler->getNameMessageKey() );
-
-               $title = $this->makeBlankTitleObject();
-               $this->assertSame( 'FooModel', $handler->getDefaultModel( $title ) );
-
-               $hints = $handler->getOutputLayoutHints();
-               $this->assertArrayHasKey( 'frob', $hints );
-               $this->assertSame( 'niz', $hints['frob'] );
-
-               $this->assertArrayHasKey( 'display', $hints );
-               $this->assertArrayHasKey( 'region', $hints );
-               $this->assertArrayHasKey( 'placement', $hints );
-       }
-
-       /**
-        * @covers \MediaWiki\Revision\SlotRoleHandler::isAllowedModel()
-        */
-       public function testIsAllowedModel() {
-               $handler = new SlotRoleHandler( 'foo', 'FooModel' );
-
-               $title = $this->makeBlankTitleObject();
-               $this->assertTrue( $handler->isAllowedModel( 'FooModel', $title ) );
-               $this->assertFalse( $handler->isAllowedModel( 'QuaxModel', $title ) );
-       }
-
-       /**
-        * @covers \MediaWiki\Revision\SlotRoleHandler::supportsArticleCount()
-        */
-       public function testSupportsArticleCount() {
-               $handler = new SlotRoleHandler( 'foo', 'FooModel' );
-
-               $this->assertFalse( $handler->supportsArticleCount() );
-       }
-
-}
diff --git a/tests/phpunit/includes/ServiceWiringTest.php b/tests/phpunit/includes/ServiceWiringTest.php
deleted file mode 100644 (file)
index 02e06f8..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-<?php
-
-/**
- * @coversNothing
- */
-class ServiceWiringTest extends MediaWikiTestCase {
-       public function testServicesAreSorted() {
-               global $IP;
-               $services = array_keys( require "$IP/includes/ServiceWiring.php" );
-               $sortedServices = $services;
-               natcasesort( $sortedServices );
-
-               $this->assertSame( $sortedServices, $services,
-                       'Please keep services sorted alphabetically' );
-       }
-}
diff --git a/tests/phpunit/includes/SiteConfigurationTest.php b/tests/phpunit/includes/SiteConfigurationTest.php
deleted file mode 100644 (file)
index 3b72262..0000000
+++ /dev/null
@@ -1,379 +0,0 @@
-<?php
-
-class SiteConfigurationTest extends MediaWikiTestCase {
-
-       /**
-        * @var SiteConfiguration
-        */
-       protected $mConf;
-
-       protected function setUp() {
-               parent::setUp();
-
-               $this->mConf = new SiteConfiguration;
-
-               $this->mConf->suffixes = [ 'wikipedia' => 'wiki' ];
-               $this->mConf->wikis = [ 'enwiki', 'dewiki', 'frwiki' ];
-               $this->mConf->settings = [
-                       'SimpleKey' => [
-                               'wiki' => 'wiki',
-                               'tag' => 'tag',
-                               'enwiki' => 'enwiki',
-                               'dewiki' => 'dewiki',
-                               'frwiki' => 'frwiki',
-                       ],
-
-                       'Fallback' => [
-                               'default' => 'default',
-                               'wiki' => 'wiki',
-                               'tag' => 'tag',
-                               'frwiki' => 'frwiki',
-                               'null_wiki' => null,
-                       ],
-
-                       'WithParams' => [
-                               'default' => '$lang $site $wiki',
-                       ],
-
-                       '+SomeGlobal' => [
-                               'wiki' => [
-                                       'wiki' => 'wiki',
-                               ],
-                               'tag' => [
-                                       'tag' => 'tag',
-                               ],
-                               'enwiki' => [
-                                       'enwiki' => 'enwiki',
-                               ],
-                               'dewiki' => [
-                                       'dewiki' => 'dewiki',
-                               ],
-                               'frwiki' => [
-                                       'frwiki' => 'frwiki',
-                               ],
-                       ],
-
-                       'MergeIt' => [
-                               '+wiki' => [
-                                       'wiki' => 'wiki',
-                               ],
-                               '+tag' => [
-                                       'tag' => 'tag',
-                               ],
-                               'default' => [
-                                       'default' => 'default',
-                               ],
-                               '+enwiki' => [
-                                       'enwiki' => 'enwiki',
-                               ],
-                               '+dewiki' => [
-                                       'dewiki' => 'dewiki',
-                               ],
-                               '+frwiki' => [
-                                       'frwiki' => 'frwiki',
-                               ],
-                       ],
-               ];
-
-               $GLOBALS['SomeGlobal'] = [ 'SomeGlobal' => 'SomeGlobal' ];
-       }
-
-       /**
-        * This function is used as a callback within the tests below
-        */
-       public static function getSiteParamsCallback( $conf, $wiki ) {
-               $site = null;
-               $lang = null;
-               foreach ( $conf->suffixes as $suffix ) {
-                       if ( substr( $wiki, -strlen( $suffix ) ) == $suffix ) {
-                               $site = $suffix;
-                               $lang = substr( $wiki, 0, -strlen( $suffix ) );
-                               break;
-                       }
-               }
-
-               return [
-                       'suffix' => $site,
-                       'lang' => $lang,
-                       'params' => [
-                               'lang' => $lang,
-                               'site' => $site,
-                               'wiki' => $wiki,
-                       ],
-                       'tags' => [ 'tag' ],
-               ];
-       }
-
-       /**
-        * @covers SiteConfiguration::siteFromDB
-        */
-       public function testSiteFromDb() {
-               $this->assertEquals(
-                       [ 'wikipedia', 'en' ],
-                       $this->mConf->siteFromDB( 'enwiki' ),
-                       'siteFromDB()'
-               );
-               $this->assertEquals(
-                       [ 'wikipedia', '' ],
-                       $this->mConf->siteFromDB( 'wiki' ),
-                       'siteFromDB() on a suffix'
-               );
-               $this->assertEquals(
-                       [ null, null ],
-                       $this->mConf->siteFromDB( 'wikien' ),
-                       'siteFromDB() on a non-existing wiki'
-               );
-
-               $this->mConf->suffixes = [ 'wiki', '' ];
-               $this->assertEquals(
-                       [ '', 'wikien' ],
-                       $this->mConf->siteFromDB( 'wikien' ),
-                       'siteFromDB() on a non-existing wiki (2)'
-               );
-       }
-
-       /**
-        * @covers SiteConfiguration::getLocalDatabases
-        */
-       public function testGetLocalDatabases() {
-               $this->assertEquals(
-                       [ 'enwiki', 'dewiki', 'frwiki' ],
-                       $this->mConf->getLocalDatabases(),
-                       'getLocalDatabases()'
-               );
-       }
-
-       /**
-        * @covers SiteConfiguration::get
-        */
-       public function testGetConfVariables() {
-               // Simple
-               $this->assertEquals(
-                       'enwiki',
-                       $this->mConf->get( 'SimpleKey', 'enwiki', 'wiki' ),
-                       'get(): simple setting on an existing wiki'
-               );
-               $this->assertEquals(
-                       'dewiki',
-                       $this->mConf->get( 'SimpleKey', 'dewiki', 'wiki' ),
-                       'get(): simple setting on an existing wiki (2)'
-               );
-               $this->assertEquals(
-                       'frwiki',
-                       $this->mConf->get( 'SimpleKey', 'frwiki', 'wiki' ),
-                       'get(): simple setting on an existing wiki (3)'
-               );
-               $this->assertEquals(
-                       'wiki',
-                       $this->mConf->get( 'SimpleKey', 'wiki', 'wiki' ),
-                       'get(): simple setting on an suffix'
-               );
-               $this->assertEquals(
-                       'wiki',
-                       $this->mConf->get( 'SimpleKey', 'eswiki', 'wiki' ),
-                       'get(): simple setting on an non-existing wiki'
-               );
-
-               // Fallback
-               $this->assertEquals(
-                       'wiki',
-                       $this->mConf->get( 'Fallback', 'enwiki', 'wiki' ),
-                       'get(): fallback setting on an existing wiki'
-               );
-               $this->assertEquals(
-                       'tag',
-                       $this->mConf->get( 'Fallback', 'dewiki', 'wiki', [], [ 'tag' ] ),
-                       'get(): fallback setting on an existing wiki (with wiki tag)'
-               );
-               $this->assertEquals(
-                       'frwiki',
-                       $this->mConf->get( 'Fallback', 'frwiki', 'wiki', [], [ 'tag' ] ),
-                       'get(): no fallback if wiki has its own setting (matching tag)'
-               );
-               $this->assertSame(
-                       // Potential regression test for T192855
-                       null,
-                       $this->mConf->get( 'Fallback', 'null_wiki', 'wiki', [], [ 'tag' ] ),
-                       'get(): no fallback if wiki has its own setting (matching tag and uses null)'
-               );
-               $this->assertEquals(
-                       'wiki',
-                       $this->mConf->get( 'Fallback', 'wiki', 'wiki' ),
-                       'get(): fallback setting on an suffix'
-               );
-               $this->assertEquals(
-                       'wiki',
-                       $this->mConf->get( 'Fallback', 'wiki', 'wiki', [], [ 'tag' ] ),
-                       'get(): fallback setting on an suffix (with wiki tag)'
-               );
-               $this->assertEquals(
-                       'wiki',
-                       $this->mConf->get( 'Fallback', 'eswiki', 'wiki' ),
-                       'get(): fallback setting on an non-existing wiki'
-               );
-               $this->assertEquals(
-                       'tag',
-                       $this->mConf->get( 'Fallback', 'eswiki', 'wiki', [], [ 'tag' ] ),
-                       'get(): fallback setting on an non-existing wiki (with wiki tag)'
-               );
-
-               // Merging
-               $common = [ 'wiki' => 'wiki', 'default' => 'default' ];
-               $commonTag = [ 'tag' => 'tag', 'wiki' => 'wiki', 'default' => 'default' ];
-               $this->assertEquals(
-                       [ 'enwiki' => 'enwiki' ] + $common,
-                       $this->mConf->get( 'MergeIt', 'enwiki', 'wiki' ),
-                       'get(): merging setting on an existing wiki'
-               );
-               $this->assertEquals(
-                       [ 'enwiki' => 'enwiki' ] + $commonTag,
-                       $this->mConf->get( 'MergeIt', 'enwiki', 'wiki', [], [ 'tag' ] ),
-                       'get(): merging setting on an existing wiki (with tag)'
-               );
-               $this->assertEquals(
-                       [ 'dewiki' => 'dewiki' ] + $common,
-                       $this->mConf->get( 'MergeIt', 'dewiki', 'wiki' ),
-                       'get(): merging setting on an existing wiki (2)'
-               );
-               $this->assertEquals(
-                       [ 'dewiki' => 'dewiki' ] + $commonTag,
-                       $this->mConf->get( 'MergeIt', 'dewiki', 'wiki', [], [ 'tag' ] ),
-                       'get(): merging setting on an existing wiki (2) (with tag)'
-               );
-               $this->assertEquals(
-                       [ 'frwiki' => 'frwiki' ] + $common,
-                       $this->mConf->get( 'MergeIt', 'frwiki', 'wiki' ),
-                       'get(): merging setting on an existing wiki (3)'
-               );
-               $this->assertEquals(
-                       [ 'frwiki' => 'frwiki' ] + $commonTag,
-                       $this->mConf->get( 'MergeIt', 'frwiki', 'wiki', [], [ 'tag' ] ),
-                       'get(): merging setting on an existing wiki (3) (with tag)'
-               );
-               $this->assertEquals(
-                       [ 'wiki' => 'wiki' ] + $common,
-                       $this->mConf->get( 'MergeIt', 'wiki', 'wiki' ),
-                       'get(): merging setting on an suffix'
-               );
-               $this->assertEquals(
-                       [ 'wiki' => 'wiki' ] + $commonTag,
-                       $this->mConf->get( 'MergeIt', 'wiki', 'wiki', [], [ 'tag' ] ),
-                       'get(): merging setting on an suffix (with tag)'
-               );
-               $this->assertEquals(
-                       $common,
-                       $this->mConf->get( 'MergeIt', 'eswiki', 'wiki' ),
-                       'get(): merging setting on an non-existing wiki'
-               );
-               $this->assertEquals(
-                       $commonTag,
-                       $this->mConf->get( 'MergeIt', 'eswiki', 'wiki', [], [ 'tag' ] ),
-                       'get(): merging setting on an non-existing wiki (with tag)'
-               );
-       }
-
-       /**
-        * @covers SiteConfiguration::siteFromDB
-        */
-       public function testSiteFromDbWithCallback() {
-               $this->mConf->siteParamsCallback = 'SiteConfigurationTest::getSiteParamsCallback';
-
-               $this->assertEquals(
-                       [ 'wiki', 'en' ],
-                       $this->mConf->siteFromDB( 'enwiki' ),
-                       'siteFromDB() with callback'
-               );
-               $this->assertEquals(
-                       [ 'wiki', '' ],
-                       $this->mConf->siteFromDB( 'wiki' ),
-                       'siteFromDB() with callback on a suffix'
-               );
-               $this->assertEquals(
-                       [ null, null ],
-                       $this->mConf->siteFromDB( 'wikien' ),
-                       'siteFromDB() with callback on a non-existing wiki'
-               );
-       }
-
-       /**
-        * @covers SiteConfiguration::get
-        */
-       public function testParameterReplacement() {
-               $this->mConf->siteParamsCallback = 'SiteConfigurationTest::getSiteParamsCallback';
-
-               $this->assertEquals(
-                       'en wiki enwiki',
-                       $this->mConf->get( 'WithParams', 'enwiki', 'wiki' ),
-                       'get(): parameter replacement on an existing wiki'
-               );
-               $this->assertEquals(
-                       'de wiki dewiki',
-                       $this->mConf->get( 'WithParams', 'dewiki', 'wiki' ),
-                       'get(): parameter replacement on an existing wiki (2)'
-               );
-               $this->assertEquals(
-                       'fr wiki frwiki',
-                       $this->mConf->get( 'WithParams', 'frwiki', 'wiki' ),
-                       'get(): parameter replacement on an existing wiki (3)'
-               );
-               $this->assertEquals(
-                       ' wiki wiki',
-                       $this->mConf->get( 'WithParams', 'wiki', 'wiki' ),
-                       'get(): parameter replacement on an suffix'
-               );
-               $this->assertEquals(
-                       'es wiki eswiki',
-                       $this->mConf->get( 'WithParams', 'eswiki', 'wiki' ),
-                       'get(): parameter replacement on an non-existing wiki'
-               );
-       }
-
-       /**
-        * @covers SiteConfiguration::getAll
-        */
-       public function testGetAllGlobals() {
-               $this->mConf->siteParamsCallback = 'SiteConfigurationTest::getSiteParamsCallback';
-
-               $getall = [
-                       'SimpleKey' => 'enwiki',
-                       'Fallback' => 'tag',
-                       'WithParams' => 'en wiki enwiki',
-                       'SomeGlobal' => [ 'enwiki' => 'enwiki' ] + $GLOBALS['SomeGlobal'],
-                       'MergeIt' => [
-                               'enwiki' => 'enwiki',
-                               'tag' => 'tag',
-                               'wiki' => 'wiki',
-                               'default' => 'default'
-                       ],
-               ];
-               $this->assertEquals( $getall, $this->mConf->getAll( 'enwiki' ), 'getAll()' );
-
-               $this->mConf->extractAllGlobals( 'enwiki', 'wiki' );
-
-               $this->assertEquals(
-                       $getall['SimpleKey'],
-                       $GLOBALS['SimpleKey'],
-                       'extractAllGlobals(): simple setting'
-               );
-               $this->assertEquals(
-                       $getall['Fallback'],
-                       $GLOBALS['Fallback'],
-                       'extractAllGlobals(): fallback setting'
-               );
-               $this->assertEquals(
-                       $getall['WithParams'],
-                       $GLOBALS['WithParams'],
-                       'extractAllGlobals(): parameter replacement'
-               );
-               $this->assertEquals(
-                       $getall['SomeGlobal'],
-                       $GLOBALS['SomeGlobal'],
-                       'extractAllGlobals(): merging with global'
-               );
-               $this->assertEquals(
-                       $getall['MergeIt'],
-                       $GLOBALS['MergeIt'],
-                       'extractAllGlobals(): merging setting'
-               );
-       }
-}
diff --git a/tests/phpunit/includes/Storage/PreparedEditTest.php b/tests/phpunit/includes/Storage/PreparedEditTest.php
deleted file mode 100644 (file)
index 29999ee..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<?php
-
-namespace MediaWiki\Edit;
-
-use ParserOutput;
-use MediaWikiTestCase;
-
-/**
- * @covers \MediaWiki\Edit\PreparedEdit
- */
-class PreparedEditTest extends MediaWikiTestCase {
-       function testCallback() {
-               $output = new ParserOutput();
-               $edit = new PreparedEdit();
-               $edit->parserOutputCallback = function () {
-                       return new ParserOutput();
-               };
-
-               $this->assertEquals( $output, $edit->getOutput() );
-               $this->assertEquals( $output, $edit->output );
-       }
-}
index 225a786..9b021c4 100644 (file)
@@ -494,17 +494,31 @@ class TitleTest extends MediaWikiTestCase {
         */
        public function testGetBaseText( $title, $expected, $msg = '' ) {
                $title = Title::newFromText( $title );
-               $this->assertEquals( $expected,
+               $this->assertSame( $expected,
                        $title->getBaseText(),
                        $msg
                );
        }
 
+       /**
+        * @dataProvider provideBaseTitleCases
+        * @covers Title::getBaseTitle
+        */
+       public function testGetBaseTitle( $title, $expected, $msg = '' ) {
+               $title = Title::newFromText( $title );
+               $base = $title->getBaseTitle();
+               $this->assertTrue( $base->isValid(), $msg );
+               $this->assertTrue(
+                       $base->equals( Title::makeTitleSafe( $title->getNamespace(), $expected ) ),
+                       $msg
+               );
+       }
+
        public static function provideBaseTitleCases() {
                return [
                        # Title, expected base, optional message
                        [ 'User:John_Doe/subOne/subTwo', 'John Doe/subOne' ],
-                       [ 'User:Foo/Bar/Baz', 'Foo/Bar' ],
+                       [ 'User:Foo / Bar / Baz', 'Foo / Bar ' ],
                ];
        }
 
@@ -520,11 +534,25 @@ class TitleTest extends MediaWikiTestCase {
                );
        }
 
+       /**
+        * @dataProvider provideRootTitleCases
+        * @covers Title::getRootTitle
+        */
+       public function testGetRootTitle( $title, $expected, $msg = '' ) {
+               $title = Title::newFromText( $title );
+               $root = $title->getRootTitle();
+               $this->assertTrue( $root->isValid(), $msg );
+               $this->assertTrue(
+                       $root->equals( Title::makeTitleSafe( $title->getNamespace(), $expected ) ),
+                       $msg
+               );
+       }
+
        public static function provideRootTitleCases() {
                return [
                        # Title, expected base, optional message
                        [ 'User:John_Doe/subOne/subTwo', 'John Doe' ],
-                       [ 'User:Foo/Bar/Baz', 'Foo' ],
+                       [ 'User:Foo / Bar / Baz', 'Foo ' ],
                ];
        }
 
@@ -709,6 +737,12 @@ class TitleTest extends MediaWikiTestCase {
                        [ Title::makeTitle( NS_MAIN, '|' ), false ],
                        [ Title::makeTitle( NS_MAIN, '#' ), false ],
                        [ Title::makeTitle( NS_MAIN, 'Test' ), true ],
+                       [ Title::makeTitle( NS_MAIN, ' Test' ), false ],
+                       [ Title::makeTitle( NS_MAIN, '_Test' ), false ],
+                       [ Title::makeTitle( NS_MAIN, 'Test ' ), false ],
+                       [ Title::makeTitle( NS_MAIN, 'Test_' ), false ],
+                       [ Title::makeTitle( NS_MAIN, "Test\nthis" ), false ],
+                       [ Title::makeTitle( NS_MAIN, "Test\tthis" ), false ],
                        [ Title::makeTitle( -33, 'Test' ), false ],
                        [ Title::makeTitle( 77663399, 'Test' ), false ],
                ];
diff --git a/tests/phpunit/includes/XmlSelectTest.php b/tests/phpunit/includes/XmlSelectTest.php
deleted file mode 100644 (file)
index 52e20bd..0000000
+++ /dev/null
@@ -1,182 +0,0 @@
-<?php
-
-/**
- * @group Xml
- */
-class XmlSelectTest extends MediaWikiTestCase {
-
-       /**
-        * @var XmlSelect
-        */
-       protected $select;
-
-       protected function setUp() {
-               parent::setUp();
-               $this->select = new XmlSelect();
-       }
-
-       protected function tearDown() {
-               parent::tearDown();
-               $this->select = null;
-       }
-
-       /**
-        * @covers XmlSelect::__construct
-        */
-       public function testConstructWithoutParameters() {
-               $this->assertEquals( '<select></select>', $this->select->getHTML() );
-       }
-
-       /**
-        * Parameters are $name (false), $id (false), $default (false)
-        * @dataProvider provideConstructionParameters
-        * @covers XmlSelect::__construct
-        */
-       public function testConstructParameters( $name, $id, $default, $expected ) {
-               $this->select = new XmlSelect( $name, $id, $default );
-               $this->assertEquals( $expected, $this->select->getHTML() );
-       }
-
-       /**
-        * Provide parameters for testConstructParameters() which use three
-        * parameters:
-        *  - $name    (default: false)
-        *  - $id      (default: false)
-        *  - $default (default: false)
-        * Provides a fourth parameters representing the expected HTML output
-        */
-       public static function provideConstructionParameters() {
-               return [
-                       /**
-                        * Values are set following a 3-bit Gray code where two successive
-                        * values differ by only one value.
-                        * See https://en.wikipedia.org/wiki/Gray_code
-                        */
-                       #      $name   $id    $default
-                       [ false, false, false, '<select></select>' ],
-                       [ false, false, 'foo', '<select></select>' ],
-                       [ false, 'id', 'foo', '<select id="id"></select>' ],
-                       [ false, 'id', false, '<select id="id"></select>' ],
-                       [ 'name', 'id', false, '<select name="name" id="id"></select>' ],
-                       [ 'name', 'id', 'foo', '<select name="name" id="id"></select>' ],
-                       [ 'name', false, 'foo', '<select name="name"></select>' ],
-                       [ 'name', false, false, '<select name="name"></select>' ],
-               ];
-       }
-
-       /**
-        * @covers XmlSelect::addOption
-        */
-       public function testAddOption() {
-               $this->select->addOption( 'foo' );
-               $this->assertEquals(
-                       '<select><option value="foo">foo</option></select>',
-                       $this->select->getHTML()
-               );
-       }
-
-       /**
-        * @covers XmlSelect::addOption
-        */
-       public function testAddOptionWithDefault() {
-               $this->select->addOption( 'foo', true );
-               $this->assertEquals(
-                       '<select><option value="1">foo</option></select>',
-                       $this->select->getHTML()
-               );
-       }
-
-       /**
-        * @covers XmlSelect::addOption
-        */
-       public function testAddOptionWithFalse() {
-               $this->select->addOption( 'foo', false );
-               $this->assertEquals(
-                       '<select><option value="foo">foo</option></select>',
-                       $this->select->getHTML()
-               );
-       }
-
-       /**
-        * @covers XmlSelect::addOption
-        */
-       public function testAddOptionWithValueZero() {
-               $this->select->addOption( 'foo', 0 );
-               $this->assertEquals(
-                       '<select><option value="0">foo</option></select>',
-                       $this->select->getHTML()
-               );
-       }
-
-       /**
-        * @covers XmlSelect::setDefault
-        */
-       public function testSetDefault() {
-               $this->select->setDefault( 'bar1' );
-               $this->select->addOption( 'foo1' );
-               $this->select->addOption( 'bar1' );
-               $this->select->addOption( 'foo2' );
-               $this->assertEquals(
-                       '<select><option value="foo1">foo1</option>' . "\n" .
-                               '<option value="bar1" selected="">bar1</option>' . "\n" .
-                               '<option value="foo2">foo2</option></select>', $this->select->getHTML() );
-       }
-
-       /**
-        * Adding default later on should set the correct selection or
-        * raise an exception.
-        * To handle this, we need to render the options in getHtml()
-        * @covers XmlSelect::setDefault
-        */
-       public function testSetDefaultAfterAddingOptions() {
-               $this->select->addOption( 'foo1' );
-               $this->select->addOption( 'bar1' );
-               $this->select->addOption( 'foo2' );
-               $this->select->setDefault( 'bar1' ); # setting default after adding options
-               $this->assertEquals(
-                       '<select><option value="foo1">foo1</option>' . "\n" .
-                               '<option value="bar1" selected="">bar1</option>' . "\n" .
-                               '<option value="foo2">foo2</option></select>', $this->select->getHTML() );
-       }
-
-       /**
-        * @covers XmlSelect::setAttribute
-        * @covers XmlSelect::getAttribute
-        */
-       public function testGetAttributes() {
-               # create some attributes
-               $this->select->setAttribute( 'dummy', 0x777 );
-               $this->select->setAttribute( 'string', 'euro €' );
-               $this->select->setAttribute( 1911, 'razor' );
-
-               # verify we can retrieve them
-               $this->assertEquals(
-                       $this->select->getAttribute( 'dummy' ),
-                       0x777
-               );
-               $this->assertEquals(
-                       $this->select->getAttribute( 'string' ),
-                       'euro €'
-               );
-               $this->assertEquals(
-                       $this->select->getAttribute( 1911 ),
-                       'razor'
-               );
-
-               # inexistent keys should give us 'null'
-               $this->assertEquals(
-                       $this->select->getAttribute( 'I DO NOT EXIT' ),
-                       null
-               );
-
-               # verify string / integer
-               $this->assertEquals(
-                       $this->select->getAttribute( '1911' ),
-                       'razor'
-               );
-               $this->assertEquals(
-                       $this->select->getAttribute( 'dummy' ),
-                       0x777
-               );
-       }
-}
index 3badd28..5e5fea3 100644 (file)
@@ -1383,57 +1383,6 @@ class ApiEditPageTest extends ApiTestCase {
                }
        }
 
-       public function testEditAbortedByHook() {
-               $name = 'Help:' . ucfirst( __FUNCTION__ );
-
-               $this->setExpectedException( ApiUsageException::class,
-                       'The modification you tried to make was aborted by an extension.' );
-
-               $this->hideDeprecated( 'APIEditBeforeSave hook (used in ' .
-                       'hook-APIEditBeforeSave-closure)' );
-
-               $this->setTemporaryHook( 'APIEditBeforeSave',
-                       function () {
-                               return false;
-                       }
-               );
-
-               try {
-                       $this->doApiRequestWithToken( [
-                               'action' => 'edit',
-                               'title' => $name,
-                               'text' => 'Some text',
-                       ] );
-               } finally {
-                       $this->assertFalse( Title::newFromText( $name )->exists() );
-               }
-       }
-
-       public function testEditAbortedByHookWithCustomOutput() {
-               $name = 'Help:' . ucfirst( __FUNCTION__ );
-
-               $this->hideDeprecated( 'APIEditBeforeSave hook (used in ' .
-                       'hook-APIEditBeforeSave-closure)' );
-
-               $this->setTemporaryHook( 'APIEditBeforeSave',
-                       function ( $unused1, $unused2, &$r ) {
-                               $r['msg'] = 'Some message';
-                               return false;
-                       } );
-
-               $result = $this->doApiRequestWithToken( [
-                       'action' => 'edit',
-                       'title' => $name,
-                       'text' => 'Some text',
-               ] );
-               Wikimedia\restoreWarnings();
-
-               $this->assertSame( [ 'msg' => 'Some message', 'result' => 'Failure' ],
-                       $result[0]['edit'] );
-
-               $this->assertFalse( Title::newFromText( $name )->exists() );
-       }
-
        public function testEditAbortedByEditPageHookWithResult() {
                $name = 'Help:' . ucfirst( __FUNCTION__ );
 
diff --git a/tests/phpunit/includes/auth/AuthenticationResponseTest.php b/tests/phpunit/includes/auth/AuthenticationResponseTest.php
deleted file mode 100644 (file)
index c796822..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-<?php
-
-namespace MediaWiki\Auth;
-
-/**
- * @group AuthManager
- * @covers \MediaWiki\Auth\AuthenticationResponse
- */
-class AuthenticationResponseTest extends \MediaWikiTestCase {
-       /**
-        * @dataProvider provideConstructors
-        * @param string $constructor
-        * @param array $args
-        * @param array|Exception $expect
-        */
-       public function testConstructors( $constructor, $args, $expect ) {
-               if ( is_array( $expect ) ) {
-                       $res = new AuthenticationResponse();
-                       $res->messageType = 'warning';
-                       foreach ( $expect as $field => $value ) {
-                               $res->$field = $value;
-                       }
-                       $ret = call_user_func_array( "MediaWiki\\Auth\\AuthenticationResponse::$constructor", $args );
-                       $this->assertEquals( $res, $ret );
-               } else {
-                       try {
-                               call_user_func_array( "MediaWiki\\Auth\\AuthenticationResponse::$constructor", $args );
-                               $this->fail( 'Expected exception not thrown' );
-                       } catch ( \Exception $ex ) {
-                               $this->assertEquals( $expect, $ex );
-                       }
-               }
-       }
-
-       public function provideConstructors() {
-               $req = $this->getMockForAbstractClass( AuthenticationRequest::class );
-               $msg = new \Message( 'mainpage' );
-
-               return [
-                       [ 'newPass', [], [
-                               'status' => AuthenticationResponse::PASS,
-                       ] ],
-                       [ 'newPass', [ 'name' ], [
-                               'status' => AuthenticationResponse::PASS,
-                               'username' => 'name',
-                       ] ],
-                       [ 'newPass', [ 'name', null ], [
-                               'status' => AuthenticationResponse::PASS,
-                               'username' => 'name',
-                       ] ],
-
-                       [ 'newFail', [ $msg ], [
-                               'status' => AuthenticationResponse::FAIL,
-                               'message' => $msg,
-                               'messageType' => 'error',
-                       ] ],
-
-                       [ 'newRestart', [ $msg ], [
-                               'status' => AuthenticationResponse::RESTART,
-                               'message' => $msg,
-                       ] ],
-
-                       [ 'newAbstain', [], [
-                               'status' => AuthenticationResponse::ABSTAIN,
-                       ] ],
-
-                       [ 'newUI', [ [ $req ], $msg ], [
-                               'status' => AuthenticationResponse::UI,
-                               'neededRequests' => [ $req ],
-                               'message' => $msg,
-                               'messageType' => 'warning',
-                       ] ],
-
-                       [ 'newUI', [ [ $req ], $msg, 'warning' ], [
-                               'status' => AuthenticationResponse::UI,
-                               'neededRequests' => [ $req ],
-                               'message' => $msg,
-                               'messageType' => 'warning',
-                       ] ],
-
-                       [ 'newUI', [ [ $req ], $msg, 'error' ], [
-                               'status' => AuthenticationResponse::UI,
-                               'neededRequests' => [ $req ],
-                               'message' => $msg,
-                               'messageType' => 'error',
-                       ] ],
-                       [ 'newUI', [ [], $msg ],
-                               new \InvalidArgumentException( '$reqs may not be empty' )
-                       ],
-
-                       [ 'newRedirect', [ [ $req ], 'http://example.org/redir' ], [
-                               'status' => AuthenticationResponse::REDIRECT,
-                               'neededRequests' => [ $req ],
-                               'redirectTarget' => 'http://example.org/redir',
-                       ] ],
-                       [
-                               'newRedirect',
-                               [ [ $req ], 'http://example.org/redir', [ 'foo' => 'bar' ] ],
-                               [
-                                       'status' => AuthenticationResponse::REDIRECT,
-                                       'neededRequests' => [ $req ],
-                                       'redirectTarget' => 'http://example.org/redir',
-                                       'redirectApiData' => [ 'foo' => 'bar' ],
-                               ]
-                       ],
-                       [ 'newRedirect', [ [], 'http://example.org/redir' ],
-                               new \InvalidArgumentException( '$reqs may not be empty' )
-                       ],
-               ];
-       }
-
-}
index 40fe4c8..892add9 100644 (file)
@@ -323,4 +323,62 @@ class BlockManagerTest extends MediaWikiTestCase {
 
                $this->assertSame( 2, count( $method->invoke( $blockManager, $blocks ) ) );
        }
+
+       /**
+        * @covers ::trackBlockWithCookie
+        * @dataProvider provideTrackBlockWithCookie
+        * @param bool $expectCookieSet
+        * @param bool $hasCookie
+        * @param bool $isBlocked
+        */
+       public function testTrackBlockWithCookie( $expectCookieSet, $hasCookie, $isBlocked ) {
+               $blockID = 123;
+               $this->setMwGlobals( 'wgCookiePrefix', '' );
+
+               $request = new FauxRequest();
+               if ( $hasCookie ) {
+                       $request->setCookie( 'BlockID', 'the value does not matter' );
+               }
+
+               if ( $isBlocked ) {
+                       $block = $this->getMockBuilder( DatabaseBlock::class )
+                               ->setMethods( [ 'getType', 'getId' ] )
+                               ->getMock();
+                       $block->method( 'getType' )
+                               ->willReturn( DatabaseBlock::TYPE_IP );
+                       $block->method( 'getId' )
+                               ->willReturn( $blockID );
+               } else {
+                       $block = null;
+               }
+
+               $user = $this->getMockBuilder( User::class )
+                       ->setMethods( [ 'getBlock', 'getRequest' ] )
+                       ->getMock();
+               $user->method( 'getBlock' )
+                       ->willReturn( $block );
+               $user->method( 'getRequest' )
+                       ->willReturn( $request );
+               /** @var User $user */
+
+               // Although the block cookie is set via DeferredUpdates, in command line mode updates are
+               // processed immediately
+               $blockManager = $this->getBlockManager( [] );
+               $blockManager->trackBlockWithCookie( $user );
+
+               /** @var FauxResponse $response */
+               $response = $request->response();
+               $this->assertCount( $expectCookieSet ? 1 : 0, $response->getCookies() );
+               $this->assertEquals( $expectCookieSet ? $blockID : null, $response->getCookie( 'BlockID' ) );
+       }
+
+       public function provideTrackBlockWithCookie() {
+               return [
+                       // $expectCookieSet, $hasCookie, $isBlocked
+                       [ false, false, false ],
+                       [ false, true, false ],
+                       [ true, false, true ],
+                       [ false, true, true ],
+               ];
+       }
 }
diff --git a/tests/phpunit/includes/changes/ChangesListFilterGroupTest.php b/tests/phpunit/includes/changes/ChangesListFilterGroupTest.php
deleted file mode 100644 (file)
index 6190516..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-<?php
-
-/**
- * @covers ChangesListFilterGroup
- */
-class ChangesListFilterGroupTest extends MediaWikiTestCase {
-       /**
-        * phpcs:disable Generic.Files.LineLength
-        * @expectedException MWException
-        * @expectedExceptionMessage Group names may not contain '_'.  Use the naming convention: 'camelCase'
-        * phpcs:enable
-        */
-       public function testReservedCharacter() {
-               new MockChangesListFilterGroup(
-                       [
-                               'type' => 'some_type',
-                               'name' => 'group_name',
-                               'priority' => 1,
-                               'filters' => [],
-                       ]
-               );
-       }
-
-       public function testAutoPriorities() {
-               $group = new MockChangesListFilterGroup(
-                       [
-                               'type' => 'some_type',
-                               'name' => 'groupName',
-                               'isFullCoverage' => true,
-                               'priority' => 1,
-                               'filters' => [
-                                       [ 'name' => 'hidefoo' ],
-                                       [ 'name' => 'hidebar' ],
-                                       [ 'name' => 'hidebaz' ],
-                               ],
-                       ]
-               );
-
-               $filters = $group->getFilters();
-               $this->assertEquals(
-                       [
-                               -2,
-                               -3,
-                               -4,
-                       ],
-                       array_map(
-                               function ( $f ) {
-                                       return $f->getPriority();
-                               },
-                               array_values( $filters )
-                       )
-               );
-       }
-
-       // Get without warnings
-       public function testGetFilter() {
-               $group = new MockChangesListFilterGroup(
-                       [
-                               'type' => 'some_type',
-                               'name' => 'groupName',
-                               'isFullCoverage' => true,
-                               'priority' => 1,
-                               'filters' => [
-                                       [ 'name' => 'foo' ],
-                               ],
-                       ]
-               );
-
-               $this->assertEquals(
-                       'foo',
-                       $group->getFilter( 'foo' )->getName()
-               );
-
-               $this->assertEquals(
-                       null,
-                       $group->getFilter( 'bar' )
-               );
-       }
-}
diff --git a/tests/phpunit/includes/config/ConfigFactoryTest.php b/tests/phpunit/includes/config/ConfigFactoryTest.php
deleted file mode 100644 (file)
index ea747af..0000000
+++ /dev/null
@@ -1,168 +0,0 @@
-<?php
-
-use MediaWiki\MediaWikiServices;
-
-class ConfigFactoryTest extends MediaWikiTestCase {
-
-       /**
-        * @covers ConfigFactory::register
-        */
-       public function testRegister() {
-               $factory = new ConfigFactory();
-               $factory->register( 'unittest', 'GlobalVarConfig::newInstance' );
-               $this->assertInstanceOf( GlobalVarConfig::class, $factory->makeConfig( 'unittest' ) );
-       }
-
-       /**
-        * @covers ConfigFactory::register
-        */
-       public function testRegisterInvalid() {
-               $factory = new ConfigFactory();
-               $this->setExpectedException( InvalidArgumentException::class );
-               $factory->register( 'invalid', 'Invalid callback' );
-       }
-
-       /**
-        * @covers ConfigFactory::register
-        */
-       public function testRegisterInvalidInstance() {
-               $factory = new ConfigFactory();
-               $this->setExpectedException( InvalidArgumentException::class );
-               $factory->register( 'invalidInstance', new stdClass );
-       }
-
-       /**
-        * @covers ConfigFactory::register
-        */
-       public function testRegisterInstance() {
-               $config = GlobalVarConfig::newInstance();
-               $factory = new ConfigFactory();
-               $factory->register( 'unittest', $config );
-               $this->assertSame( $config, $factory->makeConfig( 'unittest' ) );
-       }
-
-       /**
-        * @covers ConfigFactory::register
-        */
-       public function testRegisterAgain() {
-               $factory = new ConfigFactory();
-               $factory->register( 'unittest', 'GlobalVarConfig::newInstance' );
-               $config1 = $factory->makeConfig( 'unittest' );
-
-               $factory->register( 'unittest', 'GlobalVarConfig::newInstance' );
-               $config2 = $factory->makeConfig( 'unittest' );
-
-               $this->assertNotSame( $config1, $config2 );
-       }
-
-       /**
-        * @covers ConfigFactory::salvage
-        */
-       public function testSalvage() {
-               $oldFactory = new ConfigFactory();
-               $oldFactory->register( 'foo', 'GlobalVarConfig::newInstance' );
-               $oldFactory->register( 'bar', 'GlobalVarConfig::newInstance' );
-               $oldFactory->register( 'quux', 'GlobalVarConfig::newInstance' );
-
-               // instantiate two of the three defined configurations
-               $foo = $oldFactory->makeConfig( 'foo' );
-               $bar = $oldFactory->makeConfig( 'bar' );
-               $quux = $oldFactory->makeConfig( 'quux' );
-
-               // define new config instance
-               $newFactory = new ConfigFactory();
-               $newFactory->register( 'foo', 'GlobalVarConfig::newInstance' );
-               $newFactory->register( 'bar', function () {
-                       return new HashConfig();
-               } );
-
-               // "foo" and "quux" are defined in the old and the new factory.
-               // The old factory has instances for "foo" and "bar", but not "quux".
-               $newFactory->salvage( $oldFactory );
-
-               $newFoo = $newFactory->makeConfig( 'foo' );
-               $this->assertSame( $foo, $newFoo, 'existing instance should be salvaged' );
-
-               $newBar = $newFactory->makeConfig( 'bar' );
-               $this->assertNotSame( $bar, $newBar, 'don\'t salvage if callbacks differ' );
-
-               // the new factory doesn't have quux defined, so the quux instance should not be salvaged
-               $this->setExpectedException( ConfigException::class );
-               $newFactory->makeConfig( 'quux' );
-       }
-
-       /**
-        * @covers ConfigFactory::getConfigNames
-        */
-       public function testGetConfigNames() {
-               $factory = new ConfigFactory();
-               $factory->register( 'foo', 'GlobalVarConfig::newInstance' );
-               $factory->register( 'bar', new HashConfig() );
-
-               $this->assertEquals( [ 'foo', 'bar' ], $factory->getConfigNames() );
-       }
-
-       /**
-        * @covers ConfigFactory::makeConfig
-        */
-       public function testMakeConfigWithCallback() {
-               $factory = new ConfigFactory();
-               $factory->register( 'unittest', 'GlobalVarConfig::newInstance' );
-
-               $conf = $factory->makeConfig( 'unittest' );
-               $this->assertInstanceOf( Config::class, $conf );
-               $this->assertSame( $conf, $factory->makeConfig( 'unittest' ) );
-       }
-
-       /**
-        * @covers ConfigFactory::makeConfig
-        */
-       public function testMakeConfigWithObject() {
-               $factory = new ConfigFactory();
-               $conf = new HashConfig();
-               $factory->register( 'test', $conf );
-               $this->assertSame( $conf, $factory->makeConfig( 'test' ) );
-       }
-
-       /**
-        * @covers ConfigFactory::makeConfig
-        */
-       public function testMakeConfigFallback() {
-               $factory = new ConfigFactory();
-               $factory->register( '*', 'GlobalVarConfig::newInstance' );
-               $conf = $factory->makeConfig( 'unittest' );
-               $this->assertInstanceOf( Config::class, $conf );
-       }
-
-       /**
-        * @covers ConfigFactory::makeConfig
-        */
-       public function testMakeConfigWithNoBuilders() {
-               $factory = new ConfigFactory();
-               $this->setExpectedException( ConfigException::class );
-               $factory->makeConfig( 'nobuilderregistered' );
-       }
-
-       /**
-        * @covers ConfigFactory::makeConfig
-        */
-       public function testMakeConfigWithInvalidCallback() {
-               $factory = new ConfigFactory();
-               $factory->register( 'unittest', function () {
-                       return true; // Not a Config object
-               } );
-               $this->setExpectedException( UnexpectedValueException::class );
-               $factory->makeConfig( 'unittest' );
-       }
-
-       /**
-        * @covers ConfigFactory::getDefaultInstance
-        */
-       public function testGetDefaultInstance() {
-               // NOTE: the global config factory returned here has been overwritten
-               // for operation in test mode. It may not reflect LocalSettings.
-               $factory = MediaWikiServices::getInstance()->getConfigFactory();
-               $this->assertInstanceOf( Config::class, $factory->makeConfig( 'main' ) );
-       }
-
-}
diff --git a/tests/phpunit/includes/config/HashConfigTest.php b/tests/phpunit/includes/config/HashConfigTest.php
deleted file mode 100644 (file)
index bac8311..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-<?php
-
-class HashConfigTest extends MediaWikiTestCase {
-
-       /**
-        * @covers HashConfig::newInstance
-        */
-       public function testNewInstance() {
-               $conf = HashConfig::newInstance();
-               $this->assertInstanceOf( HashConfig::class, $conf );
-       }
-
-       /**
-        * @covers HashConfig::__construct
-        */
-       public function testConstructor() {
-               $conf = new HashConfig();
-               $this->assertInstanceOf( HashConfig::class, $conf );
-
-               // Test passing arguments to the constructor
-               $conf2 = new HashConfig( [
-                       'one' => '1',
-               ] );
-               $this->assertEquals( '1', $conf2->get( 'one' ) );
-       }
-
-       /**
-        * @covers HashConfig::get
-        */
-       public function testGet() {
-               $conf = new HashConfig( [
-                       'one' => '1',
-               ] );
-               $this->assertEquals( '1', $conf->get( 'one' ) );
-               $this->setExpectedException( ConfigException::class, 'HashConfig::get: undefined option' );
-               $conf->get( 'two' );
-       }
-
-       /**
-        * @covers HashConfig::has
-        */
-       public function testHas() {
-               $conf = new HashConfig( [
-                       'one' => '1',
-               ] );
-               $this->assertTrue( $conf->has( 'one' ) );
-               $this->assertFalse( $conf->has( 'two' ) );
-       }
-
-       /**
-        * @covers HashConfig::set
-        */
-       public function testSet() {
-               $conf = new HashConfig( [
-                       'one' => '1',
-               ] );
-               $conf->set( 'two', '2' );
-               $this->assertEquals( '2', $conf->get( 'two' ) );
-               // Check that set overwrites
-               $conf->set( 'one', '3' );
-               $this->assertEquals( '3', $conf->get( 'one' ) );
-       }
-}
diff --git a/tests/phpunit/includes/config/MultiConfigTest.php b/tests/phpunit/includes/config/MultiConfigTest.php
deleted file mode 100644 (file)
index fc28395..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-
-class MultiConfigTest extends MediaWikiTestCase {
-
-       /**
-        * Tests that settings are fetched in the right order
-        *
-        * @covers MultiConfig::__construct
-        * @covers MultiConfig::get
-        */
-       public function testGet() {
-               $multi = new MultiConfig( [
-                       new HashConfig( [ 'foo' => 'bar' ] ),
-                       new HashConfig( [ 'foo' => 'baz', 'bar' => 'foo' ] ),
-                       new HashConfig( [ 'bar' => 'baz' ] ),
-               ] );
-
-               $this->assertEquals( 'bar', $multi->get( 'foo' ) );
-               $this->assertEquals( 'foo', $multi->get( 'bar' ) );
-               $this->setExpectedException( ConfigException::class, 'MultiConfig::get: undefined option:' );
-               $multi->get( 'notset' );
-       }
-
-       /**
-        * @covers MultiConfig::has
-        */
-       public function testHas() {
-               $conf = new MultiConfig( [
-                       new HashConfig( [ 'foo' => 'foo' ] ),
-                       new HashConfig( [ 'something' => 'bleh' ] ),
-                       new HashConfig( [ 'meh' => 'eh' ] ),
-               ] );
-
-               $this->assertTrue( $conf->has( 'foo' ) );
-               $this->assertTrue( $conf->has( 'something' ) );
-               $this->assertTrue( $conf->has( 'meh' ) );
-               $this->assertFalse( $conf->has( 'what' ) );
-       }
-}
diff --git a/tests/phpunit/includes/config/ServiceOptionsTest.php b/tests/phpunit/includes/config/ServiceOptionsTest.php
deleted file mode 100644 (file)
index 966cf41..0000000
+++ /dev/null
@@ -1,149 +0,0 @@
-<?php
-
-use MediaWiki\Config\ServiceOptions;
-
-/**
- * @coversDefaultClass \MediaWiki\Config\ServiceOptions
- */
-class ServiceOptionsTest extends MediaWikiTestCase {
-       public static $testObj;
-
-       public static function setUpBeforeClass() {
-               parent::setUpBeforeClass();
-
-               self::$testObj = new stdclass();
-       }
-
-       /**
-        * @dataProvider provideConstructor
-        * @covers ::__construct
-        * @covers ::assertRequiredOptions
-        * @covers ::get
-        */
-       public function testConstructor( $expected, $keys, ...$sources ) {
-               $options = new ServiceOptions( $keys, ...$sources );
-
-               foreach ( $expected as $key => $val ) {
-                       $this->assertSame( $val, $options->get( $key ) );
-               }
-
-               // This is lumped in the same test because there's no support for depending on a test that
-               // has a data provider.
-               $options->assertRequiredOptions( array_keys( $expected ) );
-
-               // Suppress warning if no assertions were run. This is expected for empty arguments.
-               $this->assertTrue( true );
-       }
-
-       public function provideConstructor() {
-               return [
-                       'No keys' => [ [], [], [ 'a' => 'aval' ] ],
-                       'Simple array source' => [
-                               [ 'a' => 'aval', 'b' => 'bval' ],
-                               [ 'a', 'b' ],
-                               [ 'a' => 'aval', 'b' => 'bval', 'c' => 'cval' ],
-                       ],
-                       'Simple HashConfig source' => [
-                               [ 'a' => 'aval', 'b' => 'bval' ],
-                               [ 'a', 'b' ],
-                               new HashConfig( [ 'a' => 'aval', 'b' => 'bval', 'c' => 'cval' ] ),
-                       ],
-                       'Three different sources' => [
-                               [ 'a' => 'aval', 'b' => 'bval' ],
-                               [ 'a', 'b' ],
-                               [ 'z' => 'zval' ],
-                               new HashConfig( [ 'a' => 'aval', 'c' => 'cval' ] ),
-                               [ 'b' => 'bval', 'd' => 'dval' ],
-                       ],
-                       'null key' => [
-                               [ 'a' => null ],
-                               [ 'a' ],
-                               [ 'a' => null ],
-                       ],
-                       'Numeric option name' => [
-                               [ '0' => 'nothing' ],
-                               [ '0' ],
-                               [ '0' => 'nothing' ],
-                       ],
-                       'Multiple sources for one key' => [
-                               [ 'a' => 'winner' ],
-                               [ 'a' ],
-                               [ 'a' => 'winner' ],
-                               [ 'a' => 'second place' ],
-                       ],
-                       'Object value is passed by reference' => [
-                               [ 'a' => self::$testObj ],
-                               [ 'a' ],
-                               [ 'a' => self::$testObj ],
-                       ],
-               ];
-       }
-
-       /**
-        * @covers ::__construct
-        */
-       public function testKeyNotFound() {
-               $this->setExpectedException( InvalidArgumentException::class,
-                       'Key "a" not found in input sources' );
-
-               new ServiceOptions( [ 'a' ], [ 'b' => 'bval' ], [ 'c' => 'cval' ] );
-       }
-
-       /**
-        * @covers ::__construct
-        * @covers ::assertRequiredOptions
-        */
-       public function testOutOfOrderAssertRequiredOptions() {
-               $options = new ServiceOptions( [ 'a', 'b' ], [ 'a' => '', 'b' => '' ] );
-               $options->assertRequiredOptions( [ 'b', 'a' ] );
-               $this->assertTrue( true, 'No exception thrown' );
-       }
-
-       /**
-        * @covers ::__construct
-        * @covers ::get
-        */
-       public function testGetUnrecognized() {
-               $this->setExpectedException( InvalidArgumentException::class,
-                       'Unrecognized option "b"' );
-
-               $options = new ServiceOptions( [ 'a' ], [ 'a' => '' ] );
-               $options->get( 'b' );
-       }
-
-       /**
-        * @covers ::__construct
-        * @covers ::assertRequiredOptions
-        */
-       public function testExtraKeys() {
-               $this->setExpectedException( Wikimedia\Assert\PreconditionException::class,
-                       'Precondition failed: Unsupported options passed: b, c!' );
-
-               $options = new ServiceOptions( [ 'a', 'b', 'c' ], [ 'a' => '', 'b' => '', 'c' => '' ] );
-               $options->assertRequiredOptions( [ 'a' ] );
-       }
-
-       /**
-        * @covers ::__construct
-        * @covers ::assertRequiredOptions
-        */
-       public function testMissingKeys() {
-               $this->setExpectedException( Wikimedia\Assert\PreconditionException::class,
-                       'Precondition failed: Required options missing: a, b!' );
-
-               $options = new ServiceOptions( [ 'c' ], [ 'c' => '' ] );
-               $options->assertRequiredOptions( [ 'a', 'b', 'c' ] );
-       }
-
-       /**
-        * @covers ::__construct
-        * @covers ::assertRequiredOptions
-        */
-       public function testExtraAndMissingKeys() {
-               $this->setExpectedException( Wikimedia\Assert\PreconditionException::class,
-                       'Precondition failed: Unsupported options passed: b! Required options missing: c!' );
-
-               $options = new ServiceOptions( [ 'a', 'b' ], [ 'a' => '', 'b' => '' ] );
-               $options->assertRequiredOptions( [ 'a', 'c' ] );
-       }
-}
diff --git a/tests/phpunit/includes/content/JsonContentHandlerTest.php b/tests/phpunit/includes/content/JsonContentHandlerTest.php
deleted file mode 100644 (file)
index abfb673..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-<?php
-
-class JsonContentHandlerTest extends MediaWikiTestCase {
-
-       /**
-        * @covers JsonContentHandler::makeEmptyContent
-        */
-       public function testMakeEmptyContent() {
-               $handler = new JsonContentHandler();
-               $content = $handler->makeEmptyContent();
-               $this->assertInstanceOf( JsonContent::class, $content );
-               $this->assertTrue( $content->isValid() );
-       }
-}
index b14d89c..25dedbc 100644 (file)
@@ -37,10 +37,8 @@ class DeprecationHelperTest extends MediaWikiTestCase {
 
        public function provideGet() {
                return [
-                       [ 'protectedDeprecated', null, null ],
                        [ 'protectedNonDeprecated', E_USER_ERROR,
                                'Cannot access non-public property TestDeprecatedClass::$protectedNonDeprecated' ],
-                       [ 'privateDeprecated', null, null ],
                        [ 'privateNonDeprecated', E_USER_ERROR,
                          'Cannot access non-public property TestDeprecatedClass::$privateNonDeprecated' ],
                        [ 'nonExistent', E_USER_NOTICE, 'Undefined property: TestDeprecatedClass::$nonExistent' ],
@@ -71,10 +69,8 @@ class DeprecationHelperTest extends MediaWikiTestCase {
 
        public function provideSet() {
                return [
-                       [ 'protectedDeprecated', null, null ],
                        [ 'protectedNonDeprecated', E_USER_ERROR,
                          'Cannot access non-public property TestDeprecatedClass::$protectedNonDeprecated' ],
-                       [ 'privateDeprecated', null, null ],
                        [ 'privateNonDeprecated', E_USER_ERROR,
                          'Cannot access non-public property TestDeprecatedClass::$privateNonDeprecated' ],
                        [ 'nonExistent', null, null ],
@@ -100,15 +96,6 @@ class DeprecationHelperTest extends MediaWikiTestCase {
        }
 
        public function testSubclassGetSet() {
-               $this->assertDeprecationWarningIssued( function () {
-                       $this->assertSame( 1, $this->testSubclass->getDeprecatedPrivateParentProperty() );
-               } );
-               $this->assertDeprecationWarningIssued( function () {
-                       $this->testSubclass->setDeprecatedPrivateParentProperty( 0 );
-               } );
-               $wrapper = TestingAccessWrapper::newFromObject( $this->testSubclass );
-               $this->assertSame( 0, $wrapper->privateDeprecated );
-
                $fullName = 'TestDeprecatedClass::$privateNonDeprecated';
                $this->assertErrorTriggered( function () {
                        $this->assertSame( null, $this->testSubclass->getNonDeprecatedPrivateParentProperty() );
@@ -165,4 +152,22 @@ class DeprecationHelperTest extends MediaWikiTestCase {
                $this->assertNotEmpty( $wrapper->deprecationWarnings );
        }
 
+       /**
+        * Test bad MW version values to throw exceptions as expected
+        *
+        * @dataProvider provideBadMWVersion
+        */
+       public function testBadMWVersion( $version, $expected ) {
+               $this->setExpectedException( $expected );
+
+               wfDeprecated( __METHOD__, $version );
+       }
+
+       public function provideBadMWVersion() {
+               return [
+                       [ 1, Exception::class ],
+                       [ 1.33, Exception::class ],
+                       [ null, Exception::class ]
+               ];
+       }
 }
diff --git a/tests/phpunit/includes/debug/logger/MonologSpiTest.php b/tests/phpunit/includes/debug/logger/MonologSpiTest.php
deleted file mode 100644 (file)
index fda3ac6..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-<?php
-/**
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- */
-
-namespace MediaWiki\Logger;
-
-use MediaWikiTestCase;
-use Wikimedia\TestingAccessWrapper;
-
-class MonologSpiTest extends MediaWikiTestCase {
-
-       /**
-        * @covers MediaWiki\Logger\MonologSpi::mergeConfig
-        */
-       public function testMergeConfig() {
-               $base = [
-                       'loggers' => [
-                               '@default' => [
-                                       'processors' => [ 'constructor' ],
-                                       'handlers' => [ 'constructor' ],
-                               ],
-                       ],
-                       'processors' => [
-                               'constructor' => [
-                                       'class' => 'constructor',
-                               ],
-                       ],
-                       'handlers' => [
-                               'constructor' => [
-                                       'class' => 'constructor',
-                                       'formatter' => 'constructor',
-                               ],
-                       ],
-                       'formatters' => [
-                               'constructor' => [
-                                       'class' => 'constructor',
-                               ],
-                       ],
-               ];
-
-               $fixture = new MonologSpi( $base );
-               $this->assertSame(
-                       $base,
-                       TestingAccessWrapper::newFromObject( $fixture )->config
-               );
-
-               $fixture->mergeConfig( [
-                       'loggers' => [
-                               'merged' => [
-                                       'processors' => [ 'merged' ],
-                                       'handlers' => [ 'merged' ],
-                               ],
-                       ],
-                       'processors' => [
-                               'merged' => [
-                                       'class' => 'merged',
-                               ],
-                       ],
-                       'magic' => [
-                               'idkfa' => [ 'xyzzy' ],
-                       ],
-                       'handlers' => [
-                               'merged' => [
-                                       'class' => 'merged',
-                                       'formatter' => 'merged',
-                               ],
-                       ],
-                       'formatters' => [
-                               'merged' => [
-                                       'class' => 'merged',
-                               ],
-                       ],
-               ] );
-               $this->assertSame(
-                       [
-                               'loggers' => [
-                                       '@default' => [
-                                               'processors' => [ 'constructor' ],
-                                               'handlers' => [ 'constructor' ],
-                                       ],
-                                       'merged' => [
-                                               'processors' => [ 'merged' ],
-                                               'handlers' => [ 'merged' ],
-                                       ],
-                               ],
-                               'processors' => [
-                                       'constructor' => [
-                                               'class' => 'constructor',
-                                       ],
-                                       'merged' => [
-                                               'class' => 'merged',
-                                       ],
-                               ],
-                               'handlers' => [
-                                       'constructor' => [
-                                               'class' => 'constructor',
-                                               'formatter' => 'constructor',
-                                       ],
-                                       'merged' => [
-                                               'class' => 'merged',
-                                               'formatter' => 'merged',
-                                       ],
-                               ],
-                               'formatters' => [
-                                       'constructor' => [
-                                               'class' => 'constructor',
-                                       ],
-                                       'merged' => [
-                                               'class' => 'merged',
-                                       ],
-                               ],
-                               'magic' => [
-                                       'idkfa' => [ 'xyzzy' ],
-                               ],
-                       ],
-                       TestingAccessWrapper::newFromObject( $fixture )->config
-               );
-       }
-
-}
diff --git a/tests/phpunit/includes/debug/logger/monolog/AvroFormatterTest.php b/tests/phpunit/includes/debug/logger/monolog/AvroFormatterTest.php
deleted file mode 100644 (file)
index baa4df7..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-<?php
-/**
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- */
-
-namespace MediaWiki\Logger\Monolog;
-
-use MediaWikiTestCase;
-use PHPUnit_Framework_Error_Notice;
-
-/**
- * @covers \MediaWiki\Logger\Monolog\AvroFormatter
- */
-class AvroFormatterTest extends MediaWikiTestCase {
-
-       protected function setUp() {
-               if ( !class_exists( 'AvroStringIO' ) ) {
-                       $this->markTestSkipped( 'Avro is required for the AvroFormatterTest' );
-               }
-               parent::setUp();
-       }
-
-       public function testSchemaNotAvailable() {
-               $formatter = new AvroFormatter( [] );
-               $this->setExpectedException(
-                       'PHPUnit_Framework_Error_Notice',
-                       "The schema for channel 'marty' is not available"
-               );
-               $formatter->format( [ 'channel' => 'marty' ] );
-       }
-
-       public function testSchemaNotAvailableReturnValue() {
-               $formatter = new AvroFormatter( [] );
-               $noticeEnabled = PHPUnit_Framework_Error_Notice::$enabled;
-               // disable conversion of notices
-               PHPUnit_Framework_Error_Notice::$enabled = false;
-               // have to keep the user notice from being output
-               \Wikimedia\suppressWarnings();
-               $res = $formatter->format( [ 'channel' => 'marty' ] );
-               \Wikimedia\restoreWarnings();
-               PHPUnit_Framework_Error_Notice::$enabled = $noticeEnabled;
-               $this->assertNull( $res );
-       }
-
-       public function testDoesSomethingWhenSchemaAvailable() {
-               $formatter = new AvroFormatter( [
-                       'string' => [
-                               'schema' => [ 'type' => 'string' ],
-                               'revision' => 1010101,
-                       ]
-               ] );
-               $res = $formatter->format( [
-                       'channel' => 'string',
-                       'context' => 'better to be',
-               ] );
-               $this->assertNotNull( $res );
-               // basically just tell us if avro changes its string encoding, or if
-               // we completely fail to generate a log message.
-               $this->assertEquals( 'AAAAAAAAD2m1GGJldHRlciB0byBiZQ==', base64_encode( $res ) );
-       }
-}
diff --git a/tests/phpunit/includes/debug/logger/monolog/KafkaHandlerTest.php b/tests/phpunit/includes/debug/logger/monolog/KafkaHandlerTest.php
deleted file mode 100644 (file)
index 4c0ca04..0000000
+++ /dev/null
@@ -1,227 +0,0 @@
-<?php
-/**
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- */
-
-namespace MediaWiki\Logger\Monolog;
-
-use MediaWikiTestCase;
-use Monolog\Logger;
-use Wikimedia\TestingAccessWrapper;
-
-/**
- * @covers \MediaWiki\Logger\Monolog\KafkaHandler
- */
-class KafkaHandlerTest extends MediaWikiTestCase {
-
-       protected function setUp() {
-               if ( !class_exists( 'Monolog\Handler\AbstractProcessingHandler' )
-                       || !class_exists( 'Kafka\Produce' )
-               ) {
-                       $this->markTestSkipped( 'Monolog and Kafka are required for the KafkaHandlerTest' );
-               }
-
-               parent::setUp();
-       }
-
-       public function topicNamingProvider() {
-               return [
-                       [ [], 'monolog_foo' ],
-                       [ [ 'alias' => [ 'foo' => 'bar' ] ], 'bar' ]
-               ];
-       }
-
-       /**
-        * @dataProvider topicNamingProvider
-        */
-       public function testTopicNaming( $options, $expect ) {
-               $produce = $this->getMockBuilder( 'Kafka\Produce' )
-                       ->disableOriginalConstructor()
-                       ->getMock();
-               $produce->expects( $this->any() )
-                       ->method( 'getAvailablePartitions' )
-                       ->will( $this->returnValue( [ 'A' ] ) );
-               $produce->expects( $this->once() )
-                       ->method( 'setMessages' )
-                       ->with( $expect, $this->anything(), $this->anything() );
-               $produce->expects( $this->any() )
-                       ->method( 'send' )
-                       ->will( $this->returnValue( true ) );
-
-               $handler = new KafkaHandler( $produce, $options );
-               $handler->handle( [
-                       'channel' => 'foo',
-                       'level' => Logger::EMERGENCY,
-                       'extra' => [],
-                       'context' => [],
-               ] );
-       }
-
-       public function swallowsExceptionsWhenRequested() {
-               return [
-                       // defaults to false
-                       [ [], true ],
-                       // also try false explicitly
-                       [ [ 'swallowExceptions' => false ], true ],
-                       // turn it on
-                       [ [ 'swallowExceptions' => true ], false ],
-               ];
-       }
-
-       /**
-        * @dataProvider swallowsExceptionsWhenRequested
-        */
-       public function testGetAvailablePartitionsException( $options, $expectException ) {
-               $produce = $this->getMockBuilder( 'Kafka\Produce' )
-                       ->disableOriginalConstructor()
-                       ->getMock();
-               $produce->expects( $this->any() )
-                       ->method( 'getAvailablePartitions' )
-                       ->will( $this->throwException( new \Kafka\Exception ) );
-               $produce->expects( $this->any() )
-                       ->method( 'send' )
-                       ->will( $this->returnValue( true ) );
-
-               if ( $expectException ) {
-                       $this->setExpectedException( 'Kafka\Exception' );
-               }
-
-               $handler = new KafkaHandler( $produce, $options );
-               $handler->handle( [
-                       'channel' => 'foo',
-                       'level' => Logger::EMERGENCY,
-                       'extra' => [],
-                       'context' => [],
-               ] );
-
-               if ( !$expectException ) {
-                       $this->assertTrue( true, 'no exception was thrown' );
-               }
-       }
-
-       /**
-        * @dataProvider swallowsExceptionsWhenRequested
-        */
-       public function testSendException( $options, $expectException ) {
-               $produce = $this->getMockBuilder( 'Kafka\Produce' )
-                       ->disableOriginalConstructor()
-                       ->getMock();
-               $produce->expects( $this->any() )
-                       ->method( 'getAvailablePartitions' )
-                       ->will( $this->returnValue( [ 'A' ] ) );
-               $produce->expects( $this->any() )
-                       ->method( 'send' )
-                       ->will( $this->throwException( new \Kafka\Exception ) );
-
-               if ( $expectException ) {
-                       $this->setExpectedException( 'Kafka\Exception' );
-               }
-
-               $handler = new KafkaHandler( $produce, $options );
-               $handler->handle( [
-                       'channel' => 'foo',
-                       'level' => Logger::EMERGENCY,
-                       'extra' => [],
-                       'context' => [],
-               ] );
-
-               if ( !$expectException ) {
-                       $this->assertTrue( true, 'no exception was thrown' );
-               }
-       }
-
-       public function testHandlesNullFormatterResult() {
-               $produce = $this->getMockBuilder( 'Kafka\Produce' )
-                       ->disableOriginalConstructor()
-                       ->getMock();
-               $produce->expects( $this->any() )
-                       ->method( 'getAvailablePartitions' )
-                       ->will( $this->returnValue( [ 'A' ] ) );
-               $mockMethod = $produce->expects( $this->exactly( 2 ) )
-                       ->method( 'setMessages' );
-               $produce->expects( $this->any() )
-                       ->method( 'send' )
-                       ->will( $this->returnValue( true ) );
-               // evil hax
-               $matcher = TestingAccessWrapper::newFromObject( $mockMethod )->matcher;
-               TestingAccessWrapper::newFromObject( $matcher )->parametersMatcher =
-                       new \PHPUnit_Framework_MockObject_Matcher_ConsecutiveParameters( [
-                               [ $this->anything(), $this->anything(), [ 'words' ] ],
-                               [ $this->anything(), $this->anything(), [ 'lines' ] ]
-                       ] );
-
-               $formatter = $this->createMock( \Monolog\Formatter\FormatterInterface::class );
-               $formatter->expects( $this->any() )
-                       ->method( 'format' )
-                       ->will( $this->onConsecutiveCalls( 'words', null, 'lines' ) );
-
-               $handler = new KafkaHandler( $produce, [] );
-               $handler->setFormatter( $formatter );
-               for ( $i = 0; $i < 3; ++$i ) {
-                       $handler->handle( [
-                               'channel' => 'foo',
-                               'level' => Logger::EMERGENCY,
-                               'extra' => [],
-                               'context' => [],
-                       ] );
-               }
-       }
-
-       public function testBatchHandlesNullFormatterResult() {
-               $produce = $this->getMockBuilder( 'Kafka\Produce' )
-                       ->disableOriginalConstructor()
-                       ->getMock();
-               $produce->expects( $this->any() )
-                       ->method( 'getAvailablePartitions' )
-                       ->will( $this->returnValue( [ 'A' ] ) );
-               $produce->expects( $this->once() )
-                       ->method( 'setMessages' )
-                       ->with( $this->anything(), $this->anything(), [ 'words', 'lines' ] );
-               $produce->expects( $this->any() )
-                       ->method( 'send' )
-                       ->will( $this->returnValue( true ) );
-
-               $formatter = $this->createMock( \Monolog\Formatter\FormatterInterface::class );
-               $formatter->expects( $this->any() )
-                       ->method( 'format' )
-                       ->will( $this->onConsecutiveCalls( 'words', null, 'lines' ) );
-
-               $handler = new KafkaHandler( $produce, [] );
-               $handler->setFormatter( $formatter );
-               $handler->handleBatch( [
-                       [
-                               'channel' => 'foo',
-                               'level' => Logger::EMERGENCY,
-                               'extra' => [],
-                               'context' => [],
-                       ],
-                       [
-                               'channel' => 'foo',
-                               'level' => Logger::EMERGENCY,
-                               'extra' => [],
-                               'context' => [],
-                       ],
-                       [
-                               'channel' => 'foo',
-                               'level' => Logger::EMERGENCY,
-                               'extra' => [],
-                               'context' => [],
-                       ],
-               ] );
-       }
-}
diff --git a/tests/phpunit/includes/debug/logger/monolog/LineFormatterTest.php b/tests/phpunit/includes/debug/logger/monolog/LineFormatterTest.php
deleted file mode 100644 (file)
index bdd5c81..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-<?php
-/**
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- */
-
-namespace MediaWiki\Logger\Monolog;
-
-use AssertionError;
-use InvalidArgumentException;
-use LengthException;
-use LogicException;
-use MediaWikiTestCase;
-use Wikimedia\TestingAccessWrapper;
-
-class LineFormatterTest extends MediaWikiTestCase {
-
-       protected function setUp() {
-               if ( !class_exists( 'Monolog\Formatter\LineFormatter' ) ) {
-                       $this->markTestSkipped( 'This test requires monolog to be installed' );
-               }
-               parent::setUp();
-       }
-
-       /**
-        * @covers MediaWiki\Logger\Monolog\LineFormatter::normalizeException
-        */
-       public function testNormalizeExceptionNoTrace() {
-               $fixture = new LineFormatter();
-               $fixture->includeStacktraces( false );
-               $fixture = TestingAccessWrapper::newFromObject( $fixture );
-               $boom = new InvalidArgumentException( 'boom', 0,
-                       new LengthException( 'too long', 0,
-                               new LogicException( 'Spock wuz here' )
-                       )
-               );
-               $out = $fixture->normalizeException( $boom );
-               $this->assertContains( "\n[Exception InvalidArgumentException]", $out );
-               $this->assertContains( "\nCaused by: [Exception LengthException]", $out );
-               $this->assertContains( "\nCaused by: [Exception LogicException]", $out );
-               $this->assertNotContains( "\n  #0", $out );
-       }
-
-       /**
-        * @covers MediaWiki\Logger\Monolog\LineFormatter::normalizeException
-        */
-       public function testNormalizeExceptionTrace() {
-               $fixture = new LineFormatter();
-               $fixture->includeStacktraces( true );
-               $fixture = TestingAccessWrapper::newFromObject( $fixture );
-               $boom = new InvalidArgumentException( 'boom', 0,
-                       new LengthException( 'too long', 0,
-                               new LogicException( 'Spock wuz here' )
-                       )
-               );
-               $out = $fixture->normalizeException( $boom );
-               $this->assertContains( "\n[Exception InvalidArgumentException]", $out );
-               $this->assertContains( "\nCaused by: [Exception LengthException]", $out );
-               $this->assertContains( "\nCaused by: [Exception LogicException]", $out );
-               $this->assertContains( "\n  #0", $out );
-       }
-
-       /**
-        * @covers MediaWiki\Logger\Monolog\LineFormatter::normalizeException
-        */
-       public function testNormalizeExceptionErrorNoTrace() {
-               if ( !class_exists( AssertionError::class ) ) {
-                       $this->markTestSkipped( 'AssertionError class does not exist' );
-               }
-
-               $fixture = new LineFormatter();
-               $fixture->includeStacktraces( false );
-               $fixture = TestingAccessWrapper::newFromObject( $fixture );
-               $boom = new InvalidArgumentException( 'boom', 0,
-                       new LengthException( 'too long', 0,
-                               new AssertionError( 'Spock wuz here' )
-                       )
-               );
-               $out = $fixture->normalizeException( $boom );
-               $this->assertContains( "\n[Exception InvalidArgumentException]", $out );
-               $this->assertContains( "\nCaused by: [Exception LengthException]", $out );
-               $this->assertContains( "\nCaused by: [Error AssertionError]", $out );
-               $this->assertNotContains( "\n  #0", $out );
-       }
-
-       /**
-        * @covers MediaWiki\Logger\Monolog\LineFormatter::normalizeException
-        */
-       public function testNormalizeExceptionErrorTrace() {
-               if ( !class_exists( AssertionError::class ) ) {
-                       $this->markTestSkipped( 'AssertionError class does not exist' );
-               }
-
-               $fixture = new LineFormatter();
-               $fixture->includeStacktraces( true );
-               $fixture = TestingAccessWrapper::newFromObject( $fixture );
-               $boom = new InvalidArgumentException( 'boom', 0,
-                       new LengthException( 'too long', 0,
-                               new AssertionError( 'Spock wuz here' )
-                       )
-               );
-               $out = $fixture->normalizeException( $boom );
-               $this->assertContains( "\n[Exception InvalidArgumentException]", $out );
-               $this->assertContains( "\nCaused by: [Exception LengthException]", $out );
-               $this->assertContains( "\nCaused by: [Error AssertionError]", $out );
-               $this->assertContains( "\n  #0", $out );
-       }
-}
diff --git a/tests/phpunit/includes/diff/ArrayDiffFormatterTest.php b/tests/phpunit/includes/diff/ArrayDiffFormatterTest.php
deleted file mode 100644 (file)
index 8d94404..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-<?php
-
-/**
- * @author Addshore
- *
- * @group Diff
- */
-class ArrayDiffFormatterTest extends MediaWikiTestCase {
-
-       /**
-        * @param Diff $input
-        * @param array $expectedOutput
-        * @dataProvider provideTestFormat
-        * @covers ArrayDiffFormatter::format
-        */
-       public function testFormat( $input, $expectedOutput ) {
-               $instance = new ArrayDiffFormatter();
-               $output = $instance->format( $input );
-               $this->assertEquals( $expectedOutput, $output );
-       }
-
-       private function getMockDiff( $edits ) {
-               $diff = $this->getMockBuilder( Diff::class )
-                       ->disableOriginalConstructor()
-                       ->getMock();
-               $diff->expects( $this->any() )
-                       ->method( 'getEdits' )
-                       ->will( $this->returnValue( $edits ) );
-               return $diff;
-       }
-
-       private function getMockDiffOp( $type = null, $orig = [], $closing = [] ) {
-               $diffOp = $this->getMockBuilder( DiffOp::class )
-                       ->disableOriginalConstructor()
-                       ->getMock();
-               $diffOp->expects( $this->any() )
-                       ->method( 'getType' )
-                       ->will( $this->returnValue( $type ) );
-               $diffOp->expects( $this->any() )
-                       ->method( 'getOrig' )
-                       ->will( $this->returnValue( $orig ) );
-               if ( $type === 'change' ) {
-                       $diffOp->expects( $this->any() )
-                               ->method( 'getClosing' )
-                               ->with( $this->isType( 'integer' ) )
-                               ->will( $this->returnCallback( function () {
-                                       return 'mockLine';
-                               } ) );
-               } else {
-                       $diffOp->expects( $this->any() )
-                               ->method( 'getClosing' )
-                               ->will( $this->returnValue( $closing ) );
-               }
-               return $diffOp;
-       }
-
-       public function provideTestFormat() {
-               $emptyArrayTestCases = [
-                       $this->getMockDiff( [] ),
-                       $this->getMockDiff( [ $this->getMockDiffOp( 'add' ) ] ),
-                       $this->getMockDiff( [ $this->getMockDiffOp( 'delete' ) ] ),
-                       $this->getMockDiff( [ $this->getMockDiffOp( 'change' ) ] ),
-                       $this->getMockDiff( [ $this->getMockDiffOp( 'copy' ) ] ),
-                       $this->getMockDiff( [ $this->getMockDiffOp( 'FOOBARBAZ' ) ] ),
-                       $this->getMockDiff( [ $this->getMockDiffOp( 'add', 'line' ) ] ),
-                       $this->getMockDiff( [ $this->getMockDiffOp( 'delete', [], [ 'line' ] ) ] ),
-                       $this->getMockDiff( [ $this->getMockDiffOp( 'copy', [], [ 'line' ] ) ] ),
-               ];
-
-               $otherTestCases = [];
-               $otherTestCases[] = [
-                       $this->getMockDiff( [ $this->getMockDiffOp( 'add', [], [ 'a1' ] ) ] ),
-                       [ [ 'action' => 'add', 'new' => 'a1', 'newline' => 1 ] ],
-               ];
-               $otherTestCases[] = [
-                       $this->getMockDiff( [ $this->getMockDiffOp( 'add', [], [ 'a1', 'a2' ] ) ] ),
-                       [
-                               [ 'action' => 'add', 'new' => 'a1', 'newline' => 1 ],
-                               [ 'action' => 'add', 'new' => 'a2', 'newline' => 2 ],
-                       ],
-               ];
-               $otherTestCases[] = [
-                       $this->getMockDiff( [ $this->getMockDiffOp( 'delete', [ 'd1' ] ) ] ),
-                       [ [ 'action' => 'delete', 'old' => 'd1', 'oldline' => 1 ] ],
-               ];
-               $otherTestCases[] = [
-                       $this->getMockDiff( [ $this->getMockDiffOp( 'delete', [ 'd1', 'd2' ] ) ] ),
-                       [
-                               [ 'action' => 'delete', 'old' => 'd1', 'oldline' => 1 ],
-                               [ 'action' => 'delete', 'old' => 'd2', 'oldline' => 2 ],
-                       ],
-               ];
-               $otherTestCases[] = [
-                       $this->getMockDiff( [ $this->getMockDiffOp( 'change', [ 'd1' ], [ 'a1' ] ) ] ),
-                       [ [
-                               'action' => 'change',
-                               'old' => 'd1',
-                               'new' => 'mockLine',
-                               'newline' => 1, 'oldline' => 1
-                       ] ],
-               ];
-               $otherTestCases[] = [
-                       $this->getMockDiff( [ $this->getMockDiffOp(
-                               'change',
-                               [ 'd1', 'd2' ],
-                               [ 'a1', 'a2' ]
-                       ) ] ),
-                       [
-                               [
-                                       'action' => 'change',
-                                       'old' => 'd1',
-                                       'new' => 'mockLine',
-                                       'newline' => 1, 'oldline' => 1
-                               ],
-                               [
-                                       'action' => 'change',
-                                       'old' => 'd2',
-                                       'new' => 'mockLine',
-                                       'newline' => 2, 'oldline' => 2
-                               ],
-                       ],
-               ];
-
-               $testCases = [];
-               foreach ( $emptyArrayTestCases as $testCase ) {
-                       $testCases[] = [ $testCase, [] ];
-               }
-               foreach ( $otherTestCases as $testCase ) {
-                       $testCases[] = [ $testCase[0], $testCase[1] ];
-               }
-               return $testCases;
-       }
-
-}
diff --git a/tests/phpunit/includes/diff/DiffOpTest.php b/tests/phpunit/includes/diff/DiffOpTest.php
deleted file mode 100644 (file)
index 3026fad..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-<?php
-/**
- * @author Addshore
- *
- * @group Diff
- */
-class DiffOpTest extends MediaWikiTestCase {
-
-       /**
-        * @covers DiffOp::getType
-        */
-       public function testGetType() {
-               $obj = new FakeDiffOp();
-               $obj->type = 'foo';
-               $this->assertEquals( 'foo', $obj->getType() );
-       }
-
-       /**
-        * @covers DiffOp::getOrig
-        */
-       public function testGetOrig() {
-               $obj = new FakeDiffOp();
-               $obj->orig = [ 'foo' ];
-               $this->assertEquals( [ 'foo' ], $obj->getOrig() );
-       }
-
-       /**
-        * @covers DiffOp::getClosing
-        */
-       public function testGetClosing() {
-               $obj = new FakeDiffOp();
-               $obj->closing = [ 'foo' ];
-               $this->assertEquals( [ 'foo' ], $obj->getClosing() );
-       }
-
-       /**
-        * @covers DiffOp::getClosing
-        */
-       public function testGetClosingWithParameter() {
-               $obj = new FakeDiffOp();
-               $obj->closing = [ 'foo', 'bar', 'baz' ];
-               $this->assertEquals( 'foo', $obj->getClosing( 0 ) );
-               $this->assertEquals( 'bar', $obj->getClosing( 1 ) );
-               $this->assertEquals( 'baz', $obj->getClosing( 2 ) );
-               $this->assertEquals( null, $obj->getClosing( 3 ) );
-       }
-
-       /**
-        * @covers DiffOp::norig
-        */
-       public function testNorig() {
-               $obj = new FakeDiffOp();
-               $this->assertEquals( 0, $obj->norig() );
-               $obj->orig = [ 'foo' ];
-               $this->assertEquals( 1, $obj->norig() );
-       }
-
-       /**
-        * @covers DiffOp::nclosing
-        */
-       public function testNclosing() {
-               $obj = new FakeDiffOp();
-               $this->assertEquals( 0, $obj->nclosing() );
-               $obj->closing = [ 'foo' ];
-               $this->assertEquals( 1, $obj->nclosing() );
-       }
-
-}
diff --git a/tests/phpunit/includes/diff/DiffTest.php b/tests/phpunit/includes/diff/DiffTest.php
deleted file mode 100644 (file)
index da6d7d9..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-
-/**
- * @author Addshore
- *
- * @group Diff
- */
-class DiffTest extends MediaWikiTestCase {
-
-       /**
-        * @covers Diff::getEdits
-        */
-       public function testGetEdits() {
-               $obj = new Diff( [], [] );
-               $obj->edits = 'FooBarBaz';
-               $this->assertEquals( 'FooBarBaz', $obj->getEdits() );
-       }
-
-}
diff --git a/tests/phpunit/includes/exception/MWExceptionHandlerTest.php b/tests/phpunit/includes/exception/MWExceptionHandlerTest.php
deleted file mode 100644 (file)
index 6606065..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-<?php
-/**
- * @author Antoine Musso
- * @copyright Copyright © 2013, Antoine Musso
- * @copyright Copyright © 2013, Wikimedia Foundation Inc.
- * @file
- */
-
-class MWExceptionHandlerTest extends MediaWikiTestCase {
-
-       /**
-        * @covers MWExceptionHandler::getRedactedTrace
-        */
-       public function testGetRedactedTrace() {
-               $refvar = 'value';
-               try {
-                       $array = [ 'a', 'b' ];
-                       $object = new stdClass();
-                       self::helperThrowAnException( $array, $object, $refvar );
-               } catch ( Exception $e ) {
-               }
-
-               # Make sure our stack trace contains an array and an object passed to
-               # some function in the stacktrace. Else, we can not assert the trace
-               # redaction achieved its job.
-               $trace = $e->getTrace();
-               $hasObject = false;
-               $hasArray = false;
-               foreach ( $trace as $frame ) {
-                       if ( !isset( $frame['args'] ) ) {
-                               continue;
-                       }
-                       foreach ( $frame['args'] as $arg ) {
-                               $hasObject = $hasObject || is_object( $arg );
-                               $hasArray = $hasArray || is_array( $arg );
-                       }
-
-                       if ( $hasObject && $hasArray ) {
-                               break;
-                       }
-               }
-               $this->assertTrue( $hasObject,
-                       "The stacktrace must have a function having an object has parameter" );
-               $this->assertTrue( $hasArray,
-                       "The stacktrace must have a function having an array has parameter" );
-
-               # Now we redact the trace.. and make sure no function arguments are
-               # arrays or objects.
-               $redacted = MWExceptionHandler::getRedactedTrace( $e );
-
-               foreach ( $redacted as $frame ) {
-                       if ( !isset( $frame['args'] ) ) {
-                               continue;
-                       }
-                       foreach ( $frame['args'] as $arg ) {
-                               $this->assertNotInternalType( 'array', $arg );
-                               $this->assertNotInternalType( 'object', $arg );
-                       }
-               }
-
-               $this->assertEquals( 'value', $refvar, 'Ensuring reference variable wasn\'t changed' );
-       }
-
-       /**
-        * Helper function for testExpandArgumentsInCall
-        *
-        * Pass it an object and an array, and something by reference :-)
-        *
-        * @throws Exception
-        */
-       protected static function helperThrowAnException( $a, $b, &$c ) {
-               throw new Exception();
-       }
-}
diff --git a/tests/phpunit/includes/installer/InstallDocFormatterTest.php b/tests/phpunit/includes/installer/InstallDocFormatterTest.php
deleted file mode 100644 (file)
index 9584d4b..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-<?php
-
-class InstallDocFormatterTest extends MediaWikiTestCase {
-       /**
-        * @covers InstallDocFormatter
-        * @dataProvider provideDocFormattingTests
-        */
-       public function testFormat( $expected, $unformattedText, $message = '' ) {
-               $this->assertEquals(
-                       $expected,
-                       InstallDocFormatter::format( $unformattedText ),
-                       $message
-               );
-       }
-
-       /**
-        * Provider for testFormat()
-        */
-       public static function provideDocFormattingTests() {
-               # Format: (expected string, unformattedText string, optional message)
-               return [
-                       # Escape some wikitext
-                       [ 'Install &lt;tag>', 'Install <tag>', 'Escaping <' ],
-                       [ 'Install &#123;&#123;template}}', 'Install {{template}}', 'Escaping [[' ],
-                       [ 'Install &#91;&#91;page]]', 'Install [[page]]', 'Escaping {{' ],
-                       [ 'Install &#95;&#95;TOC&#95;&#95;', 'Install __TOC__', 'Escaping __' ],
-                       [ 'Install ', "Install \r", 'Removing \r' ],
-
-                       # Transform \t{1,2} into :{1,2}
-                       [ ':One indentation', "\tOne indentation", 'Replacing a single \t' ],
-                       [ '::Two indentations', "\t\tTwo indentations", 'Replacing 2 x \t' ],
-
-                       # Transform 'T123' links
-                       [
-                               '<span class="config-plainlink">[https://phabricator.wikimedia.org/T123 T123]</span>',
-                               'T123', 'Testing T123 links' ],
-                       [
-                               'bug <span class="config-plainlink">[https://phabricator.wikimedia.org/T123 T123]</span>',
-                               'bug T123', 'Testing bug T123 links' ],
-                       [
-                               '(<span class="config-plainlink">[https://phabricator.wikimedia.org/T987654 T987654]</span>)',
-                               '(T987654)', 'Testing (T987654) links' ],
-
-                       # "Tabc" shouldn't work
-                       [ 'Tfoobar', 'Tfoobar', "Don't match T followed by non-digits" ],
-                       [ 'T!!fakefake!!', 'T!!fakefake!!', "Don't match T followed by non-digits" ],
-
-                       # Transform 'bug 123' links
-                       [
-                               '<span class="config-plainlink">[https://bugzilla.wikimedia.org/123 bug 123]</span>',
-                               'bug 123', 'Testing bug 123 links' ],
-                       [
-                               '(<span class="config-plainlink">[https://bugzilla.wikimedia.org/987654 bug 987654]</span>)',
-                               '(bug 987654)', 'Testing (bug 987654) links' ],
-
-                       # "bug abc" shouldn't work
-                       [ 'bug foobar', 'bug foobar', "Don't match bug followed by non-digits" ],
-                       [ 'bug !!fakefake!!', 'bug !!fakefake!!', "Don't match bug followed by non-digits" ],
-
-                       # Transform '$wgFooBar' links
-                       [
-                               '<span class="config-plainlink">'
-                                       . '[https://www.mediawiki.org/wiki/Manual:$wgFooBar $wgFooBar]</span>',
-                               '$wgFooBar', 'Testing basic $wgFooBar' ],
-                       [
-                               '<span class="config-plainlink">'
-                                       . '[https://www.mediawiki.org/wiki/Manual:$wgFooBar45 $wgFooBar45]</span>',
-                               '$wgFooBar45', 'Testing $wgFooBar45 (with numbers)' ],
-                       [
-                               '<span class="config-plainlink">'
-                                       . '[https://www.mediawiki.org/wiki/Manual:$wgFoo_Bar $wgFoo_Bar]</span>',
-                               '$wgFoo_Bar', 'Testing $wgFoo_Bar (with underscore)' ],
-
-                       # Icky variables that shouldn't link
-                       [
-                               '$myAwesomeVariable',
-                               '$myAwesomeVariable',
-                               'Testing $myAwesomeVariable (not starting with $wg)'
-                       ],
-                       [ '$()not!a&Var', '$()not!a&Var', 'Testing $()not!a&Var (obviously not a variable)' ],
-               ];
-       }
-}
diff --git a/tests/phpunit/includes/installer/OracleInstallerTest.php b/tests/phpunit/includes/installer/OracleInstallerTest.php
deleted file mode 100644 (file)
index e255089..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-
-/**
- * @group Database
- * @group Installer
- */
-class OracleInstallerTest extends MediaWikiTestCase {
-
-       /**
-        * @dataProvider provideOracleConnectStrings
-        * @covers OracleInstaller::checkConnectStringFormat
-        */
-       public function testCheckConnectStringFormat( $expected, $connectString, $msg = '' ) {
-               $validity = $expected ? 'should be valid' : 'should NOT be valid';
-               $msg = "'$connectString' ($msg) $validity.";
-               $this->assertEquals( $expected,
-                       OracleInstaller::checkConnectStringFormat( $connectString ),
-                       $msg
-               );
-       }
-
-       /**
-        * Provider to test OracleInstaller::checkConnectStringFormat()
-        */
-       function provideOracleConnectStrings() {
-               // expected result, connectString[, message]
-               return [
-                       [ true, 'simple_01', 'Simple TNS name' ],
-                       [ true, 'simple_01.world', 'TNS name with domain' ],
-                       [ true, 'simple_01.domain.net', 'TNS name with domain' ],
-                       [ true, 'host123', 'Host only' ],
-                       [ true, 'host123.domain.net', 'FQDN only' ],
-                       [ true, '//host123.domain.net', 'FQDN URL only' ],
-                       [ true, '123.223.213.132', 'Host IP only' ],
-                       [ true, 'host:1521', 'Host and port' ],
-                       [ true, 'host:1521/service', 'Host, port and service' ],
-                       [ true, 'host:1521/service:shared', 'Host, port, service and shared server type' ],
-                       [ true, 'host:1521/service:dedicated', 'Host, port, service and dedicated server type' ],
-                       [ true, 'host:1521/service:pooled', 'Host, port, service and pooled server type' ],
-                       [
-                               true,
-                               'host:1521/service:shared/instance1',
-                               'Host, port, service, server type and instance'
-                       ],
-                       [ true, 'host:1521//instance1', 'Host, port and instance' ],
-               ];
-       }
-
-}
diff --git a/tests/phpunit/includes/interwiki/InterwikiLookupAdapterTest.php b/tests/phpunit/includes/interwiki/InterwikiLookupAdapterTest.php
deleted file mode 100644 (file)
index 0a13de1..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-<?php
-
-use MediaWiki\Interwiki\InterwikiLookupAdapter;
-
-/**
- * @covers MediaWiki\Interwiki\InterwikiLookupAdapter
- *
- * @group MediaWiki
- * @group Interwiki
- */
-class InterwikiLookupAdapterTest extends MediaWikiTestCase {
-
-       /**
-        * @var InterwikiLookupAdapter
-        */
-       private $interwikiLookup;
-
-       protected function setUp() {
-               parent::setUp();
-
-               $this->interwikiLookup = new InterwikiLookupAdapter(
-                       $this->getSiteLookup( $this->getSites() )
-               );
-       }
-
-       public function testIsValidInterwiki() {
-               $this->assertTrue(
-                       $this->interwikiLookup->isValidInterwiki( 'enwt' ),
-                       'enwt known prefix is valid'
-               );
-               $this->assertTrue(
-                       $this->interwikiLookup->isValidInterwiki( 'foo' ),
-                       'foo site known prefix is valid'
-               );
-               $this->assertFalse(
-                       $this->interwikiLookup->isValidInterwiki( 'xyz' ),
-                       'unknown prefix is not valid'
-               );
-       }
-
-       public function testFetch() {
-               $interwiki = $this->interwikiLookup->fetch( '' );
-               $this->assertNull( $interwiki );
-
-               $interwiki = $this->interwikiLookup->fetch( 'xyz' );
-               $this->assertFalse( $interwiki );
-
-               $interwiki = $this->interwikiLookup->fetch( 'foo' );
-               $this->assertInstanceOf( Interwiki::class, $interwiki );
-               $this->assertSame( 'foobar', $interwiki->getWikiID() );
-
-               $interwiki = $this->interwikiLookup->fetch( 'enwt' );
-               $this->assertInstanceOf( Interwiki::class, $interwiki );
-
-               $this->assertSame( 'https://en.wiktionary.org/wiki/$1', $interwiki->getURL(), 'getURL' );
-               $this->assertSame( 'https://en.wiktionary.org/w/api.php', $interwiki->getAPI(), 'getAPI' );
-               $this->assertSame( 'enwiktionary', $interwiki->getWikiID(), 'getWikiID' );
-               $this->assertTrue( $interwiki->isLocal(), 'isLocal' );
-       }
-
-       public function testGetAllPrefixes() {
-               $foo = [
-                       'iw_prefix' => 'foo',
-                       'iw_url' => '',
-                       'iw_api' => '',
-                       'iw_wikiid' => 'foobar',
-                       'iw_local' => false,
-                       'iw_trans' => false,
-               ];
-               $enwt = [
-                       'iw_prefix' => 'enwt',
-                       'iw_url' => 'https://en.wiktionary.org/wiki/$1',
-                       'iw_api' => 'https://en.wiktionary.org/w/api.php',
-                       'iw_wikiid' => 'enwiktionary',
-                       'iw_local' => true,
-                       'iw_trans' => false,
-               ];
-
-               $this->assertEquals(
-                       [ $foo, $enwt ],
-                       $this->interwikiLookup->getAllPrefixes(),
-                       'getAllPrefixes()'
-               );
-
-               $this->assertEquals(
-                       [ $foo ],
-                       $this->interwikiLookup->getAllPrefixes( false ),
-                       'get external prefixes'
-               );
-
-               $this->assertEquals(
-                       [ $enwt ],
-                       $this->interwikiLookup->getAllPrefixes( true ),
-                       'get local prefixes'
-               );
-       }
-
-       private function getSiteLookup( SiteList $sites ) {
-               $siteLookup = $this->getMockBuilder( SiteLookup::class )
-                       ->disableOriginalConstructor()
-                       ->getMock();
-
-               $siteLookup->expects( $this->any() )
-                       ->method( 'getSites' )
-                       ->will( $this->returnValue( $sites ) );
-
-               return $siteLookup;
-       }
-
-       private function getSites() {
-               $sites = [];
-
-               $site = new Site();
-               $site->setGlobalId( 'foobar' );
-               $site->addInterwikiId( 'foo' );
-               $site->setSource( 'external' );
-               $sites[] = $site;
-
-               $site = new MediaWikiSite();
-               $site->setGlobalId( 'enwiktionary' );
-               $site->setGroup( 'wiktionary' );
-               $site->setLanguageCode( 'en' );
-               $site->addNavigationId( 'enwiktionary' );
-               $site->addInterwikiId( 'enwt' );
-               $site->setSource( 'local' );
-               $site->setPath( MediaWikiSite::PATH_PAGE, "https://en.wiktionary.org/wiki/$1" );
-               $site->setPath( MediaWikiSite::PATH_FILE, "https://en.wiktionary.org/w/$1" );
-               $sites[] = $site;
-
-               return new SiteList( $sites );
-       }
-
-}
diff --git a/tests/phpunit/includes/libs/objectcache/ReplicatedBagOStuffTest.php b/tests/phpunit/includes/libs/objectcache/ReplicatedBagOStuffTest.php
deleted file mode 100644 (file)
index 550ec0b..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-<?php
-
-class ReplicatedBagOStuffTest extends MediaWikiTestCase {
-       /** @var HashBagOStuff */
-       private $writeCache;
-       /** @var HashBagOStuff */
-       private $readCache;
-       /** @var ReplicatedBagOStuff */
-       private $cache;
-
-       protected function setUp() {
-               parent::setUp();
-
-               $this->writeCache = new HashBagOStuff();
-               $this->readCache = new HashBagOStuff();
-               $this->cache = new ReplicatedBagOStuff( [
-                       'writeFactory' => $this->writeCache,
-                       'readFactory' => $this->readCache,
-               ] );
-       }
-
-       /**
-        * @covers ReplicatedBagOStuff::set
-        */
-       public function testSet() {
-               $key = 'a key';
-               $value = 'a value';
-               $this->cache->set( $key, $value );
-
-               // Write to master.
-               $this->assertEquals( $value, $this->writeCache->get( $key ) );
-               // Don't write to replica. Replication is deferred to backend.
-               $this->assertFalse( $this->readCache->get( $key ) );
-       }
-
-       /**
-        * @covers ReplicatedBagOStuff::get
-        */
-       public function testGet() {
-               $key = 'a key';
-
-               $write = 'one value';
-               $this->writeCache->set( $key, $write );
-               $read = 'another value';
-               $this->readCache->set( $key, $read );
-
-               // Read from replica.
-               $this->assertEquals( $read, $this->cache->get( $key ) );
-       }
-
-       /**
-        * @covers ReplicatedBagOStuff::get
-        */
-       public function testGetAbsent() {
-               $key = 'a key';
-               $value = 'a value';
-               $this->writeCache->set( $key, $value );
-
-               // Don't read from master. No failover if value is absent.
-               $this->assertFalse( $this->cache->get( $key ) );
-       }
-}
diff --git a/tests/phpunit/includes/media/GIFMetadataExtractorTest.php b/tests/phpunit/includes/media/GIFMetadataExtractorTest.php
deleted file mode 100644 (file)
index 278b441..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-<?php
-
-/**
- * @group Media
- */
-class GIFMetadataExtractorTest extends MediaWikiTestCase {
-
-       protected function setUp() {
-               parent::setUp();
-
-               $this->mediaPath = __DIR__ . '/../../data/media/';
-       }
-
-       /**
-        * Put in a file, and see if the metadata coming out is as expected.
-        * @param string $filename
-        * @param array $expected The extracted metadata.
-        * @dataProvider provideGetMetadata
-        * @covers GIFMetadataExtractor::getMetadata
-        */
-       public function testGetMetadata( $filename, $expected ) {
-               $actual = GIFMetadataExtractor::getMetadata( $this->mediaPath . $filename );
-               $this->assertEquals( $expected, $actual );
-       }
-
-       public static function provideGetMetadata() {
-               $xmpNugget = <<<EOF
-<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
-<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 7.30'>
-<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
-
- <rdf:Description rdf:about=''
-  xmlns:Iptc4xmpCore='http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/'>
-  <Iptc4xmpCore:Location>The interwebs</Iptc4xmpCore:Location>
- </rdf:Description>
-
- <rdf:Description rdf:about=''
-  xmlns:tiff='http://ns.adobe.com/tiff/1.0/'>
-  <tiff:Artist>Bawolff</tiff:Artist>
-  <tiff:ImageDescription>
-   <rdf:Alt>
-    <rdf:li xml:lang='x-default'>A file to test GIF</rdf:li>
-   </rdf:Alt>
-  </tiff:ImageDescription>
- </rdf:Description>
-</rdf:RDF>
-</x:xmpmeta>
-                                                                                                    
-                                                                                                    
-                                                                                                    
-                                                                                                    
-                                                                                                    
-                                                                                                    
-                                                                                                    
-                                                                                                    
-                                                                                                    
-                                                                                                    
-                                                                                                    
-                                                                                                    
-                                                                                                    
-                                                                                                    
-                                                                                                    
-                                                                                                    
-                                                                                                    
-                                                                                                    
-                                                                                                    
-                                                                                                    
-                                                                                                    
-                                                                                                    
-                                                                                                    
-                                                                                                    
-<?xpacket end='w'?>
-EOF;
-               $xmpNugget = str_replace( "\r", '', $xmpNugget ); // Windows compat
-
-               return [
-                       [
-                               'nonanimated.gif',
-                               [
-                                       'comment' => [ 'GIF test file ⁕ Created with GIMP' ],
-                                       'duration' => 0.1,
-                                       'frameCount' => 1,
-                                       'looped' => false,
-                                       'xmp' => '',
-                               ]
-                       ],
-                       [
-                               'animated.gif',
-                               [
-                                       'comment' => [ 'GIF test file . Created with GIMP' ],
-                                       'duration' => 2.4,
-                                       'frameCount' => 4,
-                                       'looped' => true,
-                                       'xmp' => '',
-                               ]
-                       ],
-
-                       [
-                               'animated-xmp.gif',
-                               [
-                                       'xmp' => $xmpNugget,
-                                       'duration' => 2.4,
-                                       'frameCount' => 4,
-                                       'looped' => true,
-                                       'comment' => [ 'GIƒ·test·file' ],
-                               ]
-                       ],
-               ];
-       }
-}
diff --git a/tests/phpunit/includes/media/IPTCTest.php b/tests/phpunit/includes/media/IPTCTest.php
deleted file mode 100644 (file)
index 4b3ba07..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-<?php
-
-/**
- * @group Media
- */
-class IPTCTest extends MediaWikiTestCase {
-
-       /**
-        * @covers IPTC::getCharset
-        */
-       public function testRecognizeUtf8() {
-               // utf-8 is the only one used in practise.
-               $res = IPTC::getCharset( "\x1b%G" );
-               $this->assertEquals( 'UTF-8', $res );
-       }
-
-       /**
-        * @covers IPTC::parse
-        */
-       public function testIPTCParseNoCharset88591() {
-               // basically IPTC for keyword with value of 0xBC which is 1/4 in iso-8859-1
-               // This data doesn't specify a charset. We're supposed to guess
-               // (which basically means utf-8 if valid, windows 1252 (iso 8859-1) if not)
-               $iptcData = "Photoshop 3.0\08BIM\4\4\0\0\0\0\0\x06\x1c\x02\x19\x00\x01\xBC";
-               $res = IPTC::parse( $iptcData );
-               $this->assertEquals( [ '¼' ], $res['Keywords'] );
-       }
-
-       /**
-        * @covers IPTC::parse
-        */
-       public function testIPTCParseNoCharset88591b() {
-               /* This one contains a sequence that's valid iso 8859-1 but not valid utf8 */
-               /* \xC3 = Ã, \xB8 = ¸  */
-               $iptcData = "Photoshop 3.0\08BIM\4\4\0\0\0\0\0\x09\x1c\x02\x19\x00\x04\xC3\xC3\xC3\xB8";
-               $res = IPTC::parse( $iptcData );
-               $this->assertEquals( [ 'ÃÃø' ], $res['Keywords'] );
-       }
-
-       /**
-        * Same as testIPTCParseNoCharset88591b, but forcing the charset to utf-8.
-        * What should happen is the first "\xC3\xC3" should be dropped as invalid,
-        * leaving \xC3\xB8, which is ø
-        * @covers IPTC::parse
-        */
-       public function testIPTCParseForcedUTFButInvalid() {
-               $iptcData = "Photoshop 3.0\08BIM\4\4\0\0\0\0\0\x11\x1c\x02\x19\x00\x04\xC3\xC3\xC3\xB8"
-                       . "\x1c\x01\x5A\x00\x03\x1B\x25\x47";
-               $res = IPTC::parse( $iptcData );
-               $this->assertEquals( [ 'ø' ], $res['Keywords'] );
-       }
-
-       /**
-        * @covers IPTC::parse
-        */
-       public function testIPTCParseNoCharsetUTF8() {
-               $iptcData = "Photoshop 3.0\08BIM\4\4\0\0\0\0\0\x07\x1c\x02\x19\x00\x02¼";
-               $res = IPTC::parse( $iptcData );
-               $this->assertEquals( [ '¼' ], $res['Keywords'] );
-       }
-
-       /**
-        * Testing something that has 2 values for keyword
-        * @covers IPTC::parse
-        */
-       public function testIPTCParseMulti() {
-               $iptcData = /* identifier */ "Photoshop 3.0\08BIM\4\4"
-                       /* length */ . "\0\0\0\0\0\x0D"
-                       . "\x1c\x02\x19" . "\x00\x01" . "\xBC"
-                       . "\x1c\x02\x19" . "\x00\x02" . "\xBC\xBD";
-               $res = IPTC::parse( $iptcData );
-               $this->assertEquals( [ '¼', '¼½' ], $res['Keywords'] );
-       }
-
-       /**
-        * @covers IPTC::parse
-        */
-       public function testIPTCParseUTF8() {
-               // This has the magic "\x1c\x01\x5A\x00\x03\x1B\x25\x47" which marks content as UTF8.
-               $iptcData =
-                       "Photoshop 3.0\08BIM\4\4\0\0\0\0\0\x0F\x1c\x02\x19\x00\x02¼\x1c\x01\x5A\x00\x03\x1B\x25\x47";
-               $res = IPTC::parse( $iptcData );
-               $this->assertEquals( [ '¼' ], $res['Keywords'] );
-       }
-}
diff --git a/tests/phpunit/includes/media/MediaHandlerTest.php b/tests/phpunit/includes/media/MediaHandlerTest.php
deleted file mode 100644 (file)
index 7a052f6..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-<?php
-
-/**
- * @group Media
- */
-class MediaHandlerTest extends MediaWikiTestCase {
-
-       /**
-        * @covers MediaHandler::fitBoxWidth
-        *
-        * @dataProvider provideTestFitBoxWidth
-        */
-       public function testFitBoxWidth( $width, $height, $max, $expected ) {
-               $y = round( $expected * $height / $width );
-               $result = MediaHandler::fitBoxWidth( $width, $height, $max );
-               $y2 = round( $result * $height / $width );
-               $this->assertEquals( $expected,
-                       $result,
-                       "($width, $height, $max) wanted: {$expected}x$y, got: {z$result}x$y2" );
-       }
-
-       public static function provideTestFitBoxWidth() {
-               return array_merge(
-                       static::generateTestFitBoxWidthData( 50, 50, [
-                                       50 => 50,
-                                       17 => 17,
-                                       18 => 18 ]
-                       ),
-                       static::generateTestFitBoxWidthData( 366, 300, [
-                                       50 => 61,
-                                       17 => 21,
-                                       18 => 22 ]
-                       ),
-                       static::generateTestFitBoxWidthData( 300, 366, [
-                                       50 => 41,
-                                       17 => 14,
-                                       18 => 15 ]
-                       ),
-                       static::generateTestFitBoxWidthData( 100, 400, [
-                                       50 => 12,
-                                       17 => 4,
-                                       18 => 4 ]
-                       )
-               );
-       }
-
-       /**
-        * Generate single test cases by combining the dimensions and tests contents
-        *
-        * It creates:
-        * [$width, $height, $max, $expected],
-        * [$width, $height, $max2, $expected2], ...
-        * out of parameters:
-        * $width, $height, { $max => $expected, $max2 => $expected2, ... }
-        *
-        * @param int $width
-        * @param int $height
-        * @param array $tests associative array of $max => $expected values
-        * @return array
-        */
-       private static function generateTestFitBoxWidthData( $width, $height, $tests ) {
-               $result = [];
-               foreach ( $tests as $max => $expected ) {
-                       $result[] = [ $width, $height, $max, $expected ];
-               }
-               return $result;
-       }
-}
diff --git a/tests/phpunit/includes/media/SVGMetadataExtractorTest.php b/tests/phpunit/includes/media/SVGMetadataExtractorTest.php
deleted file mode 100644 (file)
index 6b94d0a..0000000
+++ /dev/null
@@ -1,201 +0,0 @@
-<?php
-
-/**
- * @group Media
- * @covers SVGMetadataExtractor
- */
-class SVGMetadataExtractorTest extends MediaWikiTestCase {
-
-       /**
-        * @dataProvider provideSvgFiles
-        */
-       public function testGetMetadata( $infile, $expected ) {
-               $this->assertMetadata( $infile, $expected );
-       }
-
-       /**
-        * @dataProvider provideSvgFilesWithXMLMetadata
-        */
-       public function testGetXMLMetadata( $infile, $expected ) {
-               $r = new XMLReader();
-               $this->assertMetadata( $infile, $expected );
-       }
-
-       /**
-        * @dataProvider provideSvgUnits
-        */
-       public function testScaleSVGUnit( $inUnit, $expected ) {
-               $this->assertEquals(
-                       $expected,
-                       SVGReader::scaleSVGUnit( $inUnit ),
-                       'SVG unit conversion and scaling failure'
-               );
-       }
-
-       function assertMetadata( $infile, $expected ) {
-               try {
-                       $data = SVGMetadataExtractor::getMetadata( $infile );
-                       $this->assertEquals( $expected, $data, 'SVG metadata extraction test' );
-               } catch ( MWException $e ) {
-                       if ( $expected === false ) {
-                               $this->assertTrue( true, 'SVG metadata extracted test (expected failure)' );
-                       } else {
-                               throw $e;
-                       }
-               }
-       }
-
-       public static function provideSvgFiles() {
-               $base = __DIR__ . '/../../data/media';
-
-               return [
-                       [
-                               "$base/Wikimedia-logo.svg",
-                               [
-                                       'width' => 1024,
-                                       'height' => 1024,
-                                       'originalWidth' => '1024',
-                                       'originalHeight' => '1024',
-                                       'translations' => [],
-                               ]
-                       ],
-                       [
-                               "$base/QA_icon.svg",
-                               [
-                                       'width' => 60,
-                                       'height' => 60,
-                                       'originalWidth' => '60',
-                                       'originalHeight' => '60',
-                                       'translations' => [],
-                               ]
-                       ],
-                       [
-                               "$base/Gtk-media-play-ltr.svg",
-                               [
-                                       'width' => 60,
-                                       'height' => 60,
-                                       'originalWidth' => '60.0000000',
-                                       'originalHeight' => '60.0000000',
-                                       'translations' => [],
-                               ]
-                       ],
-                       [
-                               "$base/Toll_Texas_1.svg",
-                               // This file triggered T33719, needs entity expansion in the xmlns checks
-                               [
-                                       'width' => 385,
-                                       'height' => 385,
-                                       'originalWidth' => '385',
-                                       'originalHeight' => '385.0004883',
-                                       'translations' => [],
-                               ]
-                       ],
-                       [
-                               "$base/Tux.svg",
-                               [
-                                       'width' => 512,
-                                       'height' => 594,
-                                       'originalWidth' => '100%',
-                                       'originalHeight' => '100%',
-                                       'title' => 'Tux',
-                                       'translations' => [],
-                                       'description' => 'For more information see: http://commons.wikimedia.org/wiki/Image:Tux.svg',
-                               ]
-                       ],
-                       [
-                               "$base/Speech_bubbles.svg",
-                               [
-                                       'width' => 627,
-                                       'height' => 461,
-                                       'originalWidth' => '17.7cm',
-                                       'originalHeight' => '13cm',
-                                       'translations' => [
-                                               'de' => SVGReader::LANG_FULL_MATCH,
-                                               'fr' => SVGReader::LANG_FULL_MATCH,
-                                               'nl' => SVGReader::LANG_FULL_MATCH,
-                                               'tlh-ca' => SVGReader::LANG_FULL_MATCH,
-                                               'tlh' => SVGReader::LANG_PREFIX_MATCH
-                                       ],
-                               ]
-                       ],
-                       [
-                               "$base/Soccer_ball_animated.svg",
-                               [
-                                       'width' => 150,
-                                       'height' => 150,
-                                       'originalWidth' => '150',
-                                       'originalHeight' => '150',
-                                       'animated' => true,
-                                       'translations' => []
-                               ],
-                       ],
-                       [
-                               "$base/comma_separated_viewbox.svg",
-                               [
-                                       'width' => 512,
-                                       'height' => 594,
-                                       'originalWidth' => '100%',
-                                       'originalHeight' => '100%',
-                                       'translations' => []
-                               ],
-                       ],
-               ];
-       }
-
-       public static function provideSvgFilesWithXMLMetadata() {
-               $base = __DIR__ . '/../../data/media';
-               // phpcs:disable Generic.Files.LineLength
-               $metadata = '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
-      <ns4:Work xmlns:ns4="http://creativecommons.org/ns#" rdf:about="">
-        <ns5:format xmlns:ns5="http://purl.org/dc/elements/1.1/">image/svg+xml</ns5:format>
-        <ns5:type xmlns:ns5="http://purl.org/dc/elements/1.1/" rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
-      </ns4:Work>
-    </rdf:RDF>';
-               // phpcs:enable
-
-               $metadata = str_replace( "\r", '', $metadata ); // Windows compat
-               return [
-                       [
-                               "$base/US_states_by_total_state_tax_revenue.svg",
-                               [
-                                       'height' => 593,
-                                       'metadata' => $metadata,
-                                       'width' => 959,
-                                       'originalWidth' => '958.69',
-                                       'originalHeight' => '592.78998',
-                                       'translations' => [],
-                               ]
-                       ],
-               ];
-       }
-
-       public static function provideSvgUnits() {
-               return [
-                       [ '1' , 1 ],
-                       [ '1.1' , 1.1 ],
-                       [ '0.1' , 0.1 ],
-                       [ '.1' , 0.1 ],
-                       [ '1e2' , 100 ],
-                       [ '1E2' , 100 ],
-                       [ '+1' , 1 ],
-                       [ '-1' , -1 ],
-                       [ '-1.1' , -1.1 ],
-                       [ '1e+2' , 100 ],
-                       [ '1e-2' , 0.01 ],
-                       [ '10px' , 10 ],
-                       [ '10pt' , 10 * 1.25 ],
-                       [ '10pc' , 10 * 15 ],
-                       [ '10mm' , 10 * 3.543307 ],
-                       [ '10cm' , 10 * 35.43307 ],
-                       [ '10in' , 10 * 90 ],
-                       [ '10em' , 10 * 16 ],
-                       [ '10ex' , 10 * 12 ],
-                       [ '10%' , 51.2 ],
-                       [ '10 px' , 10 ],
-                       // Invalid values
-                       [ '1e1.1', 10 ],
-                       [ '10bp', 10 ],
-                       [ 'p10', null ],
-               ];
-       }
-}
diff --git a/tests/phpunit/includes/objectcache/MemcachedBagOStuffTest.php b/tests/phpunit/includes/objectcache/MemcachedBagOStuffTest.php
deleted file mode 100644 (file)
index 45971da..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-<?php
-/**
- * @group BagOStuff
- */
-class MemcachedBagOStuffTest extends MediaWikiTestCase {
-       /** @var MemcachedBagOStuff */
-       private $cache;
-
-       protected function setUp() {
-               parent::setUp();
-               $this->cache = new MemcachedPhpBagOStuff( [ 'keyspace' => 'test', 'servers' => [] ] );
-       }
-
-       /**
-        * @covers MemcachedBagOStuff::makeKey
-        */
-       public function testKeyNormalization() {
-               $this->assertEquals(
-                       'test:vanilla',
-                       $this->cache->makeKey( 'vanilla' )
-               );
-
-               $this->assertEquals(
-                       'test:punctuation_marks_are_ok:!@$^&*()',
-                       $this->cache->makeKey( 'punctuation_marks_are_ok', '!@$^&*()' )
-               );
-
-               $this->assertEquals(
-                       'test:but_spaces:hashes%23:and%0Anewlines:are_not',
-                       $this->cache->makeKey( 'but spaces', 'hashes#', "and\nnewlines", 'are_not' )
-               );
-
-               $this->assertEquals(
-                       'test:this:key:contains:%F0%9D%95%9E%F0%9D%95%A6%F0%9D%95%9D%F0%9D%95%A5%F0%9' .
-                               'D%95%9A%F0%9D%95%93%F0%9D%95%AA%F0%9D%95%A5%F0%9D%95%96:characters',
-                       $this->cache->makeKey( 'this', 'key', 'contains', '𝕞𝕦𝕝𝕥𝕚𝕓𝕪𝕥𝕖', 'characters' )
-               );
-
-               $this->assertEquals(
-                       'test:this:key:contains:#c118f92685a635cb843039de50014c9c',
-                       $this->cache->makeKey( 'this', 'key', 'contains', '𝕥𝕠𝕠 𝕞𝕒𝕟𝕪 𝕞𝕦𝕝𝕥𝕚𝕓𝕪𝕥𝕖 𝕔𝕙𝕒𝕣𝕒𝕔𝕥𝕖𝕣𝕤' )
-               );
-
-               $this->assertEquals(
-                       'test:BagOStuff-long-key:##dc89dcb43b28614da27660240af478b5',
-                       $this->cache->makeKey( '𝕖𝕧𝕖𝕟', '𝕚𝕗', '𝕨𝕖', '𝕄𝔻𝟝', '𝕖𝕒𝕔𝕙',
-                               '𝕒𝕣𝕘𝕦𝕞𝕖𝕟𝕥', '𝕥𝕙𝕚𝕤', '𝕜𝕖𝕪', '𝕨𝕠𝕦𝕝𝕕', '𝕤𝕥𝕚𝕝𝕝', '𝕓𝕖', '𝕥𝕠𝕠', '𝕝𝕠𝕟𝕘' )
-               );
-
-               $this->assertEquals(
-                       'test:%23%235820ad1d105aa4dc698585c39df73e19',
-                       $this->cache->makeKey( '##5820ad1d105aa4dc698585c39df73e19' )
-               );
-
-               $this->assertEquals(
-                       'test:percent_is_escaped:!@$%25^&*()',
-                       $this->cache->makeKey( 'percent_is_escaped', '!@$%^&*()' )
-               );
-
-               $this->assertEquals(
-                       'test:colon_is_escaped:!@$%3A^&*()',
-                       $this->cache->makeKey( 'colon_is_escaped', '!@$:^&*()' )
-               );
-
-               $this->assertEquals(
-                       'test:long_key_part_hashed:#0244f7b1811d982dd932dd7de01465ac',
-                       $this->cache->makeKey( 'long_key_part_hashed', str_repeat( 'y', 500 ) )
-               );
-       }
-
-       /**
-        * @dataProvider validKeyProvider
-        * @covers MemcachedBagOStuff::validateKeyEncoding
-        */
-       public function testValidateKeyEncoding( $key ) {
-               $this->assertSame( $key, $this->cache->validateKeyEncoding( $key ) );
-       }
-
-       public function validKeyProvider() {
-               return [
-                       'empty' => [ '' ],
-                       'digits' => [ '09' ],
-                       'letters' => [ 'AZaz' ],
-                       'ASCII special characters' => [ '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~' ],
-               ];
-       }
-
-       /**
-        * @dataProvider invalidKeyProvider
-        * @covers MemcachedBagOStuff::validateKeyEncoding
-        */
-       public function testValidateKeyEncodingThrowsException( $key ) {
-               $this->setExpectedException( Exception::class );
-               $this->cache->validateKeyEncoding( $key );
-       }
-
-       public function invalidKeyProvider() {
-               return [
-                       [ "\x00" ],
-                       [ ' ' ],
-                       [ "\x1F" ],
-                       [ "\x7F" ],
-                       [ "\x80" ],
-                       [ "\xFF" ],
-               ];
-       }
-}
diff --git a/tests/phpunit/includes/objectcache/RESTBagOStuffTest.php b/tests/phpunit/includes/objectcache/RESTBagOStuffTest.php
deleted file mode 100644 (file)
index dfbca70..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-<?php
-/**
- * @group BagOStuff
- *
- * @covers RESTBagOStuff
- */
-class RESTBagOStuffTest extends MediaWikiTestCase {
-
-       /**
-        * @var MultiHttpClient
-        */
-       private $client;
-       /**
-        * @var RESTBagOStuff
-        */
-       private $bag;
-
-       public function setUp() {
-               parent::setUp();
-               $this->client =
-                       $this->getMockBuilder( MultiHttpClient::class )
-                               ->setConstructorArgs( [ [] ] )
-                               ->setMethods( [ 'run' ] )
-                               ->getMock();
-               $this->bag = new RESTBagOStuff( [ 'client' => $this->client, 'url' => 'http://test/rest/' ] );
-       }
-
-       public function testGet() {
-               $this->client->expects( $this->once() )->method( 'run' )->with( [
-                       'method' => 'GET',
-                       'url' => 'http://test/rest/42xyz42',
-                       'headers' => []
-                       // list( $rcode, $rdesc, $rhdrs, $rbody, $rerr )
-               ] )->willReturn( [ 200, 'OK', [], '"somedata"', 0 ] );
-               $result = $this->bag->get( '42xyz42' );
-               $this->assertEquals( 'somedata', $result );
-       }
-
-       public function testGetNotExist() {
-               $this->client->expects( $this->once() )->method( 'run' )->with( [
-                       'method' => 'GET',
-                       'url' => 'http://test/rest/42xyz42',
-                       'headers' => []
-                       // list( $rcode, $rdesc, $rhdrs, $rbody, $rerr )
-               ] )->willReturn( [ 404, 'Not found', [], 'Nothing to see here', 0 ] );
-               $result = $this->bag->get( '42xyz42' );
-               $this->assertFalse( $result );
-       }
-
-       public function testGetBadClient() {
-               $this->client->expects( $this->once() )->method( 'run' )->with( [
-                       'method' => 'GET',
-                       'url' => 'http://test/rest/42xyz42',
-                       'headers' => []
-                       // list( $rcode, $rdesc, $rhdrs, $rbody, $rerr )
-               ] )->willReturn( [ 0, '', [], '', 'cURL has failed you today' ] );
-               $result = $this->bag->get( '42xyz42' );
-               $this->assertFalse( $result );
-               $this->assertEquals( BagOStuff::ERR_UNREACHABLE, $this->bag->getLastError() );
-       }
-
-       public function testGetBadServer() {
-               $this->client->expects( $this->once() )->method( 'run' )->with( [
-                       'method' => 'GET',
-                       'url' => 'http://test/rest/42xyz42',
-                       'headers' => []
-                       // list( $rcode, $rdesc, $rhdrs, $rbody, $rerr )
-               ] )->willReturn( [ 500, 'Too busy', [], 'Server is too busy', '' ] );
-               $result = $this->bag->get( '42xyz42' );
-               $this->assertFalse( $result );
-               $this->assertEquals( BagOStuff::ERR_UNEXPECTED, $this->bag->getLastError() );
-       }
-
-       public function testPut() {
-               $this->client->expects( $this->once() )->method( 'run' )->with( [
-                       'method' => 'PUT',
-                       'url' => 'http://test/rest/42xyz42',
-                       'body' => '"postdata"',
-                       'headers' => []
-                       // list( $rcode, $rdesc, $rhdrs, $rbody, $rerr )
-               ] )->willReturn( [ 200, 'OK', [], 'Done', 0 ] );
-               $result = $this->bag->set( '42xyz42', 'postdata' );
-               $this->assertTrue( $result );
-       }
-
-       public function testDelete() {
-               $this->client->expects( $this->once() )->method( 'run' )->with( [
-                       'method' => 'DELETE',
-                       'url' => 'http://test/rest/42xyz42',
-                       'headers' => []
-                       // list( $rcode, $rdesc, $rhdrs, $rbody, $rerr )
-               ] )->willReturn( [ 200, 'OK', [], 'Done', 0 ] );
-               $result = $this->bag->delete( '42xyz42' );
-               $this->assertTrue( $result );
-       }
-}
diff --git a/tests/phpunit/includes/parser/TidyTest.php b/tests/phpunit/includes/parser/TidyTest.php
deleted file mode 100644 (file)
index 898ef2d..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-<?php
-
-/**
- * @group Parser
- * @covers MWTidy
- */
-class TidyTest extends MediaWikiTestCase {
-
-       protected function setUp() {
-               parent::setUp();
-               if ( !MWTidy::isEnabled() ) {
-                       $this->markTestSkipped( 'Tidy not found' );
-               }
-       }
-
-       /**
-        * @dataProvider provideTestWrapping
-        */
-       public function testTidyWrapping( $expected, $text, $msg = '' ) {
-               $text = MWTidy::tidy( $text );
-               // We don't care about where Tidy wants to stick is <p>s
-               $text = trim( preg_replace( '#</?p>#', '', $text ) );
-               // Windows, we love you!
-               $text = str_replace( "\r", '', $text );
-               $this->assertEquals( $expected, $text, $msg );
-       }
-
-       public static function provideTestWrapping() {
-               $testMathML = <<<'MathML'
-<math xmlns="http://www.w3.org/1998/Math/MathML">
-    <mrow>
-      <mi>a</mi>
-      <mo>&InvisibleTimes;</mo>
-      <msup>
-        <mi>x</mi>
-        <mn>2</mn>
-      </msup>
-      <mo>+</mo>
-      <mi>b</mi>
-      <mo>&InvisibleTimes; </mo>
-      <mi>x</mi>
-      <mo>+</mo>
-      <mi>c</mi>
-    </mrow>
-  </math>
-MathML;
-               return [
-                       [
-                               '<mw:editsection page="foo" section="bar">foo</mw:editsection>',
-                               '<mw:editsection page="foo" section="bar">foo</mw:editsection>',
-                               '<mw:editsection> should survive tidy'
-                       ],
-                       [
-                               '<editsection page="foo" section="bar">foo</editsection>',
-                               '<editsection page="foo" section="bar">foo</editsection>',
-                               '<editsection> should survive tidy'
-                       ],
-                       [ '<mw:toc>foo</mw:toc>', '<mw:toc>foo</mw:toc>', '<mw:toc> should survive tidy' ],
-                       [ "<link foo=\"bar\" />foo", '<link foo="bar"/>foo', '<link> should survive tidy' ],
-                       [ "<meta foo=\"bar\" />foo", '<meta foo="bar"/>foo', '<meta> should survive tidy' ],
-                       [ $testMathML, $testMathML, '<math> should survive tidy' ],
-               ];
-       }
-}
diff --git a/tests/phpunit/includes/password/PasswordTest.php b/tests/phpunit/includes/password/PasswordTest.php
deleted file mode 100644 (file)
index 61a5147..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-/**
- * Testing framework for the Password infrastructure
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- */
-
-/**
- * @covers InvalidPassword
- */
-class PasswordTest extends MediaWikiTestCase {
-       public function testInvalidPlaintext() {
-               $passwordFactory = new PasswordFactory();
-               $invalid = $passwordFactory->newFromPlaintext( null );
-
-               $this->assertInstanceOf( InvalidPassword::class, $invalid );
-       }
-}
diff --git a/tests/phpunit/includes/preferences/FiltersTest.php b/tests/phpunit/includes/preferences/FiltersTest.php
deleted file mode 100644 (file)
index 60b01b8..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-<?php
-/**
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- */
-
-use MediaWiki\Preferences\IntvalFilter;
-use MediaWiki\Preferences\MultiUsernameFilter;
-use MediaWiki\Preferences\TimezoneFilter;
-
-/**
- * @group Preferences
- */
-class FiltersTest extends MediaWikiTestCase {
-       /**
-        * @covers MediaWiki\Preferences\IntvalFilter::filterFromForm()
-        * @covers MediaWiki\Preferences\IntvalFilter::filterForForm()
-        */
-       public function testIntvalFilter() {
-               $filter = new IntvalFilter();
-               self::assertSame( 0, $filter->filterFromForm( '0' ) );
-               self::assertSame( 3, $filter->filterFromForm( '3' ) );
-               self::assertSame( '123', $filter->filterForForm( '123' ) );
-       }
-
-       /**
-        * @covers       MediaWiki\Preferences\TimezoneFilter::filterFromForm()
-        * @dataProvider provideTimezoneFilter
-        *
-        * @param string $input
-        * @param string $expected
-        */
-       public function testTimezoneFilter( $input, $expected ) {
-               $filter = new TimezoneFilter();
-               $result = $filter->filterFromForm( $input );
-               self::assertEquals( $expected, $result );
-       }
-
-       public function provideTimezoneFilter() {
-               return [
-                       [ 'ZoneInfo', 'Offset|0' ],
-                       [ 'ZoneInfo|bogus', 'Offset|0' ],
-                       [ 'System', 'System' ],
-                       [ '2:30', 'Offset|150' ],
-               ];
-       }
-
-       /**
-        * @covers MediaWiki\Preferences\MultiUsernameFilter::filterFromForm()
-        * @dataProvider provideMultiUsernameFilterFrom
-        *
-        * @param string $input
-        * @param string|null $expected
-        */
-       public function testMultiUsernameFilterFrom( $input, $expected ) {
-               $filter = $this->makeMultiUsernameFilter();
-               $result = $filter->filterFromForm( $input );
-               self::assertSame( $expected, $result );
-       }
-
-       public function provideMultiUsernameFilterFrom() {
-               return [
-                       [ '', null ],
-                       [ "\n\n\n", null ],
-                       [ 'Foo', '1' ],
-                       [ "\n\n\nFoo\nBar\n", "1\n2" ],
-                       [ "Baz\nInvalid\nFoo", "3\n1" ],
-                       [ "Invalid", null ],
-                       [ "Invalid\n\n\nInvalid\n", null ],
-               ];
-       }
-
-       /**
-        * @covers MediaWiki\Preferences\MultiUsernameFilter::filterForForm()
-        * @dataProvider provideMultiUsernameFilterFor
-        *
-        * @param string $input
-        * @param string $expected
-        */
-       public function testMultiUsernameFilterFor( $input, $expected ) {
-               $filter = $this->makeMultiUsernameFilter();
-               $result = $filter->filterForForm( $input );
-               self::assertSame( $expected, $result );
-       }
-
-       public function provideMultiUsernameFilterFor() {
-               return [
-                       [ '', '' ],
-                       [ "\n", '' ],
-                       [ '1', 'Foo' ],
-                       [ "\n1\n\n2\377\n", "Foo\nBar" ],
-                       [ "666\n667", '' ],
-               ];
-       }
-
-       private function makeMultiUsernameFilter() {
-               $userMapping = [
-                       'Foo' => 1,
-                       'Bar' => 2,
-                       'Baz' => 3,
-               ];
-               $flipped = array_flip( $userMapping );
-               $idLookup = self::getMockBuilder( CentralIdLookup::class )
-                       ->disableOriginalConstructor()
-                       ->setMethods( [ 'centralIdsFromNames', 'namesFromCentralIds' ] )
-                       ->getMockForAbstractClass();
-
-               $idLookup->method( 'centralIdsFromNames' )
-                       ->will( self::returnCallback( function ( $names ) use ( $userMapping ) {
-                               $ids = [];
-                               foreach ( $names as $name ) {
-                                       $ids[] = $userMapping[$name] ?? null;
-                               }
-                               return array_filter( $ids, 'is_numeric' );
-                       } ) );
-               $idLookup->method( 'namesFromCentralIds' )
-                       ->will( self::returnCallback( function ( $ids ) use ( $flipped ) {
-                               $names = [];
-                               foreach ( $ids as $id ) {
-                                       $names[] = $flipped[$id] ?? null;
-                               }
-                               return array_filter( $names, 'is_string' );
-                       } ) );
-
-               return new MultiUsernameFilter( $idLookup );
-       }
-}
diff --git a/tests/phpunit/includes/registration/ExtensionProcessorTest.php b/tests/phpunit/includes/registration/ExtensionProcessorTest.php
deleted file mode 100644 (file)
index cdd5c63..0000000
+++ /dev/null
@@ -1,829 +0,0 @@
-<?php
-
-use Wikimedia\TestingAccessWrapper;
-
-/**
- * @covers ExtensionProcessor
- */
-class ExtensionProcessorTest extends MediaWikiTestCase {
-
-       private $dir, $dirname;
-
-       public function setUp() {
-               parent::setUp();
-               $this->dir = __DIR__ . '/FooBar/extension.json';
-               $this->dirname = dirname( $this->dir );
-       }
-
-       /**
-        * 'name' is absolutely required
-        *
-        * @var array
-        */
-       public static $default = [
-               'name' => 'FooBar',
-       ];
-
-       public function testExtractInfo() {
-               // Test that attributes that begin with @ are ignored
-               $processor = new ExtensionProcessor();
-               $processor->extractInfo( $this->dir, self::$default + [
-                       '@metadata' => [ 'foobarbaz' ],
-                       'AnAttribute' => [ 'omg' ],
-                       'AutoloadClasses' => [ 'FooBar' => 'includes/FooBar.php' ],
-                       'SpecialPages' => [ 'Foo' => 'SpecialFoo' ],
-                       'callback' => 'FooBar::onRegistration',
-               ], 1 );
-
-               $extracted = $processor->getExtractedInfo();
-               $attributes = $extracted['attributes'];
-               $this->assertArrayHasKey( 'AnAttribute', $attributes );
-               $this->assertArrayNotHasKey( '@metadata', $attributes );
-               $this->assertArrayNotHasKey( 'AutoloadClasses', $attributes );
-               $this->assertSame(
-                       [ 'FooBar' => 'FooBar::onRegistration' ],
-                       $extracted['callbacks']
-               );
-               $this->assertSame(
-                       [ 'Foo' => 'SpecialFoo' ],
-                       $extracted['globals']['wgSpecialPages']
-               );
-       }
-
-       public function testExtractNamespaces() {
-               // Test that namespace IDs can be overwritten
-               if ( !defined( 'MW_EXTENSION_PROCESSOR_TEST_EXTRACT_INFO_X' ) ) {
-                       define( 'MW_EXTENSION_PROCESSOR_TEST_EXTRACT_INFO_X', 123456 );
-               }
-
-               $processor = new ExtensionProcessor();
-               $processor->extractInfo( $this->dir, self::$default + [
-                       'namespaces' => [
-                               [
-                                       'id' => 332200,
-                                       'constant' => 'MW_EXTENSION_PROCESSOR_TEST_EXTRACT_INFO_A',
-                                       'name' => 'Test_A',
-                                       'defaultcontentmodel' => 'TestModel',
-                                       'gender' => [
-                                               'male' => 'Male test',
-                                               'female' => 'Female test',
-                                       ],
-                                       'subpages' => true,
-                                       'content' => true,
-                                       'protection' => 'userright',
-                               ],
-                               [ // Test_X will use ID 123456 not 334400
-                                       'id' => 334400,
-                                       'constant' => 'MW_EXTENSION_PROCESSOR_TEST_EXTRACT_INFO_X',
-                                       'name' => 'Test_X',
-                                       'defaultcontentmodel' => 'TestModel'
-                               ],
-                       ]
-               ], 1 );
-
-               $extracted = $processor->getExtractedInfo();
-
-               $this->assertArrayHasKey(
-                       'MW_EXTENSION_PROCESSOR_TEST_EXTRACT_INFO_A',
-                       $extracted['defines']
-               );
-               $this->assertArrayNotHasKey(
-                       'MW_EXTENSION_PROCESSOR_TEST_EXTRACT_INFO_X',
-                       $extracted['defines']
-               );
-
-               $this->assertSame(
-                       $extracted['defines']['MW_EXTENSION_PROCESSOR_TEST_EXTRACT_INFO_A'],
-                       332200
-               );
-
-               $this->assertArrayHasKey( 'ExtensionNamespaces', $extracted['attributes'] );
-               $this->assertArrayHasKey( 123456, $extracted['attributes']['ExtensionNamespaces'] );
-               $this->assertArrayHasKey( 332200, $extracted['attributes']['ExtensionNamespaces'] );
-               $this->assertArrayNotHasKey( 334400, $extracted['attributes']['ExtensionNamespaces'] );
-
-               $this->assertSame( 'Test_X', $extracted['attributes']['ExtensionNamespaces'][123456] );
-               $this->assertSame( 'Test_A', $extracted['attributes']['ExtensionNamespaces'][332200] );
-               $this->assertSame(
-                       [ 'male' => 'Male test', 'female' => 'Female test' ],
-                       $extracted['globals']['wgExtraGenderNamespaces'][332200]
-               );
-               // A has subpages, X does not
-               $this->assertTrue( $extracted['globals']['wgNamespacesWithSubpages'][332200] );
-               $this->assertArrayNotHasKey( 123456, $extracted['globals']['wgNamespacesWithSubpages'] );
-       }
-
-       public static function provideRegisterHooks() {
-               $merge = [ ExtensionRegistry::MERGE_STRATEGY => 'array_merge_recursive' ];
-               // Format:
-               // Current $wgHooks
-               // Content in extension.json
-               // Expected value of $wgHooks
-               return [
-                       // No hooks
-                       [
-                               [],
-                               self::$default,
-                               $merge,
-                       ],
-                       // No current hooks, adding one for "FooBaz" in string format
-                       [
-                               [],
-                               [ 'Hooks' => [ 'FooBaz' => 'FooBazCallback' ] ] + self::$default,
-                               [ 'FooBaz' => [ 'FooBazCallback' ] ] + $merge,
-                       ],
-                       // Hook for "FooBaz", adding another one
-                       [
-                               [ 'FooBaz' => [ 'PriorCallback' ] ],
-                               [ 'Hooks' => [ 'FooBaz' => 'FooBazCallback' ] ] + self::$default,
-                               [ 'FooBaz' => [ 'PriorCallback', 'FooBazCallback' ] ] + $merge,
-                       ],
-                       // No current hooks, adding one for "FooBaz" in verbose array format
-                       [
-                               [],
-                               [ 'Hooks' => [ 'FooBaz' => [ 'FooBazCallback' ] ] ] + self::$default,
-                               [ 'FooBaz' => [ 'FooBazCallback' ] ] + $merge,
-                       ],
-                       // Hook for "BarBaz", adding one for "FooBaz"
-                       [
-                               [ 'BarBaz' => [ 'BarBazCallback' ] ],
-                               [ 'Hooks' => [ 'FooBaz' => 'FooBazCallback' ] ] + self::$default,
-                               [
-                                       'BarBaz' => [ 'BarBazCallback' ],
-                                       'FooBaz' => [ 'FooBazCallback' ],
-                               ] + $merge,
-                       ],
-                       // Callbacks for FooBaz wrapped in an array
-                       [
-                               [],
-                               [ 'Hooks' => [ 'FooBaz' => [ 'Callback1' ] ] ] + self::$default,
-                               [
-                                       'FooBaz' => [ 'Callback1' ],
-                               ] + $merge,
-                       ],
-                       // Multiple callbacks for FooBaz hook
-                       [
-                               [],
-                               [ 'Hooks' => [ 'FooBaz' => [ 'Callback1', 'Callback2' ] ] ] + self::$default,
-                               [
-                                       'FooBaz' => [ 'Callback1', 'Callback2' ],
-                               ] + $merge,
-                       ],
-               ];
-       }
-
-       /**
-        * @dataProvider provideRegisterHooks
-        */
-       public function testRegisterHooks( $pre, $info, $expected ) {
-               $processor = new MockExtensionProcessor( [ 'wgHooks' => $pre ] );
-               $processor->extractInfo( $this->dir, $info, 1 );
-               $extracted = $processor->getExtractedInfo();
-               $this->assertEquals( $expected, $extracted['globals']['wgHooks'] );
-       }
-
-       public function testExtractConfig1() {
-               $processor = new ExtensionProcessor;
-               $info = [
-                       'config' => [
-                               'Bar' => 'somevalue',
-                               'Foo' => 10,
-                               '@IGNORED' => 'yes',
-                       ],
-               ] + self::$default;
-               $info2 = [
-                       'config' => [
-                               '_prefix' => 'eg',
-                               'Bar' => 'somevalue'
-                       ],
-                       'name' => 'FooBar2',
-               ];
-               $processor->extractInfo( $this->dir, $info, 1 );
-               $processor->extractInfo( $this->dir, $info2, 1 );
-               $extracted = $processor->getExtractedInfo();
-               $this->assertEquals( 'somevalue', $extracted['globals']['wgBar'] );
-               $this->assertEquals( 10, $extracted['globals']['wgFoo'] );
-               $this->assertArrayNotHasKey( 'wg@IGNORED', $extracted['globals'] );
-               // Custom prefix:
-               $this->assertEquals( 'somevalue', $extracted['globals']['egBar'] );
-       }
-
-       public function testExtractConfig2() {
-               $processor = new ExtensionProcessor;
-               $info = [
-                       'config' => [
-                               'Bar' => [ 'value' => 'somevalue' ],
-                               'Foo' => [ 'value' => 10 ],
-                               'Path' => [ 'value' => 'foo.txt', 'path' => true ],
-                               'Namespaces' => [
-                                       'value' => [
-                                               '10' => true,
-                                               '12' => false,
-                                       ],
-                                       'merge_strategy' => 'array_plus',
-                               ],
-                       ],
-               ] + self::$default;
-               $info2 = [
-                       'config' => [
-                               'Bar' => [ 'value' => 'somevalue' ],
-                       ],
-                       'config_prefix' => 'eg',
-                       'name' => 'FooBar2',
-               ];
-               $processor->extractInfo( $this->dir, $info, 2 );
-               $processor->extractInfo( $this->dir, $info2, 2 );
-               $extracted = $processor->getExtractedInfo();
-               $this->assertEquals( 'somevalue', $extracted['globals']['wgBar'] );
-               $this->assertEquals( 10, $extracted['globals']['wgFoo'] );
-               $this->assertEquals( "{$this->dirname}/foo.txt", $extracted['globals']['wgPath'] );
-               // Custom prefix:
-               $this->assertEquals( 'somevalue', $extracted['globals']['egBar'] );
-               $this->assertSame(
-                       [ 10 => true, 12 => false, ExtensionRegistry::MERGE_STRATEGY => 'array_plus' ],
-                       $extracted['globals']['wgNamespaces']
-               );
-       }
-
-       /**
-        * @expectedException RuntimeException
-        */
-       public function testDuplicateConfigKey1() {
-               $processor = new ExtensionProcessor;
-               $info = [
-                       'config' => [
-                               'Bar' => '',
-                       ]
-               ] + self::$default;
-               $info2 = [
-                       'config' => [
-                               'Bar' => 'g',
-                       ],
-                       'name' => 'FooBar2',
-               ];
-               $processor->extractInfo( $this->dir, $info, 1 );
-               $processor->extractInfo( $this->dir, $info2, 1 );
-       }
-
-       /**
-        * @expectedException RuntimeException
-        */
-       public function testDuplicateConfigKey2() {
-               $processor = new ExtensionProcessor;
-               $info = [
-                       'config' => [
-                               'Bar' => [ 'value' => 'somevalue' ],
-                       ]
-               ] + self::$default;
-               $info2 = [
-                       'config' => [
-                               'Bar' => [ 'value' => 'somevalue' ],
-                       ],
-                       'name' => 'FooBar2',
-               ];
-               $processor->extractInfo( $this->dir, $info, 2 );
-               $processor->extractInfo( $this->dir, $info2, 2 );
-       }
-
-       public static function provideExtractExtensionMessagesFiles() {
-               $dir = __DIR__ . '/FooBar/';
-               return [
-                       [
-                               [ 'ExtensionMessagesFiles' => [ 'FooBarAlias' => 'FooBar.alias.php' ] ],
-                               [ 'wgExtensionMessagesFiles' => [ 'FooBarAlias' => $dir . 'FooBar.alias.php' ] ]
-                       ],
-                       [
-                               [
-                                       'ExtensionMessagesFiles' => [
-                                               'FooBarAlias' => 'FooBar.alias.php',
-                                               'FooBarMagic' => 'FooBar.magic.i18n.php',
-                                       ],
-                               ],
-                               [
-                                       'wgExtensionMessagesFiles' => [
-                                               'FooBarAlias' => $dir . 'FooBar.alias.php',
-                                               'FooBarMagic' => $dir . 'FooBar.magic.i18n.php',
-                                       ],
-                               ],
-                       ],
-               ];
-       }
-
-       /**
-        * @dataProvider provideExtractExtensionMessagesFiles
-        */
-       public function testExtractExtensionMessagesFiles( $input, $expected ) {
-               $processor = new ExtensionProcessor();
-               $processor->extractInfo( $this->dir, $input + self::$default, 1 );
-               $out = $processor->getExtractedInfo();
-               foreach ( $expected as $key => $value ) {
-                       $this->assertEquals( $value, $out['globals'][$key] );
-               }
-       }
-
-       public static function provideExtractMessagesDirs() {
-               $dir = __DIR__ . '/FooBar/';
-               return [
-                       [
-                               [ 'MessagesDirs' => [ 'VisualEditor' => 'i18n' ] ],
-                               [ 'wgMessagesDirs' => [ 'VisualEditor' => [ $dir . 'i18n' ] ] ]
-                       ],
-                       [
-                               [ 'MessagesDirs' => [ 'VisualEditor' => [ 'i18n', 'foobar' ] ] ],
-                               [ 'wgMessagesDirs' => [ 'VisualEditor' => [ $dir . 'i18n', $dir . 'foobar' ] ] ]
-                       ],
-               ];
-       }
-
-       /**
-        * @dataProvider provideExtractMessagesDirs
-        */
-       public function testExtractMessagesDirs( $input, $expected ) {
-               $processor = new ExtensionProcessor();
-               $processor->extractInfo( $this->dir, $input + self::$default, 1 );
-               $out = $processor->getExtractedInfo();
-               foreach ( $expected as $key => $value ) {
-                       $this->assertEquals( $value, $out['globals'][$key] );
-               }
-       }
-
-       public function testExtractCredits() {
-               $processor = new ExtensionProcessor();
-               $processor->extractInfo( $this->dir, self::$default, 1 );
-               $this->setExpectedException( Exception::class );
-               $processor->extractInfo( $this->dir, self::$default, 1 );
-       }
-
-       /**
-        * @dataProvider provideExtractResourceLoaderModules
-        */
-       public function testExtractResourceLoaderModules(
-               $input,
-               array $expectedGlobals,
-               array $expectedAttribs = []
-       ) {
-               $processor = new ExtensionProcessor();
-               $processor->extractInfo( $this->dir, $input + self::$default, 1 );
-               $out = $processor->getExtractedInfo();
-               foreach ( $expectedGlobals as $key => $value ) {
-                       $this->assertEquals( $value, $out['globals'][$key] );
-               }
-               foreach ( $expectedAttribs as $key => $value ) {
-                       $this->assertEquals( $value, $out['attributes'][$key] );
-               }
-       }
-
-       public static function provideExtractResourceLoaderModules() {
-               $dir = __DIR__ . '/FooBar';
-               return [
-                       // Generic module with localBasePath/remoteExtPath specified
-                       [
-                               // Input
-                               [
-                                       'ResourceModules' => [
-                                               'test.foo' => [
-                                                       'styles' => 'foobar.js',
-                                                       'localBasePath' => '',
-                                                       'remoteExtPath' => 'FooBar',
-                                               ],
-                                       ],
-                               ],
-                               // Expected
-                               [
-                                       'wgResourceModules' => [
-                                               'test.foo' => [
-                                                       'styles' => 'foobar.js',
-                                                       'localBasePath' => $dir,
-                                                       'remoteExtPath' => 'FooBar',
-                                               ],
-                                       ],
-                               ],
-                       ],
-                       // ResourceFileModulePaths specified:
-                       [
-                               // Input
-                               [
-                                       'ResourceFileModulePaths' => [
-                                               'localBasePath' => 'modules',
-                                               'remoteExtPath' => 'FooBar/modules',
-                                       ],
-                                       'ResourceModules' => [
-                                               // No paths
-                                               'test.foo' => [
-                                                       'styles' => 'foo.js',
-                                               ],
-                                               // Different paths set
-                                               'test.bar' => [
-                                                       'styles' => 'bar.js',
-                                                       'localBasePath' => 'subdir',
-                                                       'remoteExtPath' => 'FooBar/subdir',
-                                               ],
-                                               // Custom class with no paths set
-                                               'test.class' => [
-                                                       'class' => 'FooBarModule',
-                                                       'extra' => 'argument',
-                                               ],
-                                               // Custom class with a localBasePath
-                                               'test.class.with.path' => [
-                                                       'class' => 'FooBarPathModule',
-                                                       'extra' => 'argument',
-                                                       'localBasePath' => '',
-                                               ]
-                                       ],
-                               ],
-                               // Expected
-                               [
-                                       'wgResourceModules' => [
-                                               'test.foo' => [
-                                                       'styles' => 'foo.js',
-                                                       'localBasePath' => "$dir/modules",
-                                                       'remoteExtPath' => 'FooBar/modules',
-                                               ],
-                                               'test.bar' => [
-                                                       'styles' => 'bar.js',
-                                                       'localBasePath' => "$dir/subdir",
-                                                       'remoteExtPath' => 'FooBar/subdir',
-                                               ],
-                                               'test.class' => [
-                                                       'class' => 'FooBarModule',
-                                                       'extra' => 'argument',
-                                                       'localBasePath' => "$dir/modules",
-                                                       'remoteExtPath' => 'FooBar/modules',
-                                               ],
-                                               'test.class.with.path' => [
-                                                       'class' => 'FooBarPathModule',
-                                                       'extra' => 'argument',
-                                                       'localBasePath' => $dir,
-                                                       'remoteExtPath' => 'FooBar/modules',
-                                               ]
-                                       ],
-                               ],
-                       ],
-                       // ResourceModuleSkinStyles with file module paths
-                       [
-                               // Input
-                               [
-                                       'ResourceFileModulePaths' => [
-                                               'localBasePath' => '',
-                                               'remoteSkinPath' => 'FooBar',
-                                       ],
-                                       'ResourceModuleSkinStyles' => [
-                                               'foobar' => [
-                                                       'test.foo' => 'foo.css',
-                                               ]
-                                       ],
-                               ],
-                               // Expected
-                               [
-                                       'wgResourceModuleSkinStyles' => [
-                                               'foobar' => [
-                                                       'test.foo' => 'foo.css',
-                                                       'localBasePath' => $dir,
-                                                       'remoteSkinPath' => 'FooBar',
-                                               ],
-                                       ],
-                               ],
-                       ],
-                       // ResourceModuleSkinStyles with file module paths and an override
-                       [
-                               // Input
-                               [
-                                       'ResourceFileModulePaths' => [
-                                               'localBasePath' => '',
-                                               'remoteSkinPath' => 'FooBar',
-                                       ],
-                                       'ResourceModuleSkinStyles' => [
-                                               'foobar' => [
-                                                       'test.foo' => 'foo.css',
-                                                       'remoteSkinPath' => 'BarFoo'
-                                               ],
-                                       ],
-                               ],
-                               // Expected
-                               [
-                                       'wgResourceModuleSkinStyles' => [
-                                               'foobar' => [
-                                                       'test.foo' => 'foo.css',
-                                                       'localBasePath' => $dir,
-                                                       'remoteSkinPath' => 'BarFoo',
-                                               ],
-                                       ],
-                               ],
-                       ],
-                       'QUnit test module' => [
-                               // Input
-                               [
-                                       'QUnitTestModule' => [
-                                               'localBasePath' => '',
-                                               'remoteExtPath' => 'Foo',
-                                               'scripts' => 'bar.js',
-                                       ],
-                               ],
-                               // Expected
-                               [],
-                               [
-                                       'QUnitTestModules' => [
-                                               'test.FooBar' => [
-                                                       'localBasePath' => $dir,
-                                                       'remoteExtPath' => 'Foo',
-                                                       'scripts' => 'bar.js',
-                                               ],
-                                       ],
-                               ],
-                       ],
-               ];
-       }
-
-       public static function provideSetToGlobal() {
-               return [
-                       [
-                               [ 'wgAPIModules', 'wgAvailableRights' ],
-                               [],
-                               [
-                                       'APIModules' => [ 'foobar' => 'ApiFooBar' ],
-                                       'AvailableRights' => [ 'foobar', 'unfoobar' ],
-                               ],
-                               [
-                                       'wgAPIModules' => [ 'foobar' => 'ApiFooBar' ],
-                                       'wgAvailableRights' => [ 'foobar', 'unfoobar' ],
-                               ],
-                       ],
-                       [
-                               [ 'wgAPIModules', 'wgAvailableRights' ],
-                               [
-                                       'wgAPIModules' => [ 'barbaz' => 'ApiBarBaz' ],
-                                       'wgAvailableRights' => [ 'barbaz' ]
-                               ],
-                               [
-                                       'APIModules' => [ 'foobar' => 'ApiFooBar' ],
-                                       'AvailableRights' => [ 'foobar', 'unfoobar' ],
-                               ],
-                               [
-                                       'wgAPIModules' => [ 'barbaz' => 'ApiBarBaz', 'foobar' => 'ApiFooBar' ],
-                                       'wgAvailableRights' => [ 'barbaz', 'foobar', 'unfoobar' ],
-                               ],
-                       ],
-                       [
-                               [ 'wgGroupPermissions' ],
-                               [
-                                       'wgGroupPermissions' => [
-                                               'sysop' => [ 'delete' ]
-                                       ],
-                               ],
-                               [
-                                       'GroupPermissions' => [
-                                               'sysop' => [ 'undelete' ],
-                                               'user' => [ 'edit' ]
-                                       ],
-                               ],
-                               [
-                                       'wgGroupPermissions' => [
-                                               'sysop' => [ 'delete', 'undelete' ],
-                                               'user' => [ 'edit' ]
-                                       ],
-                               ]
-                       ]
-               ];
-       }
-
-       /**
-        * Attributes under manifest_version 2
-        */
-       public function testExtractAttributes() {
-               $processor = new ExtensionProcessor();
-               // Load FooBar extension
-               $processor->extractInfo( $this->dir, [ 'name' => 'FooBar' ], 2 );
-               $processor->extractInfo(
-                       $this->dir,
-                       [
-                               'name' => 'Baz',
-                               'attributes' => [
-                                       // Loaded
-                                       'FooBar' => [
-                                               'Plugins' => [
-                                                       'ext.baz.foobar',
-                                               ],
-                                       ],
-                                       // Not loaded
-                                       'FizzBuzz' => [
-                                               'MorePlugins' => [
-                                                       'ext.baz.fizzbuzz',
-                                               ],
-                                       ],
-                               ],
-                       ],
-                       2
-               );
-
-               $info = $processor->getExtractedInfo();
-               $this->assertArrayHasKey( 'FooBarPlugins', $info['attributes'] );
-               $this->assertSame( [ 'ext.baz.foobar' ], $info['attributes']['FooBarPlugins'] );
-               $this->assertArrayNotHasKey( 'FizzBuzzMorePlugins', $info['attributes'] );
-       }
-
-       /**
-        * Attributes under manifest_version 1
-        */
-       public function testAttributes1() {
-               $processor = new ExtensionProcessor();
-               $processor->extractInfo(
-                       $this->dir,
-                       [
-                               'name' => 'FooBar',
-                               'FooBarPlugins' => [
-                                       'ext.baz.foobar',
-                               ],
-                               'FizzBuzzMorePlugins' => [
-                                       'ext.baz.fizzbuzz',
-                               ],
-                       ],
-                       1
-               );
-               $processor->extractInfo(
-                       $this->dir,
-                       [
-                               'name' => 'FooBar2',
-                               'FizzBuzzMorePlugins' => [
-                                       'ext.bar.fizzbuzz',
-                               ]
-                       ],
-                       1
-               );
-
-               $info = $processor->getExtractedInfo();
-               $this->assertArrayHasKey( 'FooBarPlugins', $info['attributes'] );
-               $this->assertSame( [ 'ext.baz.foobar' ], $info['attributes']['FooBarPlugins'] );
-               $this->assertArrayHasKey( 'FizzBuzzMorePlugins', $info['attributes'] );
-               $this->assertSame(
-                       [ 'ext.baz.fizzbuzz', 'ext.bar.fizzbuzz' ],
-                       $info['attributes']['FizzBuzzMorePlugins']
-               );
-       }
-
-       public function testAttributes1_notarray() {
-               $processor = new ExtensionProcessor();
-               $this->setExpectedException(
-                       InvalidArgumentException::class,
-                       "The value for 'FooBarPlugins' should be an array (from {$this->dir})"
-               );
-               $processor->extractInfo(
-                       $this->dir,
-                       [
-                               'FooBarPlugins' => 'ext.baz.foobar',
-                       ] + self::$default,
-                       1
-               );
-       }
-
-       public function testExtractPathBasedGlobal() {
-               $processor = new ExtensionProcessor();
-               $processor->extractInfo(
-                       $this->dir,
-                       [
-                               'ParserTestFiles' => [
-                                       'tests/parserTests.txt',
-                                       'tests/extraParserTests.txt',
-                               ],
-                               'ServiceWiringFiles' => [
-                                       'includes/ServiceWiring.php'
-                               ],
-                       ] + self::$default,
-                       1
-               );
-               $globals = $processor->getExtractedInfo()['globals'];
-               $this->assertArrayHasKey( 'wgParserTestFiles', $globals );
-               $this->assertSame( [
-                       "{$this->dirname}/tests/parserTests.txt",
-                       "{$this->dirname}/tests/extraParserTests.txt"
-               ], $globals['wgParserTestFiles'] );
-               $this->assertArrayHasKey( 'wgServiceWiringFiles', $globals );
-               $this->assertSame( [
-                       "{$this->dirname}/includes/ServiceWiring.php"
-               ], $globals['wgServiceWiringFiles'] );
-       }
-
-       public function testGetRequirements() {
-               $info = self::$default + [
-                       'requires' => [
-                               'MediaWiki' => '>= 1.25.0',
-                               'platform' => [
-                                       'php' => '>= 5.5.9'
-                               ],
-                               'extensions' => [
-                                       'Bar' => '*'
-                               ]
-                       ]
-               ];
-               $processor = new ExtensionProcessor();
-               $this->assertSame(
-                       $info['requires'],
-                       $processor->getRequirements( $info, false )
-               );
-               $this->assertSame(
-                       [],
-                       $processor->getRequirements( [], false )
-               );
-       }
-
-       public function testGetDevRequirements() {
-               $info = self::$default + [
-                       'dev-requires' => [
-                               'MediaWiki' => '>= 1.31.0',
-                               'platform' => [
-                                       'ext-foo' => '*',
-                               ],
-                               'skins' => [
-                                       'Baz' => '*',
-                               ],
-                               'extensions' => [
-                                       'Biz' => '*',
-                               ],
-                       ],
-               ];
-               $processor = new ExtensionProcessor();
-               $this->assertSame(
-                       $info['dev-requires'],
-                       $processor->getRequirements( $info, true )
-               );
-               // Set some standard requirements, so we can test merging
-               $info['requires'] = [
-                       'MediaWiki' => '>= 1.25.0',
-                       'platform' => [
-                               'php' => '>= 5.5.9'
-                       ],
-                       'extensions' => [
-                               'Bar' => '*'
-                       ]
-               ];
-               $this->assertSame(
-                       [
-                               'MediaWiki' => '>= 1.25.0 >= 1.31.0',
-                               'platform' => [
-                                       'php' => '>= 5.5.9',
-                                       'ext-foo' => '*',
-                               ],
-                               'extensions' => [
-                                       'Bar' => '*',
-                                       'Biz' => '*',
-                               ],
-                               'skins' => [
-                                       'Baz' => '*',
-                               ],
-                       ],
-                       $processor->getRequirements( $info, true )
-               );
-
-               // If there's no dev-requires, it just returns requires
-               unset( $info['dev-requires'] );
-               $this->assertSame(
-                       $info['requires'],
-                       $processor->getRequirements( $info, true )
-               );
-       }
-
-       public function testGetExtraAutoloaderPaths() {
-               $processor = new ExtensionProcessor();
-               $this->assertSame(
-                       [ "{$this->dirname}/vendor/autoload.php" ],
-                       $processor->getExtraAutoloaderPaths( $this->dirname, [
-                               'load_composer_autoloader' => true,
-                       ] )
-               );
-       }
-
-       /**
-        * Verify that extension.schema.json is in sync with ExtensionProcessor
-        *
-        * @coversNothing
-        */
-       public function testGlobalSettingsDocumentedInSchema() {
-               global $IP;
-               $globalSettings = TestingAccessWrapper::newFromClass(
-                       ExtensionProcessor::class )->globalSettings;
-
-               $version = ExtensionRegistry::MANIFEST_VERSION;
-               $schema = FormatJson::decode(
-                       file_get_contents( "$IP/docs/extension.schema.v$version.json" ),
-                       true
-               );
-               $missing = [];
-               foreach ( $globalSettings as $global ) {
-                       if ( !isset( $schema['properties'][$global] ) ) {
-                               $missing[] = $global;
-                       }
-               }
-
-               $this->assertEquals( [], $missing,
-                       "The following global settings are not documented in docs/extension.schema.json" );
-       }
-}
-
-/**
- * Allow overriding the default value of $this->globals
- * so we can test merging
- */
-class MockExtensionProcessor extends ExtensionProcessor {
-       public function __construct( $globals = [] ) {
-               $this->globals = $globals + $this->globals;
-       }
-}
diff --git a/tests/phpunit/includes/search/SearchIndexFieldTest.php b/tests/phpunit/includes/search/SearchIndexFieldTest.php
deleted file mode 100644 (file)
index 8b4119e..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-<?php
-
-/**
- * @group Search
- * @covers SearchIndexFieldDefinition
- */
-class SearchIndexFieldTest extends MediaWikiTestCase {
-
-       public function getMergeCases() {
-               return [
-                       [ 0, 'test', 0, 'test', true ],
-                       [ SearchIndexField::INDEX_TYPE_NESTED, 'test',
-                               SearchIndexField::INDEX_TYPE_NESTED, 'test', false ],
-                       [ 0, 'test', 0, 'test2', true ],
-                       [ 0, 'test', 1, 'test', false ],
-               ];
-       }
-
-       /**
-        * @dataProvider getMergeCases
-        * @param int $t1
-        * @param string $n1
-        * @param int $t2
-        * @param string $n2
-        * @param bool $result
-        */
-       public function testMerge( $t1, $n1, $t2, $n2, $result ) {
-               $field1 =
-                       $this->getMockBuilder( SearchIndexFieldDefinition::class )
-                               ->setMethods( [ 'getMapping' ] )
-                               ->setConstructorArgs( [ $n1, $t1 ] )
-                               ->getMock();
-               $field2 =
-                       $this->getMockBuilder( SearchIndexFieldDefinition::class )
-                               ->setMethods( [ 'getMapping' ] )
-                               ->setConstructorArgs( [ $n2, $t2 ] )
-                               ->getMock();
-
-               if ( $result ) {
-                       $this->assertNotFalse( $field1->merge( $field2 ) );
-               } else {
-                       $this->assertFalse( $field1->merge( $field2 ) );
-               }
-
-               $field1->setFlag( 0xFF );
-               $this->assertFalse( $field1->merge( $field2 ) );
-
-               $field1->setMergeCallback(
-                       function ( $a, $b ) {
-                               return "test";
-                       }
-               );
-               $this->assertEquals( "test", $field1->merge( $field2 ) );
-       }
-
-}
diff --git a/tests/phpunit/includes/session/MetadataMergeExceptionTest.php b/tests/phpunit/includes/session/MetadataMergeExceptionTest.php
deleted file mode 100644 (file)
index 8cb4302..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-
-namespace MediaWiki\Session;
-
-use MediaWikiTestCase;
-
-/**
- * @group Session
- * @covers MediaWiki\Session\MetadataMergeException
- */
-class MetadataMergeExceptionTest extends MediaWikiTestCase {
-
-       public function testBasics() {
-               $data = [ 'foo' => 'bar' ];
-
-               $ex = new MetadataMergeException();
-               $this->assertInstanceOf( \UnexpectedValueException::class, $ex );
-               $this->assertSame( [], $ex->getContext() );
-
-               $ex2 = new MetadataMergeException( 'Message', 42, $ex, $data );
-               $this->assertSame( 'Message', $ex2->getMessage() );
-               $this->assertSame( 42, $ex2->getCode() );
-               $this->assertSame( $ex, $ex2->getPrevious() );
-               $this->assertSame( $data, $ex2->getContext() );
-
-               $ex->setContext( $data );
-               $this->assertSame( $data, $ex->getContext() );
-       }
-
-}
diff --git a/tests/phpunit/includes/session/SessionIdTest.php b/tests/phpunit/includes/session/SessionIdTest.php
deleted file mode 100644 (file)
index 2b06d97..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<?php
-
-namespace MediaWiki\Session;
-
-use MediaWikiTestCase;
-
-/**
- * @group Session
- * @covers MediaWiki\Session\SessionId
- */
-class SessionIdTest extends MediaWikiTestCase {
-
-       public function testEverything() {
-               $id = new SessionId( 'foo' );
-               $this->assertSame( 'foo', $id->getId() );
-               $this->assertSame( 'foo', (string)$id );
-               $id->setId( 'bar' );
-               $this->assertSame( 'bar', $id->getId() );
-               $this->assertSame( 'bar', (string)$id );
-       }
-
-}
diff --git a/tests/phpunit/includes/site/CachingSiteStoreTest.php b/tests/phpunit/includes/site/CachingSiteStoreTest.php
deleted file mode 100644 (file)
index f04d35c..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-<?php
-
-/**
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- * @since 1.25
- *
- * @ingroup Site
- * @ingroup Test
- *
- * @group Site
- * @group Database
- *
- * @author Jeroen De Dauw < jeroendedauw@gmail.com >
- */
-class CachingSiteStoreTest extends MediaWikiTestCase {
-
-       /**
-        * @covers CachingSiteStore::getSites
-        */
-       public function testGetSites() {
-               $testSites = TestSites::getSites();
-
-               $store = new CachingSiteStore(
-                       $this->getHashSiteStore( $testSites ),
-                       ObjectCache::getLocalClusterInstance()
-               );
-
-               $sites = $store->getSites();
-
-               $this->assertInstanceOf( SiteList::class, $sites );
-
-               /**
-                * @var Site $site
-                */
-               foreach ( $sites as $site ) {
-                       $this->assertInstanceOf( Site::class, $site );
-               }
-
-               foreach ( $testSites as $site ) {
-                       if ( $site->getGlobalId() !== null ) {
-                               $this->assertTrue( $sites->hasSite( $site->getGlobalId() ) );
-                       }
-               }
-       }
-
-       /**
-        * @covers CachingSiteStore::saveSites
-        */
-       public function testSaveSites() {
-               $store = new CachingSiteStore(
-                       new HashSiteStore(), ObjectCache::getLocalClusterInstance()
-               );
-
-               $sites = [];
-
-               $site = new Site();
-               $site->setGlobalId( 'ertrywuutr' );
-               $site->setLanguageCode( 'en' );
-               $sites[] = $site;
-
-               $site = new MediaWikiSite();
-               $site->setGlobalId( 'sdfhxujgkfpth' );
-               $site->setLanguageCode( 'nl' );
-               $sites[] = $site;
-
-               $this->assertTrue( $store->saveSites( $sites ) );
-
-               $site = $store->getSite( 'ertrywuutr' );
-               $this->assertInstanceOf( Site::class, $site );
-               $this->assertEquals( 'en', $site->getLanguageCode() );
-
-               $site = $store->getSite( 'sdfhxujgkfpth' );
-               $this->assertInstanceOf( Site::class, $site );
-               $this->assertEquals( 'nl', $site->getLanguageCode() );
-       }
-
-       /**
-        * @covers CachingSiteStore::reset
-        */
-       public function testReset() {
-               $dbSiteStore = $this->getMockBuilder( SiteStore::class )
-                       ->disableOriginalConstructor()
-                       ->getMock();
-
-               $dbSiteStore->expects( $this->any() )
-                       ->method( 'getSite' )
-                       ->will( $this->returnValue( $this->getTestSite() ) );
-
-               $dbSiteStore->expects( $this->any() )
-                       ->method( 'getSites' )
-                       ->will( $this->returnCallback( function () {
-                               $siteList = new SiteList();
-                               $siteList->setSite( $this->getTestSite() );
-
-                               return $siteList;
-                       } ) );
-
-               $store = new CachingSiteStore( $dbSiteStore, ObjectCache::getLocalClusterInstance() );
-
-               // initialize internal cache
-               $this->assertGreaterThan( 0, $store->getSites()->count(), 'count sites' );
-
-               $store->getSite( 'enwiki' )->setLanguageCode( 'en-ca' );
-
-               // sanity check: $store should have the new language code for 'enwiki'
-               $this->assertEquals( 'en-ca', $store->getSite( 'enwiki' )->getLanguageCode(), 'sanity check' );
-
-               // purge cache
-               $store->reset();
-
-               // the internal cache of $store should be updated, and now pulling
-               // the site from the 'fallback' DBSiteStore with the original language code.
-               $this->assertEquals( 'en', $store->getSite( 'enwiki' )->getLanguageCode(), 'reset' );
-       }
-
-       public function getTestSite() {
-               $enwiki = new MediaWikiSite();
-               $enwiki->setGlobalId( 'enwiki' );
-               $enwiki->setLanguageCode( 'en' );
-
-               return $enwiki;
-       }
-
-       /**
-        * @covers CachingSiteStore::clear
-        */
-       public function testClear() {
-               $store = new CachingSiteStore(
-                       new HashSiteStore(), ObjectCache::getLocalClusterInstance()
-               );
-               $this->assertTrue( $store->clear() );
-
-               $site = $store->getSite( 'enwiki' );
-               $this->assertNull( $site );
-
-               $sites = $store->getSites();
-               $this->assertEquals( 0, $sites->count() );
-       }
-
-       /**
-        * @param Site[] $sites
-        *
-        * @return SiteStore
-        */
-       private function getHashSiteStore( array $sites ) {
-               $siteStore = new HashSiteStore();
-               $siteStore->saveSites( $sites );
-
-               return $siteStore;
-       }
-
-}
diff --git a/tests/phpunit/includes/site/HashSiteStoreTest.php b/tests/phpunit/includes/site/HashSiteStoreTest.php
deleted file mode 100644 (file)
index 6269fd3..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-<?php
-
-/**
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- * @since 1.25
- *
- * @ingroup Site
- * @group Site
- *
- * @author Katie Filbert < aude.wiki@gmail.com >
- */
-class HashSiteStoreTest extends MediaWikiTestCase {
-
-       /**
-        * @covers HashSiteStore::getSites
-        */
-       public function testGetSites() {
-               $expectedSites = [];
-
-               foreach ( TestSites::getSites() as $testSite ) {
-                       $siteId = $testSite->getGlobalId();
-                       $expectedSites[$siteId] = $testSite;
-               }
-
-               $siteStore = new HashSiteStore( $expectedSites );
-
-               $this->assertEquals( new SiteList( $expectedSites ), $siteStore->getSites() );
-       }
-
-       /**
-        * @covers HashSiteStore::saveSite
-        * @covers HashSiteStore::getSite
-        */
-       public function testSaveSite() {
-               $store = new HashSiteStore();
-
-               $site = new Site();
-               $site->setGlobalId( 'dewiki' );
-
-               $this->assertCount( 0, $store->getSites(), '0 sites in store' );
-
-               $store->saveSite( $site );
-
-               $this->assertCount( 1, $store->getSites(), 'Store has 1 sites' );
-               $this->assertEquals( $site, $store->getSite( 'dewiki' ), 'Store has dewiki' );
-       }
-
-       /**
-        * @covers HashSiteStore::saveSites
-        */
-       public function testSaveSites() {
-               $store = new HashSiteStore();
-
-               $sites = [];
-
-               $site = new Site();
-               $site->setGlobalId( 'enwiki' );
-               $site->setLanguageCode( 'en' );
-               $sites[] = $site;
-
-               $site = new MediaWikiSite();
-               $site->setGlobalId( 'eswiki' );
-               $site->setLanguageCode( 'es' );
-               $sites[] = $site;
-
-               $this->assertCount( 0, $store->getSites(), '0 sites in store' );
-
-               $store->saveSites( $sites );
-
-               $this->assertCount( 2, $store->getSites(), 'Store has 2 sites' );
-               $this->assertTrue( $store->getSites()->hasSite( 'enwiki' ), 'Store has enwiki' );
-               $this->assertTrue( $store->getSites()->hasSite( 'eswiki' ), 'Store has eswiki' );
-       }
-
-       /**
-        * @covers HashSiteStore::clear
-        */
-       public function testClear() {
-               $store = new HashSiteStore();
-
-               $site = new Site();
-               $site->setGlobalId( 'arwiki' );
-               $store->saveSite( $site );
-
-               $this->assertCount( 1, $store->getSites(), '1 site in store' );
-
-               $store->clear();
-               $this->assertCount( 0, $store->getSites(), '0 sites in store' );
-       }
-}
diff --git a/tests/phpunit/includes/skins/SkinFactoryTest.php b/tests/phpunit/includes/skins/SkinFactoryTest.php
deleted file mode 100644 (file)
index 4289fd9..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-<?php
-
-class SkinFactoryTest extends MediaWikiTestCase {
-
-       /**
-        * @covers SkinFactory::register
-        */
-       public function testRegister() {
-               $factory = new SkinFactory();
-               $factory->register( 'fallback', 'Fallback', function () {
-                       return new SkinFallback();
-               } );
-               $this->assertTrue( true ); // No exception thrown
-               $this->setExpectedException( InvalidArgumentException::class );
-               $factory->register( 'invalid', 'Invalid', 'Invalid callback' );
-       }
-
-       /**
-        * @covers SkinFactory::makeSkin
-        */
-       public function testMakeSkinWithNoBuilders() {
-               $factory = new SkinFactory();
-               $this->setExpectedException( SkinException::class );
-               $factory->makeSkin( 'nobuilderregistered' );
-       }
-
-       /**
-        * @covers SkinFactory::makeSkin
-        */
-       public function testMakeSkinWithInvalidCallback() {
-               $factory = new SkinFactory();
-               $factory->register( 'unittest', 'Unittest', function () {
-                       return true; // Not a Skin object
-               } );
-               $this->setExpectedException( UnexpectedValueException::class );
-               $factory->makeSkin( 'unittest' );
-       }
-
-       /**
-        * @covers SkinFactory::makeSkin
-        */
-       public function testMakeSkinWithValidCallback() {
-               $factory = new SkinFactory();
-               $factory->register( 'testfallback', 'TestFallback', function () {
-                       return new SkinFallback();
-               } );
-
-               $skin = $factory->makeSkin( 'testfallback' );
-               $this->assertInstanceOf( Skin::class, $skin );
-               $this->assertInstanceOf( SkinFallback::class, $skin );
-               $this->assertEquals( 'fallback', $skin->getSkinName() );
-       }
-
-       /**
-        * @covers Skin::__construct
-        * @covers Skin::getSkinName
-        */
-       public function testGetSkinName() {
-               $skin = new SkinFallback();
-               $this->assertEquals( 'fallback', $skin->getSkinName(), 'Default' );
-               $skin = new SkinFallback( 'testname' );
-               $this->assertEquals( 'testname', $skin->getSkinName(), 'Constructor argument' );
-       }
-
-       /**
-        * @covers SkinFactory::getSkinNames
-        */
-       public function testGetSkinNames() {
-               $factory = new SkinFactory();
-               // A fake callback we can use that will never be called
-               $callback = function () {
-                       // NOP
-               };
-               $factory->register( 'skin1', 'Skin1', $callback );
-               $factory->register( 'skin2', 'Skin2', $callback );
-               $names = $factory->getSkinNames();
-               $this->assertArrayHasKey( 'skin1', $names );
-               $this->assertArrayHasKey( 'skin2', $names );
-               $this->assertEquals( 'Skin1', $names['skin1'] );
-               $this->assertEquals( 'Skin2', $names['skin2'] );
-       }
-}
diff --git a/tests/phpunit/includes/title/ForeignTitleTest.php b/tests/phpunit/includes/title/ForeignTitleTest.php
deleted file mode 100644 (file)
index f2fccc7..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-<?php
-/**
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- * @author This, that and the other
- */
-
-/**
- * @covers ForeignTitle
- *
- * @group Title
- */
-class ForeignTitleTest extends MediaWikiTestCase {
-
-       public function basicProvider() {
-               return [
-                       [
-                               new ForeignTitle( 20, 'Contributor', 'JohnDoe' ),
-                               20, 'Contributor', 'JohnDoe'
-                       ],
-                       [
-                               new ForeignTitle( '1', 'Discussion', 'Capital' ),
-                               1, 'Discussion', 'Capital'
-                       ],
-                       [
-                               new ForeignTitle( 0, '', 'MainNamespace' ),
-                               0, '', 'MainNamespace'
-                       ],
-                       [
-                               new ForeignTitle( 4, 'Some ns', 'Article title with spaces' ),
-                               4, 'Some_ns', 'Article_title_with_spaces'
-                       ],
-               ];
-       }
-
-       /**
-        * @dataProvider basicProvider
-        */
-       public function testBasic( ForeignTitle $title, $expectedId, $expectedName,
-               $expectedText
-       ) {
-               $this->assertEquals( true, $title->isNamespaceIdKnown() );
-               $this->assertEquals( $expectedId, $title->getNamespaceId() );
-               $this->assertEquals( $expectedName, $title->getNamespaceName() );
-               $this->assertEquals( $expectedText, $title->getText() );
-       }
-
-       public function testUnknownNamespaceCheck() {
-               $title = new ForeignTitle( null, 'this', 'that' );
-
-               $this->assertEquals( false, $title->isNamespaceIdKnown() );
-               $this->assertEquals( 'this', $title->getNamespaceName() );
-               $this->assertEquals( 'that', $title->getText() );
-       }
-
-       public function testUnknownNamespaceError() {
-               $this->setExpectedException( MWException::class );
-               $title = new ForeignTitle( null, 'this', 'that' );
-               $title->getNamespaceId();
-       }
-
-       public function fullTextProvider() {
-               return [
-                       [
-                               new ForeignTitle( 20, 'Contributor', 'JohnDoe' ),
-                               'Contributor:JohnDoe'
-                       ],
-                       [
-                               new ForeignTitle( '1', 'Discussion', 'Capital' ),
-                               'Discussion:Capital'
-                       ],
-                       [
-                               new ForeignTitle( 0, '', 'MainNamespace' ),
-                               'MainNamespace'
-                       ],
-                       [
-                               new ForeignTitle( 4, 'Some ns', 'Article title with spaces' ),
-                               'Some_ns:Article_title_with_spaces'
-                       ],
-               ];
-       }
-
-       /**
-        * @dataProvider fullTextProvider
-        */
-       public function testFullText( ForeignTitle $title, $fullText ) {
-               $this->assertEquals( $fullText, $title->getFullText() );
-       }
-}
diff --git a/tests/phpunit/includes/title/NamespaceAwareForeignTitleFactoryTest.php b/tests/phpunit/includes/title/NamespaceAwareForeignTitleFactoryTest.php
deleted file mode 100644 (file)
index 9aa3578..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-<?php
-/**
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- * @author This, that and the other
- */
-
-/**
- * @covers NamespaceAwareForeignTitleFactory
- *
- * @group Title
- */
-class NamespaceAwareForeignTitleFactoryTest extends MediaWikiTestCase {
-
-       public function basicProvider() {
-               return [
-                       [
-                               'MainNamespaceArticle', 0,
-                               new ForeignTitle( 0, '', 'MainNamespaceArticle' ),
-                       ],
-                       [
-                               'MainNamespaceArticle', null,
-                               new ForeignTitle( 0, '', 'MainNamespaceArticle' ),
-                       ],
-                       [
-                               'Magic:_The_Gathering', 0,
-                               new ForeignTitle( 0, '', 'Magic:_The_Gathering' ),
-                       ],
-                       [
-                               'Talk:Nice_talk', 1,
-                               new ForeignTitle( 1, 'Talk', 'Nice_talk' ),
-                       ],
-                       [
-                               'Talk:Magic:_The_Gathering', 1,
-                               new ForeignTitle( 1, 'Talk', 'Magic:_The_Gathering' ),
-                       ],
-                       [
-                               'Bogus:Nice_talk', 0,
-                               new ForeignTitle( 0, '', 'Bogus:Nice_talk' ),
-                       ],
-                       [
-                               'Bogus:Nice_talk', null,
-                               new ForeignTitle( 9000, 'Bogus', 'Nice_talk' ),
-                       ],
-                       [
-                               'Bogus:Nice_talk', 4,
-                               new ForeignTitle( 4, 'Bogus', 'Nice_talk' ),
-                       ],
-                       [
-                               'Bogus:Nice_talk', 1,
-                               new ForeignTitle( 1, 'Talk', 'Nice_talk' ),
-                       ],
-                       // Misconfigured wiki with unregistered namespace (T114115)
-                       [
-                               'Nice_talk', 1234,
-                               new ForeignTitle( 1234, 'Ns1234', 'Nice_talk' ),
-                       ],
-               ];
-       }
-
-       /**
-        * @dataProvider basicProvider
-        */
-       public function testBasic( $title, $ns, ForeignTitle $foreignTitle ) {
-               $foreignNamespaces = [
-                       0 => '', 1 => 'Talk', 100 => 'Portal', 9000 => 'Bogus'
-               ];
-
-               $factory = new NamespaceAwareForeignTitleFactory( $foreignNamespaces );
-               $testTitle = $factory->createForeignTitle( $title, $ns );
-
-               $this->assertEquals( $testTitle->isNamespaceIdKnown(),
-                       $foreignTitle->isNamespaceIdKnown() );
-
-               if (
-                       $testTitle->isNamespaceIdKnown() &&
-                       $foreignTitle->isNamespaceIdKnown()
-               ) {
-                       $this->assertEquals( $testTitle->getNamespaceId(),
-                               $foreignTitle->getNamespaceId() );
-               }
-
-               $this->assertEquals( $testTitle->getNamespaceName(),
-                       $foreignTitle->getNamespaceName() );
-               $this->assertEquals( $testTitle->getText(), $foreignTitle->getText() );
-       }
-}
diff --git a/tests/phpunit/includes/title/TitleValueTest.php b/tests/phpunit/includes/title/TitleValueTest.php
deleted file mode 100644 (file)
index bbeb068..0000000
+++ /dev/null
@@ -1,149 +0,0 @@
-<?php
-/**
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- * @author Daniel Kinzler
- */
-
-/**
- * @covers TitleValue
- *
- * @group Title
- */
-class TitleValueTest extends MediaWikiTestCase {
-
-       public function goodConstructorProvider() {
-               return [
-                       [ NS_MAIN, '', 'fragment', '', true, false ],
-                       [ NS_USER, 'TestThis', 'stuff', '', true, false ],
-                       [ NS_USER, 'TestThis', '', 'baz', false, true ],
-               ];
-       }
-
-       /**
-        * @dataProvider goodConstructorProvider
-        */
-       public function testConstruction( $ns, $text, $fragment, $interwiki, $hasFragment,
-               $hasInterwiki
-       ) {
-               $title = new TitleValue( $ns, $text, $fragment, $interwiki );
-
-               $this->assertEquals( $ns, $title->getNamespace() );
-               $this->assertTrue( $title->inNamespace( $ns ) );
-               $this->assertEquals( $text, $title->getText() );
-               $this->assertEquals( $fragment, $title->getFragment() );
-               $this->assertEquals( $hasFragment, $title->hasFragment() );
-               $this->assertEquals( $interwiki, $title->getInterwiki() );
-               $this->assertEquals( $hasInterwiki, $title->isExternal() );
-       }
-
-       public function badConstructorProvider() {
-               return [
-                       [ 'foo', 'title', 'fragment', '' ],
-                       [ null, 'title', 'fragment', '' ],
-                       [ 2.3, 'title', 'fragment', '' ],
-
-                       [ NS_MAIN, 5, 'fragment', '' ],
-                       [ NS_MAIN, null, 'fragment', '' ],
-                       [ NS_USER, '', 'fragment', '' ],
-                       [ NS_MAIN, 'foo bar', '', '' ],
-                       [ NS_MAIN, 'bar_', '', '' ],
-                       [ NS_MAIN, '_foo', '', '' ],
-                       [ NS_MAIN, ' eek ', '', '' ],
-
-                       [ NS_MAIN, 'title', 5, '' ],
-                       [ NS_MAIN, 'title', null, '' ],
-                       [ NS_MAIN, 'title', [], '' ],
-
-                       [ NS_MAIN, 'title', '', 5 ],
-                       [ NS_MAIN, 'title', null, 5 ],
-                       [ NS_MAIN, 'title', [], 5 ],
-               ];
-       }
-
-       /**
-        * @dataProvider badConstructorProvider
-        */
-       public function testConstructionErrors( $ns, $text, $fragment, $interwiki ) {
-               $this->setExpectedException( InvalidArgumentException::class );
-               new TitleValue( $ns, $text, $fragment, $interwiki );
-       }
-
-       public function fragmentTitleProvider() {
-               return [
-                       [ new TitleValue( NS_MAIN, 'Test' ), 'foo' ],
-                       [ new TitleValue( NS_TALK, 'Test', 'foo' ), '' ],
-                       [ new TitleValue( NS_CATEGORY, 'Test', 'foo' ), 'bar' ],
-               ];
-       }
-
-       /**
-        * @dataProvider fragmentTitleProvider
-        */
-       public function testCreateFragmentTitle( TitleValue $title, $fragment ) {
-               $fragmentTitle = $title->createFragmentTarget( $fragment );
-
-               $this->assertEquals( $title->getNamespace(), $fragmentTitle->getNamespace() );
-               $this->assertEquals( $title->getText(), $fragmentTitle->getText() );
-               $this->assertEquals( $fragment, $fragmentTitle->getFragment() );
-       }
-
-       public function getTextProvider() {
-               return [
-                       [ 'Foo', 'Foo' ],
-                       [ 'Foo_Bar', 'Foo Bar' ],
-               ];
-       }
-
-       /**
-        * @dataProvider getTextProvider
-        */
-       public function testGetText( $dbkey, $text ) {
-               $title = new TitleValue( NS_MAIN, $dbkey );
-
-               $this->assertEquals( $text, $title->getText() );
-       }
-
-       public function provideTestToString() {
-               yield [
-                       new TitleValue( 0, 'Foo' ),
-                       '0:Foo'
-               ];
-               yield [
-                       new TitleValue( 1, 'Bar_Baz' ),
-                       '1:Bar_Baz'
-               ];
-               yield [
-                       new TitleValue( 9, 'JoJo', 'Frag' ),
-                       '9:JoJo#Frag'
-               ];
-               yield [
-                       new TitleValue( 200, 'tea', 'Fragment', 'wikicode' ),
-                       'wikicode:200:tea#Fragment'
-               ];
-       }
-
-       /**
-        * @dataProvider provideTestToString
-        */
-       public function testToString( TitleValue $value, $expected ) {
-               $this->assertSame(
-                       $expected,
-                       $value->__toString()
-               );
-       }
-}
diff --git a/tests/phpunit/includes/user/UserArrayFromResultTest.php b/tests/phpunit/includes/user/UserArrayFromResultTest.php
deleted file mode 100644 (file)
index 4cbfe46..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-<?php
-
-/**
- * @author Addshore
- * @covers UserArrayFromResult
- */
-class UserArrayFromResultTest extends MediaWikiTestCase {
-
-       private function getMockResultWrapper( $row = null, $numRows = 1 ) {
-               $resultWrapper = $this->getMockBuilder( Wikimedia\Rdbms\ResultWrapper::class )
-                       ->disableOriginalConstructor();
-
-               $resultWrapper = $resultWrapper->getMock();
-               $resultWrapper->expects( $this->atLeastOnce() )
-                       ->method( 'current' )
-                       ->will( $this->returnValue( $row ) );
-               $resultWrapper->expects( $this->any() )
-                       ->method( 'numRows' )
-                       ->will( $this->returnValue( $numRows ) );
-
-               return $resultWrapper;
-       }
-
-       private function getRowWithUsername( $username = 'fooUser' ) {
-               $row = new stdClass();
-               $row->user_name = $username;
-               return $row;
-       }
-
-       /**
-        * @covers UserArrayFromResult::__construct
-        */
-       public function testConstructionWithFalseRow() {
-               $row = false;
-               $resultWrapper = $this->getMockResultWrapper( $row );
-
-               $object = new UserArrayFromResult( $resultWrapper );
-
-               $this->assertEquals( $resultWrapper, $object->res );
-               $this->assertSame( 0, $object->key );
-               $this->assertEquals( $row, $object->current );
-       }
-
-       /**
-        * @covers UserArrayFromResult::__construct
-        */
-       public function testConstructionWithRow() {
-               $username = 'addshore';
-               $row = $this->getRowWithUsername( $username );
-               $resultWrapper = $this->getMockResultWrapper( $row );
-
-               $object = new UserArrayFromResult( $resultWrapper );
-
-               $this->assertEquals( $resultWrapper, $object->res );
-               $this->assertSame( 0, $object->key );
-               $this->assertInstanceOf( User::class, $object->current );
-               $this->assertEquals( $username, $object->current->mName );
-       }
-
-       public static function provideNumberOfRows() {
-               return [
-                       [ 0 ],
-                       [ 1 ],
-                       [ 122 ],
-               ];
-       }
-
-       /**
-        * @dataProvider provideNumberOfRows
-        * @covers UserArrayFromResult::count
-        */
-       public function testCountWithVaryingValues( $numRows ) {
-               $object = new UserArrayFromResult( $this->getMockResultWrapper(
-                       $this->getRowWithUsername(),
-                       $numRows
-               ) );
-               $this->assertEquals( $numRows, $object->count() );
-       }
-
-       /**
-        * @covers UserArrayFromResult::current
-        */
-       public function testCurrentAfterConstruction() {
-               $username = 'addshore';
-               $userRow = $this->getRowWithUsername( $username );
-               $object = new UserArrayFromResult( $this->getMockResultWrapper( $userRow ) );
-               $this->assertInstanceOf( User::class, $object->current() );
-               $this->assertEquals( $username, $object->current()->mName );
-       }
-
-       public function provideTestValid() {
-               return [
-                       [ $this->getRowWithUsername(), true ],
-                       [ false, false ],
-               ];
-       }
-
-       /**
-        * @dataProvider provideTestValid
-        * @covers UserArrayFromResult::valid
-        */
-       public function testValid( $input, $expected ) {
-               $object = new UserArrayFromResult( $this->getMockResultWrapper( $input ) );
-               $this->assertEquals( $expected, $object->valid() );
-       }
-
-       // @todo unit test for key()
-       // @todo unit test for next()
-       // @todo unit test for rewind()
-}
diff --git a/tests/phpunit/includes/watcheditem/NoWriteWatchedItemStoreUnitTest.php b/tests/phpunit/includes/watcheditem/NoWriteWatchedItemStoreUnitTest.php
deleted file mode 100644 (file)
index f424b21..0000000
+++ /dev/null
@@ -1,250 +0,0 @@
-<?php
-
-use MediaWiki\User\UserIdentityValue;
-
-/**
- * @author Addshore
- *
- * @covers NoWriteWatchedItemStore
- */
-class NoWriteWatchedItemStoreUnitTest extends MediaWikiTestCase {
-
-       public function testAddWatch() {
-               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
-               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
-               $innerService->expects( $this->never() )->method( 'addWatch' );
-               $noWriteService = new NoWriteWatchedItemStore( $innerService );
-
-               $this->setExpectedException( DBReadOnlyError::class );
-               $noWriteService->addWatch(
-                       new UserIdentityValue( 1, 'MockUser', 0 ), new TitleValue( 0, 'Foo' ) );
-       }
-
-       public function testAddWatchBatchForUser() {
-               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
-               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
-               $innerService->expects( $this->never() )->method( 'addWatchBatchForUser' );
-               $noWriteService = new NoWriteWatchedItemStore( $innerService );
-
-               $this->setExpectedException( DBReadOnlyError::class );
-               $noWriteService->addWatchBatchForUser( new UserIdentityValue( 1, 'MockUser', 0 ), [] );
-       }
-
-       public function testRemoveWatch() {
-               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
-               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
-               $innerService->expects( $this->never() )->method( 'removeWatch' );
-               $noWriteService = new NoWriteWatchedItemStore( $innerService );
-
-               $this->setExpectedException( DBReadOnlyError::class );
-               $noWriteService->removeWatch(
-                       new UserIdentityValue( 1, 'MockUser', 0 ), new TitleValue( 0, 'Foo' ) );
-       }
-
-       public function testSetNotificationTimestampsForUser() {
-               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
-               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
-               $innerService->expects( $this->never() )->method( 'setNotificationTimestampsForUser' );
-               $noWriteService = new NoWriteWatchedItemStore( $innerService );
-
-               $this->setExpectedException( DBReadOnlyError::class );
-               $noWriteService->setNotificationTimestampsForUser(
-                       new UserIdentityValue( 1, 'MockUser', 0 ),
-                       'timestamp',
-                       []
-               );
-       }
-
-       public function testUpdateNotificationTimestamp() {
-               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
-               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
-               $innerService->expects( $this->never() )->method( 'updateNotificationTimestamp' );
-               $noWriteService = new NoWriteWatchedItemStore( $innerService );
-
-               $this->setExpectedException( DBReadOnlyError::class );
-               $noWriteService->updateNotificationTimestamp(
-                       new UserIdentityValue( 1, 'MockUser', 0 ),
-                       new TitleValue( 0, 'Foo' ),
-                       'timestamp'
-               );
-       }
-
-       public function testResetNotificationTimestamp() {
-               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
-               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
-               $innerService->expects( $this->never() )->method( 'resetNotificationTimestamp' );
-               $noWriteService = new NoWriteWatchedItemStore( $innerService );
-
-               $this->setExpectedException( DBReadOnlyError::class );
-               $noWriteService->resetNotificationTimestamp(
-                       new UserIdentityValue( 1, 'MockUser', 0 ),
-                       new TitleValue( 0, 'Foo' )
-               );
-       }
-
-       public function testCountWatchedItems() {
-               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
-               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
-               $innerService->expects( $this->once() )->method( 'countWatchedItems' )->willReturn( __METHOD__ );
-               $noWriteService = new NoWriteWatchedItemStore( $innerService );
-
-               $return = $noWriteService->countWatchedItems(
-                       new UserIdentityValue( 1, 'MockUser', 0 )
-               );
-               $this->assertEquals( __METHOD__, $return );
-       }
-
-       public function testCountWatchers() {
-               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
-               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
-               $innerService->expects( $this->once() )->method( 'countWatchers' )->willReturn( __METHOD__ );
-               $noWriteService = new NoWriteWatchedItemStore( $innerService );
-
-               $return = $noWriteService->countWatchers(
-                       new TitleValue( 0, 'Foo' )
-               );
-               $this->assertEquals( __METHOD__, $return );
-       }
-
-       public function testCountVisitingWatchers() {
-               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
-               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
-               $innerService->expects( $this->once() )
-                       ->method( 'countVisitingWatchers' )
-                       ->willReturn( __METHOD__ );
-               $noWriteService = new NoWriteWatchedItemStore( $innerService );
-
-               $return = $noWriteService->countVisitingWatchers(
-                       new TitleValue( 0, 'Foo' ),
-                       9
-               );
-               $this->assertEquals( __METHOD__, $return );
-       }
-
-       public function testCountWatchersMultiple() {
-               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
-               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
-               $innerService->expects( $this->once() )
-                       ->method( 'countVisitingWatchersMultiple' )
-                       ->willReturn( __METHOD__ );
-               $noWriteService = new NoWriteWatchedItemStore( $innerService );
-
-               $return = $noWriteService->countWatchersMultiple(
-                       [ new TitleValue( 0, 'Foo' ) ],
-                       []
-               );
-               $this->assertEquals( __METHOD__, $return );
-       }
-
-       public function testCountVisitingWatchersMultiple() {
-               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
-               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
-               $innerService->expects( $this->once() )
-                       ->method( 'countVisitingWatchersMultiple' )
-                       ->willReturn( __METHOD__ );
-               $noWriteService = new NoWriteWatchedItemStore( $innerService );
-
-               $return = $noWriteService->countVisitingWatchersMultiple(
-                       [ [ new TitleValue( 0, 'Foo' ), 99 ] ],
-                       11
-               );
-               $this->assertEquals( __METHOD__, $return );
-       }
-
-       public function testGetWatchedItem() {
-               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
-               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
-               $innerService->expects( $this->once() )->method( 'getWatchedItem' )->willReturn( __METHOD__ );
-               $noWriteService = new NoWriteWatchedItemStore( $innerService );
-
-               $return = $noWriteService->getWatchedItem(
-                       new UserIdentityValue( 1, 'MockUser', 0 ),
-                       new TitleValue( 0, 'Foo' )
-               );
-               $this->assertEquals( __METHOD__, $return );
-       }
-
-       public function testLoadWatchedItem() {
-               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
-               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
-               $innerService->expects( $this->once() )->method( 'loadWatchedItem' )->willReturn( __METHOD__ );
-               $noWriteService = new NoWriteWatchedItemStore( $innerService );
-
-               $return = $noWriteService->loadWatchedItem(
-                       new UserIdentityValue( 1, 'MockUser', 0 ),
-                       new TitleValue( 0, 'Foo' )
-               );
-               $this->assertEquals( __METHOD__, $return );
-       }
-
-       public function testGetWatchedItemsForUser() {
-               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
-               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
-               $innerService->expects( $this->once() )
-                       ->method( 'getWatchedItemsForUser' )
-                       ->willReturn( __METHOD__ );
-               $noWriteService = new NoWriteWatchedItemStore( $innerService );
-
-               $return = $noWriteService->getWatchedItemsForUser(
-                       new UserIdentityValue( 1, 'MockUser', 0 ),
-                       []
-               );
-               $this->assertEquals( __METHOD__, $return );
-       }
-
-       public function testIsWatched() {
-               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
-               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
-               $innerService->expects( $this->once() )->method( 'isWatched' )->willReturn( __METHOD__ );
-               $noWriteService = new NoWriteWatchedItemStore( $innerService );
-
-               $return = $noWriteService->isWatched(
-                       new UserIdentityValue( 1, 'MockUser', 0 ),
-                       new TitleValue( 0, 'Foo' )
-               );
-               $this->assertEquals( __METHOD__, $return );
-       }
-
-       public function testGetNotificationTimestampsBatch() {
-               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
-               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
-               $innerService->expects( $this->once() )
-                       ->method( 'getNotificationTimestampsBatch' )
-                       ->willReturn( __METHOD__ );
-               $noWriteService = new NoWriteWatchedItemStore( $innerService );
-
-               $return = $noWriteService->getNotificationTimestampsBatch(
-                       new UserIdentityValue( 1, 'MockUser', 0 ),
-                       [ new TitleValue( 0, 'Foo' ) ]
-               );
-               $this->assertEquals( __METHOD__, $return );
-       }
-
-       public function testCountUnreadNotifications() {
-               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
-               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
-               $innerService->expects( $this->once() )
-                       ->method( 'countUnreadNotifications' )
-                       ->willReturn( __METHOD__ );
-               $noWriteService = new NoWriteWatchedItemStore( $innerService );
-
-               $return = $noWriteService->countUnreadNotifications(
-                       new UserIdentityValue( 1, 'MockUser', 0 ),
-                       88
-               );
-               $this->assertEquals( __METHOD__, $return );
-       }
-
-       public function testDuplicateAllAssociatedEntries() {
-               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
-               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
-               $noWriteService = new NoWriteWatchedItemStore( $innerService );
-
-               $this->setExpectedException( DBReadOnlyError::class );
-               $noWriteService->duplicateAllAssociatedEntries(
-                       new TitleValue( 0, 'Foo' ),
-                       new TitleValue( 0, 'Bar' )
-               );
-       }
-
-}
index d406c88..cce9d0e 100644 (file)
@@ -11,7 +11,7 @@
  *
  * @author Katie Filbert < aude.wiki@gmail.com >
  */
-class SpecialPageAliasTest extends MediaWikiTestCase {
+class SpecialPageAliasTest extends \MediaWikiUnitTestCase {
 
        /**
         * @coversNothing
diff --git a/tests/phpunit/unit/includes/FauxResponseTest.php b/tests/phpunit/unit/includes/FauxResponseTest.php
new file mode 100644 (file)
index 0000000..5e208ac
--- /dev/null
@@ -0,0 +1,146 @@
+<?php
+/**
+ * Copyright @ 2011 Alexandre Emsenhuber
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ */
+
+class FauxResponseTest extends \MediaWikiUnitTestCase {
+       /** @var FauxResponse */
+       protected $response;
+
+       protected function setUp() {
+               parent::setUp();
+               $this->response = new FauxResponse;
+       }
+
+       /**
+        * @covers FauxResponse::setCookie
+        * @covers FauxResponse::getCookie
+        * @covers FauxResponse::getCookieData
+        * @covers FauxResponse::getCookies
+        */
+       public function testCookie() {
+               $expire = time() + 100;
+               $cookie = [
+                       'value' => 'val',
+                       'path' => '/path',
+                       'domain' => 'domain',
+                       'secure' => true,
+                       'httpOnly' => false,
+                       'raw' => false,
+                       'expire' => $expire,
+               ];
+
+               $this->assertEquals( null, $this->response->getCookie( 'xkey' ), 'Non-existing cookie' );
+               $this->response->setCookie( 'key', 'val', $expire, [
+                       'prefix' => 'x',
+                       'path' => '/path',
+                       'domain' => 'domain',
+                       'secure' => 1,
+                       'httpOnly' => 0,
+               ] );
+               $this->assertEquals( 'val', $this->response->getCookie( 'xkey' ), 'Existing cookie' );
+               $this->assertEquals( $cookie, $this->response->getCookieData( 'xkey' ),
+                       'Existing cookie (data)' );
+               $this->assertEquals( [ 'xkey' => $cookie ], $this->response->getCookies(),
+                       'Existing cookies' );
+       }
+
+       /**
+        * @covers FauxResponse::getheader
+        * @covers FauxResponse::header
+        */
+       public function testHeader() {
+               $this->assertEquals( null, $this->response->getHeader( 'Location' ), 'Non-existing header' );
+
+               $this->response->header( 'Location: http://localhost/' );
+               $this->assertEquals(
+                       'http://localhost/',
+                       $this->response->getHeader( 'Location' ),
+                       'Set header'
+               );
+
+               $this->response->header( 'Location: http://127.0.0.1/' );
+               $this->assertEquals(
+                       'http://127.0.0.1/',
+                       $this->response->getHeader( 'Location' ),
+                       'Same header'
+               );
+
+               $this->response->header( 'Location: http://127.0.0.2/', false );
+               $this->assertEquals(
+                       'http://127.0.0.1/',
+                       $this->response->getHeader( 'Location' ),
+                       'Same header with override disabled'
+               );
+
+               $this->response->header( 'Location: http://localhost/' );
+               $this->assertEquals(
+                       'http://localhost/',
+                       $this->response->getHeader( 'LOCATION' ),
+                       'Get header case insensitive'
+               );
+       }
+
+       /**
+        * @covers FauxResponse::getStatusCode
+        */
+       public function testResponseCode() {
+               $this->response->header( 'HTTP/1.1 200' );
+               $this->assertEquals( 200, $this->response->getStatusCode(), 'Header with no message' );
+
+               $this->response->header( 'HTTP/1.x 201' );
+               $this->assertEquals(
+                       201,
+                       $this->response->getStatusCode(),
+                       'Header with no message and protocol 1.x'
+               );
+
+               $this->response->header( 'HTTP/1.1 202 OK' );
+               $this->assertEquals( 202, $this->response->getStatusCode(), 'Normal header' );
+
+               $this->response->header( 'HTTP/1.x 203 OK' );
+               $this->assertEquals(
+                       203,
+                       $this->response->getStatusCode(),
+                       'Normal header with no message and protocol 1.x'
+               );
+
+               $this->response->header( 'HTTP/1.x 204 OK', false, 205 );
+               $this->assertEquals(
+                       205,
+                       $this->response->getStatusCode(),
+                       'Third parameter overrides the HTTP/... header'
+               );
+
+               $this->response->statusHeader( 210 );
+               $this->assertEquals(
+                       210,
+                       $this->response->getStatusCode(),
+                       'Handle statusHeader method'
+               );
+
+               $this->response->header( 'Location: http://localhost/', false, 206 );
+               $this->assertEquals(
+                       206,
+                       $this->response->getStatusCode(),
+                       'Third parameter with another header'
+               );
+       }
+}
diff --git a/tests/phpunit/unit/includes/FormOptionsInitializationTest.php b/tests/phpunit/unit/includes/FormOptionsInitializationTest.php
new file mode 100644 (file)
index 0000000..708956d
--- /dev/null
@@ -0,0 +1,70 @@
+<?php
+
+use Wikimedia\TestingAccessWrapper;
+
+/**
+ * Test class for FormOptions initialization
+ * Ensure the FormOptions::add() does what we want it to do.
+ *
+ * Copyright © 2011, Antoine Musso
+ *
+ * @author Antoine Musso
+ */
+class FormOptionsInitializationTest extends \MediaWikiUnitTestCase {
+       /**
+        * @var FormOptions
+        */
+       protected $object;
+
+       /**
+        * A new fresh and empty FormOptions object to test initialization
+        * with.
+        */
+       protected function setUp() {
+               parent::setUp();
+               $this->object = TestingAccessWrapper::newFromObject( new FormOptions() );
+       }
+
+       /**
+        * @covers FormOptions::add
+        */
+       public function testAddStringOption() {
+               $this->object->add( 'foo', 'string value' );
+               $this->assertEquals(
+                       [
+                               'foo' => [
+                                       'default' => 'string value',
+                                       'consumed' => false,
+                                       'type' => FormOptions::STRING,
+                                       'value' => null,
+                               ]
+                       ],
+                       $this->object->options
+               );
+       }
+
+       /**
+        * @covers FormOptions::add
+        */
+       public function testAddIntegers() {
+               $this->object->add( 'one', 1 );
+               $this->object->add( 'negone', -1 );
+               $this->assertEquals(
+                       [
+                               'negone' => [
+                                       'default' => -1,
+                                       'value' => null,
+                                       'consumed' => false,
+                                       'type' => FormOptions::INT,
+                               ],
+                               'one' => [
+                                       'default' => 1,
+                                       'value' => null,
+                                       'consumed' => false,
+                                       'type' => FormOptions::INT,
+                               ]
+                       ],
+                       $this->object->options
+               );
+       }
+}
diff --git a/tests/phpunit/unit/includes/FormOptionsTest.php b/tests/phpunit/unit/includes/FormOptionsTest.php
new file mode 100644 (file)
index 0000000..c14595b
--- /dev/null
@@ -0,0 +1,105 @@
+<?php
+/**
+ * This file host two test case classes for the MediaWiki FormOptions class:
+ *  - FormOptionsInitializationTest : tests initialization of the class.
+ *  - FormOptionsTest : tests methods an on instance
+ *
+ * The split let us take advantage of setting up a fixture for the methods
+ * tests.
+ */
+
+/**
+ * Test class for FormOptions methods.
+ *
+ * Copyright © 2011, Antoine Musso
+ *
+ * @author Antoine Musso
+ */
+class FormOptionsTest extends \MediaWikiUnitTestCase {
+       /**
+        * @var FormOptions
+        */
+       protected $object;
+
+       /**
+        * Instanciates a FormOptions object to play with.
+        * FormOptions::add() is tested by the class FormOptionsInitializationTest
+        * so we assume the function is well tested already an use it to create
+        * the fixture.
+        */
+       protected function setUp() {
+               parent::setUp();
+               $this->object = new FormOptions;
+               $this->object->add( 'string1', 'string one' );
+               $this->object->add( 'string2', 'string two' );
+               $this->object->add( 'integer', 0 );
+               $this->object->add( 'float', 0.0 );
+               $this->object->add( 'intnull', 0, FormOptions::INTNULL );
+       }
+
+       /** Helpers for testGuessType() */
+       /* @{ */
+       private function assertGuessBoolean( $data ) {
+               $this->guess( FormOptions::BOOL, $data );
+       }
+
+       private function assertGuessInt( $data ) {
+               $this->guess( FormOptions::INT, $data );
+       }
+
+       private function assertGuessFloat( $data ) {
+               $this->guess( FormOptions::FLOAT, $data );
+       }
+
+       private function assertGuessString( $data ) {
+               $this->guess( FormOptions::STRING, $data );
+       }
+
+       private function assertGuessArray( $data ) {
+               $this->guess( FormOptions::ARR, $data );
+       }
+
+       /** Generic helper */
+       private function guess( $expected, $data ) {
+               $this->assertEquals(
+                       $expected,
+                       FormOptions::guessType( $data )
+               );
+       }
+
+       /* @} */
+
+       /**
+        * Reuse helpers above assertGuessBoolean assertGuessInt assertGuessString
+        * @covers FormOptions::guessType
+        */
+       public function testGuessTypeDetection() {
+               $this->assertGuessBoolean( true );
+               $this->assertGuessBoolean( false );
+
+               $this->assertGuessInt( 0 );
+               $this->assertGuessInt( -5 );
+               $this->assertGuessInt( 5 );
+               $this->assertGuessInt( 0x0F );
+
+               $this->assertGuessFloat( 0.0 );
+               $this->assertGuessFloat( 1.5 );
+               $this->assertGuessFloat( 1e3 );
+
+               $this->assertGuessString( 'true' );
+               $this->assertGuessString( 'false' );
+               $this->assertGuessString( '5' );
+               $this->assertGuessString( '0' );
+               $this->assertGuessString( '1.5' );
+
+               $this->assertGuessArray( [ 'foo' ] );
+       }
+
+       /**
+        * @expectedException MWException
+        * @covers FormOptions::guessType
+        */
+       public function testGuessTypeOnNullThrowException() {
+               $this->object->guessType( null );
+       }
+}
diff --git a/tests/phpunit/unit/includes/LicensesTest.php b/tests/phpunit/unit/includes/LicensesTest.php
new file mode 100644 (file)
index 0000000..e5a6bae
--- /dev/null
@@ -0,0 +1,25 @@
+<?php
+
+/**
+ * @covers Licenses
+ */
+class LicensesTest extends \MediaWikiUnitTestCase {
+
+       public function testLicenses() {
+               $str = "
+* Free licenses:
+** GFDL|Debian disagrees
+";
+
+               $lc = new Licenses( [
+                       'fieldname' => 'FooField',
+                       'type' => 'select',
+                       'section' => 'description',
+                       'id' => 'wpLicense',
+                       'label' => 'A label text', # Note can't test label-message because $wgOut is not defined
+                       'name' => 'AnotherName',
+                       'licenses' => $str,
+               ] );
+               $this->assertThat( $lc, $this->isInstanceOf( Licenses::class ) );
+       }
+}
diff --git a/tests/phpunit/unit/includes/MediaWikiVersionFetcherTest.php b/tests/phpunit/unit/includes/MediaWikiVersionFetcherTest.php
new file mode 100644 (file)
index 0000000..dfdbfa7
--- /dev/null
@@ -0,0 +1,21 @@
+<?php
+
+/**
+ * Note: this is not a unit test, as it touches the file system and reads an actual file.
+ * If unit tests are added for MediaWikiVersionFetcher, this should be done in a distinct test case.
+ *
+ * @covers MediaWikiVersionFetcher
+ *
+ * @group ComposerHooks
+ *
+ * @author Jeroen De Dauw < jeroendedauw@gmail.com >
+ */
+class MediaWikiVersionFetcherTest extends \MediaWikiUnitTestCase {
+
+       public function testReturnsResult() {
+               global $wgVersion;
+               $versionFetcher = new MediaWikiVersionFetcher();
+               $this->assertSame( $wgVersion, $versionFetcher->fetchVersion() );
+       }
+
+}
diff --git a/tests/phpunit/unit/includes/Rest/EntryPointTest.php b/tests/phpunit/unit/includes/Rest/EntryPointTest.php
new file mode 100644 (file)
index 0000000..e1f2c88
--- /dev/null
@@ -0,0 +1,89 @@
+<?php
+
+namespace MediaWiki\Tests\Rest;
+
+use EmptyBagOStuff;
+use GuzzleHttp\Psr7\Uri;
+use GuzzleHttp\Psr7\Stream;
+use MediaWiki\Rest\Handler;
+use MediaWiki\Rest\EntryPoint;
+use MediaWiki\Rest\RequestData;
+use MediaWiki\Rest\ResponseFactory;
+use MediaWiki\Rest\Router;
+use WebResponse;
+
+/**
+ * @covers \MediaWiki\Rest\EntryPoint
+ * @covers \MediaWiki\Rest\Router
+ */
+class EntryPointTest extends \MediaWikiUnitTestCase {
+       private static $mockHandler;
+
+       private function createRouter() {
+               return new Router(
+                       [ __DIR__ . '/testRoutes.json' ],
+                       [],
+                       '/rest',
+                       new EmptyBagOStuff(),
+                       new ResponseFactory() );
+       }
+
+       private function createWebResponse() {
+               return $this->getMockBuilder( WebResponse::class )
+                       ->setMethods( [ 'header' ] )
+                       ->getMock();
+       }
+
+       public static function mockHandlerHeader() {
+               return new class extends Handler {
+                       public function execute() {
+                               $response = $this->getResponseFactory()->create();
+                               $response->setHeader( 'Foo', 'Bar' );
+                               return $response;
+                       }
+               };
+       }
+
+       public function testHeader() {
+               $webResponse = $this->createWebResponse();
+               $webResponse->expects( $this->any() )
+                       ->method( 'header' )
+                       ->withConsecutive(
+                               [ 'HTTP/1.1 200 OK', true, null ],
+                               [ 'Foo: Bar', true, null ]
+                       );
+
+               $entryPoint = new EntryPoint(
+                       new RequestData( [ 'uri' => new Uri( '/rest/mock/EntryPoint/header' ) ] ),
+                       $webResponse,
+                       $this->createRouter() );
+               $entryPoint->execute();
+               $this->assertTrue( true );
+       }
+
+       public static function mockHandlerBodyRewind() {
+               return new class extends Handler {
+                       public function execute() {
+                               $response = $this->getResponseFactory()->create();
+                               $stream = new Stream( fopen( 'php://memory', 'w+' ) );
+                               $stream->write( 'hello' );
+                               $response->setBody( $stream );
+                               return $response;
+                       }
+               };
+       }
+
+       /**
+        * Make sure EntryPoint rewinds a seekable body stream before reading.
+        */
+       public function testBodyRewind() {
+               $entryPoint = new EntryPoint(
+                       new RequestData( [ 'uri' => new Uri( '/rest/mock/EntryPoint/bodyRewind' ) ] ),
+                       $this->createWebResponse(),
+                       $this->createRouter() );
+               ob_start();
+               $entryPoint->execute();
+               $this->assertSame( 'hello', ob_get_clean() );
+       }
+
+}
diff --git a/tests/phpunit/unit/includes/Rest/Handler/HelloHandlerTest.php b/tests/phpunit/unit/includes/Rest/Handler/HelloHandlerTest.php
new file mode 100644 (file)
index 0000000..c68273b
--- /dev/null
@@ -0,0 +1,80 @@
+<?php
+
+namespace MediaWiki\Tests\Rest\Handler;
+
+use EmptyBagOStuff;
+use GuzzleHttp\Psr7\Uri;
+use MediaWiki\Rest\RequestData;
+use MediaWiki\Rest\ResponseFactory;
+use MediaWiki\Rest\Router;
+
+/**
+ * @covers \MediaWiki\Rest\Handler\HelloHandler
+ */
+class HelloHandlerTest extends \MediaWikiUnitTestCase {
+       public static function provideTestViaRouter() {
+               return [
+                       'normal' => [
+                               [
+                                       'method' => 'GET',
+                                       'uri' => self::makeUri( '/user/Tim/hello' ),
+                               ],
+                               [
+                                       'statusCode' => 200,
+                                       'reasonPhrase' => 'OK',
+                                       'protocolVersion' => '1.1',
+                                       'body' => '{"message":"Hello, Tim!"}',
+                               ],
+                       ],
+                       'method not allowed' => [
+                               [
+                                       'method' => 'POST',
+                                       'uri' => self::makeUri( '/user/Tim/hello' ),
+                               ],
+                               [
+                                       'statusCode' => 405,
+                                       'reasonPhrase' => 'Method Not Allowed',
+                                       'protocolVersion' => '1.1',
+                                       'body' => '{"httpCode":405,"httpReason":"Method Not Allowed"}',
+                               ],
+                       ],
+               ];
+       }
+
+       private static function makeUri( $path ) {
+               return new Uri( "http://www.example.com/rest$path" );
+       }
+
+       /** @dataProvider provideTestViaRouter */
+       public function testViaRouter( $requestInfo, $responseInfo ) {
+               $router = new Router(
+                       [ __DIR__ . '/../testRoutes.json' ],
+                       [],
+                       '/rest',
+                       new EmptyBagOStuff(),
+                       new ResponseFactory() );
+               $request = new RequestData( $requestInfo );
+               $response = $router->execute( $request );
+               if ( isset( $responseInfo['statusCode'] ) ) {
+                       $this->assertSame( $responseInfo['statusCode'], $response->getStatusCode() );
+               }
+               if ( isset( $responseInfo['reasonPhrase'] ) ) {
+                       $this->assertSame( $responseInfo['reasonPhrase'], $response->getReasonPhrase() );
+               }
+               if ( isset( $responseInfo['protocolVersion'] ) ) {
+                       $this->assertSame( $responseInfo['protocolVersion'], $response->getProtocolVersion() );
+               }
+               if ( isset( $responseInfo['body'] ) ) {
+                       $this->assertSame( $responseInfo['body'], $response->getBody()->getContents() );
+               }
+               $this->assertSame(
+                       [],
+                       array_diff( array_keys( $responseInfo ), [
+                               'statusCode',
+                               'reasonPhrase',
+                               'protocolVersion',
+                               'body'
+                       ] ),
+                       '$responseInfo may not contain unknown keys' );
+       }
+}
diff --git a/tests/phpunit/unit/includes/Rest/HeaderContainerTest.php b/tests/phpunit/unit/includes/Rest/HeaderContainerTest.php
new file mode 100644 (file)
index 0000000..e65251e
--- /dev/null
@@ -0,0 +1,171 @@
+<?php
+
+namespace MediaWiki\Tests\Rest;
+
+use MediaWiki\Rest\HeaderContainer;
+
+/**
+ * @covers \MediaWiki\Rest\HeaderContainer
+ */
+class HeaderContainerTest extends \MediaWikiUnitTestCase {
+       public static function provideSetHeader() {
+               return [
+                       'simple' => [
+                               [
+                                       [ 'Test', 'foo' ]
+                               ],
+                               [ 'Test' => [ 'foo' ] ],
+                               [ 'Test' => 'foo' ]
+                       ],
+                       'replace' => [
+                               [
+                                       [ 'Test', 'foo' ],
+                                       [ 'Test', 'bar' ],
+                               ],
+                               [ 'Test' => [ 'bar' ] ],
+                               [ 'Test' => 'bar' ],
+                       ],
+                       'array value' => [
+                               [
+                                       [ 'Test', [ '1', '2' ] ],
+                                       [ 'Test', [ '3', '4' ] ],
+                               ],
+                               [ 'Test' => [ '3', '4' ] ],
+                               [ 'Test' => '3, 4' ]
+                       ],
+                       'preserve most recent case' => [
+                               [
+                                       [ 'test', 'foo' ],
+                                       [ 'tesT', 'bar' ],
+                               ],
+                               [ 'tesT' => [ 'bar' ] ],
+                               [ 'tesT' => 'bar' ]
+                       ],
+                       'empty' => [ [], [], [] ],
+               ];
+       }
+
+       /** @dataProvider provideSetHeader */
+       public function testSetHeader( $setOps, $headers, $lines ) {
+               $hc = new HeaderContainer;
+               foreach ( $setOps as list( $name, $value ) ) {
+                       $hc->setHeader( $name, $value );
+               }
+               $this->assertSame( $headers, $hc->getHeaders() );
+               $this->assertSame( $lines, $hc->getHeaderLines() );
+       }
+
+       public static function provideAddHeader() {
+               return [
+                       'simple' => [
+                               [
+                                       [ 'Test', 'foo' ]
+                               ],
+                               [ 'Test' => [ 'foo' ] ],
+                               [ 'Test' => 'foo' ]
+                       ],
+                       'add' => [
+                               [
+                                       [ 'Test', 'foo' ],
+                                       [ 'Test', 'bar' ],
+                               ],
+                               [ 'Test' => [ 'foo', 'bar' ] ],
+                               [ 'Test' => 'foo, bar' ],
+                       ],
+                       'array value' => [
+                               [
+                                       [ 'Test', [ '1', '2' ] ],
+                                       [ 'Test', [ '3', '4' ] ],
+                               ],
+                               [ 'Test' => [ '1', '2', '3', '4' ] ],
+                               [ 'Test' => '1, 2, 3, 4' ]
+                       ],
+                       'preserve original case' => [
+                               [
+                                       [ 'Test', 'foo' ],
+                                       [ 'tesT', 'bar' ],
+                               ],
+                               [ 'Test' => [ 'foo', 'bar' ] ],
+                               [ 'Test' => 'foo, bar' ]
+                       ],
+               ];
+       }
+
+       /** @dataProvider provideAddHeader */
+       public function testAddHeader( $addOps, $headers, $lines ) {
+               $hc = new HeaderContainer;
+               foreach ( $addOps as list( $name, $value ) ) {
+                       $hc->addHeader( $name, $value );
+               }
+               $this->assertSame( $headers, $hc->getHeaders() );
+               $this->assertSame( $lines, $hc->getHeaderLines() );
+       }
+
+       public static function provideRemoveHeader() {
+               return [
+                       'simple' => [
+                               [ [ 'Test', 'foo' ] ],
+                               [ 'Test' ],
+                               [],
+                               []
+                       ],
+                       'case mismatch' => [
+                               [ [ 'Test', 'foo' ] ],
+                               [ 'tesT' ],
+                               [],
+                               []
+                       ],
+                       'remove nonexistent' => [
+                               [ [ 'A', '1' ] ],
+                               [ 'B' ],
+                               [ 'A' => [ '1' ] ],
+                               [ 'A' => '1' ]
+                       ],
+               ];
+       }
+
+       /** @dataProvider provideRemoveHeader */
+       public function testRemoveHeader( $addOps, $removeOps, $headers, $lines ) {
+               $hc = new HeaderContainer;
+               foreach ( $addOps as list( $name, $value ) ) {
+                       $hc->addHeader( $name, $value );
+               }
+               foreach ( $removeOps as $name ) {
+                       $hc->removeHeader( $name );
+               }
+               $this->assertSame( $headers, $hc->getHeaders() );
+               $this->assertSame( $lines, $hc->getHeaderLines() );
+       }
+
+       public function testHasHeader() {
+               $hc = new HeaderContainer;
+               $hc->addHeader( 'A', '1' );
+               $hc->addHeader( 'B', '2' );
+               $hc->addHeader( 'C', '3' );
+               $hc->removeHeader( 'B' );
+               $hc->removeHeader( 'c' );
+               $this->assertTrue( $hc->hasHeader( 'A' ) );
+               $this->assertTrue( $hc->hasHeader( 'a' ) );
+               $this->assertFalse( $hc->hasHeader( 'B' ) );
+               $this->assertFalse( $hc->hasHeader( 'c' ) );
+               $this->assertFalse( $hc->hasHeader( 'C' ) );
+       }
+
+       public function testGetRawHeaderLines() {
+               $hc = new HeaderContainer;
+               $hc->addHeader( 'A', '1' );
+               $hc->addHeader( 'a', '2' );
+               $hc->addHeader( 'b', '3' );
+               $hc->addHeader( 'Set-Cookie', 'x' );
+               $hc->addHeader( 'SET-cookie', 'y' );
+               $this->assertSame(
+                       [
+                               'A: 1, 2',
+                               'b: 3',
+                               'Set-Cookie: x',
+                               'Set-Cookie: y',
+                       ],
+                       $hc->getRawHeaderLines()
+               );
+       }
+}
diff --git a/tests/phpunit/unit/includes/Rest/PathTemplateMatcher/PathMatcherTest.php b/tests/phpunit/unit/includes/Rest/PathTemplateMatcher/PathMatcherTest.php
new file mode 100644 (file)
index 0000000..f56024c
--- /dev/null
@@ -0,0 +1,76 @@
+<?php
+
+namespace MediaWiki\Tests\Rest\PathTemplateMatcher;
+
+use MediaWiki\Rest\PathTemplateMatcher\PathConflict;
+use MediaWiki\Rest\PathTemplateMatcher\PathMatcher;
+
+/**
+ * @covers \MediaWiki\Rest\PathTemplateMatcher\PathMatcher
+ * @covers \MediaWiki\Rest\PathTemplateMatcher\PathConflict
+ */
+class PathMatcherTest extends \MediaWikiUnitTestCase {
+       private static $normalRoutes = [
+               '/a/b',
+               '/b/{x}',
+               '/c/{x}/d',
+               '/c/{x}/e',
+               '/c/{x}/{y}/d',
+       ];
+
+       public static function provideConflictingRoutes() {
+               return [
+                       [ '/a/b', 0, '/a/b' ],
+                       [ '/a/{x}', 0, '/a/b' ],
+                       [ '/{x}/c', 1, '/b/{x}' ],
+                       [ '/b/a', 1, '/b/{x}' ],
+                       [ '/b/{x}', 1, '/b/{x}' ],
+                       [ '/{x}/{y}/d', 2, '/c/{x}/d' ],
+               ];
+       }
+
+       public static function provideMatch() {
+               return [
+                       [ '', false ],
+                       [ '/a/b', [ 'params' => [], 'userData' => 0 ] ],
+                       [ '/b', false ],
+                       [ '/b/1', [ 'params' => [ 'x' => '1' ], 'userData' => 1 ] ],
+                       [ '/c/1/d', [ 'params' => [ 'x' => '1' ], 'userData' => 2 ] ],
+                       [ '/c/1/e', [ 'params' => [ 'x' => '1' ], 'userData' => 3 ] ],
+                       [ '/c/000/e', [ 'params' => [ 'x' => '000' ], 'userData' => 3 ] ],
+                       [ '/c/1/f', false ],
+                       [ '/c//e', [ 'params' => [ 'x' => '' ], 'userData' => 3 ] ],
+                       [ '/c///e', false ],
+               ];
+       }
+
+       public function createNormalRouter() {
+               $pm = new PathMatcher;
+               foreach ( self::$normalRoutes as $i => $route ) {
+                       $pm->add( $route, $i );
+               }
+               return $pm;
+       }
+
+       /** @dataProvider provideConflictingRoutes */
+       public function testAddConflict( $attempt, $expectedUserData, $expectedTemplate ) {
+               $pm = $this->createNormalRouter();
+               $actualTemplate = null;
+               $actualUserData = null;
+               try {
+                       $pm->add( $attempt, 'conflict' );
+               } catch ( PathConflict $pc ) {
+                       $actualTemplate = $pc->existingTemplate;
+                       $actualUserData = $pc->existingUserData;
+               }
+               $this->assertSame( $expectedUserData, $actualUserData );
+               $this->assertSame( $expectedTemplate, $actualTemplate );
+       }
+
+       /** @dataProvider provideMatch */
+       public function testMatch( $path, $expectedResult ) {
+               $pm = $this->createNormalRouter();
+               $result = $pm->match( $path );
+               $this->assertSame( $expectedResult, $result );
+       }
+}
diff --git a/tests/phpunit/unit/includes/Rest/StringStreamTest.php b/tests/phpunit/unit/includes/Rest/StringStreamTest.php
new file mode 100644 (file)
index 0000000..1e72239
--- /dev/null
@@ -0,0 +1,130 @@
+<?php
+
+namespace MediaWiki\Tests\Rest;
+
+use MediaWiki\Rest\StringStream;
+
+/** @covers \MediaWiki\Rest\StringStream */
+class StringStreamTest extends \MediaWikiUnitTestCase {
+       public static function provideSeekGetContents() {
+               return [
+                       [ 'abcde', 0, SEEK_SET, 'abcde' ],
+                       [ 'abcde', 1, SEEK_SET, 'bcde' ],
+                       [ 'abcde', 5, SEEK_SET, '' ],
+                       [ 'abcde', 1, SEEK_CUR, 'cde' ],
+                       [ 'abcde', 0, SEEK_END, '' ],
+               ];
+       }
+
+       /** @dataProvider provideSeekGetContents */
+       public function testCopyToStream( $input, $offset, $whence, $expected ) {
+               $ss = new StringStream;
+               $ss->write( $input );
+               $ss->seek( 1 );
+               $ss->seek( $offset, $whence );
+               $destStream = fopen( 'php://memory', 'w+' );
+               $ss->copyToStream( $destStream );
+               fseek( $destStream, 0 );
+               $result = stream_get_contents( $destStream );
+               $this->assertSame( $expected, $result );
+       }
+
+       public function testGetSize() {
+               $ss = new StringStream;
+               $this->assertSame( 0, $ss->getSize() );
+               $ss->write( "hello" );
+               $this->assertSame( 5, $ss->getSize() );
+               $ss->rewind();
+               $this->assertSame( 5, $ss->getSize() );
+       }
+
+       public function testTell() {
+               $ss = new StringStream;
+               $this->assertSame( $ss->tell(), 0 );
+               $ss->write( "abc" );
+               $this->assertSame( $ss->tell(), 3 );
+               $ss->seek( 0 );
+               $ss->read( 1 );
+               $this->assertSame( $ss->tell(), 1 );
+       }
+
+       public function testEof() {
+               $ss = new StringStream( 'abc' );
+               $this->assertFalse( $ss->eof() );
+               $ss->read( 1 );
+               $this->assertFalse( $ss->eof() );
+               $ss->read( 1 );
+               $this->assertFalse( $ss->eof() );
+               $ss->read( 1 );
+               $this->assertTrue( $ss->eof() );
+               $ss->rewind();
+               $this->assertFalse( $ss->eof() );
+       }
+
+       public function testIsSeekable() {
+               $ss = new StringStream;
+               $this->assertTrue( $ss->isSeekable() );
+       }
+
+       public function testIsReadable() {
+               $ss = new StringStream;
+               $this->assertTrue( $ss->isReadable() );
+       }
+
+       public function testIsWritable() {
+               $ss = new StringStream;
+               $this->assertTrue( $ss->isWritable() );
+       }
+
+       public function testSeekWrite() {
+               $ss = new StringStream;
+               $this->assertSame( '', (string)$ss );
+               $ss->write( 'a' );
+               $this->assertSame( 'a', (string)$ss );
+               $ss->write( 'b' );
+               $this->assertSame( 'ab', (string)$ss );
+               $ss->seek( 1 );
+               $ss->write( 'c' );
+               $this->assertSame( 'ac', (string)$ss );
+       }
+
+       /** @dataProvider provideSeekGetContents */
+       public function testSeekGetContents( $input, $offset, $whence, $expected ) {
+               $ss = new StringStream( $input );
+               $ss->seek( 1 );
+               $ss->seek( $offset, $whence );
+               $this->assertSame( $expected, $ss->getContents() );
+       }
+
+       public static function provideSeekRead() {
+               return [
+                       [ 'abcde', 0, SEEK_SET, 1, 'a' ],
+                       [ 'abcde', 0, SEEK_SET, 2, 'ab' ],
+                       [ 'abcde', 4, SEEK_SET, 2, 'e' ],
+                       [ 'abcde', 5, SEEK_SET, 1, '' ],
+                       [ 'abcde', 1, SEEK_CUR, 1, 'c' ],
+                       [ 'abcde', 0, SEEK_END, 1, '' ],
+                       [ 'abcde', -1, SEEK_END, 1, 'e' ],
+               ];
+       }
+
+       /** @dataProvider provideSeekRead */
+       public function testSeekRead( $input, $offset, $whence, $length, $expected ) {
+               $ss = new StringStream( $input );
+               $ss->seek( 1 );
+               $ss->seek( $offset, $whence );
+               $this->assertSame( $expected, $ss->read( $length ) );
+       }
+
+       /** @expectedException \InvalidArgumentException */
+       public function testReadBeyondEnd() {
+               $ss = new StringStream( 'abc' );
+               $ss->seek( 1, SEEK_END );
+       }
+
+       /** @expectedException \InvalidArgumentException */
+       public function testReadBeforeStart() {
+               $ss = new StringStream( 'abc' );
+               $ss->seek( -1 );
+       }
+}
diff --git a/tests/phpunit/unit/includes/Rest/testRoutes.json b/tests/phpunit/unit/includes/Rest/testRoutes.json
new file mode 100644 (file)
index 0000000..7e43bb0
--- /dev/null
@@ -0,0 +1,14 @@
+[
+       {
+               "path": "/user/{name}/hello",
+               "class": "MediaWiki\\Rest\\Handler\\HelloHandler"
+       },
+       {
+               "path": "/mock/EntryPoint/header",
+               "factory": "MediaWiki\\Tests\\Rest\\EntryPointTest::mockHandlerHeader"
+       },
+       {
+               "path": "/mock/EntryPoint/bodyRewind",
+               "factory": "MediaWiki\\Tests\\Rest\\EntryPointTest::mockHandlerBodyRewind"
+       }
+]
diff --git a/tests/phpunit/unit/includes/Revision/FallbackSlotRoleHandlerTest.php b/tests/phpunit/unit/includes/Revision/FallbackSlotRoleHandlerTest.php
new file mode 100644 (file)
index 0000000..17b3504
--- /dev/null
@@ -0,0 +1,72 @@
+<?php
+
+namespace MediaWiki\Tests\Revision;
+
+use MediaWiki\Revision\FallbackSlotRoleHandler;
+use Title;
+
+/**
+ * @covers \MediaWiki\Revision\FallbackSlotRoleHandler
+ */
+class FallbackSlotRoleHandlerTest extends \MediaWikiUnitTestCase {
+
+       /**
+        * @return Title
+        */
+       private function makeBlankTitleObject() {
+               return $this->createMock( Title::class );
+       }
+
+       /**
+        * @covers \MediaWiki\Revision\FallbackSlotRoleHandler::__construct
+        * @covers \MediaWiki\Revision\FallbackSlotRoleHandler::getRole()
+        * @covers \MediaWiki\Revision\FallbackSlotRoleHandler::getNameMessageKey()
+        * @covers \MediaWiki\Revision\FallbackSlotRoleHandler::getDefaultModel()
+        * @covers \MediaWiki\Revision\FallbackSlotRoleHandler::getOutputLayoutHints()
+        */
+       public function testConstruction() {
+               $handler = new FallbackSlotRoleHandler( 'foo' );
+               $this->assertSame( 'foo', $handler->getRole() );
+               $this->assertSame( 'slot-name-foo', $handler->getNameMessageKey() );
+
+               $title = $this->makeBlankTitleObject();
+               $this->assertSame( CONTENT_MODEL_TEXT, $handler->getDefaultModel( $title ) );
+
+               $hints = $handler->getOutputLayoutHints();
+               $this->assertArrayHasKey( 'display', $hints );
+               $this->assertArrayHasKey( 'region', $hints );
+               $this->assertArrayHasKey( 'placement', $hints );
+       }
+
+       /**
+        * @covers \MediaWiki\Revision\FallbackSlotRoleHandler::isAllowedModel()
+        */
+       public function testIsAllowedModel() {
+               $handler = new FallbackSlotRoleHandler( 'foo', 'FooModel' );
+
+               // For the fallback handler, no models are allowed
+               $title = $this->makeBlankTitleObject();
+               $this->assertFalse( $handler->isAllowedModel( 'FooModel', $title ) );
+               $this->assertFalse( $handler->isAllowedModel( 'QuaxModel', $title ) );
+       }
+
+       /**
+        * @covers \MediaWiki\Revision\SlotRoleHandler::isAllowedModel()
+        */
+       public function testIsAllowedOn() {
+               $handler = new FallbackSlotRoleHandler( 'foo', 'FooModel' );
+
+               $title = $this->makeBlankTitleObject();
+               $this->assertFalse( $handler->isAllowedOn( $title ) );
+       }
+
+       /**
+        * @covers \MediaWiki\Revision\FallbackSlotRoleHandler::supportsArticleCount()
+        */
+       public function testSupportsArticleCount() {
+               $handler = new FallbackSlotRoleHandler( 'foo', 'FooModel' );
+
+               $this->assertFalse( $handler->supportsArticleCount() );
+       }
+
+}
diff --git a/tests/phpunit/unit/includes/Revision/RevisionStoreFactoryTest.php b/tests/phpunit/unit/includes/Revision/RevisionStoreFactoryTest.php
new file mode 100644 (file)
index 0000000..8e8fbd7
--- /dev/null
@@ -0,0 +1,193 @@
+<?php
+
+namespace MediaWiki\Tests\Revision;
+
+use ActorMigration;
+use CommentStore;
+use MediaWiki\Logger\Spi as LoggerSpi;
+use MediaWiki\Revision\RevisionStore;
+use MediaWiki\Revision\RevisionStoreFactory;
+use MediaWiki\Revision\SlotRoleRegistry;
+use MediaWiki\Storage\BlobStore;
+use MediaWiki\Storage\BlobStoreFactory;
+use MediaWiki\Storage\NameTableStore;
+use MediaWiki\Storage\NameTableStoreFactory;
+use MediaWiki\Storage\SqlBlobStore;
+use Psr\Log\LoggerInterface;
+use Psr\Log\NullLogger;
+use WANObjectCache;
+use Wikimedia\Rdbms\ILBFactory;
+use Wikimedia\Rdbms\ILoadBalancer;
+use Wikimedia\TestingAccessWrapper;
+
+class RevisionStoreFactoryTest extends \MediaWikiUnitTestCase {
+
+       /**
+        * @covers \MediaWiki\Revision\RevisionStoreFactory::__construct
+        */
+       public function testValidConstruction_doesntCauseErrors() {
+               new RevisionStoreFactory(
+                       $this->getMockLoadBalancerFactory(),
+                       $this->getMockBlobStoreFactory(),
+                       $this->getNameTableStoreFactory(),
+                       $this->getMockSlotRoleRegistry(),
+                       $this->getHashWANObjectCache(),
+                       $this->getMockCommentStore(),
+                       ActorMigration::newMigration(),
+                       MIGRATION_OLD,
+                       $this->getMockLoggerSpi(),
+                       true
+               );
+               $this->assertTrue( true );
+       }
+
+       public function provideWikiIds() {
+               yield [ true ];
+               yield [ false ];
+               yield [ 'somewiki' ];
+               yield [ 'somewiki', MIGRATION_OLD , false ];
+               yield [ 'somewiki', MIGRATION_NEW , true ];
+       }
+
+       /**
+        * @dataProvider provideWikiIds
+        * @covers \MediaWiki\Revision\RevisionStoreFactory::getRevisionStore
+        */
+       public function testGetRevisionStore(
+               $dbDomain,
+               $mcrMigrationStage = MIGRATION_OLD,
+               $contentHandlerUseDb = true
+       ) {
+               $lbFactory = $this->getMockLoadBalancerFactory();
+               $blobStoreFactory = $this->getMockBlobStoreFactory();
+               $nameTableStoreFactory = $this->getNameTableStoreFactory();
+               $slotRoleRegistry = $this->getMockSlotRoleRegistry();
+               $cache = $this->getHashWANObjectCache();
+               $commentStore = $this->getMockCommentStore();
+               $actorMigration = ActorMigration::newMigration();
+               $loggerProvider = $this->getMockLoggerSpi();
+
+               $factory = new RevisionStoreFactory(
+                       $lbFactory,
+                       $blobStoreFactory,
+                       $nameTableStoreFactory,
+                       $slotRoleRegistry,
+                       $cache,
+                       $commentStore,
+                       $actorMigration,
+                       $mcrMigrationStage,
+                       $loggerProvider,
+                       $contentHandlerUseDb
+               );
+
+               $store = $factory->getRevisionStore( $dbDomain );
+               $wrapper = TestingAccessWrapper::newFromObject( $store );
+
+               // ensure the correct object type is returned
+               $this->assertInstanceOf( RevisionStore::class, $store );
+
+               // ensure the RevisionStore is for the given wikiId
+               $this->assertSame( $dbDomain, $wrapper->dbDomain );
+
+               // ensure all other required services are correctly set
+               $this->assertSame( $cache, $wrapper->cache );
+               $this->assertSame( $commentStore, $wrapper->commentStore );
+               $this->assertSame( $mcrMigrationStage, $wrapper->mcrMigrationStage );
+               $this->assertSame( $actorMigration, $wrapper->actorMigration );
+               $this->assertSame( $contentHandlerUseDb, $store->getContentHandlerUseDB() );
+
+               $this->assertInstanceOf( ILoadBalancer::class, $wrapper->loadBalancer );
+               $this->assertInstanceOf( BlobStore::class, $wrapper->blobStore );
+               $this->assertInstanceOf( NameTableStore::class, $wrapper->contentModelStore );
+               $this->assertInstanceOf( NameTableStore::class, $wrapper->slotRoleStore );
+               $this->assertInstanceOf( LoggerInterface::class, $wrapper->logger );
+       }
+
+       /**
+        * @return \PHPUnit_Framework_MockObject_MockObject|ILoadBalancer
+        */
+       private function getMockLoadBalancer() {
+               return $this->getMockBuilder( ILoadBalancer::class )
+                       ->disableOriginalConstructor()->getMock();
+       }
+
+       /**
+        * @return \PHPUnit_Framework_MockObject_MockObject|ILBFactory
+        */
+       private function getMockLoadBalancerFactory() {
+               $mock = $this->getMockBuilder( ILBFactory::class )
+                       ->disableOriginalConstructor()->getMock();
+
+               $mock->method( 'getMainLB' )
+                       ->willReturnCallback( function () {
+                               return $this->getMockLoadBalancer();
+                       } );
+
+               return $mock;
+       }
+
+       /**
+        * @return \PHPUnit_Framework_MockObject_MockObject|SqlBlobStore
+        */
+       private function getMockSqlBlobStore() {
+               return $this->getMockBuilder( SqlBlobStore::class )
+                       ->disableOriginalConstructor()->getMock();
+       }
+
+       /**
+        * @return \PHPUnit_Framework_MockObject_MockObject|BlobStoreFactory
+        */
+       private function getMockBlobStoreFactory() {
+               $mock = $this->getMockBuilder( BlobStoreFactory::class )
+                       ->disableOriginalConstructor()->getMock();
+
+               $mock->method( 'newSqlBlobStore' )
+                       ->willReturnCallback( function () {
+                               return $this->getMockSqlBlobStore();
+                       } );
+
+               return $mock;
+       }
+
+       /**
+        * @return SlotRoleRegistry
+        */
+       private function getMockSlotRoleRegistry() {
+               return $this->createMock( SlotRoleRegistry::class );
+       }
+
+       /**
+        * @return NameTableStoreFactory
+        */
+       private function getNameTableStoreFactory() {
+               return new NameTableStoreFactory(
+                       $this->getMockLoadBalancerFactory(),
+                       $this->getHashWANObjectCache(),
+                       new NullLogger() );
+       }
+
+       /**
+        * @return \PHPUnit_Framework_MockObject_MockObject|CommentStore
+        */
+       private function getMockCommentStore() {
+               return $this->getMockBuilder( CommentStore::class )
+                       ->disableOriginalConstructor()->getMock();
+       }
+
+       private function getHashWANObjectCache() {
+               return new WANObjectCache( [ 'cache' => new \HashBagOStuff() ] );
+       }
+
+       /**
+        * @return \PHPUnit_Framework_MockObject_MockObject|LoggerSpi
+        */
+       private function getMockLoggerSpi() {
+               $mock = $this->getMock( LoggerSpi::class );
+
+               $mock->method( 'getLogger' )
+                       ->willReturn( new NullLogger() );
+
+               return $mock;
+       }
+
+}
diff --git a/tests/phpunit/unit/includes/Revision/SlotRoleHandlerTest.php b/tests/phpunit/unit/includes/Revision/SlotRoleHandlerTest.php
new file mode 100644 (file)
index 0000000..39217c2
--- /dev/null
@@ -0,0 +1,64 @@
+<?php
+
+namespace MediaWiki\Tests\Revision;
+
+use MediaWiki\Revision\SlotRoleHandler;
+use Title;
+
+/**
+ * @covers \MediaWiki\Revision\SlotRoleHandler
+ */
+class SlotRoleHandlerTest extends \MediaWikiUnitTestCase {
+
+       /**
+        * @return Title
+        */
+       private function makeBlankTitleObject() {
+               return $this->createMock( Title::class );
+       }
+
+       /**
+        * @covers \MediaWiki\Revision\SlotRoleHandler::__construct
+        * @covers \MediaWiki\Revision\SlotRoleHandler::getRole()
+        * @covers \MediaWiki\Revision\SlotRoleHandler::getNameMessageKey()
+        * @covers \MediaWiki\Revision\SlotRoleHandler::getDefaultModel()
+        * @covers \MediaWiki\Revision\SlotRoleHandler::getOutputLayoutHints()
+        */
+       public function testConstruction() {
+               $handler = new SlotRoleHandler( 'foo', 'FooModel', [ 'frob' => 'niz' ] );
+               $this->assertSame( 'foo', $handler->getRole() );
+               $this->assertSame( 'slot-name-foo', $handler->getNameMessageKey() );
+
+               $title = $this->makeBlankTitleObject();
+               $this->assertSame( 'FooModel', $handler->getDefaultModel( $title ) );
+
+               $hints = $handler->getOutputLayoutHints();
+               $this->assertArrayHasKey( 'frob', $hints );
+               $this->assertSame( 'niz', $hints['frob'] );
+
+               $this->assertArrayHasKey( 'display', $hints );
+               $this->assertArrayHasKey( 'region', $hints );
+               $this->assertArrayHasKey( 'placement', $hints );
+       }
+
+       /**
+        * @covers \MediaWiki\Revision\SlotRoleHandler::isAllowedModel()
+        */
+       public function testIsAllowedModel() {
+               $handler = new SlotRoleHandler( 'foo', 'FooModel' );
+
+               $title = $this->makeBlankTitleObject();
+               $this->assertTrue( $handler->isAllowedModel( 'FooModel', $title ) );
+               $this->assertFalse( $handler->isAllowedModel( 'QuaxModel', $title ) );
+       }
+
+       /**
+        * @covers \MediaWiki\Revision\SlotRoleHandler::supportsArticleCount()
+        */
+       public function testSupportsArticleCount() {
+               $handler = new SlotRoleHandler( 'foo', 'FooModel' );
+
+               $this->assertFalse( $handler->supportsArticleCount() );
+       }
+
+}
diff --git a/tests/phpunit/unit/includes/ServiceWiringTest.php b/tests/phpunit/unit/includes/ServiceWiringTest.php
new file mode 100644 (file)
index 0000000..25b0214
--- /dev/null
@@ -0,0 +1,16 @@
+<?php
+
+/**
+ * @coversNothing
+ */
+class ServiceWiringTest extends \MediaWikiUnitTestCase {
+       public function testServicesAreSorted() {
+               global $IP;
+               $services = array_keys( require "$IP/includes/ServiceWiring.php" );
+               $sortedServices = $services;
+               natcasesort( $sortedServices );
+
+               $this->assertSame( $sortedServices, $services,
+                       'Please keep services sorted alphabetically' );
+       }
+}
diff --git a/tests/phpunit/unit/includes/SiteConfigurationTest.php b/tests/phpunit/unit/includes/SiteConfigurationTest.php
new file mode 100644 (file)
index 0000000..b992a86
--- /dev/null
@@ -0,0 +1,379 @@
+<?php
+
+class SiteConfigurationTest extends \MediaWikiUnitTestCase {
+
+       /**
+        * @var SiteConfiguration
+        */
+       protected $mConf;
+
+       protected function setUp() {
+               parent::setUp();
+
+               $this->mConf = new SiteConfiguration;
+
+               $this->mConf->suffixes = [ 'wikipedia' => 'wiki' ];
+               $this->mConf->wikis = [ 'enwiki', 'dewiki', 'frwiki' ];
+               $this->mConf->settings = [
+                       'SimpleKey' => [
+                               'wiki' => 'wiki',
+                               'tag' => 'tag',
+                               'enwiki' => 'enwiki',
+                               'dewiki' => 'dewiki',
+                               'frwiki' => 'frwiki',
+                       ],
+
+                       'Fallback' => [
+                               'default' => 'default',
+                               'wiki' => 'wiki',
+                               'tag' => 'tag',
+                               'frwiki' => 'frwiki',
+                               'null_wiki' => null,
+                       ],
+
+                       'WithParams' => [
+                               'default' => '$lang $site $wiki',
+                       ],
+
+                       '+SomeGlobal' => [
+                               'wiki' => [
+                                       'wiki' => 'wiki',
+                               ],
+                               'tag' => [
+                                       'tag' => 'tag',
+                               ],
+                               'enwiki' => [
+                                       'enwiki' => 'enwiki',
+                               ],
+                               'dewiki' => [
+                                       'dewiki' => 'dewiki',
+                               ],
+                               'frwiki' => [
+                                       'frwiki' => 'frwiki',
+                               ],
+                       ],
+
+                       'MergeIt' => [
+                               '+wiki' => [
+                                       'wiki' => 'wiki',
+                               ],
+                               '+tag' => [
+                                       'tag' => 'tag',
+                               ],
+                               'default' => [
+                                       'default' => 'default',
+                               ],
+                               '+enwiki' => [
+                                       'enwiki' => 'enwiki',
+                               ],
+                               '+dewiki' => [
+                                       'dewiki' => 'dewiki',
+                               ],
+                               '+frwiki' => [
+                                       'frwiki' => 'frwiki',
+                               ],
+                       ],
+               ];
+
+               $GLOBALS['SomeGlobal'] = [ 'SomeGlobal' => 'SomeGlobal' ];
+       }
+
+       /**
+        * This function is used as a callback within the tests below
+        */
+       public static function getSiteParamsCallback( $conf, $wiki ) {
+               $site = null;
+               $lang = null;
+               foreach ( $conf->suffixes as $suffix ) {
+                       if ( substr( $wiki, -strlen( $suffix ) ) == $suffix ) {
+                               $site = $suffix;
+                               $lang = substr( $wiki, 0, -strlen( $suffix ) );
+                               break;
+                       }
+               }
+
+               return [
+                       'suffix' => $site,
+                       'lang' => $lang,
+                       'params' => [
+                               'lang' => $lang,
+                               'site' => $site,
+                               'wiki' => $wiki,
+                       ],
+                       'tags' => [ 'tag' ],
+               ];
+       }
+
+       /**
+        * @covers SiteConfiguration::siteFromDB
+        */
+       public function testSiteFromDb() {
+               $this->assertEquals(
+                       [ 'wikipedia', 'en' ],
+                       $this->mConf->siteFromDB( 'enwiki' ),
+                       'siteFromDB()'
+               );
+               $this->assertEquals(
+                       [ 'wikipedia', '' ],
+                       $this->mConf->siteFromDB( 'wiki' ),
+                       'siteFromDB() on a suffix'
+               );
+               $this->assertEquals(
+                       [ null, null ],
+                       $this->mConf->siteFromDB( 'wikien' ),
+                       'siteFromDB() on a non-existing wiki'
+               );
+
+               $this->mConf->suffixes = [ 'wiki', '' ];
+               $this->assertEquals(
+                       [ '', 'wikien' ],
+                       $this->mConf->siteFromDB( 'wikien' ),
+                       'siteFromDB() on a non-existing wiki (2)'
+               );
+       }
+
+       /**
+        * @covers SiteConfiguration::getLocalDatabases
+        */
+       public function testGetLocalDatabases() {
+               $this->assertEquals(
+                       [ 'enwiki', 'dewiki', 'frwiki' ],
+                       $this->mConf->getLocalDatabases(),
+                       'getLocalDatabases()'
+               );
+       }
+
+       /**
+        * @covers SiteConfiguration::get
+        */
+       public function testGetConfVariables() {
+               // Simple
+               $this->assertEquals(
+                       'enwiki',
+                       $this->mConf->get( 'SimpleKey', 'enwiki', 'wiki' ),
+                       'get(): simple setting on an existing wiki'
+               );
+               $this->assertEquals(
+                       'dewiki',
+                       $this->mConf->get( 'SimpleKey', 'dewiki', 'wiki' ),
+                       'get(): simple setting on an existing wiki (2)'
+               );
+               $this->assertEquals(
+                       'frwiki',
+                       $this->mConf->get( 'SimpleKey', 'frwiki', 'wiki' ),
+                       'get(): simple setting on an existing wiki (3)'
+               );
+               $this->assertEquals(
+                       'wiki',
+                       $this->mConf->get( 'SimpleKey', 'wiki', 'wiki' ),
+                       'get(): simple setting on an suffix'
+               );
+               $this->assertEquals(
+                       'wiki',
+                       $this->mConf->get( 'SimpleKey', 'eswiki', 'wiki' ),
+                       'get(): simple setting on an non-existing wiki'
+               );
+
+               // Fallback
+               $this->assertEquals(
+                       'wiki',
+                       $this->mConf->get( 'Fallback', 'enwiki', 'wiki' ),
+                       'get(): fallback setting on an existing wiki'
+               );
+               $this->assertEquals(
+                       'tag',
+                       $this->mConf->get( 'Fallback', 'dewiki', 'wiki', [], [ 'tag' ] ),
+                       'get(): fallback setting on an existing wiki (with wiki tag)'
+               );
+               $this->assertEquals(
+                       'frwiki',
+                       $this->mConf->get( 'Fallback', 'frwiki', 'wiki', [], [ 'tag' ] ),
+                       'get(): no fallback if wiki has its own setting (matching tag)'
+               );
+               $this->assertSame(
+                       // Potential regression test for T192855
+                       null,
+                       $this->mConf->get( 'Fallback', 'null_wiki', 'wiki', [], [ 'tag' ] ),
+                       'get(): no fallback if wiki has its own setting (matching tag and uses null)'
+               );
+               $this->assertEquals(
+                       'wiki',
+                       $this->mConf->get( 'Fallback', 'wiki', 'wiki' ),
+                       'get(): fallback setting on an suffix'
+               );
+               $this->assertEquals(
+                       'wiki',
+                       $this->mConf->get( 'Fallback', 'wiki', 'wiki', [], [ 'tag' ] ),
+                       'get(): fallback setting on an suffix (with wiki tag)'
+               );
+               $this->assertEquals(
+                       'wiki',
+                       $this->mConf->get( 'Fallback', 'eswiki', 'wiki' ),
+                       'get(): fallback setting on an non-existing wiki'
+               );
+               $this->assertEquals(
+                       'tag',
+                       $this->mConf->get( 'Fallback', 'eswiki', 'wiki', [], [ 'tag' ] ),
+                       'get(): fallback setting on an non-existing wiki (with wiki tag)'
+               );
+
+               // Merging
+               $common = [ 'wiki' => 'wiki', 'default' => 'default' ];
+               $commonTag = [ 'tag' => 'tag', 'wiki' => 'wiki', 'default' => 'default' ];
+               $this->assertEquals(
+                       [ 'enwiki' => 'enwiki' ] + $common,
+                       $this->mConf->get( 'MergeIt', 'enwiki', 'wiki' ),
+                       'get(): merging setting on an existing wiki'
+               );
+               $this->assertEquals(
+                       [ 'enwiki' => 'enwiki' ] + $commonTag,
+                       $this->mConf->get( 'MergeIt', 'enwiki', 'wiki', [], [ 'tag' ] ),
+                       'get(): merging setting on an existing wiki (with tag)'
+               );
+               $this->assertEquals(
+                       [ 'dewiki' => 'dewiki' ] + $common,
+                       $this->mConf->get( 'MergeIt', 'dewiki', 'wiki' ),
+                       'get(): merging setting on an existing wiki (2)'
+               );
+               $this->assertEquals(
+                       [ 'dewiki' => 'dewiki' ] + $commonTag,
+                       $this->mConf->get( 'MergeIt', 'dewiki', 'wiki', [], [ 'tag' ] ),
+                       'get(): merging setting on an existing wiki (2) (with tag)'
+               );
+               $this->assertEquals(
+                       [ 'frwiki' => 'frwiki' ] + $common,
+                       $this->mConf->get( 'MergeIt', 'frwiki', 'wiki' ),
+                       'get(): merging setting on an existing wiki (3)'
+               );
+               $this->assertEquals(
+                       [ 'frwiki' => 'frwiki' ] + $commonTag,
+                       $this->mConf->get( 'MergeIt', 'frwiki', 'wiki', [], [ 'tag' ] ),
+                       'get(): merging setting on an existing wiki (3) (with tag)'
+               );
+               $this->assertEquals(
+                       [ 'wiki' => 'wiki' ] + $common,
+                       $this->mConf->get( 'MergeIt', 'wiki', 'wiki' ),
+                       'get(): merging setting on an suffix'
+               );
+               $this->assertEquals(
+                       [ 'wiki' => 'wiki' ] + $commonTag,
+                       $this->mConf->get( 'MergeIt', 'wiki', 'wiki', [], [ 'tag' ] ),
+                       'get(): merging setting on an suffix (with tag)'
+               );
+               $this->assertEquals(
+                       $common,
+                       $this->mConf->get( 'MergeIt', 'eswiki', 'wiki' ),
+                       'get(): merging setting on an non-existing wiki'
+               );
+               $this->assertEquals(
+                       $commonTag,
+                       $this->mConf->get( 'MergeIt', 'eswiki', 'wiki', [], [ 'tag' ] ),
+                       'get(): merging setting on an non-existing wiki (with tag)'
+               );
+       }
+
+       /**
+        * @covers SiteConfiguration::siteFromDB
+        */
+       public function testSiteFromDbWithCallback() {
+               $this->mConf->siteParamsCallback = 'SiteConfigurationTest::getSiteParamsCallback';
+
+               $this->assertEquals(
+                       [ 'wiki', 'en' ],
+                       $this->mConf->siteFromDB( 'enwiki' ),
+                       'siteFromDB() with callback'
+               );
+               $this->assertEquals(
+                       [ 'wiki', '' ],
+                       $this->mConf->siteFromDB( 'wiki' ),
+                       'siteFromDB() with callback on a suffix'
+               );
+               $this->assertEquals(
+                       [ null, null ],
+                       $this->mConf->siteFromDB( 'wikien' ),
+                       'siteFromDB() with callback on a non-existing wiki'
+               );
+       }
+
+       /**
+        * @covers SiteConfiguration::get
+        */
+       public function testParameterReplacement() {
+               $this->mConf->siteParamsCallback = 'SiteConfigurationTest::getSiteParamsCallback';
+
+               $this->assertEquals(
+                       'en wiki enwiki',
+                       $this->mConf->get( 'WithParams', 'enwiki', 'wiki' ),
+                       'get(): parameter replacement on an existing wiki'
+               );
+               $this->assertEquals(
+                       'de wiki dewiki',
+                       $this->mConf->get( 'WithParams', 'dewiki', 'wiki' ),
+                       'get(): parameter replacement on an existing wiki (2)'
+               );
+               $this->assertEquals(
+                       'fr wiki frwiki',
+                       $this->mConf->get( 'WithParams', 'frwiki', 'wiki' ),
+                       'get(): parameter replacement on an existing wiki (3)'
+               );
+               $this->assertEquals(
+                       ' wiki wiki',
+                       $this->mConf->get( 'WithParams', 'wiki', 'wiki' ),
+                       'get(): parameter replacement on an suffix'
+               );
+               $this->assertEquals(
+                       'es wiki eswiki',
+                       $this->mConf->get( 'WithParams', 'eswiki', 'wiki' ),
+                       'get(): parameter replacement on an non-existing wiki'
+               );
+       }
+
+       /**
+        * @covers SiteConfiguration::getAll
+        */
+       public function testGetAllGlobals() {
+               $this->mConf->siteParamsCallback = 'SiteConfigurationTest::getSiteParamsCallback';
+
+               $getall = [
+                       'SimpleKey' => 'enwiki',
+                       'Fallback' => 'tag',
+                       'WithParams' => 'en wiki enwiki',
+                       'SomeGlobal' => [ 'enwiki' => 'enwiki' ] + $GLOBALS['SomeGlobal'],
+                       'MergeIt' => [
+                               'enwiki' => 'enwiki',
+                               'tag' => 'tag',
+                               'wiki' => 'wiki',
+                               'default' => 'default'
+                       ],
+               ];
+               $this->assertEquals( $getall, $this->mConf->getAll( 'enwiki' ), 'getAll()' );
+
+               $this->mConf->extractAllGlobals( 'enwiki', 'wiki' );
+
+               $this->assertEquals(
+                       $getall['SimpleKey'],
+                       $GLOBALS['SimpleKey'],
+                       'extractAllGlobals(): simple setting'
+               );
+               $this->assertEquals(
+                       $getall['Fallback'],
+                       $GLOBALS['Fallback'],
+                       'extractAllGlobals(): fallback setting'
+               );
+               $this->assertEquals(
+                       $getall['WithParams'],
+                       $GLOBALS['WithParams'],
+                       'extractAllGlobals(): parameter replacement'
+               );
+               $this->assertEquals(
+                       $getall['SomeGlobal'],
+                       $GLOBALS['SomeGlobal'],
+                       'extractAllGlobals(): merging with global'
+               );
+               $this->assertEquals(
+                       $getall['MergeIt'],
+                       $GLOBALS['MergeIt'],
+                       'extractAllGlobals(): merging setting'
+               );
+       }
+}
diff --git a/tests/phpunit/unit/includes/Storage/PreparedEditTest.php b/tests/phpunit/unit/includes/Storage/PreparedEditTest.php
new file mode 100644 (file)
index 0000000..e3249e7
--- /dev/null
@@ -0,0 +1,21 @@
+<?php
+
+namespace MediaWiki\Edit;
+
+use ParserOutput;
+
+/**
+ * @covers \MediaWiki\Edit\PreparedEdit
+ */
+class PreparedEditTest extends \MediaWikiUnitTestCase {
+       function testCallback() {
+               $output = new ParserOutput();
+               $edit = new PreparedEdit();
+               $edit->parserOutputCallback = function () {
+                       return new ParserOutput();
+               };
+
+               $this->assertEquals( $output, $edit->getOutput() );
+               $this->assertEquals( $output, $edit->output );
+       }
+}
diff --git a/tests/phpunit/unit/includes/XmlSelectTest.php b/tests/phpunit/unit/includes/XmlSelectTest.php
new file mode 100644 (file)
index 0000000..54d269e
--- /dev/null
@@ -0,0 +1,182 @@
+<?php
+
+/**
+ * @group Xml
+ */
+class XmlSelectTest extends \MediaWikiUnitTestCase {
+
+       /**
+        * @var XmlSelect
+        */
+       protected $select;
+
+       protected function setUp() {
+               parent::setUp();
+               $this->select = new XmlSelect();
+       }
+
+       protected function tearDown() {
+               parent::tearDown();
+               $this->select = null;
+       }
+
+       /**
+        * @covers XmlSelect::__construct
+        */
+       public function testConstructWithoutParameters() {
+               $this->assertEquals( '<select></select>', $this->select->getHTML() );
+       }
+
+       /**
+        * Parameters are $name (false), $id (false), $default (false)
+        * @dataProvider provideConstructionParameters
+        * @covers XmlSelect::__construct
+        */
+       public function testConstructParameters( $name, $id, $default, $expected ) {
+               $this->select = new XmlSelect( $name, $id, $default );
+               $this->assertEquals( $expected, $this->select->getHTML() );
+       }
+
+       /**
+        * Provide parameters for testConstructParameters() which use three
+        * parameters:
+        *  - $name    (default: false)
+        *  - $id      (default: false)
+        *  - $default (default: false)
+        * Provides a fourth parameters representing the expected HTML output
+        */
+       public static function provideConstructionParameters() {
+               return [
+                       /**
+                        * Values are set following a 3-bit Gray code where two successive
+                        * values differ by only one value.
+                        * See https://en.wikipedia.org/wiki/Gray_code
+                        */
+                       #      $name   $id    $default
+                       [ false, false, false, '<select></select>' ],
+                       [ false, false, 'foo', '<select></select>' ],
+                       [ false, 'id', 'foo', '<select id="id"></select>' ],
+                       [ false, 'id', false, '<select id="id"></select>' ],
+                       [ 'name', 'id', false, '<select name="name" id="id"></select>' ],
+                       [ 'name', 'id', 'foo', '<select name="name" id="id"></select>' ],
+                       [ 'name', false, 'foo', '<select name="name"></select>' ],
+                       [ 'name', false, false, '<select name="name"></select>' ],
+               ];
+       }
+
+       /**
+        * @covers XmlSelect::addOption
+        */
+       public function testAddOption() {
+               $this->select->addOption( 'foo' );
+               $this->assertEquals(
+                       '<select><option value="foo">foo</option></select>',
+                       $this->select->getHTML()
+               );
+       }
+
+       /**
+        * @covers XmlSelect::addOption
+        */
+       public function testAddOptionWithDefault() {
+               $this->select->addOption( 'foo', true );
+               $this->assertEquals(
+                       '<select><option value="1">foo</option></select>',
+                       $this->select->getHTML()
+               );
+       }
+
+       /**
+        * @covers XmlSelect::addOption
+        */
+       public function testAddOptionWithFalse() {
+               $this->select->addOption( 'foo', false );
+               $this->assertEquals(
+                       '<select><option value="foo">foo</option></select>',
+                       $this->select->getHTML()
+               );
+       }
+
+       /**
+        * @covers XmlSelect::addOption
+        */
+       public function testAddOptionWithValueZero() {
+               $this->select->addOption( 'foo', 0 );
+               $this->assertEquals(
+                       '<select><option value="0">foo</option></select>',
+                       $this->select->getHTML()
+               );
+       }
+
+       /**
+        * @covers XmlSelect::setDefault
+        */
+       public function testSetDefault() {
+               $this->select->setDefault( 'bar1' );
+               $this->select->addOption( 'foo1' );
+               $this->select->addOption( 'bar1' );
+               $this->select->addOption( 'foo2' );
+               $this->assertEquals(
+                       '<select><option value="foo1">foo1</option>' . "\n" .
+                               '<option value="bar1" selected="">bar1</option>' . "\n" .
+                               '<option value="foo2">foo2</option></select>', $this->select->getHTML() );
+       }
+
+       /**
+        * Adding default later on should set the correct selection or
+        * raise an exception.
+        * To handle this, we need to render the options in getHtml()
+        * @covers XmlSelect::setDefault
+        */
+       public function testSetDefaultAfterAddingOptions() {
+               $this->select->addOption( 'foo1' );
+               $this->select->addOption( 'bar1' );
+               $this->select->addOption( 'foo2' );
+               $this->select->setDefault( 'bar1' ); # setting default after adding options
+               $this->assertEquals(
+                       '<select><option value="foo1">foo1</option>' . "\n" .
+                               '<option value="bar1" selected="">bar1</option>' . "\n" .
+                               '<option value="foo2">foo2</option></select>', $this->select->getHTML() );
+       }
+
+       /**
+        * @covers XmlSelect::setAttribute
+        * @covers XmlSelect::getAttribute
+        */
+       public function testGetAttributes() {
+               # create some attributes
+               $this->select->setAttribute( 'dummy', 0x777 );
+               $this->select->setAttribute( 'string', 'euro €' );
+               $this->select->setAttribute( 1911, 'razor' );
+
+               # verify we can retrieve them
+               $this->assertEquals(
+                       $this->select->getAttribute( 'dummy' ),
+                       0x777
+               );
+               $this->assertEquals(
+                       $this->select->getAttribute( 'string' ),
+                       'euro €'
+               );
+               $this->assertEquals(
+                       $this->select->getAttribute( 1911 ),
+                       'razor'
+               );
+
+               # inexistent keys should give us 'null'
+               $this->assertEquals(
+                       $this->select->getAttribute( 'I DO NOT EXIT' ),
+                       null
+               );
+
+               # verify string / integer
+               $this->assertEquals(
+                       $this->select->getAttribute( '1911' ),
+                       'razor'
+               );
+               $this->assertEquals(
+                       $this->select->getAttribute( 'dummy' ),
+                       0x777
+               );
+       }
+}
diff --git a/tests/phpunit/unit/includes/auth/AuthenticationResponseTest.php b/tests/phpunit/unit/includes/auth/AuthenticationResponseTest.php
new file mode 100644 (file)
index 0000000..44b0631
--- /dev/null
@@ -0,0 +1,112 @@
+<?php
+
+namespace MediaWiki\Auth;
+
+/**
+ * @group AuthManager
+ * @covers \MediaWiki\Auth\AuthenticationResponse
+ */
+class AuthenticationResponseTest extends \MediaWikiUnitTestCase {
+       /**
+        * @dataProvider provideConstructors
+        * @param string $constructor
+        * @param array $args
+        * @param array|Exception $expect
+        */
+       public function testConstructors( $constructor, $args, $expect ) {
+               if ( is_array( $expect ) ) {
+                       $res = new AuthenticationResponse();
+                       $res->messageType = 'warning';
+                       foreach ( $expect as $field => $value ) {
+                               $res->$field = $value;
+                       }
+                       $ret = call_user_func_array( "MediaWiki\\Auth\\AuthenticationResponse::$constructor", $args );
+                       $this->assertEquals( $res, $ret );
+               } else {
+                       try {
+                               call_user_func_array( "MediaWiki\\Auth\\AuthenticationResponse::$constructor", $args );
+                               $this->fail( 'Expected exception not thrown' );
+                       } catch ( \Exception $ex ) {
+                               $this->assertEquals( $expect, $ex );
+                       }
+               }
+       }
+
+       public function provideConstructors() {
+               $req = $this->getMockForAbstractClass( AuthenticationRequest::class );
+               $msg = new \Message( 'mainpage' );
+
+               return [
+                       [ 'newPass', [], [
+                               'status' => AuthenticationResponse::PASS,
+                       ] ],
+                       [ 'newPass', [ 'name' ], [
+                               'status' => AuthenticationResponse::PASS,
+                               'username' => 'name',
+                       ] ],
+                       [ 'newPass', [ 'name', null ], [
+                               'status' => AuthenticationResponse::PASS,
+                               'username' => 'name',
+                       ] ],
+
+                       [ 'newFail', [ $msg ], [
+                               'status' => AuthenticationResponse::FAIL,
+                               'message' => $msg,
+                               'messageType' => 'error',
+                       ] ],
+
+                       [ 'newRestart', [ $msg ], [
+                               'status' => AuthenticationResponse::RESTART,
+                               'message' => $msg,
+                       ] ],
+
+                       [ 'newAbstain', [], [
+                               'status' => AuthenticationResponse::ABSTAIN,
+                       ] ],
+
+                       [ 'newUI', [ [ $req ], $msg ], [
+                               'status' => AuthenticationResponse::UI,
+                               'neededRequests' => [ $req ],
+                               'message' => $msg,
+                               'messageType' => 'warning',
+                       ] ],
+
+                       [ 'newUI', [ [ $req ], $msg, 'warning' ], [
+                               'status' => AuthenticationResponse::UI,
+                               'neededRequests' => [ $req ],
+                               'message' => $msg,
+                               'messageType' => 'warning',
+                       ] ],
+
+                       [ 'newUI', [ [ $req ], $msg, 'error' ], [
+                               'status' => AuthenticationResponse::UI,
+                               'neededRequests' => [ $req ],
+                               'message' => $msg,
+                               'messageType' => 'error',
+                       ] ],
+                       [ 'newUI', [ [], $msg ],
+                               new \InvalidArgumentException( '$reqs may not be empty' )
+                       ],
+
+                       [ 'newRedirect', [ [ $req ], 'http://example.org/redir' ], [
+                               'status' => AuthenticationResponse::REDIRECT,
+                               'neededRequests' => [ $req ],
+                               'redirectTarget' => 'http://example.org/redir',
+                       ] ],
+                       [
+                               'newRedirect',
+                               [ [ $req ], 'http://example.org/redir', [ 'foo' => 'bar' ] ],
+                               [
+                                       'status' => AuthenticationResponse::REDIRECT,
+                                       'neededRequests' => [ $req ],
+                                       'redirectTarget' => 'http://example.org/redir',
+                                       'redirectApiData' => [ 'foo' => 'bar' ],
+                               ]
+                       ],
+                       [ 'newRedirect', [ [], 'http://example.org/redir' ],
+                               new \InvalidArgumentException( '$reqs may not be empty' )
+                       ],
+               ];
+       }
+
+}
diff --git a/tests/phpunit/unit/includes/changes/ChangesListFilterGroupTest.php b/tests/phpunit/unit/includes/changes/ChangesListFilterGroupTest.php
new file mode 100644 (file)
index 0000000..bd54d50
--- /dev/null
@@ -0,0 +1,79 @@
+<?php
+
+/**
+ * @covers ChangesListFilterGroup
+ */
+class ChangesListFilterGroupTest extends \MediaWikiUnitTestCase {
+       /**
+        * phpcs:disable Generic.Files.LineLength
+        * @expectedException MWException
+        * @expectedExceptionMessage Group names may not contain '_'.  Use the naming convention: 'camelCase'
+        * phpcs:enable
+        */
+       public function testReservedCharacter() {
+               new MockChangesListFilterGroup(
+                       [
+                               'type' => 'some_type',
+                               'name' => 'group_name',
+                               'priority' => 1,
+                               'filters' => [],
+                       ]
+               );
+       }
+
+       public function testAutoPriorities() {
+               $group = new MockChangesListFilterGroup(
+                       [
+                               'type' => 'some_type',
+                               'name' => 'groupName',
+                               'isFullCoverage' => true,
+                               'priority' => 1,
+                               'filters' => [
+                                       [ 'name' => 'hidefoo' ],
+                                       [ 'name' => 'hidebar' ],
+                                       [ 'name' => 'hidebaz' ],
+                               ],
+                       ]
+               );
+
+               $filters = $group->getFilters();
+               $this->assertEquals(
+                       [
+                               -2,
+                               -3,
+                               -4,
+                       ],
+                       array_map(
+                               function ( $f ) {
+                                       return $f->getPriority();
+                               },
+                               array_values( $filters )
+                       )
+               );
+       }
+
+       // Get without warnings
+       public function testGetFilter() {
+               $group = new MockChangesListFilterGroup(
+                       [
+                               'type' => 'some_type',
+                               'name' => 'groupName',
+                               'isFullCoverage' => true,
+                               'priority' => 1,
+                               'filters' => [
+                                       [ 'name' => 'foo' ],
+                               ],
+                       ]
+               );
+
+               $this->assertEquals(
+                       'foo',
+                       $group->getFilter( 'foo' )->getName()
+               );
+
+               $this->assertEquals(
+                       null,
+                       $group->getFilter( 'bar' )
+               );
+       }
+}
diff --git a/tests/phpunit/unit/includes/config/ConfigFactoryTest.php b/tests/phpunit/unit/includes/config/ConfigFactoryTest.php
new file mode 100644 (file)
index 0000000..a136018
--- /dev/null
@@ -0,0 +1,168 @@
+<?php
+
+use MediaWiki\MediaWikiServices;
+
+class ConfigFactoryTest extends \MediaWikiUnitTestCase {
+
+       /**
+        * @covers ConfigFactory::register
+        */
+       public function testRegister() {
+               $factory = new ConfigFactory();
+               $factory->register( 'unittest', 'GlobalVarConfig::newInstance' );
+               $this->assertInstanceOf( GlobalVarConfig::class, $factory->makeConfig( 'unittest' ) );
+       }
+
+       /**
+        * @covers ConfigFactory::register
+        */
+       public function testRegisterInvalid() {
+               $factory = new ConfigFactory();
+               $this->setExpectedException( InvalidArgumentException::class );
+               $factory->register( 'invalid', 'Invalid callback' );
+       }
+
+       /**
+        * @covers ConfigFactory::register
+        */
+       public function testRegisterInvalidInstance() {
+               $factory = new ConfigFactory();
+               $this->setExpectedException( InvalidArgumentException::class );
+               $factory->register( 'invalidInstance', new stdClass );
+       }
+
+       /**
+        * @covers ConfigFactory::register
+        */
+       public function testRegisterInstance() {
+               $config = GlobalVarConfig::newInstance();
+               $factory = new ConfigFactory();
+               $factory->register( 'unittest', $config );
+               $this->assertSame( $config, $factory->makeConfig( 'unittest' ) );
+       }
+
+       /**
+        * @covers ConfigFactory::register
+        */
+       public function testRegisterAgain() {
+               $factory = new ConfigFactory();
+               $factory->register( 'unittest', 'GlobalVarConfig::newInstance' );
+               $config1 = $factory->makeConfig( 'unittest' );
+
+               $factory->register( 'unittest', 'GlobalVarConfig::newInstance' );
+               $config2 = $factory->makeConfig( 'unittest' );
+
+               $this->assertNotSame( $config1, $config2 );
+       }
+
+       /**
+        * @covers ConfigFactory::salvage
+        */
+       public function testSalvage() {
+               $oldFactory = new ConfigFactory();
+               $oldFactory->register( 'foo', 'GlobalVarConfig::newInstance' );
+               $oldFactory->register( 'bar', 'GlobalVarConfig::newInstance' );
+               $oldFactory->register( 'quux', 'GlobalVarConfig::newInstance' );
+
+               // instantiate two of the three defined configurations
+               $foo = $oldFactory->makeConfig( 'foo' );
+               $bar = $oldFactory->makeConfig( 'bar' );
+               $quux = $oldFactory->makeConfig( 'quux' );
+
+               // define new config instance
+               $newFactory = new ConfigFactory();
+               $newFactory->register( 'foo', 'GlobalVarConfig::newInstance' );
+               $newFactory->register( 'bar', function () {
+                       return new HashConfig();
+               } );
+
+               // "foo" and "quux" are defined in the old and the new factory.
+               // The old factory has instances for "foo" and "bar", but not "quux".
+               $newFactory->salvage( $oldFactory );
+
+               $newFoo = $newFactory->makeConfig( 'foo' );
+               $this->assertSame( $foo, $newFoo, 'existing instance should be salvaged' );
+
+               $newBar = $newFactory->makeConfig( 'bar' );
+               $this->assertNotSame( $bar, $newBar, 'don\'t salvage if callbacks differ' );
+
+               // the new factory doesn't have quux defined, so the quux instance should not be salvaged
+               $this->setExpectedException( ConfigException::class );
+               $newFactory->makeConfig( 'quux' );
+       }
+
+       /**
+        * @covers ConfigFactory::getConfigNames
+        */
+       public function testGetConfigNames() {
+               $factory = new ConfigFactory();
+               $factory->register( 'foo', 'GlobalVarConfig::newInstance' );
+               $factory->register( 'bar', new HashConfig() );
+
+               $this->assertEquals( [ 'foo', 'bar' ], $factory->getConfigNames() );
+       }
+
+       /**
+        * @covers ConfigFactory::makeConfig
+        */
+       public function testMakeConfigWithCallback() {
+               $factory = new ConfigFactory();
+               $factory->register( 'unittest', 'GlobalVarConfig::newInstance' );
+
+               $conf = $factory->makeConfig( 'unittest' );
+               $this->assertInstanceOf( Config::class, $conf );
+               $this->assertSame( $conf, $factory->makeConfig( 'unittest' ) );
+       }
+
+       /**
+        * @covers ConfigFactory::makeConfig
+        */
+       public function testMakeConfigWithObject() {
+               $factory = new ConfigFactory();
+               $conf = new HashConfig();
+               $factory->register( 'test', $conf );
+               $this->assertSame( $conf, $factory->makeConfig( 'test' ) );
+       }
+
+       /**
+        * @covers ConfigFactory::makeConfig
+        */
+       public function testMakeConfigFallback() {
+               $factory = new ConfigFactory();
+               $factory->register( '*', 'GlobalVarConfig::newInstance' );
+               $conf = $factory->makeConfig( 'unittest' );
+               $this->assertInstanceOf( Config::class, $conf );
+       }
+
+       /**
+        * @covers ConfigFactory::makeConfig
+        */
+       public function testMakeConfigWithNoBuilders() {
+               $factory = new ConfigFactory();
+               $this->setExpectedException( ConfigException::class );
+               $factory->makeConfig( 'nobuilderregistered' );
+       }
+
+       /**
+        * @covers ConfigFactory::makeConfig
+        */
+       public function testMakeConfigWithInvalidCallback() {
+               $factory = new ConfigFactory();
+               $factory->register( 'unittest', function () {
+                       return true; // Not a Config object
+               } );
+               $this->setExpectedException( UnexpectedValueException::class );
+               $factory->makeConfig( 'unittest' );
+       }
+
+       /**
+        * @covers ConfigFactory::getDefaultInstance
+        */
+       public function testGetDefaultInstance() {
+               // NOTE: the global config factory returned here has been overwritten
+               // for operation in test mode. It may not reflect LocalSettings.
+               $factory = MediaWikiServices::getInstance()->getConfigFactory();
+               $this->assertInstanceOf( Config::class, $factory->makeConfig( 'main' ) );
+       }
+
+}
diff --git a/tests/phpunit/unit/includes/config/HashConfigTest.php b/tests/phpunit/unit/includes/config/HashConfigTest.php
new file mode 100644 (file)
index 0000000..d46ee09
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+
+class HashConfigTest extends \MediaWikiUnitTestCase {
+
+       /**
+        * @covers HashConfig::newInstance
+        */
+       public function testNewInstance() {
+               $conf = HashConfig::newInstance();
+               $this->assertInstanceOf( HashConfig::class, $conf );
+       }
+
+       /**
+        * @covers HashConfig::__construct
+        */
+       public function testConstructor() {
+               $conf = new HashConfig();
+               $this->assertInstanceOf( HashConfig::class, $conf );
+
+               // Test passing arguments to the constructor
+               $conf2 = new HashConfig( [
+                       'one' => '1',
+               ] );
+               $this->assertEquals( '1', $conf2->get( 'one' ) );
+       }
+
+       /**
+        * @covers HashConfig::get
+        */
+       public function testGet() {
+               $conf = new HashConfig( [
+                       'one' => '1',
+               ] );
+               $this->assertEquals( '1', $conf->get( 'one' ) );
+               $this->setExpectedException( ConfigException::class, 'HashConfig::get: undefined option' );
+               $conf->get( 'two' );
+       }
+
+       /**
+        * @covers HashConfig::has
+        */
+       public function testHas() {
+               $conf = new HashConfig( [
+                       'one' => '1',
+               ] );
+               $this->assertTrue( $conf->has( 'one' ) );
+               $this->assertFalse( $conf->has( 'two' ) );
+       }
+
+       /**
+        * @covers HashConfig::set
+        */
+       public function testSet() {
+               $conf = new HashConfig( [
+                       'one' => '1',
+               ] );
+               $conf->set( 'two', '2' );
+               $this->assertEquals( '2', $conf->get( 'two' ) );
+               // Check that set overwrites
+               $conf->set( 'one', '3' );
+               $this->assertEquals( '3', $conf->get( 'one' ) );
+       }
+}
diff --git a/tests/phpunit/unit/includes/config/MultiConfigTest.php b/tests/phpunit/unit/includes/config/MultiConfigTest.php
new file mode 100644 (file)
index 0000000..4351151
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+
+class MultiConfigTest extends \MediaWikiUnitTestCase {
+
+       /**
+        * Tests that settings are fetched in the right order
+        *
+        * @covers MultiConfig::__construct
+        * @covers MultiConfig::get
+        */
+       public function testGet() {
+               $multi = new MultiConfig( [
+                       new HashConfig( [ 'foo' => 'bar' ] ),
+                       new HashConfig( [ 'foo' => 'baz', 'bar' => 'foo' ] ),
+                       new HashConfig( [ 'bar' => 'baz' ] ),
+               ] );
+
+               $this->assertEquals( 'bar', $multi->get( 'foo' ) );
+               $this->assertEquals( 'foo', $multi->get( 'bar' ) );
+               $this->setExpectedException( ConfigException::class, 'MultiConfig::get: undefined option:' );
+               $multi->get( 'notset' );
+       }
+
+       /**
+        * @covers MultiConfig::has
+        */
+       public function testHas() {
+               $conf = new MultiConfig( [
+                       new HashConfig( [ 'foo' => 'foo' ] ),
+                       new HashConfig( [ 'something' => 'bleh' ] ),
+                       new HashConfig( [ 'meh' => 'eh' ] ),
+               ] );
+
+               $this->assertTrue( $conf->has( 'foo' ) );
+               $this->assertTrue( $conf->has( 'something' ) );
+               $this->assertTrue( $conf->has( 'meh' ) );
+               $this->assertFalse( $conf->has( 'what' ) );
+       }
+}
diff --git a/tests/phpunit/unit/includes/config/ServiceOptionsTest.php b/tests/phpunit/unit/includes/config/ServiceOptionsTest.php
new file mode 100644 (file)
index 0000000..c58c6f5
--- /dev/null
@@ -0,0 +1,149 @@
+<?php
+
+use MediaWiki\Config\ServiceOptions;
+
+/**
+ * @coversDefaultClass \MediaWiki\Config\ServiceOptions
+ */
+class ServiceOptionsTest extends \MediaWikiUnitTestCase {
+       public static $testObj;
+
+       public static function setUpBeforeClass() {
+               parent::setUpBeforeClass();
+
+               self::$testObj = new stdclass();
+       }
+
+       /**
+        * @dataProvider provideConstructor
+        * @covers ::__construct
+        * @covers ::assertRequiredOptions
+        * @covers ::get
+        */
+       public function testConstructor( $expected, $keys, ...$sources ) {
+               $options = new ServiceOptions( $keys, ...$sources );
+
+               foreach ( $expected as $key => $val ) {
+                       $this->assertSame( $val, $options->get( $key ) );
+               }
+
+               // This is lumped in the same test because there's no support for depending on a test that
+               // has a data provider.
+               $options->assertRequiredOptions( array_keys( $expected ) );
+
+               // Suppress warning if no assertions were run. This is expected for empty arguments.
+               $this->assertTrue( true );
+       }
+
+       public function provideConstructor() {
+               return [
+                       'No keys' => [ [], [], [ 'a' => 'aval' ] ],
+                       'Simple array source' => [
+                               [ 'a' => 'aval', 'b' => 'bval' ],
+                               [ 'a', 'b' ],
+                               [ 'a' => 'aval', 'b' => 'bval', 'c' => 'cval' ],
+                       ],
+                       'Simple HashConfig source' => [
+                               [ 'a' => 'aval', 'b' => 'bval' ],
+                               [ 'a', 'b' ],
+                               new HashConfig( [ 'a' => 'aval', 'b' => 'bval', 'c' => 'cval' ] ),
+                       ],
+                       'Three different sources' => [
+                               [ 'a' => 'aval', 'b' => 'bval' ],
+                               [ 'a', 'b' ],
+                               [ 'z' => 'zval' ],
+                               new HashConfig( [ 'a' => 'aval', 'c' => 'cval' ] ),
+                               [ 'b' => 'bval', 'd' => 'dval' ],
+                       ],
+                       'null key' => [
+                               [ 'a' => null ],
+                               [ 'a' ],
+                               [ 'a' => null ],
+                       ],
+                       'Numeric option name' => [
+                               [ '0' => 'nothing' ],
+                               [ '0' ],
+                               [ '0' => 'nothing' ],
+                       ],
+                       'Multiple sources for one key' => [
+                               [ 'a' => 'winner' ],
+                               [ 'a' ],
+                               [ 'a' => 'winner' ],
+                               [ 'a' => 'second place' ],
+                       ],
+                       'Object value is passed by reference' => [
+                               [ 'a' => self::$testObj ],
+                               [ 'a' ],
+                               [ 'a' => self::$testObj ],
+                       ],
+               ];
+       }
+
+       /**
+        * @covers ::__construct
+        */
+       public function testKeyNotFound() {
+               $this->setExpectedException( InvalidArgumentException::class,
+                       'Key "a" not found in input sources' );
+
+               new ServiceOptions( [ 'a' ], [ 'b' => 'bval' ], [ 'c' => 'cval' ] );
+       }
+
+       /**
+        * @covers ::__construct
+        * @covers ::assertRequiredOptions
+        */
+       public function testOutOfOrderAssertRequiredOptions() {
+               $options = new ServiceOptions( [ 'a', 'b' ], [ 'a' => '', 'b' => '' ] );
+               $options->assertRequiredOptions( [ 'b', 'a' ] );
+               $this->assertTrue( true, 'No exception thrown' );
+       }
+
+       /**
+        * @covers ::__construct
+        * @covers ::get
+        */
+       public function testGetUnrecognized() {
+               $this->setExpectedException( InvalidArgumentException::class,
+                       'Unrecognized option "b"' );
+
+               $options = new ServiceOptions( [ 'a' ], [ 'a' => '' ] );
+               $options->get( 'b' );
+       }
+
+       /**
+        * @covers ::__construct
+        * @covers ::assertRequiredOptions
+        */
+       public function testExtraKeys() {
+               $this->setExpectedException( Wikimedia\Assert\PreconditionException::class,
+                       'Precondition failed: Unsupported options passed: b, c!' );
+
+               $options = new ServiceOptions( [ 'a', 'b', 'c' ], [ 'a' => '', 'b' => '', 'c' => '' ] );
+               $options->assertRequiredOptions( [ 'a' ] );
+       }
+
+       /**
+        * @covers ::__construct
+        * @covers ::assertRequiredOptions
+        */
+       public function testMissingKeys() {
+               $this->setExpectedException( Wikimedia\Assert\PreconditionException::class,
+                       'Precondition failed: Required options missing: a, b!' );
+
+               $options = new ServiceOptions( [ 'c' ], [ 'c' => '' ] );
+               $options->assertRequiredOptions( [ 'a', 'b', 'c' ] );
+       }
+
+       /**
+        * @covers ::__construct
+        * @covers ::assertRequiredOptions
+        */
+       public function testExtraAndMissingKeys() {
+               $this->setExpectedException( Wikimedia\Assert\PreconditionException::class,
+                       'Precondition failed: Unsupported options passed: b! Required options missing: c!' );
+
+               $options = new ServiceOptions( [ 'a', 'b' ], [ 'a' => '', 'b' => '' ] );
+               $options->assertRequiredOptions( [ 'a', 'c' ] );
+       }
+}
diff --git a/tests/phpunit/unit/includes/content/JsonContentHandlerTest.php b/tests/phpunit/unit/includes/content/JsonContentHandlerTest.php
new file mode 100644 (file)
index 0000000..70db73c
--- /dev/null
@@ -0,0 +1,14 @@
+<?php
+
+class JsonContentHandlerTest extends \MediaWikiUnitTestCase {
+
+       /**
+        * @covers JsonContentHandler::makeEmptyContent
+        */
+       public function testMakeEmptyContent() {
+               $handler = new JsonContentHandler();
+               $content = $handler->makeEmptyContent();
+               $this->assertInstanceOf( JsonContent::class, $content );
+               $this->assertTrue( $content->isValid() );
+       }
+}
diff --git a/tests/phpunit/unit/includes/debug/logger/MonologSpiTest.php b/tests/phpunit/unit/includes/debug/logger/MonologSpiTest.php
new file mode 100644 (file)
index 0000000..ecb5d17
--- /dev/null
@@ -0,0 +1,135 @@
+<?php
+/**
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ */
+
+namespace MediaWiki\Logger;
+
+use Wikimedia\TestingAccessWrapper;
+
+class MonologSpiTest extends \MediaWikiUnitTestCase {
+
+       /**
+        * @covers MediaWiki\Logger\MonologSpi::mergeConfig
+        */
+       public function testMergeConfig() {
+               $base = [
+                       'loggers' => [
+                               '@default' => [
+                                       'processors' => [ 'constructor' ],
+                                       'handlers' => [ 'constructor' ],
+                               ],
+                       ],
+                       'processors' => [
+                               'constructor' => [
+                                       'class' => 'constructor',
+                               ],
+                       ],
+                       'handlers' => [
+                               'constructor' => [
+                                       'class' => 'constructor',
+                                       'formatter' => 'constructor',
+                               ],
+                       ],
+                       'formatters' => [
+                               'constructor' => [
+                                       'class' => 'constructor',
+                               ],
+                       ],
+               ];
+
+               $fixture = new MonologSpi( $base );
+               $this->assertSame(
+                       $base,
+                       TestingAccessWrapper::newFromObject( $fixture )->config
+               );
+
+               $fixture->mergeConfig( [
+                       'loggers' => [
+                               'merged' => [
+                                       'processors' => [ 'merged' ],
+                                       'handlers' => [ 'merged' ],
+                               ],
+                       ],
+                       'processors' => [
+                               'merged' => [
+                                       'class' => 'merged',
+                               ],
+                       ],
+                       'magic' => [
+                               'idkfa' => [ 'xyzzy' ],
+                       ],
+                       'handlers' => [
+                               'merged' => [
+                                       'class' => 'merged',
+                                       'formatter' => 'merged',
+                               ],
+                       ],
+                       'formatters' => [
+                               'merged' => [
+                                       'class' => 'merged',
+                               ],
+                       ],
+               ] );
+               $this->assertSame(
+                       [
+                               'loggers' => [
+                                       '@default' => [
+                                               'processors' => [ 'constructor' ],
+                                               'handlers' => [ 'constructor' ],
+                                       ],
+                                       'merged' => [
+                                               'processors' => [ 'merged' ],
+                                               'handlers' => [ 'merged' ],
+                                       ],
+                               ],
+                               'processors' => [
+                                       'constructor' => [
+                                               'class' => 'constructor',
+                                       ],
+                                       'merged' => [
+                                               'class' => 'merged',
+                                       ],
+                               ],
+                               'handlers' => [
+                                       'constructor' => [
+                                               'class' => 'constructor',
+                                               'formatter' => 'constructor',
+                                       ],
+                                       'merged' => [
+                                               'class' => 'merged',
+                                               'formatter' => 'merged',
+                                       ],
+                               ],
+                               'formatters' => [
+                                       'constructor' => [
+                                               'class' => 'constructor',
+                                       ],
+                                       'merged' => [
+                                               'class' => 'merged',
+                                       ],
+                               ],
+                               'magic' => [
+                                       'idkfa' => [ 'xyzzy' ],
+                               ],
+                       ],
+                       TestingAccessWrapper::newFromObject( $fixture )->config
+               );
+       }
+
+}
diff --git a/tests/phpunit/unit/includes/debug/logger/monolog/AvroFormatterTest.php b/tests/phpunit/unit/includes/debug/logger/monolog/AvroFormatterTest.php
new file mode 100644 (file)
index 0000000..e091561
--- /dev/null
@@ -0,0 +1,75 @@
+<?php
+/**
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ */
+
+namespace MediaWiki\Logger\Monolog;
+
+use PHPUnit_Framework_Error_Notice;
+
+/**
+ * @covers \MediaWiki\Logger\Monolog\AvroFormatter
+ */
+class AvroFormatterTest extends \MediaWikiUnitTestCase {
+
+       protected function setUp() {
+               if ( !class_exists( 'AvroStringIO' ) ) {
+                       $this->markTestSkipped( 'Avro is required for the AvroFormatterTest' );
+               }
+               parent::setUp();
+       }
+
+       public function testSchemaNotAvailable() {
+               $formatter = new AvroFormatter( [] );
+               $this->setExpectedException(
+                       'PHPUnit_Framework_Error_Notice',
+                       "The schema for channel 'marty' is not available"
+               );
+               $formatter->format( [ 'channel' => 'marty' ] );
+       }
+
+       public function testSchemaNotAvailableReturnValue() {
+               $formatter = new AvroFormatter( [] );
+               $noticeEnabled = PHPUnit_Framework_Error_Notice::$enabled;
+               // disable conversion of notices
+               PHPUnit_Framework_Error_Notice::$enabled = false;
+               // have to keep the user notice from being output
+               \Wikimedia\suppressWarnings();
+               $res = $formatter->format( [ 'channel' => 'marty' ] );
+               \Wikimedia\restoreWarnings();
+               PHPUnit_Framework_Error_Notice::$enabled = $noticeEnabled;
+               $this->assertNull( $res );
+       }
+
+       public function testDoesSomethingWhenSchemaAvailable() {
+               $formatter = new AvroFormatter( [
+                       'string' => [
+                               'schema' => [ 'type' => 'string' ],
+                               'revision' => 1010101,
+                       ]
+               ] );
+               $res = $formatter->format( [
+                       'channel' => 'string',
+                       'context' => 'better to be',
+               ] );
+               $this->assertNotNull( $res );
+               // basically just tell us if avro changes its string encoding, or if
+               // we completely fail to generate a log message.
+               $this->assertEquals( 'AAAAAAAAD2m1GGJldHRlciB0byBiZQ==', base64_encode( $res ) );
+       }
+}
diff --git a/tests/phpunit/unit/includes/debug/logger/monolog/KafkaHandlerTest.php b/tests/phpunit/unit/includes/debug/logger/monolog/KafkaHandlerTest.php
new file mode 100644 (file)
index 0000000..bbac17f
--- /dev/null
@@ -0,0 +1,226 @@
+<?php
+/**
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ */
+
+namespace MediaWiki\Logger\Monolog;
+
+use Monolog\Logger;
+use Wikimedia\TestingAccessWrapper;
+
+/**
+ * @covers \MediaWiki\Logger\Monolog\KafkaHandler
+ */
+class KafkaHandlerTest extends \MediaWikiUnitTestCase {
+
+       protected function setUp() {
+               if ( !class_exists( 'Monolog\Handler\AbstractProcessingHandler' )
+                       || !class_exists( 'Kafka\Produce' )
+               ) {
+                       $this->markTestSkipped( 'Monolog and Kafka are required for the KafkaHandlerTest' );
+               }
+
+               parent::setUp();
+       }
+
+       public function topicNamingProvider() {
+               return [
+                       [ [], 'monolog_foo' ],
+                       [ [ 'alias' => [ 'foo' => 'bar' ] ], 'bar' ]
+               ];
+       }
+
+       /**
+        * @dataProvider topicNamingProvider
+        */
+       public function testTopicNaming( $options, $expect ) {
+               $produce = $this->getMockBuilder( 'Kafka\Produce' )
+                       ->disableOriginalConstructor()
+                       ->getMock();
+               $produce->expects( $this->any() )
+                       ->method( 'getAvailablePartitions' )
+                       ->will( $this->returnValue( [ 'A' ] ) );
+               $produce->expects( $this->once() )
+                       ->method( 'setMessages' )
+                       ->with( $expect, $this->anything(), $this->anything() );
+               $produce->expects( $this->any() )
+                       ->method( 'send' )
+                       ->will( $this->returnValue( true ) );
+
+               $handler = new KafkaHandler( $produce, $options );
+               $handler->handle( [
+                       'channel' => 'foo',
+                       'level' => Logger::EMERGENCY,
+                       'extra' => [],
+                       'context' => [],
+               ] );
+       }
+
+       public function swallowsExceptionsWhenRequested() {
+               return [
+                       // defaults to false
+                       [ [], true ],
+                       // also try false explicitly
+                       [ [ 'swallowExceptions' => false ], true ],
+                       // turn it on
+                       [ [ 'swallowExceptions' => true ], false ],
+               ];
+       }
+
+       /**
+        * @dataProvider swallowsExceptionsWhenRequested
+        */
+       public function testGetAvailablePartitionsException( $options, $expectException ) {
+               $produce = $this->getMockBuilder( 'Kafka\Produce' )
+                       ->disableOriginalConstructor()
+                       ->getMock();
+               $produce->expects( $this->any() )
+                       ->method( 'getAvailablePartitions' )
+                       ->will( $this->throwException( new \Kafka\Exception ) );
+               $produce->expects( $this->any() )
+                       ->method( 'send' )
+                       ->will( $this->returnValue( true ) );
+
+               if ( $expectException ) {
+                       $this->setExpectedException( 'Kafka\Exception' );
+               }
+
+               $handler = new KafkaHandler( $produce, $options );
+               $handler->handle( [
+                       'channel' => 'foo',
+                       'level' => Logger::EMERGENCY,
+                       'extra' => [],
+                       'context' => [],
+               ] );
+
+               if ( !$expectException ) {
+                       $this->assertTrue( true, 'no exception was thrown' );
+               }
+       }
+
+       /**
+        * @dataProvider swallowsExceptionsWhenRequested
+        */
+       public function testSendException( $options, $expectException ) {
+               $produce = $this->getMockBuilder( 'Kafka\Produce' )
+                       ->disableOriginalConstructor()
+                       ->getMock();
+               $produce->expects( $this->any() )
+                       ->method( 'getAvailablePartitions' )
+                       ->will( $this->returnValue( [ 'A' ] ) );
+               $produce->expects( $this->any() )
+                       ->method( 'send' )
+                       ->will( $this->throwException( new \Kafka\Exception ) );
+
+               if ( $expectException ) {
+                       $this->setExpectedException( 'Kafka\Exception' );
+               }
+
+               $handler = new KafkaHandler( $produce, $options );
+               $handler->handle( [
+                       'channel' => 'foo',
+                       'level' => Logger::EMERGENCY,
+                       'extra' => [],
+                       'context' => [],
+               ] );
+
+               if ( !$expectException ) {
+                       $this->assertTrue( true, 'no exception was thrown' );
+               }
+       }
+
+       public function testHandlesNullFormatterResult() {
+               $produce = $this->getMockBuilder( 'Kafka\Produce' )
+                       ->disableOriginalConstructor()
+                       ->getMock();
+               $produce->expects( $this->any() )
+                       ->method( 'getAvailablePartitions' )
+                       ->will( $this->returnValue( [ 'A' ] ) );
+               $mockMethod = $produce->expects( $this->exactly( 2 ) )
+                       ->method( 'setMessages' );
+               $produce->expects( $this->any() )
+                       ->method( 'send' )
+                       ->will( $this->returnValue( true ) );
+               // evil hax
+               $matcher = TestingAccessWrapper::newFromObject( $mockMethod )->matcher;
+               TestingAccessWrapper::newFromObject( $matcher )->parametersMatcher =
+                       new \PHPUnit_Framework_MockObject_Matcher_ConsecutiveParameters( [
+                               [ $this->anything(), $this->anything(), [ 'words' ] ],
+                               [ $this->anything(), $this->anything(), [ 'lines' ] ]
+                       ] );
+
+               $formatter = $this->createMock( \Monolog\Formatter\FormatterInterface::class );
+               $formatter->expects( $this->any() )
+                       ->method( 'format' )
+                       ->will( $this->onConsecutiveCalls( 'words', null, 'lines' ) );
+
+               $handler = new KafkaHandler( $produce, [] );
+               $handler->setFormatter( $formatter );
+               for ( $i = 0; $i < 3; ++$i ) {
+                       $handler->handle( [
+                               'channel' => 'foo',
+                               'level' => Logger::EMERGENCY,
+                               'extra' => [],
+                               'context' => [],
+                       ] );
+               }
+       }
+
+       public function testBatchHandlesNullFormatterResult() {
+               $produce = $this->getMockBuilder( 'Kafka\Produce' )
+                       ->disableOriginalConstructor()
+                       ->getMock();
+               $produce->expects( $this->any() )
+                       ->method( 'getAvailablePartitions' )
+                       ->will( $this->returnValue( [ 'A' ] ) );
+               $produce->expects( $this->once() )
+                       ->method( 'setMessages' )
+                       ->with( $this->anything(), $this->anything(), [ 'words', 'lines' ] );
+               $produce->expects( $this->any() )
+                       ->method( 'send' )
+                       ->will( $this->returnValue( true ) );
+
+               $formatter = $this->createMock( \Monolog\Formatter\FormatterInterface::class );
+               $formatter->expects( $this->any() )
+                       ->method( 'format' )
+                       ->will( $this->onConsecutiveCalls( 'words', null, 'lines' ) );
+
+               $handler = new KafkaHandler( $produce, [] );
+               $handler->setFormatter( $formatter );
+               $handler->handleBatch( [
+                       [
+                               'channel' => 'foo',
+                               'level' => Logger::EMERGENCY,
+                               'extra' => [],
+                               'context' => [],
+                       ],
+                       [
+                               'channel' => 'foo',
+                               'level' => Logger::EMERGENCY,
+                               'extra' => [],
+                               'context' => [],
+                       ],
+                       [
+                               'channel' => 'foo',
+                               'level' => Logger::EMERGENCY,
+                               'extra' => [],
+                               'context' => [],
+                       ],
+               ] );
+       }
+}
diff --git a/tests/phpunit/unit/includes/debug/logger/monolog/LineFormatterTest.php b/tests/phpunit/unit/includes/debug/logger/monolog/LineFormatterTest.php
new file mode 100644 (file)
index 0000000..8da3d93
--- /dev/null
@@ -0,0 +1,121 @@
+<?php
+/**
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ */
+
+namespace MediaWiki\Logger\Monolog;
+
+use AssertionError;
+use InvalidArgumentException;
+use LengthException;
+use LogicException;
+use Wikimedia\TestingAccessWrapper;
+
+class LineFormatterTest extends \MediaWikiUnitTestCase {
+
+       protected function setUp() {
+               if ( !class_exists( 'Monolog\Formatter\LineFormatter' ) ) {
+                       $this->markTestSkipped( 'This test requires monolog to be installed' );
+               }
+               parent::setUp();
+       }
+
+       /**
+        * @covers MediaWiki\Logger\Monolog\LineFormatter::normalizeException
+        */
+       public function testNormalizeExceptionNoTrace() {
+               $fixture = new LineFormatter();
+               $fixture->includeStacktraces( false );
+               $fixture = TestingAccessWrapper::newFromObject( $fixture );
+               $boom = new InvalidArgumentException( 'boom', 0,
+                       new LengthException( 'too long', 0,
+                               new LogicException( 'Spock wuz here' )
+                       )
+               );
+               $out = $fixture->normalizeException( $boom );
+               $this->assertContains( "\n[Exception InvalidArgumentException]", $out );
+               $this->assertContains( "\nCaused by: [Exception LengthException]", $out );
+               $this->assertContains( "\nCaused by: [Exception LogicException]", $out );
+               $this->assertNotContains( "\n  #0", $out );
+       }
+
+       /**
+        * @covers MediaWiki\Logger\Monolog\LineFormatter::normalizeException
+        */
+       public function testNormalizeExceptionTrace() {
+               $fixture = new LineFormatter();
+               $fixture->includeStacktraces( true );
+               $fixture = TestingAccessWrapper::newFromObject( $fixture );
+               $boom = new InvalidArgumentException( 'boom', 0,
+                       new LengthException( 'too long', 0,
+                               new LogicException( 'Spock wuz here' )
+                       )
+               );
+               $out = $fixture->normalizeException( $boom );
+               $this->assertContains( "\n[Exception InvalidArgumentException]", $out );
+               $this->assertContains( "\nCaused by: [Exception LengthException]", $out );
+               $this->assertContains( "\nCaused by: [Exception LogicException]", $out );
+               $this->assertContains( "\n  #0", $out );
+       }
+
+       /**
+        * @covers MediaWiki\Logger\Monolog\LineFormatter::normalizeException
+        */
+       public function testNormalizeExceptionErrorNoTrace() {
+               if ( !class_exists( AssertionError::class ) ) {
+                       $this->markTestSkipped( 'AssertionError class does not exist' );
+               }
+
+               $fixture = new LineFormatter();
+               $fixture->includeStacktraces( false );
+               $fixture = TestingAccessWrapper::newFromObject( $fixture );
+               $boom = new InvalidArgumentException( 'boom', 0,
+                       new LengthException( 'too long', 0,
+                               new AssertionError( 'Spock wuz here' )
+                       )
+               );
+               $out = $fixture->normalizeException( $boom );
+               $this->assertContains( "\n[Exception InvalidArgumentException]", $out );
+               $this->assertContains( "\nCaused by: [Exception LengthException]", $out );
+               $this->assertContains( "\nCaused by: [Error AssertionError]", $out );
+               $this->assertNotContains( "\n  #0", $out );
+       }
+
+       /**
+        * @covers MediaWiki\Logger\Monolog\LineFormatter::normalizeException
+        */
+       public function testNormalizeExceptionErrorTrace() {
+               if ( !class_exists( AssertionError::class ) ) {
+                       $this->markTestSkipped( 'AssertionError class does not exist' );
+               }
+
+               $fixture = new LineFormatter();
+               $fixture->includeStacktraces( true );
+               $fixture = TestingAccessWrapper::newFromObject( $fixture );
+               $boom = new InvalidArgumentException( 'boom', 0,
+                       new LengthException( 'too long', 0,
+                               new AssertionError( 'Spock wuz here' )
+                       )
+               );
+               $out = $fixture->normalizeException( $boom );
+               $this->assertContains( "\n[Exception InvalidArgumentException]", $out );
+               $this->assertContains( "\nCaused by: [Exception LengthException]", $out );
+               $this->assertContains( "\nCaused by: [Error AssertionError]", $out );
+               $this->assertContains( "\n  #0", $out );
+       }
+}
diff --git a/tests/phpunit/unit/includes/diff/ArrayDiffFormatterTest.php b/tests/phpunit/unit/includes/diff/ArrayDiffFormatterTest.php
new file mode 100644 (file)
index 0000000..d436991
--- /dev/null
@@ -0,0 +1,134 @@
+<?php
+
+/**
+ * @author Addshore
+ *
+ * @group Diff
+ */
+class ArrayDiffFormatterTest extends \MediaWikiUnitTestCase {
+
+       /**
+        * @param Diff $input
+        * @param array $expectedOutput
+        * @dataProvider provideTestFormat
+        * @covers ArrayDiffFormatter::format
+        */
+       public function testFormat( $input, $expectedOutput ) {
+               $instance = new ArrayDiffFormatter();
+               $output = $instance->format( $input );
+               $this->assertEquals( $expectedOutput, $output );
+       }
+
+       private function getMockDiff( $edits ) {
+               $diff = $this->getMockBuilder( Diff::class )
+                       ->disableOriginalConstructor()
+                       ->getMock();
+               $diff->expects( $this->any() )
+                       ->method( 'getEdits' )
+                       ->will( $this->returnValue( $edits ) );
+               return $diff;
+       }
+
+       private function getMockDiffOp( $type = null, $orig = [], $closing = [] ) {
+               $diffOp = $this->getMockBuilder( DiffOp::class )
+                       ->disableOriginalConstructor()
+                       ->getMock();
+               $diffOp->expects( $this->any() )
+                       ->method( 'getType' )
+                       ->will( $this->returnValue( $type ) );
+               $diffOp->expects( $this->any() )
+                       ->method( 'getOrig' )
+                       ->will( $this->returnValue( $orig ) );
+               if ( $type === 'change' ) {
+                       $diffOp->expects( $this->any() )
+                               ->method( 'getClosing' )
+                               ->with( $this->isType( 'integer' ) )
+                               ->will( $this->returnCallback( function () {
+                                       return 'mockLine';
+                               } ) );
+               } else {
+                       $diffOp->expects( $this->any() )
+                               ->method( 'getClosing' )
+                               ->will( $this->returnValue( $closing ) );
+               }
+               return $diffOp;
+       }
+
+       public function provideTestFormat() {
+               $emptyArrayTestCases = [
+                       $this->getMockDiff( [] ),
+                       $this->getMockDiff( [ $this->getMockDiffOp( 'add' ) ] ),
+                       $this->getMockDiff( [ $this->getMockDiffOp( 'delete' ) ] ),
+                       $this->getMockDiff( [ $this->getMockDiffOp( 'change' ) ] ),
+                       $this->getMockDiff( [ $this->getMockDiffOp( 'copy' ) ] ),
+                       $this->getMockDiff( [ $this->getMockDiffOp( 'FOOBARBAZ' ) ] ),
+                       $this->getMockDiff( [ $this->getMockDiffOp( 'add', 'line' ) ] ),
+                       $this->getMockDiff( [ $this->getMockDiffOp( 'delete', [], [ 'line' ] ) ] ),
+                       $this->getMockDiff( [ $this->getMockDiffOp( 'copy', [], [ 'line' ] ) ] ),
+               ];
+
+               $otherTestCases = [];
+               $otherTestCases[] = [
+                       $this->getMockDiff( [ $this->getMockDiffOp( 'add', [], [ 'a1' ] ) ] ),
+                       [ [ 'action' => 'add', 'new' => 'a1', 'newline' => 1 ] ],
+               ];
+               $otherTestCases[] = [
+                       $this->getMockDiff( [ $this->getMockDiffOp( 'add', [], [ 'a1', 'a2' ] ) ] ),
+                       [
+                               [ 'action' => 'add', 'new' => 'a1', 'newline' => 1 ],
+                               [ 'action' => 'add', 'new' => 'a2', 'newline' => 2 ],
+                       ],
+               ];
+               $otherTestCases[] = [
+                       $this->getMockDiff( [ $this->getMockDiffOp( 'delete', [ 'd1' ] ) ] ),
+                       [ [ 'action' => 'delete', 'old' => 'd1', 'oldline' => 1 ] ],
+               ];
+               $otherTestCases[] = [
+                       $this->getMockDiff( [ $this->getMockDiffOp( 'delete', [ 'd1', 'd2' ] ) ] ),
+                       [
+                               [ 'action' => 'delete', 'old' => 'd1', 'oldline' => 1 ],
+                               [ 'action' => 'delete', 'old' => 'd2', 'oldline' => 2 ],
+                       ],
+               ];
+               $otherTestCases[] = [
+                       $this->getMockDiff( [ $this->getMockDiffOp( 'change', [ 'd1' ], [ 'a1' ] ) ] ),
+                       [ [
+                               'action' => 'change',
+                               'old' => 'd1',
+                               'new' => 'mockLine',
+                               'newline' => 1, 'oldline' => 1
+                       ] ],
+               ];
+               $otherTestCases[] = [
+                       $this->getMockDiff( [ $this->getMockDiffOp(
+                               'change',
+                               [ 'd1', 'd2' ],
+                               [ 'a1', 'a2' ]
+                       ) ] ),
+                       [
+                               [
+                                       'action' => 'change',
+                                       'old' => 'd1',
+                                       'new' => 'mockLine',
+                                       'newline' => 1, 'oldline' => 1
+                               ],
+                               [
+                                       'action' => 'change',
+                                       'old' => 'd2',
+                                       'new' => 'mockLine',
+                                       'newline' => 2, 'oldline' => 2
+                               ],
+                       ],
+               ];
+
+               $testCases = [];
+               foreach ( $emptyArrayTestCases as $testCase ) {
+                       $testCases[] = [ $testCase, [] ];
+               }
+               foreach ( $otherTestCases as $testCase ) {
+                       $testCases[] = [ $testCase[0], $testCase[1] ];
+               }
+               return $testCases;
+       }
+
+}
diff --git a/tests/phpunit/unit/includes/diff/DiffOpTest.php b/tests/phpunit/unit/includes/diff/DiffOpTest.php
new file mode 100644 (file)
index 0000000..4e1aced
--- /dev/null
@@ -0,0 +1,68 @@
+<?php
+/**
+ * @author Addshore
+ *
+ * @group Diff
+ */
+class DiffOpTest extends \MediaWikiUnitTestCase {
+
+       /**
+        * @covers DiffOp::getType
+        */
+       public function testGetType() {
+               $obj = new FakeDiffOp();
+               $obj->type = 'foo';
+               $this->assertEquals( 'foo', $obj->getType() );
+       }
+
+       /**
+        * @covers DiffOp::getOrig
+        */
+       public function testGetOrig() {
+               $obj = new FakeDiffOp();
+               $obj->orig = [ 'foo' ];
+               $this->assertEquals( [ 'foo' ], $obj->getOrig() );
+       }
+
+       /**
+        * @covers DiffOp::getClosing
+        */
+       public function testGetClosing() {
+               $obj = new FakeDiffOp();
+               $obj->closing = [ 'foo' ];
+               $this->assertEquals( [ 'foo' ], $obj->getClosing() );
+       }
+
+       /**
+        * @covers DiffOp::getClosing
+        */
+       public function testGetClosingWithParameter() {
+               $obj = new FakeDiffOp();
+               $obj->closing = [ 'foo', 'bar', 'baz' ];
+               $this->assertEquals( 'foo', $obj->getClosing( 0 ) );
+               $this->assertEquals( 'bar', $obj->getClosing( 1 ) );
+               $this->assertEquals( 'baz', $obj->getClosing( 2 ) );
+               $this->assertEquals( null, $obj->getClosing( 3 ) );
+       }
+
+       /**
+        * @covers DiffOp::norig
+        */
+       public function testNorig() {
+               $obj = new FakeDiffOp();
+               $this->assertEquals( 0, $obj->norig() );
+               $obj->orig = [ 'foo' ];
+               $this->assertEquals( 1, $obj->norig() );
+       }
+
+       /**
+        * @covers DiffOp::nclosing
+        */
+       public function testNclosing() {
+               $obj = new FakeDiffOp();
+               $this->assertEquals( 0, $obj->nclosing() );
+               $obj->closing = [ 'foo' ];
+               $this->assertEquals( 1, $obj->nclosing() );
+       }
+
+}
diff --git a/tests/phpunit/unit/includes/diff/DiffTest.php b/tests/phpunit/unit/includes/diff/DiffTest.php
new file mode 100644 (file)
index 0000000..f0a8490
--- /dev/null
@@ -0,0 +1,19 @@
+<?php
+
+/**
+ * @author Addshore
+ *
+ * @group Diff
+ */
+class DiffTest extends \MediaWikiUnitTestCase {
+
+       /**
+        * @covers Diff::getEdits
+        */
+       public function testGetEdits() {
+               $obj = new Diff( [], [] );
+               $obj->edits = 'FooBarBaz';
+               $this->assertEquals( 'FooBarBaz', $obj->getEdits() );
+       }
+
+}
diff --git a/tests/phpunit/unit/includes/exception/MWExceptionHandlerTest.php b/tests/phpunit/unit/includes/exception/MWExceptionHandlerTest.php
new file mode 100644 (file)
index 0000000..2b021c4
--- /dev/null
@@ -0,0 +1,74 @@
+<?php
+/**
+ * @author Antoine Musso
+ * @copyright Copyright © 2013, Antoine Musso
+ * @copyright Copyright © 2013, Wikimedia Foundation Inc.
+ * @file
+ */
+
+class MWExceptionHandlerTest extends \MediaWikiUnitTestCase {
+
+       /**
+        * @covers MWExceptionHandler::getRedactedTrace
+        */
+       public function testGetRedactedTrace() {
+               $refvar = 'value';
+               try {
+                       $array = [ 'a', 'b' ];
+                       $object = new stdClass();
+                       self::helperThrowAnException( $array, $object, $refvar );
+               } catch ( Exception $e ) {
+               }
+
+               # Make sure our stack trace contains an array and an object passed to
+               # some function in the stacktrace. Else, we can not assert the trace
+               # redaction achieved its job.
+               $trace = $e->getTrace();
+               $hasObject = false;
+               $hasArray = false;
+               foreach ( $trace as $frame ) {
+                       if ( !isset( $frame['args'] ) ) {
+                               continue;
+                       }
+                       foreach ( $frame['args'] as $arg ) {
+                               $hasObject = $hasObject || is_object( $arg );
+                               $hasArray = $hasArray || is_array( $arg );
+                       }
+
+                       if ( $hasObject && $hasArray ) {
+                               break;
+                       }
+               }
+               $this->assertTrue( $hasObject,
+                       "The stacktrace must have a function having an object has parameter" );
+               $this->assertTrue( $hasArray,
+                       "The stacktrace must have a function having an array has parameter" );
+
+               # Now we redact the trace.. and make sure no function arguments are
+               # arrays or objects.
+               $redacted = MWExceptionHandler::getRedactedTrace( $e );
+
+               foreach ( $redacted as $frame ) {
+                       if ( !isset( $frame['args'] ) ) {
+                               continue;
+                       }
+                       foreach ( $frame['args'] as $arg ) {
+                               $this->assertNotInternalType( 'array', $arg );
+                               $this->assertNotInternalType( 'object', $arg );
+                       }
+               }
+
+               $this->assertEquals( 'value', $refvar, 'Ensuring reference variable wasn\'t changed' );
+       }
+
+       /**
+        * Helper function for testExpandArgumentsInCall
+        *
+        * Pass it an object and an array, and something by reference :-)
+        *
+        * @throws Exception
+        */
+       protected static function helperThrowAnException( $a, $b, &$c ) {
+               throw new Exception();
+       }
+}
diff --git a/tests/phpunit/unit/includes/installer/InstallDocFormatterTest.php b/tests/phpunit/unit/includes/installer/InstallDocFormatterTest.php
new file mode 100644 (file)
index 0000000..fddc3b8
--- /dev/null
@@ -0,0 +1,83 @@
+<?php
+
+class InstallDocFormatterTest extends \MediaWikiUnitTestCase {
+       /**
+        * @covers InstallDocFormatter
+        * @dataProvider provideDocFormattingTests
+        */
+       public function testFormat( $expected, $unformattedText, $message = '' ) {
+               $this->assertEquals(
+                       $expected,
+                       InstallDocFormatter::format( $unformattedText ),
+                       $message
+               );
+       }
+
+       /**
+        * Provider for testFormat()
+        */
+       public static function provideDocFormattingTests() {
+               # Format: (expected string, unformattedText string, optional message)
+               return [
+                       # Escape some wikitext
+                       [ 'Install &lt;tag>', 'Install <tag>', 'Escaping <' ],
+                       [ 'Install &#123;&#123;template}}', 'Install {{template}}', 'Escaping [[' ],
+                       [ 'Install &#91;&#91;page]]', 'Install [[page]]', 'Escaping {{' ],
+                       [ 'Install &#95;&#95;TOC&#95;&#95;', 'Install __TOC__', 'Escaping __' ],
+                       [ 'Install ', "Install \r", 'Removing \r' ],
+
+                       # Transform \t{1,2} into :{1,2}
+                       [ ':One indentation', "\tOne indentation", 'Replacing a single \t' ],
+                       [ '::Two indentations', "\t\tTwo indentations", 'Replacing 2 x \t' ],
+
+                       # Transform 'T123' links
+                       [
+                               '<span class="config-plainlink">[https://phabricator.wikimedia.org/T123 T123]</span>',
+                               'T123', 'Testing T123 links' ],
+                       [
+                               'bug <span class="config-plainlink">[https://phabricator.wikimedia.org/T123 T123]</span>',
+                               'bug T123', 'Testing bug T123 links' ],
+                       [
+                               '(<span class="config-plainlink">[https://phabricator.wikimedia.org/T987654 T987654]</span>)',
+                               '(T987654)', 'Testing (T987654) links' ],
+
+                       # "Tabc" shouldn't work
+                       [ 'Tfoobar', 'Tfoobar', "Don't match T followed by non-digits" ],
+                       [ 'T!!fakefake!!', 'T!!fakefake!!', "Don't match T followed by non-digits" ],
+
+                       # Transform 'bug 123' links
+                       [
+                               '<span class="config-plainlink">[https://bugzilla.wikimedia.org/123 bug 123]</span>',
+                               'bug 123', 'Testing bug 123 links' ],
+                       [
+                               '(<span class="config-plainlink">[https://bugzilla.wikimedia.org/987654 bug 987654]</span>)',
+                               '(bug 987654)', 'Testing (bug 987654) links' ],
+
+                       # "bug abc" shouldn't work
+                       [ 'bug foobar', 'bug foobar', "Don't match bug followed by non-digits" ],
+                       [ 'bug !!fakefake!!', 'bug !!fakefake!!', "Don't match bug followed by non-digits" ],
+
+                       # Transform '$wgFooBar' links
+                       [
+                               '<span class="config-plainlink">'
+                                       . '[https://www.mediawiki.org/wiki/Manual:$wgFooBar $wgFooBar]</span>',
+                               '$wgFooBar', 'Testing basic $wgFooBar' ],
+                       [
+                               '<span class="config-plainlink">'
+                                       . '[https://www.mediawiki.org/wiki/Manual:$wgFooBar45 $wgFooBar45]</span>',
+                               '$wgFooBar45', 'Testing $wgFooBar45 (with numbers)' ],
+                       [
+                               '<span class="config-plainlink">'
+                                       . '[https://www.mediawiki.org/wiki/Manual:$wgFoo_Bar $wgFoo_Bar]</span>',
+                               '$wgFoo_Bar', 'Testing $wgFoo_Bar (with underscore)' ],
+
+                       # Icky variables that shouldn't link
+                       [
+                               '$myAwesomeVariable',
+                               '$myAwesomeVariable',
+                               'Testing $myAwesomeVariable (not starting with $wg)'
+                       ],
+                       [ '$()not!a&Var', '$()not!a&Var', 'Testing $()not!a&Var (obviously not a variable)' ],
+               ];
+       }
+}
diff --git a/tests/phpunit/unit/includes/installer/OracleInstallerTest.php b/tests/phpunit/unit/includes/installer/OracleInstallerTest.php
new file mode 100644 (file)
index 0000000..69b5552
--- /dev/null
@@ -0,0 +1,48 @@
+<?php
+
+/**
+ * @group Installer
+ */
+class OracleInstallerTest extends \MediaWikiUnitTestCase {
+
+       /**
+        * @dataProvider provideOracleConnectStrings
+        * @covers OracleInstaller::checkConnectStringFormat
+        */
+       public function testCheckConnectStringFormat( $expected, $connectString, $msg = '' ) {
+               $validity = $expected ? 'should be valid' : 'should NOT be valid';
+               $msg = "'$connectString' ($msg) $validity.";
+               $this->assertEquals( $expected,
+                       OracleInstaller::checkConnectStringFormat( $connectString ),
+                       $msg
+               );
+       }
+
+       /**
+        * Provider to test OracleInstaller::checkConnectStringFormat()
+        */
+       function provideOracleConnectStrings() {
+               // expected result, connectString[, message]
+               return [
+                       [ true, 'simple_01', 'Simple TNS name' ],
+                       [ true, 'simple_01.world', 'TNS name with domain' ],
+                       [ true, 'simple_01.domain.net', 'TNS name with domain' ],
+                       [ true, 'host123', 'Host only' ],
+                       [ true, 'host123.domain.net', 'FQDN only' ],
+                       [ true, '//host123.domain.net', 'FQDN URL only' ],
+                       [ true, '123.223.213.132', 'Host IP only' ],
+                       [ true, 'host:1521', 'Host and port' ],
+                       [ true, 'host:1521/service', 'Host, port and service' ],
+                       [ true, 'host:1521/service:shared', 'Host, port, service and shared server type' ],
+                       [ true, 'host:1521/service:dedicated', 'Host, port, service and dedicated server type' ],
+                       [ true, 'host:1521/service:pooled', 'Host, port, service and pooled server type' ],
+                       [
+                               true,
+                               'host:1521/service:shared/instance1',
+                               'Host, port, service, server type and instance'
+                       ],
+                       [ true, 'host:1521//instance1', 'Host, port and instance' ],
+               ];
+       }
+
+}
diff --git a/tests/phpunit/unit/includes/interwiki/InterwikiLookupAdapterTest.php b/tests/phpunit/unit/includes/interwiki/InterwikiLookupAdapterTest.php
new file mode 100644 (file)
index 0000000..abbd2d7
--- /dev/null
@@ -0,0 +1,133 @@
+<?php
+
+use MediaWiki\Interwiki\InterwikiLookupAdapter;
+
+/**
+ * @covers MediaWiki\Interwiki\InterwikiLookupAdapter
+ *
+ * @group MediaWiki
+ * @group Interwiki
+ */
+class InterwikiLookupAdapterTest extends \MediaWikiUnitTestCase {
+
+       /**
+        * @var InterwikiLookupAdapter
+        */
+       private $interwikiLookup;
+
+       protected function setUp() {
+               parent::setUp();
+
+               $this->interwikiLookup = new InterwikiLookupAdapter(
+                       $this->getSiteLookup( $this->getSites() )
+               );
+       }
+
+       public function testIsValidInterwiki() {
+               $this->assertTrue(
+                       $this->interwikiLookup->isValidInterwiki( 'enwt' ),
+                       'enwt known prefix is valid'
+               );
+               $this->assertTrue(
+                       $this->interwikiLookup->isValidInterwiki( 'foo' ),
+                       'foo site known prefix is valid'
+               );
+               $this->assertFalse(
+                       $this->interwikiLookup->isValidInterwiki( 'xyz' ),
+                       'unknown prefix is not valid'
+               );
+       }
+
+       public function testFetch() {
+               $interwiki = $this->interwikiLookup->fetch( '' );
+               $this->assertNull( $interwiki );
+
+               $interwiki = $this->interwikiLookup->fetch( 'xyz' );
+               $this->assertFalse( $interwiki );
+
+               $interwiki = $this->interwikiLookup->fetch( 'foo' );
+               $this->assertInstanceOf( Interwiki::class, $interwiki );
+               $this->assertSame( 'foobar', $interwiki->getWikiID() );
+
+               $interwiki = $this->interwikiLookup->fetch( 'enwt' );
+               $this->assertInstanceOf( Interwiki::class, $interwiki );
+
+               $this->assertSame( 'https://en.wiktionary.org/wiki/$1', $interwiki->getURL(), 'getURL' );
+               $this->assertSame( 'https://en.wiktionary.org/w/api.php', $interwiki->getAPI(), 'getAPI' );
+               $this->assertSame( 'enwiktionary', $interwiki->getWikiID(), 'getWikiID' );
+               $this->assertTrue( $interwiki->isLocal(), 'isLocal' );
+       }
+
+       public function testGetAllPrefixes() {
+               $foo = [
+                       'iw_prefix' => 'foo',
+                       'iw_url' => '',
+                       'iw_api' => '',
+                       'iw_wikiid' => 'foobar',
+                       'iw_local' => false,
+                       'iw_trans' => false,
+               ];
+               $enwt = [
+                       'iw_prefix' => 'enwt',
+                       'iw_url' => 'https://en.wiktionary.org/wiki/$1',
+                       'iw_api' => 'https://en.wiktionary.org/w/api.php',
+                       'iw_wikiid' => 'enwiktionary',
+                       'iw_local' => true,
+                       'iw_trans' => false,
+               ];
+
+               $this->assertEquals(
+                       [ $foo, $enwt ],
+                       $this->interwikiLookup->getAllPrefixes(),
+                       'getAllPrefixes()'
+               );
+
+               $this->assertEquals(
+                       [ $foo ],
+                       $this->interwikiLookup->getAllPrefixes( false ),
+                       'get external prefixes'
+               );
+
+               $this->assertEquals(
+                       [ $enwt ],
+                       $this->interwikiLookup->getAllPrefixes( true ),
+                       'get local prefixes'
+               );
+       }
+
+       private function getSiteLookup( SiteList $sites ) {
+               $siteLookup = $this->getMockBuilder( SiteLookup::class )
+                       ->disableOriginalConstructor()
+                       ->getMock();
+
+               $siteLookup->expects( $this->any() )
+                       ->method( 'getSites' )
+                       ->will( $this->returnValue( $sites ) );
+
+               return $siteLookup;
+       }
+
+       private function getSites() {
+               $sites = [];
+
+               $site = new Site();
+               $site->setGlobalId( 'foobar' );
+               $site->addInterwikiId( 'foo' );
+               $site->setSource( 'external' );
+               $sites[] = $site;
+
+               $site = new MediaWikiSite();
+               $site->setGlobalId( 'enwiktionary' );
+               $site->setGroup( 'wiktionary' );
+               $site->setLanguageCode( 'en' );
+               $site->addNavigationId( 'enwiktionary' );
+               $site->addInterwikiId( 'enwt' );
+               $site->setSource( 'local' );
+               $site->setPath( MediaWikiSite::PATH_PAGE, "https://en.wiktionary.org/wiki/$1" );
+               $site->setPath( MediaWikiSite::PATH_FILE, "https://en.wiktionary.org/w/$1" );
+               $sites[] = $site;
+
+               return new SiteList( $sites );
+       }
+
+}
diff --git a/tests/phpunit/unit/includes/libs/objectcache/ReplicatedBagOStuffTest.php b/tests/phpunit/unit/includes/libs/objectcache/ReplicatedBagOStuffTest.php
new file mode 100644 (file)
index 0000000..64d282f
--- /dev/null
@@ -0,0 +1,62 @@
+<?php
+
+class ReplicatedBagOStuffTest extends \MediaWikiUnitTestCase {
+       /** @var HashBagOStuff */
+       private $writeCache;
+       /** @var HashBagOStuff */
+       private $readCache;
+       /** @var ReplicatedBagOStuff */
+       private $cache;
+
+       protected function setUp() {
+               parent::setUp();
+
+               $this->writeCache = new HashBagOStuff();
+               $this->readCache = new HashBagOStuff();
+               $this->cache = new ReplicatedBagOStuff( [
+                       'writeFactory' => $this->writeCache,
+                       'readFactory' => $this->readCache,
+               ] );
+       }
+
+       /**
+        * @covers ReplicatedBagOStuff::set
+        */
+       public function testSet() {
+               $key = 'a key';
+               $value = 'a value';
+               $this->cache->set( $key, $value );
+
+               // Write to master.
+               $this->assertEquals( $value, $this->writeCache->get( $key ) );
+               // Don't write to replica. Replication is deferred to backend.
+               $this->assertFalse( $this->readCache->get( $key ) );
+       }
+
+       /**
+        * @covers ReplicatedBagOStuff::get
+        */
+       public function testGet() {
+               $key = 'a key';
+
+               $write = 'one value';
+               $this->writeCache->set( $key, $write );
+               $read = 'another value';
+               $this->readCache->set( $key, $read );
+
+               // Read from replica.
+               $this->assertEquals( $read, $this->cache->get( $key ) );
+       }
+
+       /**
+        * @covers ReplicatedBagOStuff::get
+        */
+       public function testGetAbsent() {
+               $key = 'a key';
+               $value = 'a value';
+               $this->writeCache->set( $key, $value );
+
+               // Don't read from master. No failover if value is absent.
+               $this->assertFalse( $this->cache->get( $key ) );
+       }
+}
diff --git a/tests/phpunit/unit/includes/media/GIFMetadataExtractorTest.php b/tests/phpunit/unit/includes/media/GIFMetadataExtractorTest.php
new file mode 100644 (file)
index 0000000..10c450d
--- /dev/null
@@ -0,0 +1,110 @@
+<?php
+
+/**
+ * @group Media
+ */
+class GIFMetadataExtractorTest extends \MediaWikiUnitTestCase {
+
+       protected function setUp() {
+               parent::setUp();
+
+               $this->mediaPath = __DIR__ . '/../../../data/media/';
+       }
+
+       /**
+        * Put in a file, and see if the metadata coming out is as expected.
+        * @param string $filename
+        * @param array $expected The extracted metadata.
+        * @dataProvider provideGetMetadata
+        * @covers GIFMetadataExtractor::getMetadata
+        */
+       public function testGetMetadata( $filename, $expected ) {
+               $actual = GIFMetadataExtractor::getMetadata( $this->mediaPath . $filename );
+               $this->assertEquals( $expected, $actual );
+       }
+
+       public static function provideGetMetadata() {
+               $xmpNugget = <<<EOF
+<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
+<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 7.30'>
+<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
+
+ <rdf:Description rdf:about=''
+  xmlns:Iptc4xmpCore='http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/'>
+  <Iptc4xmpCore:Location>The interwebs</Iptc4xmpCore:Location>
+ </rdf:Description>
+
+ <rdf:Description rdf:about=''
+  xmlns:tiff='http://ns.adobe.com/tiff/1.0/'>
+  <tiff:Artist>Bawolff</tiff:Artist>
+  <tiff:ImageDescription>
+   <rdf:Alt>
+    <rdf:li xml:lang='x-default'>A file to test GIF</rdf:li>
+   </rdf:Alt>
+  </tiff:ImageDescription>
+ </rdf:Description>
+</rdf:RDF>
+</x:xmpmeta>
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+<?xpacket end='w'?>
+EOF;
+               $xmpNugget = str_replace( "\r", '', $xmpNugget ); // Windows compat
+
+               return [
+                       [
+                               'nonanimated.gif',
+                               [
+                                       'comment' => [ 'GIF test file ⁕ Created with GIMP' ],
+                                       'duration' => 0.1,
+                                       'frameCount' => 1,
+                                       'looped' => false,
+                                       'xmp' => '',
+                               ]
+                       ],
+                       [
+                               'animated.gif',
+                               [
+                                       'comment' => [ 'GIF test file . Created with GIMP' ],
+                                       'duration' => 2.4,
+                                       'frameCount' => 4,
+                                       'looped' => true,
+                                       'xmp' => '',
+                               ]
+                       ],
+
+                       [
+                               'animated-xmp.gif',
+                               [
+                                       'xmp' => $xmpNugget,
+                                       'duration' => 2.4,
+                                       'frameCount' => 4,
+                                       'looped' => true,
+                                       'comment' => [ 'GIƒ·test·file' ],
+                               ]
+                       ],
+               ];
+       }
+}
diff --git a/tests/phpunit/unit/includes/media/IPTCTest.php b/tests/phpunit/unit/includes/media/IPTCTest.php
new file mode 100644 (file)
index 0000000..430493c
--- /dev/null
@@ -0,0 +1,85 @@
+<?php
+
+/**
+ * @group Media
+ */
+class IPTCTest extends \MediaWikiUnitTestCase {
+
+       /**
+        * @covers IPTC::getCharset
+        */
+       public function testRecognizeUtf8() {
+               // utf-8 is the only one used in practise.
+               $res = IPTC::getCharset( "\x1b%G" );
+               $this->assertEquals( 'UTF-8', $res );
+       }
+
+       /**
+        * @covers IPTC::parse
+        */
+       public function testIPTCParseNoCharset88591() {
+               // basically IPTC for keyword with value of 0xBC which is 1/4 in iso-8859-1
+               // This data doesn't specify a charset. We're supposed to guess
+               // (which basically means utf-8 if valid, windows 1252 (iso 8859-1) if not)
+               $iptcData = "Photoshop 3.0\08BIM\4\4\0\0\0\0\0\x06\x1c\x02\x19\x00\x01\xBC";
+               $res = IPTC::parse( $iptcData );
+               $this->assertEquals( [ '¼' ], $res['Keywords'] );
+       }
+
+       /**
+        * @covers IPTC::parse
+        */
+       public function testIPTCParseNoCharset88591b() {
+               /* This one contains a sequence that's valid iso 8859-1 but not valid utf8 */
+               /* \xC3 = Ã, \xB8 = ¸  */
+               $iptcData = "Photoshop 3.0\08BIM\4\4\0\0\0\0\0\x09\x1c\x02\x19\x00\x04\xC3\xC3\xC3\xB8";
+               $res = IPTC::parse( $iptcData );
+               $this->assertEquals( [ 'ÃÃø' ], $res['Keywords'] );
+       }
+
+       /**
+        * Same as testIPTCParseNoCharset88591b, but forcing the charset to utf-8.
+        * What should happen is the first "\xC3\xC3" should be dropped as invalid,
+        * leaving \xC3\xB8, which is ø
+        * @covers IPTC::parse
+        */
+       public function testIPTCParseForcedUTFButInvalid() {
+               $iptcData = "Photoshop 3.0\08BIM\4\4\0\0\0\0\0\x11\x1c\x02\x19\x00\x04\xC3\xC3\xC3\xB8"
+                       . "\x1c\x01\x5A\x00\x03\x1B\x25\x47";
+               $res = IPTC::parse( $iptcData );
+               $this->assertEquals( [ 'ø' ], $res['Keywords'] );
+       }
+
+       /**
+        * @covers IPTC::parse
+        */
+       public function testIPTCParseNoCharsetUTF8() {
+               $iptcData = "Photoshop 3.0\08BIM\4\4\0\0\0\0\0\x07\x1c\x02\x19\x00\x02¼";
+               $res = IPTC::parse( $iptcData );
+               $this->assertEquals( [ '¼' ], $res['Keywords'] );
+       }
+
+       /**
+        * Testing something that has 2 values for keyword
+        * @covers IPTC::parse
+        */
+       public function testIPTCParseMulti() {
+               $iptcData = /* identifier */ "Photoshop 3.0\08BIM\4\4"
+                       /* length */ . "\0\0\0\0\0\x0D"
+                       . "\x1c\x02\x19" . "\x00\x01" . "\xBC"
+                       . "\x1c\x02\x19" . "\x00\x02" . "\xBC\xBD";
+               $res = IPTC::parse( $iptcData );
+               $this->assertEquals( [ '¼', '¼½' ], $res['Keywords'] );
+       }
+
+       /**
+        * @covers IPTC::parse
+        */
+       public function testIPTCParseUTF8() {
+               // This has the magic "\x1c\x01\x5A\x00\x03\x1B\x25\x47" which marks content as UTF8.
+               $iptcData =
+                       "Photoshop 3.0\08BIM\4\4\0\0\0\0\0\x0F\x1c\x02\x19\x00\x02¼\x1c\x01\x5A\x00\x03\x1B\x25\x47";
+               $res = IPTC::parse( $iptcData );
+               $this->assertEquals( [ '¼' ], $res['Keywords'] );
+       }
+}
diff --git a/tests/phpunit/unit/includes/media/MediaHandlerTest.php b/tests/phpunit/unit/includes/media/MediaHandlerTest.php
new file mode 100644 (file)
index 0000000..eb4ece8
--- /dev/null
@@ -0,0 +1,68 @@
+<?php
+
+/**
+ * @group Media
+ */
+class MediaHandlerTest extends \MediaWikiUnitTestCase {
+
+       /**
+        * @covers MediaHandler::fitBoxWidth
+        *
+        * @dataProvider provideTestFitBoxWidth
+        */
+       public function testFitBoxWidth( $width, $height, $max, $expected ) {
+               $y = round( $expected * $height / $width );
+               $result = MediaHandler::fitBoxWidth( $width, $height, $max );
+               $y2 = round( $result * $height / $width );
+               $this->assertEquals( $expected,
+                       $result,
+                       "($width, $height, $max) wanted: {$expected}x$y, got: {z$result}x$y2" );
+       }
+
+       public static function provideTestFitBoxWidth() {
+               return array_merge(
+                       static::generateTestFitBoxWidthData( 50, 50, [
+                                       50 => 50,
+                                       17 => 17,
+                                       18 => 18 ]
+                       ),
+                       static::generateTestFitBoxWidthData( 366, 300, [
+                                       50 => 61,
+                                       17 => 21,
+                                       18 => 22 ]
+                       ),
+                       static::generateTestFitBoxWidthData( 300, 366, [
+                                       50 => 41,
+                                       17 => 14,
+                                       18 => 15 ]
+                       ),
+                       static::generateTestFitBoxWidthData( 100, 400, [
+                                       50 => 12,
+                                       17 => 4,
+                                       18 => 4 ]
+                       )
+               );
+       }
+
+       /**
+        * Generate single test cases by combining the dimensions and tests contents
+        *
+        * It creates:
+        * [$width, $height, $max, $expected],
+        * [$width, $height, $max2, $expected2], ...
+        * out of parameters:
+        * $width, $height, { $max => $expected, $max2 => $expected2, ... }
+        *
+        * @param int $width
+        * @param int $height
+        * @param array $tests associative array of $max => $expected values
+        * @return array
+        */
+       private static function generateTestFitBoxWidthData( $width, $height, $tests ) {
+               $result = [];
+               foreach ( $tests as $max => $expected ) {
+                       $result[] = [ $width, $height, $max, $expected ];
+               }
+               return $result;
+       }
+}
diff --git a/tests/phpunit/unit/includes/media/SVGMetadataExtractorTest.php b/tests/phpunit/unit/includes/media/SVGMetadataExtractorTest.php
new file mode 100644 (file)
index 0000000..30d1008
--- /dev/null
@@ -0,0 +1,201 @@
+<?php
+
+/**
+ * @group Media
+ * @covers SVGMetadataExtractor
+ */
+class SVGMetadataExtractorTest extends \MediaWikiUnitTestCase {
+
+       /**
+        * @dataProvider provideSvgFiles
+        */
+       public function testGetMetadata( $infile, $expected ) {
+               $this->assertMetadata( $infile, $expected );
+       }
+
+       /**
+        * @dataProvider provideSvgFilesWithXMLMetadata
+        */
+       public function testGetXMLMetadata( $infile, $expected ) {
+               $r = new XMLReader();
+               $this->assertMetadata( $infile, $expected );
+       }
+
+       /**
+        * @dataProvider provideSvgUnits
+        */
+       public function testScaleSVGUnit( $inUnit, $expected ) {
+               $this->assertEquals(
+                       $expected,
+                       SVGReader::scaleSVGUnit( $inUnit ),
+                       'SVG unit conversion and scaling failure'
+               );
+       }
+
+       function assertMetadata( $infile, $expected ) {
+               try {
+                       $data = SVGMetadataExtractor::getMetadata( $infile );
+                       $this->assertEquals( $expected, $data, 'SVG metadata extraction test' );
+               } catch ( MWException $e ) {
+                       if ( $expected === false ) {
+                               $this->assertTrue( true, 'SVG metadata extracted test (expected failure)' );
+                       } else {
+                               throw $e;
+                       }
+               }
+       }
+
+       public static function provideSvgFiles() {
+               $base = __DIR__ . '/../../../data/media';
+
+               return [
+                       [
+                               "$base/Wikimedia-logo.svg",
+                               [
+                                       'width' => 1024,
+                                       'height' => 1024,
+                                       'originalWidth' => '1024',
+                                       'originalHeight' => '1024',
+                                       'translations' => [],
+                               ]
+                       ],
+                       [
+                               "$base/QA_icon.svg",
+                               [
+                                       'width' => 60,
+                                       'height' => 60,
+                                       'originalWidth' => '60',
+                                       'originalHeight' => '60',
+                                       'translations' => [],
+                               ]
+                       ],
+                       [
+                               "$base/Gtk-media-play-ltr.svg",
+                               [
+                                       'width' => 60,
+                                       'height' => 60,
+                                       'originalWidth' => '60.0000000',
+                                       'originalHeight' => '60.0000000',
+                                       'translations' => [],
+                               ]
+                       ],
+                       [
+                               "$base/Toll_Texas_1.svg",
+                               // This file triggered T33719, needs entity expansion in the xmlns checks
+                               [
+                                       'width' => 385,
+                                       'height' => 385,
+                                       'originalWidth' => '385',
+                                       'originalHeight' => '385.0004883',
+                                       'translations' => [],
+                               ]
+                       ],
+                       [
+                               "$base/Tux.svg",
+                               [
+                                       'width' => 512,
+                                       'height' => 594,
+                                       'originalWidth' => '100%',
+                                       'originalHeight' => '100%',
+                                       'title' => 'Tux',
+                                       'translations' => [],
+                                       'description' => 'For more information see: http://commons.wikimedia.org/wiki/Image:Tux.svg',
+                               ]
+                       ],
+                       [
+                               "$base/Speech_bubbles.svg",
+                               [
+                                       'width' => 627,
+                                       'height' => 461,
+                                       'originalWidth' => '17.7cm',
+                                       'originalHeight' => '13cm',
+                                       'translations' => [
+                                               'de' => SVGReader::LANG_FULL_MATCH,
+                                               'fr' => SVGReader::LANG_FULL_MATCH,
+                                               'nl' => SVGReader::LANG_FULL_MATCH,
+                                               'tlh-ca' => SVGReader::LANG_FULL_MATCH,
+                                               'tlh' => SVGReader::LANG_PREFIX_MATCH
+                                       ],
+                               ]
+                       ],
+                       [
+                               "$base/Soccer_ball_animated.svg",
+                               [
+                                       'width' => 150,
+                                       'height' => 150,
+                                       'originalWidth' => '150',
+                                       'originalHeight' => '150',
+                                       'animated' => true,
+                                       'translations' => []
+                               ],
+                       ],
+                       [
+                               "$base/comma_separated_viewbox.svg",
+                               [
+                                       'width' => 512,
+                                       'height' => 594,
+                                       'originalWidth' => '100%',
+                                       'originalHeight' => '100%',
+                                       'translations' => []
+                               ],
+                       ],
+               ];
+       }
+
+       public static function provideSvgFilesWithXMLMetadata() {
+               $base = __DIR__ . '/../../../data/media';
+               // phpcs:disable Generic.Files.LineLength
+               $metadata = '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+      <ns4:Work xmlns:ns4="http://creativecommons.org/ns#" rdf:about="">
+        <ns5:format xmlns:ns5="http://purl.org/dc/elements/1.1/">image/svg+xml</ns5:format>
+        <ns5:type xmlns:ns5="http://purl.org/dc/elements/1.1/" rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
+      </ns4:Work>
+    </rdf:RDF>';
+               // phpcs:enable
+
+               $metadata = str_replace( "\r", '', $metadata ); // Windows compat
+               return [
+                       [
+                               "$base/US_states_by_total_state_tax_revenue.svg",
+                               [
+                                       'height' => 593,
+                                       'metadata' => $metadata,
+                                       'width' => 959,
+                                       'originalWidth' => '958.69',
+                                       'originalHeight' => '592.78998',
+                                       'translations' => [],
+                               ]
+                       ],
+               ];
+       }
+
+       public static function provideSvgUnits() {
+               return [
+                       [ '1' , 1 ],
+                       [ '1.1' , 1.1 ],
+                       [ '0.1' , 0.1 ],
+                       [ '.1' , 0.1 ],
+                       [ '1e2' , 100 ],
+                       [ '1E2' , 100 ],
+                       [ '+1' , 1 ],
+                       [ '-1' , -1 ],
+                       [ '-1.1' , -1.1 ],
+                       [ '1e+2' , 100 ],
+                       [ '1e-2' , 0.01 ],
+                       [ '10px' , 10 ],
+                       [ '10pt' , 10 * 1.25 ],
+                       [ '10pc' , 10 * 15 ],
+                       [ '10mm' , 10 * 3.543307 ],
+                       [ '10cm' , 10 * 35.43307 ],
+                       [ '10in' , 10 * 90 ],
+                       [ '10em' , 10 * 16 ],
+                       [ '10ex' , 10 * 12 ],
+                       [ '10%' , 51.2 ],
+                       [ '10 px' , 10 ],
+                       // Invalid values
+                       [ '1e1.1', 10 ],
+                       [ '10bp', 10 ],
+                       [ 'p10', null ],
+               ];
+       }
+}
diff --git a/tests/phpunit/unit/includes/objectcache/MemcachedBagOStuffTest.php b/tests/phpunit/unit/includes/objectcache/MemcachedBagOStuffTest.php
new file mode 100644 (file)
index 0000000..eb040b4
--- /dev/null
@@ -0,0 +1,107 @@
+<?php
+/**
+ * @group BagOStuff
+ */
+class MemcachedBagOStuffTest extends \MediaWikiUnitTestCase {
+       /** @var MemcachedBagOStuff */
+       private $cache;
+
+       protected function setUp() {
+               parent::setUp();
+               $this->cache = new MemcachedPhpBagOStuff( [ 'keyspace' => 'test', 'servers' => [] ] );
+       }
+
+       /**
+        * @covers MemcachedBagOStuff::makeKey
+        */
+       public function testKeyNormalization() {
+               $this->assertEquals(
+                       'test:vanilla',
+                       $this->cache->makeKey( 'vanilla' )
+               );
+
+               $this->assertEquals(
+                       'test:punctuation_marks_are_ok:!@$^&*()',
+                       $this->cache->makeKey( 'punctuation_marks_are_ok', '!@$^&*()' )
+               );
+
+               $this->assertEquals(
+                       'test:but_spaces:hashes%23:and%0Anewlines:are_not',
+                       $this->cache->makeKey( 'but spaces', 'hashes#', "and\nnewlines", 'are_not' )
+               );
+
+               $this->assertEquals(
+                       'test:this:key:contains:%F0%9D%95%9E%F0%9D%95%A6%F0%9D%95%9D%F0%9D%95%A5%F0%9' .
+                               'D%95%9A%F0%9D%95%93%F0%9D%95%AA%F0%9D%95%A5%F0%9D%95%96:characters',
+                       $this->cache->makeKey( 'this', 'key', 'contains', '𝕞𝕦𝕝𝕥𝕚𝕓𝕪𝕥𝕖', 'characters' )
+               );
+
+               $this->assertEquals(
+                       'test:this:key:contains:#c118f92685a635cb843039de50014c9c',
+                       $this->cache->makeKey( 'this', 'key', 'contains', '𝕥𝕠𝕠 𝕞𝕒𝕟𝕪 𝕞𝕦𝕝𝕥𝕚𝕓𝕪𝕥𝕖 𝕔𝕙𝕒𝕣𝕒𝕔𝕥𝕖𝕣𝕤' )
+               );
+
+               $this->assertEquals(
+                       'test:BagOStuff-long-key:##dc89dcb43b28614da27660240af478b5',
+                       $this->cache->makeKey( '𝕖𝕧𝕖𝕟', '𝕚𝕗', '𝕨𝕖', '𝕄𝔻𝟝', '𝕖𝕒𝕔𝕙',
+                               '𝕒𝕣𝕘𝕦𝕞𝕖𝕟𝕥', '𝕥𝕙𝕚𝕤', '𝕜𝕖𝕪', '𝕨𝕠𝕦𝕝𝕕', '𝕤𝕥𝕚𝕝𝕝', '𝕓𝕖', '𝕥𝕠𝕠', '𝕝𝕠𝕟𝕘' )
+               );
+
+               $this->assertEquals(
+                       'test:%23%235820ad1d105aa4dc698585c39df73e19',
+                       $this->cache->makeKey( '##5820ad1d105aa4dc698585c39df73e19' )
+               );
+
+               $this->assertEquals(
+                       'test:percent_is_escaped:!@$%25^&*()',
+                       $this->cache->makeKey( 'percent_is_escaped', '!@$%^&*()' )
+               );
+
+               $this->assertEquals(
+                       'test:colon_is_escaped:!@$%3A^&*()',
+                       $this->cache->makeKey( 'colon_is_escaped', '!@$:^&*()' )
+               );
+
+               $this->assertEquals(
+                       'test:long_key_part_hashed:#0244f7b1811d982dd932dd7de01465ac',
+                       $this->cache->makeKey( 'long_key_part_hashed', str_repeat( 'y', 500 ) )
+               );
+       }
+
+       /**
+        * @dataProvider validKeyProvider
+        * @covers MemcachedBagOStuff::validateKeyEncoding
+        */
+       public function testValidateKeyEncoding( $key ) {
+               $this->assertSame( $key, $this->cache->validateKeyEncoding( $key ) );
+       }
+
+       public function validKeyProvider() {
+               return [
+                       'empty' => [ '' ],
+                       'digits' => [ '09' ],
+                       'letters' => [ 'AZaz' ],
+                       'ASCII special characters' => [ '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~' ],
+               ];
+       }
+
+       /**
+        * @dataProvider invalidKeyProvider
+        * @covers MemcachedBagOStuff::validateKeyEncoding
+        */
+       public function testValidateKeyEncodingThrowsException( $key ) {
+               $this->setExpectedException( Exception::class );
+               $this->cache->validateKeyEncoding( $key );
+       }
+
+       public function invalidKeyProvider() {
+               return [
+                       [ "\x00" ],
+                       [ ' ' ],
+                       [ "\x1F" ],
+                       [ "\x7F" ],
+                       [ "\x80" ],
+                       [ "\xFF" ],
+               ];
+       }
+}
diff --git a/tests/phpunit/unit/includes/objectcache/RESTBagOStuffTest.php b/tests/phpunit/unit/includes/objectcache/RESTBagOStuffTest.php
new file mode 100644 (file)
index 0000000..459e3ee
--- /dev/null
@@ -0,0 +1,96 @@
+<?php
+/**
+ * @group BagOStuff
+ *
+ * @covers RESTBagOStuff
+ */
+class RESTBagOStuffTest extends \MediaWikiUnitTestCase {
+
+       /**
+        * @var MultiHttpClient
+        */
+       private $client;
+       /**
+        * @var RESTBagOStuff
+        */
+       private $bag;
+
+       public function setUp() {
+               parent::setUp();
+               $this->client =
+                       $this->getMockBuilder( MultiHttpClient::class )
+                               ->setConstructorArgs( [ [] ] )
+                               ->setMethods( [ 'run' ] )
+                               ->getMock();
+               $this->bag = new RESTBagOStuff( [ 'client' => $this->client, 'url' => 'http://test/rest/' ] );
+       }
+
+       public function testGet() {
+               $this->client->expects( $this->once() )->method( 'run' )->with( [
+                       'method' => 'GET',
+                       'url' => 'http://test/rest/42xyz42',
+                       'headers' => []
+                       // list( $rcode, $rdesc, $rhdrs, $rbody, $rerr )
+               ] )->willReturn( [ 200, 'OK', [], '"somedata"', 0 ] );
+               $result = $this->bag->get( '42xyz42' );
+               $this->assertEquals( 'somedata', $result );
+       }
+
+       public function testGetNotExist() {
+               $this->client->expects( $this->once() )->method( 'run' )->with( [
+                       'method' => 'GET',
+                       'url' => 'http://test/rest/42xyz42',
+                       'headers' => []
+                       // list( $rcode, $rdesc, $rhdrs, $rbody, $rerr )
+               ] )->willReturn( [ 404, 'Not found', [], 'Nothing to see here', 0 ] );
+               $result = $this->bag->get( '42xyz42' );
+               $this->assertFalse( $result );
+       }
+
+       public function testGetBadClient() {
+               $this->client->expects( $this->once() )->method( 'run' )->with( [
+                       'method' => 'GET',
+                       'url' => 'http://test/rest/42xyz42',
+                       'headers' => []
+                       // list( $rcode, $rdesc, $rhdrs, $rbody, $rerr )
+               ] )->willReturn( [ 0, '', [], '', 'cURL has failed you today' ] );
+               $result = $this->bag->get( '42xyz42' );
+               $this->assertFalse( $result );
+               $this->assertEquals( BagOStuff::ERR_UNREACHABLE, $this->bag->getLastError() );
+       }
+
+       public function testGetBadServer() {
+               $this->client->expects( $this->once() )->method( 'run' )->with( [
+                       'method' => 'GET',
+                       'url' => 'http://test/rest/42xyz42',
+                       'headers' => []
+                       // list( $rcode, $rdesc, $rhdrs, $rbody, $rerr )
+               ] )->willReturn( [ 500, 'Too busy', [], 'Server is too busy', '' ] );
+               $result = $this->bag->get( '42xyz42' );
+               $this->assertFalse( $result );
+               $this->assertEquals( BagOStuff::ERR_UNEXPECTED, $this->bag->getLastError() );
+       }
+
+       public function testPut() {
+               $this->client->expects( $this->once() )->method( 'run' )->with( [
+                       'method' => 'PUT',
+                       'url' => 'http://test/rest/42xyz42',
+                       'body' => '"postdata"',
+                       'headers' => []
+                       // list( $rcode, $rdesc, $rhdrs, $rbody, $rerr )
+               ] )->willReturn( [ 200, 'OK', [], 'Done', 0 ] );
+               $result = $this->bag->set( '42xyz42', 'postdata' );
+               $this->assertTrue( $result );
+       }
+
+       public function testDelete() {
+               $this->client->expects( $this->once() )->method( 'run' )->with( [
+                       'method' => 'DELETE',
+                       'url' => 'http://test/rest/42xyz42',
+                       'headers' => []
+                       // list( $rcode, $rdesc, $rhdrs, $rbody, $rerr )
+               ] )->willReturn( [ 200, 'OK', [], 'Done', 0 ] );
+               $result = $this->bag->delete( '42xyz42' );
+               $this->assertTrue( $result );
+       }
+}
diff --git a/tests/phpunit/unit/includes/parser/TidyTest.php b/tests/phpunit/unit/includes/parser/TidyTest.php
new file mode 100644 (file)
index 0000000..1adb6a6
--- /dev/null
@@ -0,0 +1,64 @@
+<?php
+
+/**
+ * @group Parser
+ * @covers MWTidy
+ */
+class TidyTest extends \MediaWikiUnitTestCase {
+
+       protected function setUp() {
+               parent::setUp();
+               if ( !MWTidy::isEnabled() ) {
+                       $this->markTestSkipped( 'Tidy not found' );
+               }
+       }
+
+       /**
+        * @dataProvider provideTestWrapping
+        */
+       public function testTidyWrapping( $expected, $text, $msg = '' ) {
+               $text = MWTidy::tidy( $text );
+               // We don't care about where Tidy wants to stick is <p>s
+               $text = trim( preg_replace( '#</?p>#', '', $text ) );
+               // Windows, we love you!
+               $text = str_replace( "\r", '', $text );
+               $this->assertEquals( $expected, $text, $msg );
+       }
+
+       public static function provideTestWrapping() {
+               $testMathML = <<<'MathML'
+<math xmlns="http://www.w3.org/1998/Math/MathML">
+    <mrow>
+      <mi>a</mi>
+      <mo>&InvisibleTimes;</mo>
+      <msup>
+        <mi>x</mi>
+        <mn>2</mn>
+      </msup>
+      <mo>+</mo>
+      <mi>b</mi>
+      <mo>&InvisibleTimes; </mo>
+      <mi>x</mi>
+      <mo>+</mo>
+      <mi>c</mi>
+    </mrow>
+  </math>
+MathML;
+               return [
+                       [
+                               '<mw:editsection page="foo" section="bar">foo</mw:editsection>',
+                               '<mw:editsection page="foo" section="bar">foo</mw:editsection>',
+                               '<mw:editsection> should survive tidy'
+                       ],
+                       [
+                               '<editsection page="foo" section="bar">foo</editsection>',
+                               '<editsection page="foo" section="bar">foo</editsection>',
+                               '<editsection> should survive tidy'
+                       ],
+                       [ '<mw:toc>foo</mw:toc>', '<mw:toc>foo</mw:toc>', '<mw:toc> should survive tidy' ],
+                       [ "<link foo=\"bar\" />foo", '<link foo="bar"/>foo', '<link> should survive tidy' ],
+                       [ "<meta foo=\"bar\" />foo", '<meta foo="bar"/>foo', '<meta> should survive tidy' ],
+                       [ $testMathML, $testMathML, '<math> should survive tidy' ],
+               ];
+       }
+}
diff --git a/tests/phpunit/unit/includes/password/PasswordTest.php b/tests/phpunit/unit/includes/password/PasswordTest.php
new file mode 100644 (file)
index 0000000..b41c0f4
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Testing framework for the Password infrastructure
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ */
+
+/**
+ * @covers InvalidPassword
+ */
+class PasswordTest extends \MediaWikiUnitTestCase {
+       public function testInvalidPlaintext() {
+               $passwordFactory = new PasswordFactory();
+               $invalid = $passwordFactory->newFromPlaintext( null );
+
+               $this->assertInstanceOf( InvalidPassword::class, $invalid );
+       }
+}
diff --git a/tests/phpunit/unit/includes/preferences/FiltersTest.php b/tests/phpunit/unit/includes/preferences/FiltersTest.php
new file mode 100644 (file)
index 0000000..d2b5d05
--- /dev/null
@@ -0,0 +1,141 @@
+<?php
+/**
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ */
+
+use MediaWiki\Preferences\IntvalFilter;
+use MediaWiki\Preferences\MultiUsernameFilter;
+use MediaWiki\Preferences\TimezoneFilter;
+
+/**
+ * @group Preferences
+ */
+class FiltersTest extends \MediaWikiUnitTestCase {
+       /**
+        * @covers MediaWiki\Preferences\IntvalFilter::filterFromForm()
+        * @covers MediaWiki\Preferences\IntvalFilter::filterForForm()
+        */
+       public function testIntvalFilter() {
+               $filter = new IntvalFilter();
+               self::assertSame( 0, $filter->filterFromForm( '0' ) );
+               self::assertSame( 3, $filter->filterFromForm( '3' ) );
+               self::assertSame( '123', $filter->filterForForm( '123' ) );
+       }
+
+       /**
+        * @covers       MediaWiki\Preferences\TimezoneFilter::filterFromForm()
+        * @dataProvider provideTimezoneFilter
+        *
+        * @param string $input
+        * @param string $expected
+        */
+       public function testTimezoneFilter( $input, $expected ) {
+               $filter = new TimezoneFilter();
+               $result = $filter->filterFromForm( $input );
+               self::assertEquals( $expected, $result );
+       }
+
+       public function provideTimezoneFilter() {
+               return [
+                       [ 'ZoneInfo', 'Offset|0' ],
+                       [ 'ZoneInfo|bogus', 'Offset|0' ],
+                       [ 'System', 'System' ],
+                       [ '2:30', 'Offset|150' ],
+               ];
+       }
+
+       /**
+        * @covers MediaWiki\Preferences\MultiUsernameFilter::filterFromForm()
+        * @dataProvider provideMultiUsernameFilterFrom
+        *
+        * @param string $input
+        * @param string|null $expected
+        */
+       public function testMultiUsernameFilterFrom( $input, $expected ) {
+               $filter = $this->makeMultiUsernameFilter();
+               $result = $filter->filterFromForm( $input );
+               self::assertSame( $expected, $result );
+       }
+
+       public function provideMultiUsernameFilterFrom() {
+               return [
+                       [ '', null ],
+                       [ "\n\n\n", null ],
+                       [ 'Foo', '1' ],
+                       [ "\n\n\nFoo\nBar\n", "1\n2" ],
+                       [ "Baz\nInvalid\nFoo", "3\n1" ],
+                       [ "Invalid", null ],
+                       [ "Invalid\n\n\nInvalid\n", null ],
+               ];
+       }
+
+       /**
+        * @covers MediaWiki\Preferences\MultiUsernameFilter::filterForForm()
+        * @dataProvider provideMultiUsernameFilterFor
+        *
+        * @param string $input
+        * @param string $expected
+        */
+       public function testMultiUsernameFilterFor( $input, $expected ) {
+               $filter = $this->makeMultiUsernameFilter();
+               $result = $filter->filterForForm( $input );
+               self::assertSame( $expected, $result );
+       }
+
+       public function provideMultiUsernameFilterFor() {
+               return [
+                       [ '', '' ],
+                       [ "\n", '' ],
+                       [ '1', 'Foo' ],
+                       [ "\n1\n\n2\377\n", "Foo\nBar" ],
+                       [ "666\n667", '' ],
+               ];
+       }
+
+       private function makeMultiUsernameFilter() {
+               $userMapping = [
+                       'Foo' => 1,
+                       'Bar' => 2,
+                       'Baz' => 3,
+               ];
+               $flipped = array_flip( $userMapping );
+               $idLookup = self::getMockBuilder( CentralIdLookup::class )
+                       ->disableOriginalConstructor()
+                       ->setMethods( [ 'centralIdsFromNames', 'namesFromCentralIds' ] )
+                       ->getMockForAbstractClass();
+
+               $idLookup->method( 'centralIdsFromNames' )
+                       ->will( self::returnCallback( function ( $names ) use ( $userMapping ) {
+                               $ids = [];
+                               foreach ( $names as $name ) {
+                                       $ids[] = $userMapping[$name] ?? null;
+                               }
+                               return array_filter( $ids, 'is_numeric' );
+                       } ) );
+               $idLookup->method( 'namesFromCentralIds' )
+                       ->will( self::returnCallback( function ( $ids ) use ( $flipped ) {
+                               $names = [];
+                               foreach ( $ids as $id ) {
+                                       $names[] = $flipped[$id] ?? null;
+                               }
+                               return array_filter( $names, 'is_string' );
+                       } ) );
+
+               return new MultiUsernameFilter( $idLookup );
+       }
+}
diff --git a/tests/phpunit/unit/includes/registration/ExtensionProcessorTest.php b/tests/phpunit/unit/includes/registration/ExtensionProcessorTest.php
new file mode 100644 (file)
index 0000000..13de142
--- /dev/null
@@ -0,0 +1,829 @@
+<?php
+
+use Wikimedia\TestingAccessWrapper;
+
+/**
+ * @covers ExtensionProcessor
+ */
+class ExtensionProcessorTest extends \MediaWikiUnitTestCase {
+
+       private $dir, $dirname;
+
+       public function setUp() {
+               parent::setUp();
+               $this->dir = __DIR__ . '/FooBar/extension.json';
+               $this->dirname = dirname( $this->dir );
+       }
+
+       /**
+        * 'name' is absolutely required
+        *
+        * @var array
+        */
+       public static $default = [
+               'name' => 'FooBar',
+       ];
+
+       public function testExtractInfo() {
+               // Test that attributes that begin with @ are ignored
+               $processor = new ExtensionProcessor();
+               $processor->extractInfo( $this->dir, self::$default + [
+                       '@metadata' => [ 'foobarbaz' ],
+                       'AnAttribute' => [ 'omg' ],
+                       'AutoloadClasses' => [ 'FooBar' => 'includes/FooBar.php' ],
+                       'SpecialPages' => [ 'Foo' => 'SpecialFoo' ],
+                       'callback' => 'FooBar::onRegistration',
+               ], 1 );
+
+               $extracted = $processor->getExtractedInfo();
+               $attributes = $extracted['attributes'];
+               $this->assertArrayHasKey( 'AnAttribute', $attributes );
+               $this->assertArrayNotHasKey( '@metadata', $attributes );
+               $this->assertArrayNotHasKey( 'AutoloadClasses', $attributes );
+               $this->assertSame(
+                       [ 'FooBar' => 'FooBar::onRegistration' ],
+                       $extracted['callbacks']
+               );
+               $this->assertSame(
+                       [ 'Foo' => 'SpecialFoo' ],
+                       $extracted['globals']['wgSpecialPages']
+               );
+       }
+
+       public function testExtractNamespaces() {
+               // Test that namespace IDs can be overwritten
+               if ( !defined( 'MW_EXTENSION_PROCESSOR_TEST_EXTRACT_INFO_X' ) ) {
+                       define( 'MW_EXTENSION_PROCESSOR_TEST_EXTRACT_INFO_X', 123456 );
+               }
+
+               $processor = new ExtensionProcessor();
+               $processor->extractInfo( $this->dir, self::$default + [
+                       'namespaces' => [
+                               [
+                                       'id' => 332200,
+                                       'constant' => 'MW_EXTENSION_PROCESSOR_TEST_EXTRACT_INFO_A',
+                                       'name' => 'Test_A',
+                                       'defaultcontentmodel' => 'TestModel',
+                                       'gender' => [
+                                               'male' => 'Male test',
+                                               'female' => 'Female test',
+                                       ],
+                                       'subpages' => true,
+                                       'content' => true,
+                                       'protection' => 'userright',
+                               ],
+                               [ // Test_X will use ID 123456 not 334400
+                                       'id' => 334400,
+                                       'constant' => 'MW_EXTENSION_PROCESSOR_TEST_EXTRACT_INFO_X',
+                                       'name' => 'Test_X',
+                                       'defaultcontentmodel' => 'TestModel'
+                               ],
+                       ]
+               ], 1 );
+
+               $extracted = $processor->getExtractedInfo();
+
+               $this->assertArrayHasKey(
+                       'MW_EXTENSION_PROCESSOR_TEST_EXTRACT_INFO_A',
+                       $extracted['defines']
+               );
+               $this->assertArrayNotHasKey(
+                       'MW_EXTENSION_PROCESSOR_TEST_EXTRACT_INFO_X',
+                       $extracted['defines']
+               );
+
+               $this->assertSame(
+                       $extracted['defines']['MW_EXTENSION_PROCESSOR_TEST_EXTRACT_INFO_A'],
+                       332200
+               );
+
+               $this->assertArrayHasKey( 'ExtensionNamespaces', $extracted['attributes'] );
+               $this->assertArrayHasKey( 123456, $extracted['attributes']['ExtensionNamespaces'] );
+               $this->assertArrayHasKey( 332200, $extracted['attributes']['ExtensionNamespaces'] );
+               $this->assertArrayNotHasKey( 334400, $extracted['attributes']['ExtensionNamespaces'] );
+
+               $this->assertSame( 'Test_X', $extracted['attributes']['ExtensionNamespaces'][123456] );
+               $this->assertSame( 'Test_A', $extracted['attributes']['ExtensionNamespaces'][332200] );
+               $this->assertSame(
+                       [ 'male' => 'Male test', 'female' => 'Female test' ],
+                       $extracted['globals']['wgExtraGenderNamespaces'][332200]
+               );
+               // A has subpages, X does not
+               $this->assertTrue( $extracted['globals']['wgNamespacesWithSubpages'][332200] );
+               $this->assertArrayNotHasKey( 123456, $extracted['globals']['wgNamespacesWithSubpages'] );
+       }
+
+       public static function provideRegisterHooks() {
+               $merge = [ ExtensionRegistry::MERGE_STRATEGY => 'array_merge_recursive' ];
+               // Format:
+               // Current $wgHooks
+               // Content in extension.json
+               // Expected value of $wgHooks
+               return [
+                       // No hooks
+                       [
+                               [],
+                               self::$default,
+                               $merge,
+                       ],
+                       // No current hooks, adding one for "FooBaz" in string format
+                       [
+                               [],
+                               [ 'Hooks' => [ 'FooBaz' => 'FooBazCallback' ] ] + self::$default,
+                               [ 'FooBaz' => [ 'FooBazCallback' ] ] + $merge,
+                       ],
+                       // Hook for "FooBaz", adding another one
+                       [
+                               [ 'FooBaz' => [ 'PriorCallback' ] ],
+                               [ 'Hooks' => [ 'FooBaz' => 'FooBazCallback' ] ] + self::$default,
+                               [ 'FooBaz' => [ 'PriorCallback', 'FooBazCallback' ] ] + $merge,
+                       ],
+                       // No current hooks, adding one for "FooBaz" in verbose array format
+                       [
+                               [],
+                               [ 'Hooks' => [ 'FooBaz' => [ 'FooBazCallback' ] ] ] + self::$default,
+                               [ 'FooBaz' => [ 'FooBazCallback' ] ] + $merge,
+                       ],
+                       // Hook for "BarBaz", adding one for "FooBaz"
+                       [
+                               [ 'BarBaz' => [ 'BarBazCallback' ] ],
+                               [ 'Hooks' => [ 'FooBaz' => 'FooBazCallback' ] ] + self::$default,
+                               [
+                                       'BarBaz' => [ 'BarBazCallback' ],
+                                       'FooBaz' => [ 'FooBazCallback' ],
+                               ] + $merge,
+                       ],
+                       // Callbacks for FooBaz wrapped in an array
+                       [
+                               [],
+                               [ 'Hooks' => [ 'FooBaz' => [ 'Callback1' ] ] ] + self::$default,
+                               [
+                                       'FooBaz' => [ 'Callback1' ],
+                               ] + $merge,
+                       ],
+                       // Multiple callbacks for FooBaz hook
+                       [
+                               [],
+                               [ 'Hooks' => [ 'FooBaz' => [ 'Callback1', 'Callback2' ] ] ] + self::$default,
+                               [
+                                       'FooBaz' => [ 'Callback1', 'Callback2' ],
+                               ] + $merge,
+                       ],
+               ];
+       }
+
+       /**
+        * @dataProvider provideRegisterHooks
+        */
+       public function testRegisterHooks( $pre, $info, $expected ) {
+               $processor = new MockExtensionProcessor( [ 'wgHooks' => $pre ] );
+               $processor->extractInfo( $this->dir, $info, 1 );
+               $extracted = $processor->getExtractedInfo();
+               $this->assertEquals( $expected, $extracted['globals']['wgHooks'] );
+       }
+
+       public function testExtractConfig1() {
+               $processor = new ExtensionProcessor;
+               $info = [
+                       'config' => [
+                               'Bar' => 'somevalue',
+                               'Foo' => 10,
+                               '@IGNORED' => 'yes',
+                       ],
+               ] + self::$default;
+               $info2 = [
+                       'config' => [
+                               '_prefix' => 'eg',
+                               'Bar' => 'somevalue'
+                       ],
+                       'name' => 'FooBar2',
+               ];
+               $processor->extractInfo( $this->dir, $info, 1 );
+               $processor->extractInfo( $this->dir, $info2, 1 );
+               $extracted = $processor->getExtractedInfo();
+               $this->assertEquals( 'somevalue', $extracted['globals']['wgBar'] );
+               $this->assertEquals( 10, $extracted['globals']['wgFoo'] );
+               $this->assertArrayNotHasKey( 'wg@IGNORED', $extracted['globals'] );
+               // Custom prefix:
+               $this->assertEquals( 'somevalue', $extracted['globals']['egBar'] );
+       }
+
+       public function testExtractConfig2() {
+               $processor = new ExtensionProcessor;
+               $info = [
+                       'config' => [
+                               'Bar' => [ 'value' => 'somevalue' ],
+                               'Foo' => [ 'value' => 10 ],
+                               'Path' => [ 'value' => 'foo.txt', 'path' => true ],
+                               'Namespaces' => [
+                                       'value' => [
+                                               '10' => true,
+                                               '12' => false,
+                                       ],
+                                       'merge_strategy' => 'array_plus',
+                               ],
+                       ],
+               ] + self::$default;
+               $info2 = [
+                       'config' => [
+                               'Bar' => [ 'value' => 'somevalue' ],
+                       ],
+                       'config_prefix' => 'eg',
+                       'name' => 'FooBar2',
+               ];
+               $processor->extractInfo( $this->dir, $info, 2 );
+               $processor->extractInfo( $this->dir, $info2, 2 );
+               $extracted = $processor->getExtractedInfo();
+               $this->assertEquals( 'somevalue', $extracted['globals']['wgBar'] );
+               $this->assertEquals( 10, $extracted['globals']['wgFoo'] );
+               $this->assertEquals( "{$this->dirname}/foo.txt", $extracted['globals']['wgPath'] );
+               // Custom prefix:
+               $this->assertEquals( 'somevalue', $extracted['globals']['egBar'] );
+               $this->assertSame(
+                       [ 10 => true, 12 => false, ExtensionRegistry::MERGE_STRATEGY => 'array_plus' ],
+                       $extracted['globals']['wgNamespaces']
+               );
+       }
+
+       /**
+        * @expectedException RuntimeException
+        */
+       public function testDuplicateConfigKey1() {
+               $processor = new ExtensionProcessor;
+               $info = [
+                       'config' => [
+                               'Bar' => '',
+                       ]
+               ] + self::$default;
+               $info2 = [
+                       'config' => [
+                               'Bar' => 'g',
+                       ],
+                       'name' => 'FooBar2',
+               ];
+               $processor->extractInfo( $this->dir, $info, 1 );
+               $processor->extractInfo( $this->dir, $info2, 1 );
+       }
+
+       /**
+        * @expectedException RuntimeException
+        */
+       public function testDuplicateConfigKey2() {
+               $processor = new ExtensionProcessor;
+               $info = [
+                       'config' => [
+                               'Bar' => [ 'value' => 'somevalue' ],
+                       ]
+               ] + self::$default;
+               $info2 = [
+                       'config' => [
+                               'Bar' => [ 'value' => 'somevalue' ],
+                       ],
+                       'name' => 'FooBar2',
+               ];
+               $processor->extractInfo( $this->dir, $info, 2 );
+               $processor->extractInfo( $this->dir, $info2, 2 );
+       }
+
+       public static function provideExtractExtensionMessagesFiles() {
+               $dir = __DIR__ . '/FooBar/';
+               return [
+                       [
+                               [ 'ExtensionMessagesFiles' => [ 'FooBarAlias' => 'FooBar.alias.php' ] ],
+                               [ 'wgExtensionMessagesFiles' => [ 'FooBarAlias' => $dir . 'FooBar.alias.php' ] ]
+                       ],
+                       [
+                               [
+                                       'ExtensionMessagesFiles' => [
+                                               'FooBarAlias' => 'FooBar.alias.php',
+                                               'FooBarMagic' => 'FooBar.magic.i18n.php',
+                                       ],
+                               ],
+                               [
+                                       'wgExtensionMessagesFiles' => [
+                                               'FooBarAlias' => $dir . 'FooBar.alias.php',
+                                               'FooBarMagic' => $dir . 'FooBar.magic.i18n.php',
+                                       ],
+                               ],
+                       ],
+               ];
+       }
+
+       /**
+        * @dataProvider provideExtractExtensionMessagesFiles
+        */
+       public function testExtractExtensionMessagesFiles( $input, $expected ) {
+               $processor = new ExtensionProcessor();
+               $processor->extractInfo( $this->dir, $input + self::$default, 1 );
+               $out = $processor->getExtractedInfo();
+               foreach ( $expected as $key => $value ) {
+                       $this->assertEquals( $value, $out['globals'][$key] );
+               }
+       }
+
+       public static function provideExtractMessagesDirs() {
+               $dir = __DIR__ . '/FooBar/';
+               return [
+                       [
+                               [ 'MessagesDirs' => [ 'VisualEditor' => 'i18n' ] ],
+                               [ 'wgMessagesDirs' => [ 'VisualEditor' => [ $dir . 'i18n' ] ] ]
+                       ],
+                       [
+                               [ 'MessagesDirs' => [ 'VisualEditor' => [ 'i18n', 'foobar' ] ] ],
+                               [ 'wgMessagesDirs' => [ 'VisualEditor' => [ $dir . 'i18n', $dir . 'foobar' ] ] ]
+                       ],
+               ];
+       }
+
+       /**
+        * @dataProvider provideExtractMessagesDirs
+        */
+       public function testExtractMessagesDirs( $input, $expected ) {
+               $processor = new ExtensionProcessor();
+               $processor->extractInfo( $this->dir, $input + self::$default, 1 );
+               $out = $processor->getExtractedInfo();
+               foreach ( $expected as $key => $value ) {
+                       $this->assertEquals( $value, $out['globals'][$key] );
+               }
+       }
+
+       public function testExtractCredits() {
+               $processor = new ExtensionProcessor();
+               $processor->extractInfo( $this->dir, self::$default, 1 );
+               $this->setExpectedException( Exception::class );
+               $processor->extractInfo( $this->dir, self::$default, 1 );
+       }
+
+       /**
+        * @dataProvider provideExtractResourceLoaderModules
+        */
+       public function testExtractResourceLoaderModules(
+               $input,
+               array $expectedGlobals,
+               array $expectedAttribs = []
+       ) {
+               $processor = new ExtensionProcessor();
+               $processor->extractInfo( $this->dir, $input + self::$default, 1 );
+               $out = $processor->getExtractedInfo();
+               foreach ( $expectedGlobals as $key => $value ) {
+                       $this->assertEquals( $value, $out['globals'][$key] );
+               }
+               foreach ( $expectedAttribs as $key => $value ) {
+                       $this->assertEquals( $value, $out['attributes'][$key] );
+               }
+       }
+
+       public static function provideExtractResourceLoaderModules() {
+               $dir = __DIR__ . '/FooBar';
+               return [
+                       // Generic module with localBasePath/remoteExtPath specified
+                       [
+                               // Input
+                               [
+                                       'ResourceModules' => [
+                                               'test.foo' => [
+                                                       'styles' => 'foobar.js',
+                                                       'localBasePath' => '',
+                                                       'remoteExtPath' => 'FooBar',
+                                               ],
+                                       ],
+                               ],
+                               // Expected
+                               [
+                                       'wgResourceModules' => [
+                                               'test.foo' => [
+                                                       'styles' => 'foobar.js',
+                                                       'localBasePath' => $dir,
+                                                       'remoteExtPath' => 'FooBar',
+                                               ],
+                                       ],
+                               ],
+                       ],
+                       // ResourceFileModulePaths specified:
+                       [
+                               // Input
+                               [
+                                       'ResourceFileModulePaths' => [
+                                               'localBasePath' => 'modules',
+                                               'remoteExtPath' => 'FooBar/modules',
+                                       ],
+                                       'ResourceModules' => [
+                                               // No paths
+                                               'test.foo' => [
+                                                       'styles' => 'foo.js',
+                                               ],
+                                               // Different paths set
+                                               'test.bar' => [
+                                                       'styles' => 'bar.js',
+                                                       'localBasePath' => 'subdir',
+                                                       'remoteExtPath' => 'FooBar/subdir',
+                                               ],
+                                               // Custom class with no paths set
+                                               'test.class' => [
+                                                       'class' => 'FooBarModule',
+                                                       'extra' => 'argument',
+                                               ],
+                                               // Custom class with a localBasePath
+                                               'test.class.with.path' => [
+                                                       'class' => 'FooBarPathModule',
+                                                       'extra' => 'argument',
+                                                       'localBasePath' => '',
+                                               ]
+                                       ],
+                               ],
+                               // Expected
+                               [
+                                       'wgResourceModules' => [
+                                               'test.foo' => [
+                                                       'styles' => 'foo.js',
+                                                       'localBasePath' => "$dir/modules",
+                                                       'remoteExtPath' => 'FooBar/modules',
+                                               ],
+                                               'test.bar' => [
+                                                       'styles' => 'bar.js',
+                                                       'localBasePath' => "$dir/subdir",
+                                                       'remoteExtPath' => 'FooBar/subdir',
+                                               ],
+                                               'test.class' => [
+                                                       'class' => 'FooBarModule',
+                                                       'extra' => 'argument',
+                                                       'localBasePath' => "$dir/modules",
+                                                       'remoteExtPath' => 'FooBar/modules',
+                                               ],
+                                               'test.class.with.path' => [
+                                                       'class' => 'FooBarPathModule',
+                                                       'extra' => 'argument',
+                                                       'localBasePath' => $dir,
+                                                       'remoteExtPath' => 'FooBar/modules',
+                                               ]
+                                       ],
+                               ],
+                       ],
+                       // ResourceModuleSkinStyles with file module paths
+                       [
+                               // Input
+                               [
+                                       'ResourceFileModulePaths' => [
+                                               'localBasePath' => '',
+                                               'remoteSkinPath' => 'FooBar',
+                                       ],
+                                       'ResourceModuleSkinStyles' => [
+                                               'foobar' => [
+                                                       'test.foo' => 'foo.css',
+                                               ]
+                                       ],
+                               ],
+                               // Expected
+                               [
+                                       'wgResourceModuleSkinStyles' => [
+                                               'foobar' => [
+                                                       'test.foo' => 'foo.css',
+                                                       'localBasePath' => $dir,
+                                                       'remoteSkinPath' => 'FooBar',
+                                               ],
+                                       ],
+                               ],
+                       ],
+                       // ResourceModuleSkinStyles with file module paths and an override
+                       [
+                               // Input
+                               [
+                                       'ResourceFileModulePaths' => [
+                                               'localBasePath' => '',
+                                               'remoteSkinPath' => 'FooBar',
+                                       ],
+                                       'ResourceModuleSkinStyles' => [
+                                               'foobar' => [
+                                                       'test.foo' => 'foo.css',
+                                                       'remoteSkinPath' => 'BarFoo'
+                                               ],
+                                       ],
+                               ],
+                               // Expected
+                               [
+                                       'wgResourceModuleSkinStyles' => [
+                                               'foobar' => [
+                                                       'test.foo' => 'foo.css',
+                                                       'localBasePath' => $dir,
+                                                       'remoteSkinPath' => 'BarFoo',
+                                               ],
+                                       ],
+                               ],
+                       ],
+                       'QUnit test module' => [
+                               // Input
+                               [
+                                       'QUnitTestModule' => [
+                                               'localBasePath' => '',
+                                               'remoteExtPath' => 'Foo',
+                                               'scripts' => 'bar.js',
+                                       ],
+                               ],
+                               // Expected
+                               [],
+                               [
+                                       'QUnitTestModules' => [
+                                               'test.FooBar' => [
+                                                       'localBasePath' => $dir,
+                                                       'remoteExtPath' => 'Foo',
+                                                       'scripts' => 'bar.js',
+                                               ],
+                                       ],
+                               ],
+                       ],
+               ];
+       }
+
+       public static function provideSetToGlobal() {
+               return [
+                       [
+                               [ 'wgAPIModules', 'wgAvailableRights' ],
+                               [],
+                               [
+                                       'APIModules' => [ 'foobar' => 'ApiFooBar' ],
+                                       'AvailableRights' => [ 'foobar', 'unfoobar' ],
+                               ],
+                               [
+                                       'wgAPIModules' => [ 'foobar' => 'ApiFooBar' ],
+                                       'wgAvailableRights' => [ 'foobar', 'unfoobar' ],
+                               ],
+                       ],
+                       [
+                               [ 'wgAPIModules', 'wgAvailableRights' ],
+                               [
+                                       'wgAPIModules' => [ 'barbaz' => 'ApiBarBaz' ],
+                                       'wgAvailableRights' => [ 'barbaz' ]
+                               ],
+                               [
+                                       'APIModules' => [ 'foobar' => 'ApiFooBar' ],
+                                       'AvailableRights' => [ 'foobar', 'unfoobar' ],
+                               ],
+                               [
+                                       'wgAPIModules' => [ 'barbaz' => 'ApiBarBaz', 'foobar' => 'ApiFooBar' ],
+                                       'wgAvailableRights' => [ 'barbaz', 'foobar', 'unfoobar' ],
+                               ],
+                       ],
+                       [
+                               [ 'wgGroupPermissions' ],
+                               [
+                                       'wgGroupPermissions' => [
+                                               'sysop' => [ 'delete' ]
+                                       ],
+                               ],
+                               [
+                                       'GroupPermissions' => [
+                                               'sysop' => [ 'undelete' ],
+                                               'user' => [ 'edit' ]
+                                       ],
+                               ],
+                               [
+                                       'wgGroupPermissions' => [
+                                               'sysop' => [ 'delete', 'undelete' ],
+                                               'user' => [ 'edit' ]
+                                       ],
+                               ]
+                       ]
+               ];
+       }
+
+       /**
+        * Attributes under manifest_version 2
+        */
+       public function testExtractAttributes() {
+               $processor = new ExtensionProcessor();
+               // Load FooBar extension
+               $processor->extractInfo( $this->dir, [ 'name' => 'FooBar' ], 2 );
+               $processor->extractInfo(
+                       $this->dir,
+                       [
+                               'name' => 'Baz',
+                               'attributes' => [
+                                       // Loaded
+                                       'FooBar' => [
+                                               'Plugins' => [
+                                                       'ext.baz.foobar',
+                                               ],
+                                       ],
+                                       // Not loaded
+                                       'FizzBuzz' => [
+                                               'MorePlugins' => [
+                                                       'ext.baz.fizzbuzz',
+                                               ],
+                                       ],
+                               ],
+                       ],
+                       2
+               );
+
+               $info = $processor->getExtractedInfo();
+               $this->assertArrayHasKey( 'FooBarPlugins', $info['attributes'] );
+               $this->assertSame( [ 'ext.baz.foobar' ], $info['attributes']['FooBarPlugins'] );
+               $this->assertArrayNotHasKey( 'FizzBuzzMorePlugins', $info['attributes'] );
+       }
+
+       /**
+        * Attributes under manifest_version 1
+        */
+       public function testAttributes1() {
+               $processor = new ExtensionProcessor();
+               $processor->extractInfo(
+                       $this->dir,
+                       [
+                               'name' => 'FooBar',
+                               'FooBarPlugins' => [
+                                       'ext.baz.foobar',
+                               ],
+                               'FizzBuzzMorePlugins' => [
+                                       'ext.baz.fizzbuzz',
+                               ],
+                       ],
+                       1
+               );
+               $processor->extractInfo(
+                       $this->dir,
+                       [
+                               'name' => 'FooBar2',
+                               'FizzBuzzMorePlugins' => [
+                                       'ext.bar.fizzbuzz',
+                               ]
+                       ],
+                       1
+               );
+
+               $info = $processor->getExtractedInfo();
+               $this->assertArrayHasKey( 'FooBarPlugins', $info['attributes'] );
+               $this->assertSame( [ 'ext.baz.foobar' ], $info['attributes']['FooBarPlugins'] );
+               $this->assertArrayHasKey( 'FizzBuzzMorePlugins', $info['attributes'] );
+               $this->assertSame(
+                       [ 'ext.baz.fizzbuzz', 'ext.bar.fizzbuzz' ],
+                       $info['attributes']['FizzBuzzMorePlugins']
+               );
+       }
+
+       public function testAttributes1_notarray() {
+               $processor = new ExtensionProcessor();
+               $this->setExpectedException(
+                       InvalidArgumentException::class,
+                       "The value for 'FooBarPlugins' should be an array (from {$this->dir})"
+               );
+               $processor->extractInfo(
+                       $this->dir,
+                       [
+                               'FooBarPlugins' => 'ext.baz.foobar',
+                       ] + self::$default,
+                       1
+               );
+       }
+
+       public function testExtractPathBasedGlobal() {
+               $processor = new ExtensionProcessor();
+               $processor->extractInfo(
+                       $this->dir,
+                       [
+                               'ParserTestFiles' => [
+                                       'tests/parserTests.txt',
+                                       'tests/extraParserTests.txt',
+                               ],
+                               'ServiceWiringFiles' => [
+                                       'includes/ServiceWiring.php'
+                               ],
+                       ] + self::$default,
+                       1
+               );
+               $globals = $processor->getExtractedInfo()['globals'];
+               $this->assertArrayHasKey( 'wgParserTestFiles', $globals );
+               $this->assertSame( [
+                       "{$this->dirname}/tests/parserTests.txt",
+                       "{$this->dirname}/tests/extraParserTests.txt"
+               ], $globals['wgParserTestFiles'] );
+               $this->assertArrayHasKey( 'wgServiceWiringFiles', $globals );
+               $this->assertSame( [
+                       "{$this->dirname}/includes/ServiceWiring.php"
+               ], $globals['wgServiceWiringFiles'] );
+       }
+
+       public function testGetRequirements() {
+               $info = self::$default + [
+                       'requires' => [
+                               'MediaWiki' => '>= 1.25.0',
+                               'platform' => [
+                                       'php' => '>= 5.5.9'
+                               ],
+                               'extensions' => [
+                                       'Bar' => '*'
+                               ]
+                       ]
+               ];
+               $processor = new ExtensionProcessor();
+               $this->assertSame(
+                       $info['requires'],
+                       $processor->getRequirements( $info, false )
+               );
+               $this->assertSame(
+                       [],
+                       $processor->getRequirements( [], false )
+               );
+       }
+
+       public function testGetDevRequirements() {
+               $info = self::$default + [
+                       'dev-requires' => [
+                               'MediaWiki' => '>= 1.31.0',
+                               'platform' => [
+                                       'ext-foo' => '*',
+                               ],
+                               'skins' => [
+                                       'Baz' => '*',
+                               ],
+                               'extensions' => [
+                                       'Biz' => '*',
+                               ],
+                       ],
+               ];
+               $processor = new ExtensionProcessor();
+               $this->assertSame(
+                       $info['dev-requires'],
+                       $processor->getRequirements( $info, true )
+               );
+               // Set some standard requirements, so we can test merging
+               $info['requires'] = [
+                       'MediaWiki' => '>= 1.25.0',
+                       'platform' => [
+                               'php' => '>= 5.5.9'
+                       ],
+                       'extensions' => [
+                               'Bar' => '*'
+                       ]
+               ];
+               $this->assertSame(
+                       [
+                               'MediaWiki' => '>= 1.25.0 >= 1.31.0',
+                               'platform' => [
+                                       'php' => '>= 5.5.9',
+                                       'ext-foo' => '*',
+                               ],
+                               'extensions' => [
+                                       'Bar' => '*',
+                                       'Biz' => '*',
+                               ],
+                               'skins' => [
+                                       'Baz' => '*',
+                               ],
+                       ],
+                       $processor->getRequirements( $info, true )
+               );
+
+               // If there's no dev-requires, it just returns requires
+               unset( $info['dev-requires'] );
+               $this->assertSame(
+                       $info['requires'],
+                       $processor->getRequirements( $info, true )
+               );
+       }
+
+       public function testGetExtraAutoloaderPaths() {
+               $processor = new ExtensionProcessor();
+               $this->assertSame(
+                       [ "{$this->dirname}/vendor/autoload.php" ],
+                       $processor->getExtraAutoloaderPaths( $this->dirname, [
+                               'load_composer_autoloader' => true,
+                       ] )
+               );
+       }
+
+       /**
+        * Verify that extension.schema.json is in sync with ExtensionProcessor
+        *
+        * @coversNothing
+        */
+       public function testGlobalSettingsDocumentedInSchema() {
+               global $IP;
+               $globalSettings = TestingAccessWrapper::newFromClass(
+                       ExtensionProcessor::class )->globalSettings;
+
+               $version = ExtensionRegistry::MANIFEST_VERSION;
+               $schema = FormatJson::decode(
+                       file_get_contents( "$IP/docs/extension.schema.v$version.json" ),
+                       true
+               );
+               $missing = [];
+               foreach ( $globalSettings as $global ) {
+                       if ( !isset( $schema['properties'][$global] ) ) {
+                               $missing[] = $global;
+                       }
+               }
+
+               $this->assertEquals( [], $missing,
+                       "The following global settings are not documented in docs/extension.schema.json" );
+       }
+}
+
+/**
+ * Allow overriding the default value of $this->globals
+ * so we can test merging
+ */
+class MockExtensionProcessor extends ExtensionProcessor {
+       public function __construct( $globals = [] ) {
+               $this->globals = $globals + $this->globals;
+       }
+}
diff --git a/tests/phpunit/unit/includes/search/SearchIndexFieldTest.php b/tests/phpunit/unit/includes/search/SearchIndexFieldTest.php
new file mode 100644 (file)
index 0000000..a640c96
--- /dev/null
@@ -0,0 +1,56 @@
+<?php
+
+/**
+ * @group Search
+ * @covers SearchIndexFieldDefinition
+ */
+class SearchIndexFieldTest extends \MediaWikiUnitTestCase {
+
+       public function getMergeCases() {
+               return [
+                       [ 0, 'test', 0, 'test', true ],
+                       [ SearchIndexField::INDEX_TYPE_NESTED, 'test',
+                               SearchIndexField::INDEX_TYPE_NESTED, 'test', false ],
+                       [ 0, 'test', 0, 'test2', true ],
+                       [ 0, 'test', 1, 'test', false ],
+               ];
+       }
+
+       /**
+        * @dataProvider getMergeCases
+        * @param int $t1
+        * @param string $n1
+        * @param int $t2
+        * @param string $n2
+        * @param bool $result
+        */
+       public function testMerge( $t1, $n1, $t2, $n2, $result ) {
+               $field1 =
+                       $this->getMockBuilder( SearchIndexFieldDefinition::class )
+                               ->setMethods( [ 'getMapping' ] )
+                               ->setConstructorArgs( [ $n1, $t1 ] )
+                               ->getMock();
+               $field2 =
+                       $this->getMockBuilder( SearchIndexFieldDefinition::class )
+                               ->setMethods( [ 'getMapping' ] )
+                               ->setConstructorArgs( [ $n2, $t2 ] )
+                               ->getMock();
+
+               if ( $result ) {
+                       $this->assertNotFalse( $field1->merge( $field2 ) );
+               } else {
+                       $this->assertFalse( $field1->merge( $field2 ) );
+               }
+
+               $field1->setFlag( 0xFF );
+               $this->assertFalse( $field1->merge( $field2 ) );
+
+               $field1->setMergeCallback(
+                       function ( $a, $b ) {
+                               return "test";
+                       }
+               );
+               $this->assertEquals( "test", $field1->merge( $field2 ) );
+       }
+
+}
diff --git a/tests/phpunit/unit/includes/session/MetadataMergeExceptionTest.php b/tests/phpunit/unit/includes/session/MetadataMergeExceptionTest.php
new file mode 100644 (file)
index 0000000..707adfe
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+
+namespace MediaWiki\Session;
+
+/**
+ * @group Session
+ * @covers MediaWiki\Session\MetadataMergeException
+ */
+class MetadataMergeExceptionTest extends \MediaWikiUnitTestCase {
+
+       public function testBasics() {
+               $data = [ 'foo' => 'bar' ];
+
+               $ex = new MetadataMergeException();
+               $this->assertInstanceOf( \UnexpectedValueException::class, $ex );
+               $this->assertSame( [], $ex->getContext() );
+
+               $ex2 = new MetadataMergeException( 'Message', 42, $ex, $data );
+               $this->assertSame( 'Message', $ex2->getMessage() );
+               $this->assertSame( 42, $ex2->getCode() );
+               $this->assertSame( $ex, $ex2->getPrevious() );
+               $this->assertSame( $data, $ex2->getContext() );
+
+               $ex->setContext( $data );
+               $this->assertSame( $data, $ex->getContext() );
+       }
+
+}
diff --git a/tests/phpunit/unit/includes/session/SessionIdTest.php b/tests/phpunit/unit/includes/session/SessionIdTest.php
new file mode 100644 (file)
index 0000000..3c7f8cb
--- /dev/null
@@ -0,0 +1,20 @@
+<?php
+
+namespace MediaWiki\Session;
+
+/**
+ * @group Session
+ * @covers MediaWiki\Session\SessionId
+ */
+class SessionIdTest extends \MediaWikiUnitTestCase {
+
+       public function testEverything() {
+               $id = new SessionId( 'foo' );
+               $this->assertSame( 'foo', $id->getId() );
+               $this->assertSame( 'foo', (string)$id );
+               $id->setId( 'bar' );
+               $this->assertSame( 'bar', $id->getId() );
+               $this->assertSame( 'bar', (string)$id );
+       }
+
+}
diff --git a/tests/phpunit/unit/includes/site/CachingSiteStoreTest.php b/tests/phpunit/unit/includes/site/CachingSiteStoreTest.php
new file mode 100644 (file)
index 0000000..92ed1f5
--- /dev/null
@@ -0,0 +1,167 @@
+<?php
+
+/**
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @since 1.25
+ *
+ * @ingroup Site
+ * @ingroup Test
+ *
+ * @group Site
+ * @group Database
+ *
+ * @author Jeroen De Dauw < jeroendedauw@gmail.com >
+ */
+class CachingSiteStoreTest extends \MediaWikiUnitTestCase {
+
+       /**
+        * @covers CachingSiteStore::getSites
+        */
+       public function testGetSites() {
+               $testSites = TestSites::getSites();
+
+               $store = new CachingSiteStore(
+                       $this->getHashSiteStore( $testSites ),
+                       ObjectCache::getLocalClusterInstance()
+               );
+
+               $sites = $store->getSites();
+
+               $this->assertInstanceOf( SiteList::class, $sites );
+
+               /**
+                * @var Site $site
+                */
+               foreach ( $sites as $site ) {
+                       $this->assertInstanceOf( Site::class, $site );
+               }
+
+               foreach ( $testSites as $site ) {
+                       if ( $site->getGlobalId() !== null ) {
+                               $this->assertTrue( $sites->hasSite( $site->getGlobalId() ) );
+                       }
+               }
+       }
+
+       /**
+        * @covers CachingSiteStore::saveSites
+        */
+       public function testSaveSites() {
+               $store = new CachingSiteStore(
+                       new HashSiteStore(), ObjectCache::getLocalClusterInstance()
+               );
+
+               $sites = [];
+
+               $site = new Site();
+               $site->setGlobalId( 'ertrywuutr' );
+               $site->setLanguageCode( 'en' );
+               $sites[] = $site;
+
+               $site = new MediaWikiSite();
+               $site->setGlobalId( 'sdfhxujgkfpth' );
+               $site->setLanguageCode( 'nl' );
+               $sites[] = $site;
+
+               $this->assertTrue( $store->saveSites( $sites ) );
+
+               $site = $store->getSite( 'ertrywuutr' );
+               $this->assertInstanceOf( Site::class, $site );
+               $this->assertEquals( 'en', $site->getLanguageCode() );
+
+               $site = $store->getSite( 'sdfhxujgkfpth' );
+               $this->assertInstanceOf( Site::class, $site );
+               $this->assertEquals( 'nl', $site->getLanguageCode() );
+       }
+
+       /**
+        * @covers CachingSiteStore::reset
+        */
+       public function testReset() {
+               $dbSiteStore = $this->getMockBuilder( SiteStore::class )
+                       ->disableOriginalConstructor()
+                       ->getMock();
+
+               $dbSiteStore->expects( $this->any() )
+                       ->method( 'getSite' )
+                       ->will( $this->returnValue( $this->getTestSite() ) );
+
+               $dbSiteStore->expects( $this->any() )
+                       ->method( 'getSites' )
+                       ->will( $this->returnCallback( function () {
+                               $siteList = new SiteList();
+                               $siteList->setSite( $this->getTestSite() );
+
+                               return $siteList;
+                       } ) );
+
+               $store = new CachingSiteStore( $dbSiteStore, ObjectCache::getLocalClusterInstance() );
+
+               // initialize internal cache
+               $this->assertGreaterThan( 0, $store->getSites()->count(), 'count sites' );
+
+               $store->getSite( 'enwiki' )->setLanguageCode( 'en-ca' );
+
+               // sanity check: $store should have the new language code for 'enwiki'
+               $this->assertEquals( 'en-ca', $store->getSite( 'enwiki' )->getLanguageCode(), 'sanity check' );
+
+               // purge cache
+               $store->reset();
+
+               // the internal cache of $store should be updated, and now pulling
+               // the site from the 'fallback' DBSiteStore with the original language code.
+               $this->assertEquals( 'en', $store->getSite( 'enwiki' )->getLanguageCode(), 'reset' );
+       }
+
+       public function getTestSite() {
+               $enwiki = new MediaWikiSite();
+               $enwiki->setGlobalId( 'enwiki' );
+               $enwiki->setLanguageCode( 'en' );
+
+               return $enwiki;
+       }
+
+       /**
+        * @covers CachingSiteStore::clear
+        */
+       public function testClear() {
+               $store = new CachingSiteStore(
+                       new HashSiteStore(), ObjectCache::getLocalClusterInstance()
+               );
+               $this->assertTrue( $store->clear() );
+
+               $site = $store->getSite( 'enwiki' );
+               $this->assertNull( $site );
+
+               $sites = $store->getSites();
+               $this->assertEquals( 0, $sites->count() );
+       }
+
+       /**
+        * @param Site[] $sites
+        *
+        * @return SiteStore
+        */
+       private function getHashSiteStore( array $sites ) {
+               $siteStore = new HashSiteStore();
+               $siteStore->saveSites( $sites );
+
+               return $siteStore;
+       }
+
+}
diff --git a/tests/phpunit/unit/includes/site/HashSiteStoreTest.php b/tests/phpunit/unit/includes/site/HashSiteStoreTest.php
new file mode 100644 (file)
index 0000000..8b0d4e0
--- /dev/null
@@ -0,0 +1,105 @@
+<?php
+
+/**
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @since 1.25
+ *
+ * @ingroup Site
+ * @group Site
+ *
+ * @author Katie Filbert < aude.wiki@gmail.com >
+ */
+class HashSiteStoreTest extends \MediaWikiUnitTestCase {
+
+       /**
+        * @covers HashSiteStore::getSites
+        */
+       public function testGetSites() {
+               $expectedSites = [];
+
+               foreach ( TestSites::getSites() as $testSite ) {
+                       $siteId = $testSite->getGlobalId();
+                       $expectedSites[$siteId] = $testSite;
+               }
+
+               $siteStore = new HashSiteStore( $expectedSites );
+
+               $this->assertEquals( new SiteList( $expectedSites ), $siteStore->getSites() );
+       }
+
+       /**
+        * @covers HashSiteStore::saveSite
+        * @covers HashSiteStore::getSite
+        */
+       public function testSaveSite() {
+               $store = new HashSiteStore();
+
+               $site = new Site();
+               $site->setGlobalId( 'dewiki' );
+
+               $this->assertCount( 0, $store->getSites(), '0 sites in store' );
+
+               $store->saveSite( $site );
+
+               $this->assertCount( 1, $store->getSites(), 'Store has 1 sites' );
+               $this->assertEquals( $site, $store->getSite( 'dewiki' ), 'Store has dewiki' );
+       }
+
+       /**
+        * @covers HashSiteStore::saveSites
+        */
+       public function testSaveSites() {
+               $store = new HashSiteStore();
+
+               $sites = [];
+
+               $site = new Site();
+               $site->setGlobalId( 'enwiki' );
+               $site->setLanguageCode( 'en' );
+               $sites[] = $site;
+
+               $site = new MediaWikiSite();
+               $site->setGlobalId( 'eswiki' );
+               $site->setLanguageCode( 'es' );
+               $sites[] = $site;
+
+               $this->assertCount( 0, $store->getSites(), '0 sites in store' );
+
+               $store->saveSites( $sites );
+
+               $this->assertCount( 2, $store->getSites(), 'Store has 2 sites' );
+               $this->assertTrue( $store->getSites()->hasSite( 'enwiki' ), 'Store has enwiki' );
+               $this->assertTrue( $store->getSites()->hasSite( 'eswiki' ), 'Store has eswiki' );
+       }
+
+       /**
+        * @covers HashSiteStore::clear
+        */
+       public function testClear() {
+               $store = new HashSiteStore();
+
+               $site = new Site();
+               $site->setGlobalId( 'arwiki' );
+               $store->saveSite( $site );
+
+               $this->assertCount( 1, $store->getSites(), '1 site in store' );
+
+               $store->clear();
+               $this->assertCount( 0, $store->getSites(), '0 sites in store' );
+       }
+}
diff --git a/tests/phpunit/unit/includes/skins/SkinFactoryTest.php b/tests/phpunit/unit/includes/skins/SkinFactoryTest.php
new file mode 100644 (file)
index 0000000..8443c8d
--- /dev/null
@@ -0,0 +1,82 @@
+<?php
+
+class SkinFactoryTest extends \MediaWikiUnitTestCase {
+
+       /**
+        * @covers SkinFactory::register
+        */
+       public function testRegister() {
+               $factory = new SkinFactory();
+               $factory->register( 'fallback', 'Fallback', function () {
+                       return new SkinFallback();
+               } );
+               $this->assertTrue( true ); // No exception thrown
+               $this->setExpectedException( InvalidArgumentException::class );
+               $factory->register( 'invalid', 'Invalid', 'Invalid callback' );
+       }
+
+       /**
+        * @covers SkinFactory::makeSkin
+        */
+       public function testMakeSkinWithNoBuilders() {
+               $factory = new SkinFactory();
+               $this->setExpectedException( SkinException::class );
+               $factory->makeSkin( 'nobuilderregistered' );
+       }
+
+       /**
+        * @covers SkinFactory::makeSkin
+        */
+       public function testMakeSkinWithInvalidCallback() {
+               $factory = new SkinFactory();
+               $factory->register( 'unittest', 'Unittest', function () {
+                       return true; // Not a Skin object
+               } );
+               $this->setExpectedException( UnexpectedValueException::class );
+               $factory->makeSkin( 'unittest' );
+       }
+
+       /**
+        * @covers SkinFactory::makeSkin
+        */
+       public function testMakeSkinWithValidCallback() {
+               $factory = new SkinFactory();
+               $factory->register( 'testfallback', 'TestFallback', function () {
+                       return new SkinFallback();
+               } );
+
+               $skin = $factory->makeSkin( 'testfallback' );
+               $this->assertInstanceOf( Skin::class, $skin );
+               $this->assertInstanceOf( SkinFallback::class, $skin );
+               $this->assertEquals( 'fallback', $skin->getSkinName() );
+       }
+
+       /**
+        * @covers Skin::__construct
+        * @covers Skin::getSkinName
+        */
+       public function testGetSkinName() {
+               $skin = new SkinFallback();
+               $this->assertEquals( 'fallback', $skin->getSkinName(), 'Default' );
+               $skin = new SkinFallback( 'testname' );
+               $this->assertEquals( 'testname', $skin->getSkinName(), 'Constructor argument' );
+       }
+
+       /**
+        * @covers SkinFactory::getSkinNames
+        */
+       public function testGetSkinNames() {
+               $factory = new SkinFactory();
+               // A fake callback we can use that will never be called
+               $callback = function () {
+                       // NOP
+               };
+               $factory->register( 'skin1', 'Skin1', $callback );
+               $factory->register( 'skin2', 'Skin2', $callback );
+               $names = $factory->getSkinNames();
+               $this->assertArrayHasKey( 'skin1', $names );
+               $this->assertArrayHasKey( 'skin2', $names );
+               $this->assertEquals( 'Skin1', $names['skin1'] );
+               $this->assertEquals( 'Skin2', $names['skin2'] );
+       }
+}
diff --git a/tests/phpunit/unit/includes/title/ForeignTitleTest.php b/tests/phpunit/unit/includes/title/ForeignTitleTest.php
new file mode 100644 (file)
index 0000000..ec093cf
--- /dev/null
@@ -0,0 +1,103 @@
+<?php
+/**
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @author This, that and the other
+ */
+
+/**
+ * @covers ForeignTitle
+ *
+ * @group Title
+ */
+class ForeignTitleTest extends \MediaWikiUnitTestCase {
+
+       public function basicProvider() {
+               return [
+                       [
+                               new ForeignTitle( 20, 'Contributor', 'JohnDoe' ),
+                               20, 'Contributor', 'JohnDoe'
+                       ],
+                       [
+                               new ForeignTitle( '1', 'Discussion', 'Capital' ),
+                               1, 'Discussion', 'Capital'
+                       ],
+                       [
+                               new ForeignTitle( 0, '', 'MainNamespace' ),
+                               0, '', 'MainNamespace'
+                       ],
+                       [
+                               new ForeignTitle( 4, 'Some ns', 'Article title with spaces' ),
+                               4, 'Some_ns', 'Article_title_with_spaces'
+                       ],
+               ];
+       }
+
+       /**
+        * @dataProvider basicProvider
+        */
+       public function testBasic( ForeignTitle $title, $expectedId, $expectedName,
+               $expectedText
+       ) {
+               $this->assertEquals( true, $title->isNamespaceIdKnown() );
+               $this->assertEquals( $expectedId, $title->getNamespaceId() );
+               $this->assertEquals( $expectedName, $title->getNamespaceName() );
+               $this->assertEquals( $expectedText, $title->getText() );
+       }
+
+       public function testUnknownNamespaceCheck() {
+               $title = new ForeignTitle( null, 'this', 'that' );
+
+               $this->assertEquals( false, $title->isNamespaceIdKnown() );
+               $this->assertEquals( 'this', $title->getNamespaceName() );
+               $this->assertEquals( 'that', $title->getText() );
+       }
+
+       public function testUnknownNamespaceError() {
+               $this->setExpectedException( MWException::class );
+               $title = new ForeignTitle( null, 'this', 'that' );
+               $title->getNamespaceId();
+       }
+
+       public function fullTextProvider() {
+               return [
+                       [
+                               new ForeignTitle( 20, 'Contributor', 'JohnDoe' ),
+                               'Contributor:JohnDoe'
+                       ],
+                       [
+                               new ForeignTitle( '1', 'Discussion', 'Capital' ),
+                               'Discussion:Capital'
+                       ],
+                       [
+                               new ForeignTitle( 0, '', 'MainNamespace' ),
+                               'MainNamespace'
+                       ],
+                       [
+                               new ForeignTitle( 4, 'Some ns', 'Article title with spaces' ),
+                               'Some_ns:Article_title_with_spaces'
+                       ],
+               ];
+       }
+
+       /**
+        * @dataProvider fullTextProvider
+        */
+       public function testFullText( ForeignTitle $title, $fullText ) {
+               $this->assertEquals( $fullText, $title->getFullText() );
+       }
+}
diff --git a/tests/phpunit/unit/includes/title/NamespaceAwareForeignTitleFactoryTest.php b/tests/phpunit/unit/includes/title/NamespaceAwareForeignTitleFactoryTest.php
new file mode 100644 (file)
index 0000000..d777973
--- /dev/null
@@ -0,0 +1,101 @@
+<?php
+/**
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @author This, that and the other
+ */
+
+/**
+ * @covers NamespaceAwareForeignTitleFactory
+ *
+ * @group Title
+ */
+class NamespaceAwareForeignTitleFactoryTest extends \MediaWikiUnitTestCase {
+
+       public function basicProvider() {
+               return [
+                       [
+                               'MainNamespaceArticle', 0,
+                               new ForeignTitle( 0, '', 'MainNamespaceArticle' ),
+                       ],
+                       [
+                               'MainNamespaceArticle', null,
+                               new ForeignTitle( 0, '', 'MainNamespaceArticle' ),
+                       ],
+                       [
+                               'Magic:_The_Gathering', 0,
+                               new ForeignTitle( 0, '', 'Magic:_The_Gathering' ),
+                       ],
+                       [
+                               'Talk:Nice_talk', 1,
+                               new ForeignTitle( 1, 'Talk', 'Nice_talk' ),
+                       ],
+                       [
+                               'Talk:Magic:_The_Gathering', 1,
+                               new ForeignTitle( 1, 'Talk', 'Magic:_The_Gathering' ),
+                       ],
+                       [
+                               'Bogus:Nice_talk', 0,
+                               new ForeignTitle( 0, '', 'Bogus:Nice_talk' ),
+                       ],
+                       [
+                               'Bogus:Nice_talk', null,
+                               new ForeignTitle( 9000, 'Bogus', 'Nice_talk' ),
+                       ],
+                       [
+                               'Bogus:Nice_talk', 4,
+                               new ForeignTitle( 4, 'Bogus', 'Nice_talk' ),
+                       ],
+                       [
+                               'Bogus:Nice_talk', 1,
+                               new ForeignTitle( 1, 'Talk', 'Nice_talk' ),
+                       ],
+                       // Misconfigured wiki with unregistered namespace (T114115)
+                       [
+                               'Nice_talk', 1234,
+                               new ForeignTitle( 1234, 'Ns1234', 'Nice_talk' ),
+                       ],
+               ];
+       }
+
+       /**
+        * @dataProvider basicProvider
+        */
+       public function testBasic( $title, $ns, ForeignTitle $foreignTitle ) {
+               $foreignNamespaces = [
+                       0 => '', 1 => 'Talk', 100 => 'Portal', 9000 => 'Bogus'
+               ];
+
+               $factory = new NamespaceAwareForeignTitleFactory( $foreignNamespaces );
+               $testTitle = $factory->createForeignTitle( $title, $ns );
+
+               $this->assertEquals( $testTitle->isNamespaceIdKnown(),
+                       $foreignTitle->isNamespaceIdKnown() );
+
+               if (
+                       $testTitle->isNamespaceIdKnown() &&
+                       $foreignTitle->isNamespaceIdKnown()
+               ) {
+                       $this->assertEquals( $testTitle->getNamespaceId(),
+                               $foreignTitle->getNamespaceId() );
+               }
+
+               $this->assertEquals( $testTitle->getNamespaceName(),
+                       $foreignTitle->getNamespaceName() );
+               $this->assertEquals( $testTitle->getText(), $foreignTitle->getText() );
+       }
+}
diff --git a/tests/phpunit/unit/includes/title/TitleValueTest.php b/tests/phpunit/unit/includes/title/TitleValueTest.php
new file mode 100644 (file)
index 0000000..cd67a93
--- /dev/null
@@ -0,0 +1,149 @@
+<?php
+/**
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @author Daniel Kinzler
+ */
+
+/**
+ * @covers TitleValue
+ *
+ * @group Title
+ */
+class TitleValueTest extends \MediaWikiUnitTestCase {
+
+       public function goodConstructorProvider() {
+               return [
+                       [ NS_MAIN, '', 'fragment', '', true, false ],
+                       [ NS_USER, 'TestThis', 'stuff', '', true, false ],
+                       [ NS_USER, 'TestThis', '', 'baz', false, true ],
+               ];
+       }
+
+       /**
+        * @dataProvider goodConstructorProvider
+        */
+       public function testConstruction( $ns, $text, $fragment, $interwiki, $hasFragment,
+               $hasInterwiki
+       ) {
+               $title = new TitleValue( $ns, $text, $fragment, $interwiki );
+
+               $this->assertEquals( $ns, $title->getNamespace() );
+               $this->assertTrue( $title->inNamespace( $ns ) );
+               $this->assertEquals( $text, $title->getText() );
+               $this->assertEquals( $fragment, $title->getFragment() );
+               $this->assertEquals( $hasFragment, $title->hasFragment() );
+               $this->assertEquals( $interwiki, $title->getInterwiki() );
+               $this->assertEquals( $hasInterwiki, $title->isExternal() );
+       }
+
+       public function badConstructorProvider() {
+               return [
+                       [ 'foo', 'title', 'fragment', '' ],
+                       [ null, 'title', 'fragment', '' ],
+                       [ 2.3, 'title', 'fragment', '' ],
+
+                       [ NS_MAIN, 5, 'fragment', '' ],
+                       [ NS_MAIN, null, 'fragment', '' ],
+                       [ NS_USER, '', 'fragment', '' ],
+                       [ NS_MAIN, 'foo bar', '', '' ],
+                       [ NS_MAIN, 'bar_', '', '' ],
+                       [ NS_MAIN, '_foo', '', '' ],
+                       [ NS_MAIN, ' eek ', '', '' ],
+
+                       [ NS_MAIN, 'title', 5, '' ],
+                       [ NS_MAIN, 'title', null, '' ],
+                       [ NS_MAIN, 'title', [], '' ],
+
+                       [ NS_MAIN, 'title', '', 5 ],
+                       [ NS_MAIN, 'title', null, 5 ],
+                       [ NS_MAIN, 'title', [], 5 ],
+               ];
+       }
+
+       /**
+        * @dataProvider badConstructorProvider
+        */
+       public function testConstructionErrors( $ns, $text, $fragment, $interwiki ) {
+               $this->setExpectedException( InvalidArgumentException::class );
+               new TitleValue( $ns, $text, $fragment, $interwiki );
+       }
+
+       public function fragmentTitleProvider() {
+               return [
+                       [ new TitleValue( NS_MAIN, 'Test' ), 'foo' ],
+                       [ new TitleValue( NS_TALK, 'Test', 'foo' ), '' ],
+                       [ new TitleValue( NS_CATEGORY, 'Test', 'foo' ), 'bar' ],
+               ];
+       }
+
+       /**
+        * @dataProvider fragmentTitleProvider
+        */
+       public function testCreateFragmentTitle( TitleValue $title, $fragment ) {
+               $fragmentTitle = $title->createFragmentTarget( $fragment );
+
+               $this->assertEquals( $title->getNamespace(), $fragmentTitle->getNamespace() );
+               $this->assertEquals( $title->getText(), $fragmentTitle->getText() );
+               $this->assertEquals( $fragment, $fragmentTitle->getFragment() );
+       }
+
+       public function getTextProvider() {
+               return [
+                       [ 'Foo', 'Foo' ],
+                       [ 'Foo_Bar', 'Foo Bar' ],
+               ];
+       }
+
+       /**
+        * @dataProvider getTextProvider
+        */
+       public function testGetText( $dbkey, $text ) {
+               $title = new TitleValue( NS_MAIN, $dbkey );
+
+               $this->assertEquals( $text, $title->getText() );
+       }
+
+       public function provideTestToString() {
+               yield [
+                       new TitleValue( 0, 'Foo' ),
+                       '0:Foo'
+               ];
+               yield [
+                       new TitleValue( 1, 'Bar_Baz' ),
+                       '1:Bar_Baz'
+               ];
+               yield [
+                       new TitleValue( 9, 'JoJo', 'Frag' ),
+                       '9:JoJo#Frag'
+               ];
+               yield [
+                       new TitleValue( 200, 'tea', 'Fragment', 'wikicode' ),
+                       'wikicode:200:tea#Fragment'
+               ];
+       }
+
+       /**
+        * @dataProvider provideTestToString
+        */
+       public function testToString( TitleValue $value, $expected ) {
+               $this->assertSame(
+                       $expected,
+                       $value->__toString()
+               );
+       }
+}
diff --git a/tests/phpunit/unit/includes/user/UserArrayFromResultTest.php b/tests/phpunit/unit/includes/user/UserArrayFromResultTest.php
new file mode 100644 (file)
index 0000000..0b2ce17
--- /dev/null
@@ -0,0 +1,110 @@
+<?php
+
+/**
+ * @author Addshore
+ * @covers UserArrayFromResult
+ */
+class UserArrayFromResultTest extends \MediaWikiUnitTestCase {
+
+       private function getMockResultWrapper( $row = null, $numRows = 1 ) {
+               $resultWrapper = $this->getMockBuilder( Wikimedia\Rdbms\ResultWrapper::class )
+                       ->disableOriginalConstructor();
+
+               $resultWrapper = $resultWrapper->getMock();
+               $resultWrapper->expects( $this->atLeastOnce() )
+                       ->method( 'current' )
+                       ->will( $this->returnValue( $row ) );
+               $resultWrapper->expects( $this->any() )
+                       ->method( 'numRows' )
+                       ->will( $this->returnValue( $numRows ) );
+
+               return $resultWrapper;
+       }
+
+       private function getRowWithUsername( $username = 'fooUser' ) {
+               $row = new stdClass();
+               $row->user_name = $username;
+               return $row;
+       }
+
+       /**
+        * @covers UserArrayFromResult::__construct
+        */
+       public function testConstructionWithFalseRow() {
+               $row = false;
+               $resultWrapper = $this->getMockResultWrapper( $row );
+
+               $object = new UserArrayFromResult( $resultWrapper );
+
+               $this->assertEquals( $resultWrapper, $object->res );
+               $this->assertSame( 0, $object->key );
+               $this->assertEquals( $row, $object->current );
+       }
+
+       /**
+        * @covers UserArrayFromResult::__construct
+        */
+       public function testConstructionWithRow() {
+               $username = 'addshore';
+               $row = $this->getRowWithUsername( $username );
+               $resultWrapper = $this->getMockResultWrapper( $row );
+
+               $object = new UserArrayFromResult( $resultWrapper );
+
+               $this->assertEquals( $resultWrapper, $object->res );
+               $this->assertSame( 0, $object->key );
+               $this->assertInstanceOf( User::class, $object->current );
+               $this->assertEquals( $username, $object->current->mName );
+       }
+
+       public static function provideNumberOfRows() {
+               return [
+                       [ 0 ],
+                       [ 1 ],
+                       [ 122 ],
+               ];
+       }
+
+       /**
+        * @dataProvider provideNumberOfRows
+        * @covers UserArrayFromResult::count
+        */
+       public function testCountWithVaryingValues( $numRows ) {
+               $object = new UserArrayFromResult( $this->getMockResultWrapper(
+                       $this->getRowWithUsername(),
+                       $numRows
+               ) );
+               $this->assertEquals( $numRows, $object->count() );
+       }
+
+       /**
+        * @covers UserArrayFromResult::current
+        */
+       public function testCurrentAfterConstruction() {
+               $username = 'addshore';
+               $userRow = $this->getRowWithUsername( $username );
+               $object = new UserArrayFromResult( $this->getMockResultWrapper( $userRow ) );
+               $this->assertInstanceOf( User::class, $object->current() );
+               $this->assertEquals( $username, $object->current()->mName );
+       }
+
+       public function provideTestValid() {
+               return [
+                       [ $this->getRowWithUsername(), true ],
+                       [ false, false ],
+               ];
+       }
+
+       /**
+        * @dataProvider provideTestValid
+        * @covers UserArrayFromResult::valid
+        */
+       public function testValid( $input, $expected ) {
+               $object = new UserArrayFromResult( $this->getMockResultWrapper( $input ) );
+               $this->assertEquals( $expected, $object->valid() );
+       }
+
+       // @todo unit test for key()
+       // @todo unit test for next()
+       // @todo unit test for rewind()
+}
diff --git a/tests/phpunit/unit/includes/watcheditem/NoWriteWatchedItemStoreUnitTest.php b/tests/phpunit/unit/includes/watcheditem/NoWriteWatchedItemStoreUnitTest.php
new file mode 100644 (file)
index 0000000..556f518
--- /dev/null
@@ -0,0 +1,250 @@
+<?php
+
+use MediaWiki\User\UserIdentityValue;
+
+/**
+ * @author Addshore
+ *
+ * @covers NoWriteWatchedItemStore
+ */
+class NoWriteWatchedItemStoreUnitTest extends \MediaWikiUnitTestCase {
+
+       public function testAddWatch() {
+               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
+               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
+               $innerService->expects( $this->never() )->method( 'addWatch' );
+               $noWriteService = new NoWriteWatchedItemStore( $innerService );
+
+               $this->setExpectedException( DBReadOnlyError::class );
+               $noWriteService->addWatch(
+                       new UserIdentityValue( 1, 'MockUser', 0 ), new TitleValue( 0, 'Foo' ) );
+       }
+
+       public function testAddWatchBatchForUser() {
+               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
+               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
+               $innerService->expects( $this->never() )->method( 'addWatchBatchForUser' );
+               $noWriteService = new NoWriteWatchedItemStore( $innerService );
+
+               $this->setExpectedException( DBReadOnlyError::class );
+               $noWriteService->addWatchBatchForUser( new UserIdentityValue( 1, 'MockUser', 0 ), [] );
+       }
+
+       public function testRemoveWatch() {
+               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
+               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
+               $innerService->expects( $this->never() )->method( 'removeWatch' );
+               $noWriteService = new NoWriteWatchedItemStore( $innerService );
+
+               $this->setExpectedException( DBReadOnlyError::class );
+               $noWriteService->removeWatch(
+                       new UserIdentityValue( 1, 'MockUser', 0 ), new TitleValue( 0, 'Foo' ) );
+       }
+
+       public function testSetNotificationTimestampsForUser() {
+               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
+               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
+               $innerService->expects( $this->never() )->method( 'setNotificationTimestampsForUser' );
+               $noWriteService = new NoWriteWatchedItemStore( $innerService );
+
+               $this->setExpectedException( DBReadOnlyError::class );
+               $noWriteService->setNotificationTimestampsForUser(
+                       new UserIdentityValue( 1, 'MockUser', 0 ),
+                       'timestamp',
+                       []
+               );
+       }
+
+       public function testUpdateNotificationTimestamp() {
+               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
+               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
+               $innerService->expects( $this->never() )->method( 'updateNotificationTimestamp' );
+               $noWriteService = new NoWriteWatchedItemStore( $innerService );
+
+               $this->setExpectedException( DBReadOnlyError::class );
+               $noWriteService->updateNotificationTimestamp(
+                       new UserIdentityValue( 1, 'MockUser', 0 ),
+                       new TitleValue( 0, 'Foo' ),
+                       'timestamp'
+               );
+       }
+
+       public function testResetNotificationTimestamp() {
+               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
+               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
+               $innerService->expects( $this->never() )->method( 'resetNotificationTimestamp' );
+               $noWriteService = new NoWriteWatchedItemStore( $innerService );
+
+               $this->setExpectedException( DBReadOnlyError::class );
+               $noWriteService->resetNotificationTimestamp(
+                       new UserIdentityValue( 1, 'MockUser', 0 ),
+                       new TitleValue( 0, 'Foo' )
+               );
+       }
+
+       public function testCountWatchedItems() {
+               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
+               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
+               $innerService->expects( $this->once() )->method( 'countWatchedItems' )->willReturn( __METHOD__ );
+               $noWriteService = new NoWriteWatchedItemStore( $innerService );
+
+               $return = $noWriteService->countWatchedItems(
+                       new UserIdentityValue( 1, 'MockUser', 0 )
+               );
+               $this->assertEquals( __METHOD__, $return );
+       }
+
+       public function testCountWatchers() {
+               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
+               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
+               $innerService->expects( $this->once() )->method( 'countWatchers' )->willReturn( __METHOD__ );
+               $noWriteService = new NoWriteWatchedItemStore( $innerService );
+
+               $return = $noWriteService->countWatchers(
+                       new TitleValue( 0, 'Foo' )
+               );
+               $this->assertEquals( __METHOD__, $return );
+       }
+
+       public function testCountVisitingWatchers() {
+               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
+               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
+               $innerService->expects( $this->once() )
+                       ->method( 'countVisitingWatchers' )
+                       ->willReturn( __METHOD__ );
+               $noWriteService = new NoWriteWatchedItemStore( $innerService );
+
+               $return = $noWriteService->countVisitingWatchers(
+                       new TitleValue( 0, 'Foo' ),
+                       9
+               );
+               $this->assertEquals( __METHOD__, $return );
+       }
+
+       public function testCountWatchersMultiple() {
+               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
+               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
+               $innerService->expects( $this->once() )
+                       ->method( 'countVisitingWatchersMultiple' )
+                       ->willReturn( __METHOD__ );
+               $noWriteService = new NoWriteWatchedItemStore( $innerService );
+
+               $return = $noWriteService->countWatchersMultiple(
+                       [ new TitleValue( 0, 'Foo' ) ],
+                       []
+               );
+               $this->assertEquals( __METHOD__, $return );
+       }
+
+       public function testCountVisitingWatchersMultiple() {
+               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
+               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
+               $innerService->expects( $this->once() )
+                       ->method( 'countVisitingWatchersMultiple' )
+                       ->willReturn( __METHOD__ );
+               $noWriteService = new NoWriteWatchedItemStore( $innerService );
+
+               $return = $noWriteService->countVisitingWatchersMultiple(
+                       [ [ new TitleValue( 0, 'Foo' ), 99 ] ],
+                       11
+               );
+               $this->assertEquals( __METHOD__, $return );
+       }
+
+       public function testGetWatchedItem() {
+               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
+               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
+               $innerService->expects( $this->once() )->method( 'getWatchedItem' )->willReturn( __METHOD__ );
+               $noWriteService = new NoWriteWatchedItemStore( $innerService );
+
+               $return = $noWriteService->getWatchedItem(
+                       new UserIdentityValue( 1, 'MockUser', 0 ),
+                       new TitleValue( 0, 'Foo' )
+               );
+               $this->assertEquals( __METHOD__, $return );
+       }
+
+       public function testLoadWatchedItem() {
+               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
+               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
+               $innerService->expects( $this->once() )->method( 'loadWatchedItem' )->willReturn( __METHOD__ );
+               $noWriteService = new NoWriteWatchedItemStore( $innerService );
+
+               $return = $noWriteService->loadWatchedItem(
+                       new UserIdentityValue( 1, 'MockUser', 0 ),
+                       new TitleValue( 0, 'Foo' )
+               );
+               $this->assertEquals( __METHOD__, $return );
+       }
+
+       public function testGetWatchedItemsForUser() {
+               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
+               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
+               $innerService->expects( $this->once() )
+                       ->method( 'getWatchedItemsForUser' )
+                       ->willReturn( __METHOD__ );
+               $noWriteService = new NoWriteWatchedItemStore( $innerService );
+
+               $return = $noWriteService->getWatchedItemsForUser(
+                       new UserIdentityValue( 1, 'MockUser', 0 ),
+                       []
+               );
+               $this->assertEquals( __METHOD__, $return );
+       }
+
+       public function testIsWatched() {
+               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
+               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
+               $innerService->expects( $this->once() )->method( 'isWatched' )->willReturn( __METHOD__ );
+               $noWriteService = new NoWriteWatchedItemStore( $innerService );
+
+               $return = $noWriteService->isWatched(
+                       new UserIdentityValue( 1, 'MockUser', 0 ),
+                       new TitleValue( 0, 'Foo' )
+               );
+               $this->assertEquals( __METHOD__, $return );
+       }
+
+       public function testGetNotificationTimestampsBatch() {
+               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
+               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
+               $innerService->expects( $this->once() )
+                       ->method( 'getNotificationTimestampsBatch' )
+                       ->willReturn( __METHOD__ );
+               $noWriteService = new NoWriteWatchedItemStore( $innerService );
+
+               $return = $noWriteService->getNotificationTimestampsBatch(
+                       new UserIdentityValue( 1, 'MockUser', 0 ),
+                       [ new TitleValue( 0, 'Foo' ) ]
+               );
+               $this->assertEquals( __METHOD__, $return );
+       }
+
+       public function testCountUnreadNotifications() {
+               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
+               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
+               $innerService->expects( $this->once() )
+                       ->method( 'countUnreadNotifications' )
+                       ->willReturn( __METHOD__ );
+               $noWriteService = new NoWriteWatchedItemStore( $innerService );
+
+               $return = $noWriteService->countUnreadNotifications(
+                       new UserIdentityValue( 1, 'MockUser', 0 ),
+                       88
+               );
+               $this->assertEquals( __METHOD__, $return );
+       }
+
+       public function testDuplicateAllAssociatedEntries() {
+               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
+               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
+               $noWriteService = new NoWriteWatchedItemStore( $innerService );
+
+               $this->setExpectedException( DBReadOnlyError::class );
+               $noWriteService->duplicateAllAssociatedEntries(
+                       new TitleValue( 0, 'Foo' ),
+                       new TitleValue( 0, 'Bar' )
+               );
+       }
+
+}