From 0a2b996278e57a8b8c5377cd3a3eaa54f993d4a9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?M=C3=A1t=C3=A9=20Szab=C3=B3?= Date: Sat, 1 Jun 2019 16:10:15 +0200 Subject: [PATCH] Separate MediaWiki unit and integration tests This changeset implements T89432 and related tickets and is based on exploration done at the Prague Hackathon. The goal is to identify tests in MediaWiki core that can be run without having to install & configure MediaWiki and its dependencies, and provide a way to execute these tests via the standard phpunit entry point, allowing for faster development and integration with existing tooling like IDEs. The initial set of tests that met these criteria were identified using the work Amir did in I88822667693d9e00ac3d4639c87bc24e5083e5e8. These tests were then moved into a new subdirectory under phpunit/ and organized into a separate test suite. The environment for this suite is set up via a PHPUnit bootstrap file without a custom entry point. You can execute these tests by running: $ vendor/bin/phpunit -d memory_limit=512M -c tests/phpunit/unit-tests.xml Bug: T89432 Bug: T87781 Bug: T84948 Change-Id: Iad01033a0548afd4d2a6f2c1ef6fcc9debf72c0d --- .phpcs.xml | 1 + tests/common/TestSetup.php | 3 + tests/common/TestsAutoLoader.php | 3 +- tests/phpunit/MediaWikiUnitTestCase.php | 36 ++++++++++ .../includes/api/ApiBlockInfoTraitTest.php | 43 ------------ .../includes/exception/ReadOnlyErrorTest.php | 16 ----- tests/phpunit/structure/StructureTest.php | 1 + tests/phpunit/suite.xml | 11 ++++ tests/phpunit/unit-tests.xml | 49 ++++++++++++++ .../documentation/ReleaseNotesTest.php | 2 +- .../includes/CommentStoreCommentTest.php | 0 .../includes/DerivativeRequestTest.php | 0 .../{ => unit}/includes/FauxRequestTest.php | 0 .../{ => unit}/includes/FauxResponseTest.php | 2 +- .../FormOptionsInitializationTest.php | 2 +- .../{ => unit}/includes/FormOptionsTest.php | 2 +- .../GlobalFunctions/wfAppendQueryTest.php | 2 +- .../GlobalFunctions/wfArrayPlus2dTest.php | 2 +- .../GlobalFunctions/wfAssembleUrlTest.php | 2 +- .../GlobalFunctions/wfBaseNameTest.php | 2 +- .../GlobalFunctions/wfEscapeShellArgTest.php | 2 +- .../GlobalFunctions/wfGetCallerTest.php | 2 +- .../wfRemoveDotSegmentsTest.php | 2 +- .../GlobalFunctions/wfShellExecTest.php | 2 +- .../wfShorthandToIntegerTest.php | 2 +- .../GlobalFunctions/wfStringToBoolTest.php | 2 +- .../GlobalFunctions/wfTimestampTest.php | 2 +- .../GlobalFunctions/wfUrlencodeTest.php | 2 +- .../phpunit/{ => unit}/includes/HooksTest.php | 2 +- .../{ => unit}/includes/LicensesTest.php | 2 +- .../{ => unit}/includes/ListToggleTest.php | 2 +- .../includes/MagicWordFactoryTest.php | 2 +- .../includes/MediaWikiServicesTest.php | 14 ++-- .../includes/MediaWikiVersionFetcherTest.php | 2 +- .../{ => unit}/includes/PathRouterTest.php | 2 +- .../Revision/FallbackSlotRoleHandlerTest.php | 3 +- .../Revision/MainSlotRoleHandlerTest.php | 3 +- .../Revision/RevisionStoreFactoryTest.php | 3 +- .../includes/Revision/SlotRecordTest.php | 3 +- .../includes/Revision/SlotRoleHandlerTest.php | 3 +- .../includes/SanitizerValidateEmailTest.php | 0 .../{ => unit}/includes/ServiceWiringTest.php | 2 +- .../includes/SiteConfigurationTest.php | 2 +- .../includes/Storage/BlobStoreFactoryTest.php | 30 ++++++++- .../includes/Storage/PreparedEditTest.php | 3 +- .../includes/TitleArrayFromResultTest.php | 0 .../{ => unit}/includes/WikiReferenceTest.php | 0 .../phpunit/{ => unit}/includes/XmlJsTest.php | 0 .../{ => unit}/includes/XmlSelectTest.php | 2 +- .../includes/actions/ViewActionTest.php | 2 +- .../includes/api/ApiBlockInfoTraitTest.php | 66 +++++++++++++++++++ .../api/ApiContinuationManagerTest.php | 2 +- .../includes/api/ApiMessageTest.php | 2 +- .../{ => unit}/includes/api/ApiResultTest.php | 2 +- .../includes/api/ApiUsageExceptionTest.php | 2 +- .../AbstractPreAuthenticationProviderTest.php | 2 +- ...actSecondaryAuthenticationProviderTest.php | 2 +- .../auth/AuthenticationResponseTest.php | 2 +- ...inkSecondaryAuthenticationProviderTest.php | 2 +- ...ionSecondaryAuthenticationProviderTest.php | 29 +++++++- .../changes/ChangesListFilterGroupTest.php | 2 +- .../CustomUppercaseCollationTest.php | 2 +- .../ComposerVersionNormalizerTest.php | 0 .../includes/config/ConfigFactoryTest.php | 2 +- .../includes/config/EtcdConfigTest.php | 0 .../includes/config/HashConfigTest.php | 2 +- .../includes/config/MultiConfigTest.php | 2 +- .../includes/config/ServiceOptionsTest.php | 2 +- .../content/JsonContentHandlerTest.php | 2 +- .../includes/db/DatabaseOracleTest.php | 0 .../{ => unit}/includes/debug/MWDebugTest.php | 2 +- .../includes/debug/logger/MonologSpiTest.php | 3 +- .../logger/monolog/AvroFormatterTest.php | 3 +- .../debug/logger/monolog/CeeFormatterTest.php | 0 .../debug/logger/monolog/KafkaHandlerTest.php | 3 +- .../logger/monolog/LineFormatterTest.php | 3 +- .../logger/monolog/LogstashFormatterTest.php | 0 .../deferred/MWCallableUpdateTest.php | 0 .../TransactionRoundDefiningUpdateTest.php | 0 .../includes/diff/ArrayDiffFormatterTest.php | 2 +- .../{ => unit}/includes/diff/DiffOpTest.php | 2 +- .../{ => unit}/includes/diff/DiffTest.php | 2 +- .../DifferenceEngineSlotDiffRendererTest.php | 0 .../includes/diff/SlotDiffRendererTest.php | 0 .../includes/exception/HttpErrorTest.php | 2 +- .../exception/MWExceptionHandlerTest.php | 2 +- .../includes/exception/ReadOnlyErrorTest.php | 25 +++++++ .../exception/UserNotLoggedInTest.php | 2 +- .../ExternalStoreFactoryTest.php | 0 .../filebackend/SwiftFileBackendTest.php | 2 +- .../filerepo/FileBackendDBRepoWrapperTest.php | 2 +- .../includes/filerepo/FileRepoTest.php | 2 +- .../HTMLAutoCompleteSelectFieldTest.php | 2 +- .../includes/htmlform/HTMLCheckMatrixTest.php | 2 +- .../includes/htmlform/HTMLFormTest.php | 2 +- .../htmlform/HTMLRestrictionsFieldTest.php | 0 .../includes/http/GuzzleHttpRequestTest.php | 2 +- .../includes/http/HttpRequestFactoryTest.php | 2 +- .../installer/InstallDocFormatterTest.php | 2 +- .../installer/OracleInstallerTest.php | 2 +- .../interwiki/InterwikiLookupAdapterTest.php | 2 +- .../includes/jobqueue/JobQueueMemoryTest.php | 0 .../includes/json/FormatJsonTest.php | 2 +- .../includes/libs/ArrayUtilsTest.php | 0 .../{ => unit}/includes/libs/CookieTest.php | 0 .../includes/libs/DeferredStringifierTest.php | 0 .../includes/libs/DnsSrvDiscovererTest.php | 0 .../includes/libs/EasyDeflateTest.php | 0 .../includes/libs/GenericArrayObjectTest.php | 0 .../{ => unit}/includes/libs/HashRingTest.php | 0 .../includes/libs/HtmlArmorTest.php | 0 .../includes/libs/IEUrlExtensionTest.php | 0 .../{ => unit}/includes/libs/IPTest.php | 0 .../includes/libs/JavaScriptMinifierTest.php | 0 .../includes/libs/MapCacheLRUTest.php | 0 .../includes/libs/MemoizedCallableTest.php | 0 .../includes/libs/ProcessCacheLRUTest.php | 0 .../libs/SamplingStatsdClientTest.php | 0 .../includes/libs/StaticArrayWriterTest.php | 0 .../includes/libs/StringUtilsTest.php | 0 .../{ => unit}/includes/libs/TimingTest.php | 0 .../includes/libs/XhprofDataTest.php | 0 .../{ => unit}/includes/libs/XhprofTest.php | 0 .../includes/libs/XmlTypeCheckTest.php | 0 .../libs/composer/ComposerInstalledTest.php | 2 +- .../libs/composer/ComposerJsonTest.php | 4 +- .../libs/composer/ComposerLockTest.php | 2 +- .../libs/http/HttpAcceptNegotiatorTest.php | 0 .../libs/http/HttpAcceptParserTest.php | 0 .../libs/mime/MSCompoundFileReaderTest.php | 11 ++++ .../includes/libs/mime/MimeAnalyzerTest.php | 22 ++++--- .../libs/objectcache/CachedBagOStuffTest.php | 0 .../libs/objectcache/HashBagOStuffTest.php | 0 .../objectcache/ReplicatedBagOStuffTest.php | 2 +- .../libs/objectcache/WANObjectCacheTest.php | 0 .../libs/rdbms/ChronologyProtectorTest.php | 0 .../libs/rdbms/TransactionProfilerTest.php | 0 .../ConnectionManagerTest.php | 0 ...SessionConsistentConnectionManagerTest.php | 0 .../libs/rdbms/database/DBConnRefTest.php | 0 .../rdbms/database/DatabaseDomainTest.php | 0 .../libs/rdbms/database/DatabaseMssqlTest.php | 0 .../rdbms/database/DatabaseMysqlBaseTest.php | 0 .../libs/rdbms/database/DatabaseSQLTest.php | 0 .../database/DatabaseSqliteRdbmsTest.php | 0 .../libs/rdbms/database/DatabaseTest.php | 0 .../libs/services/ServiceContainerTest.php | 0 .../includes/libs/services/TestWiring1.php | 0 .../includes/libs/services/TestWiring2.php | 0 .../PrefixingStatsdDataFactoryProxyTest.php | 0 .../media/GIFMetadataExtractorTest.php | 4 +- .../{ => unit}/includes/media/IPTCTest.php | 2 +- .../media/JpegMetadataExtractorTest.php | 4 +- .../includes/media/MediaHandlerTest.php | 2 +- .../media/SVGMetadataExtractorTest.php | 6 +- .../includes/media/WebPHandlerTest.php | 18 ++--- .../objectcache/MemcachedBagOStuffTest.php | 2 +- .../objectcache/RESTBagOStuffTest.php | 2 +- .../objectcache/RedisBagOStuffTest.php | 0 .../{ => unit}/includes/page/ArticleTest.php | 2 +- .../includes/parser/ParserPreloadTest.php | 2 +- .../includes/parser/PreprocessorTest.php | 4 +- .../{ => unit}/includes/parser/TidyTest.php | 2 +- .../includes/password/PasswordFactoryTest.php | 2 +- .../includes/password/PasswordTest.php | 2 +- .../includes/preferences/FiltersTest.php | 2 +- .../ExtensionJsonValidatorTest.php | 4 +- .../registration/ExtensionProcessorTest.php | 2 +- .../registration/VersionCheckerTest.php | 0 .../DerivativeResourceLoaderContextTest.php | 0 .../resourceloader/MessageBlobStoreTest.php | 19 +++++- .../ResourceLoaderClientHtmlTest.php | 0 .../ResourceLoaderContextTest.php | 0 .../includes/search/SearchIndexFieldTest.php | 2 +- .../search/SearchSuggestionSetTest.php | 0 .../session/MetadataMergeExceptionTest.php | 4 +- .../includes/session/SessionIdTest.php | 4 +- .../includes/session/SessionInfoTest.php | 11 ++-- .../includes/session/SessionProviderTest.php | 3 +- .../includes/session/SessionTest.php | 3 +- .../{ => unit}/includes/session/TokenTest.php | 3 +- .../includes/shell/CommandFactoryTest.php | 0 .../{ => unit}/includes/shell/CommandTest.php | 0 .../includes/shell/FirejailCommandTest.php | 5 +- .../includes/site/CachingSiteStoreTest.php | 2 +- .../includes/site/HashSiteStoreTest.php | 2 +- .../site/MediaWikiPageNameNormalizerTest.php | 0 .../includes/site/SiteExporterTest.php | 2 +- .../includes/site/SiteImporterTest.php | 0 .../includes/site/SiteImporterTest.xml | 0 .../includes/skins/SkinFactoryTest.php | 2 +- .../includes/skins/SkinTemplateTest.php | 2 +- .../{ => unit}/includes/skins/SkinTest.php | 2 +- .../includes/sparql/SparqlClientTest.php | 0 .../includes/specials/ImageListPagerTest.php | 8 ++- .../includes/specials/SpecialUploadTest.php | 2 +- .../UncategorizedCategoriesPageTest.php | 19 +++++- .../includes/tidy/RemexDriverTest.php | 2 +- .../includes/tidy/html5lib-tests.json | 0 .../includes/title/ForeignTitleTest.php | 2 +- .../title/NaiveForeignTitleFactoryTest.php | 2 +- .../NamespaceAwareForeignTitleFactoryTest.php | 2 +- .../includes/title/TitleValueTest.php | 2 +- .../includes/user/UserArrayFromResultTest.php | 2 +- .../includes/utils/AvroValidatorTest.php | 0 .../includes/utils/BatchRowUpdateTest.php | 19 +++++- .../includes/utils/ClassCollectorTest.php | 0 .../includes/utils/FileContentsHasherTest.php | 2 +- .../includes/utils/MWCryptHashTest.php | 0 .../includes/utils/MWRestrictionsTest.php | 0 .../includes/utils/UIDGeneratorTest.php | 0 .../includes/utils/ZipDirectoryReaderTest.php | 2 +- .../NoWriteWatchedItemStoreUnitTest.php | 2 +- tests/phpunit/unit/initUnitTests.php | 56 ++++++++++++++++ .../languages/SpecialPageAliasTest.php | 2 +- .../structure/ApiPrefixUniquenessTest.php | 3 +- .../structure/AutoLoaderStructureTest.php | 8 ++- .../structure/ContentHandlerSanityTest.php | 5 +- .../structure/PasswordPolicyStructureTest.php | 5 +- 219 files changed, 551 insertions(+), 242 deletions(-) create mode 100644 tests/phpunit/MediaWikiUnitTestCase.php delete mode 100644 tests/phpunit/includes/api/ApiBlockInfoTraitTest.php delete mode 100644 tests/phpunit/includes/exception/ReadOnlyErrorTest.php create mode 100644 tests/phpunit/unit-tests.xml rename tests/phpunit/{ => unit}/documentation/ReleaseNotesTest.php (96%) rename tests/phpunit/{ => unit}/includes/CommentStoreCommentTest.php (100%) rename tests/phpunit/{ => unit}/includes/DerivativeRequestTest.php (100%) rename tests/phpunit/{ => unit}/includes/FauxRequestTest.php (100%) rename tests/phpunit/{ => unit}/includes/FauxResponseTest.php (98%) rename tests/phpunit/{ => unit}/includes/FormOptionsInitializationTest.php (94%) rename tests/phpunit/{ => unit}/includes/FormOptionsTest.php (97%) rename tests/phpunit/{ => unit}/includes/GlobalFunctions/wfAppendQueryTest.php (97%) rename tests/phpunit/{ => unit}/includes/GlobalFunctions/wfArrayPlus2dTest.php (96%) rename tests/phpunit/{ => unit}/includes/GlobalFunctions/wfAssembleUrlTest.php (97%) rename tests/phpunit/{ => unit}/includes/GlobalFunctions/wfBaseNameTest.php (94%) rename tests/phpunit/{ => unit}/includes/GlobalFunctions/wfEscapeShellArgTest.php (93%) rename tests/phpunit/{ => unit}/includes/GlobalFunctions/wfGetCallerTest.php (94%) rename tests/phpunit/{ => unit}/includes/GlobalFunctions/wfRemoveDotSegmentsTest.php (96%) rename tests/phpunit/{ => unit}/includes/GlobalFunctions/wfShellExecTest.php (89%) rename tests/phpunit/{ => unit}/includes/GlobalFunctions/wfShorthandToIntegerTest.php (91%) rename tests/phpunit/{ => unit}/includes/GlobalFunctions/wfStringToBoolTest.php (93%) rename tests/phpunit/{ => unit}/includes/GlobalFunctions/wfTimestampTest.php (99%) rename tests/phpunit/{ => unit}/includes/GlobalFunctions/wfUrlencodeTest.php (98%) rename tests/phpunit/{ => unit}/includes/HooksTest.php (99%) rename tests/phpunit/{ => unit}/includes/LicensesTest.php (90%) rename tests/phpunit/{ => unit}/includes/ListToggleTest.php (96%) rename tests/phpunit/{ => unit}/includes/MagicWordFactoryTest.php (97%) rename tests/phpunit/{ => unit}/includes/MediaWikiServicesTest.php (95%) rename tests/phpunit/{ => unit}/includes/MediaWikiVersionFetcherTest.php (88%) rename tests/phpunit/{ => unit}/includes/PathRouterTest.php (99%) rename tests/phpunit/{ => unit}/includes/Revision/FallbackSlotRoleHandlerTest.php (96%) rename tests/phpunit/{ => unit}/includes/Revision/MainSlotRoleHandlerTest.php (96%) rename tests/phpunit/{ => unit}/includes/Revision/RevisionStoreFactoryTest.php (98%) rename tests/phpunit/{ => unit}/includes/Revision/SlotRecordTest.php (99%) rename tests/phpunit/{ => unit}/includes/Revision/SlotRoleHandlerTest.php (96%) rename tests/phpunit/{ => unit}/includes/SanitizerValidateEmailTest.php (100%) rename tests/phpunit/{ => unit}/includes/ServiceWiringTest.php (85%) rename tests/phpunit/{ => unit}/includes/SiteConfigurationTest.php (99%) rename tests/phpunit/{ => unit}/includes/Storage/BlobStoreFactoryTest.php (58%) rename tests/phpunit/{ => unit}/includes/Storage/PreparedEditTest.php (83%) rename tests/phpunit/{ => unit}/includes/TitleArrayFromResultTest.php (100%) rename tests/phpunit/{ => unit}/includes/WikiReferenceTest.php (100%) rename tests/phpunit/{ => unit}/includes/XmlJsTest.php (100%) rename tests/phpunit/{ => unit}/includes/XmlSelectTest.php (98%) rename tests/phpunit/{ => unit}/includes/actions/ViewActionTest.php (92%) create mode 100644 tests/phpunit/unit/includes/api/ApiBlockInfoTraitTest.php rename tests/phpunit/{ => unit}/includes/api/ApiContinuationManagerTest.php (99%) rename tests/phpunit/{ => unit}/includes/api/ApiMessageTest.php (99%) rename tests/phpunit/{ => unit}/includes/api/ApiResultTest.php (99%) rename tests/phpunit/{ => unit}/includes/api/ApiUsageExceptionTest.php (96%) rename tests/phpunit/{ => unit}/includes/auth/AbstractPreAuthenticationProviderTest.php (93%) rename tests/phpunit/{ => unit}/includes/auth/AbstractSecondaryAuthenticationProviderTest.php (99%) rename tests/phpunit/{ => unit}/includes/auth/AuthenticationResponseTest.php (97%) rename tests/phpunit/{ => unit}/includes/auth/ConfirmLinkSecondaryAuthenticationProviderTest.php (99%) rename tests/phpunit/{ => unit}/includes/auth/EmailNotificationSecondaryAuthenticationProviderTest.php (86%) rename tests/phpunit/{ => unit}/includes/changes/ChangesListFilterGroupTest.php (95%) rename tests/phpunit/{ => unit}/includes/collation/CustomUppercaseCollationTest.php (95%) rename tests/phpunit/{ => unit}/includes/composer/ComposerVersionNormalizerTest.php (100%) rename tests/phpunit/{ => unit}/includes/config/ConfigFactoryTest.php (98%) rename tests/phpunit/{ => unit}/includes/config/EtcdConfigTest.php (100%) rename tests/phpunit/{ => unit}/includes/config/HashConfigTest.php (96%) rename tests/phpunit/{ => unit}/includes/config/MultiConfigTest.php (94%) rename tests/phpunit/{ => unit}/includes/config/ServiceOptionsTest.php (98%) rename tests/phpunit/{ => unit}/includes/content/JsonContentHandlerTest.php (82%) rename tests/phpunit/{ => unit}/includes/db/DatabaseOracleTest.php (100%) rename tests/phpunit/{ => unit}/includes/debug/MWDebugTest.php (98%) rename tests/phpunit/{ => unit}/includes/debug/logger/MonologSpiTest.php (97%) rename tests/phpunit/{ => unit}/includes/debug/logger/monolog/AvroFormatterTest.php (96%) rename tests/phpunit/{ => unit}/includes/debug/logger/monolog/CeeFormatterTest.php (100%) rename tests/phpunit/{ => unit}/includes/debug/logger/monolog/KafkaHandlerTest.php (98%) rename tests/phpunit/{ => unit}/includes/debug/logger/monolog/LineFormatterTest.php (98%) rename tests/phpunit/{ => unit}/includes/debug/logger/monolog/LogstashFormatterTest.php (100%) rename tests/phpunit/{ => unit}/includes/deferred/MWCallableUpdateTest.php (100%) rename tests/phpunit/{ => unit}/includes/deferred/TransactionRoundDefiningUpdateTest.php (100%) rename tests/phpunit/{ => unit}/includes/diff/ArrayDiffFormatterTest.php (98%) rename tests/phpunit/{ => unit}/includes/diff/DiffOpTest.php (96%) rename tests/phpunit/{ => unit}/includes/diff/DiffTest.php (83%) rename tests/phpunit/{ => unit}/includes/diff/DifferenceEngineSlotDiffRendererTest.php (100%) rename tests/phpunit/{ => unit}/includes/diff/SlotDiffRendererTest.php (100%) rename tests/phpunit/{ => unit}/includes/exception/HttpErrorTest.php (96%) rename tests/phpunit/{ => unit}/includes/exception/MWExceptionHandlerTest.php (96%) create mode 100644 tests/phpunit/unit/includes/exception/ReadOnlyErrorTest.php rename tests/phpunit/{ => unit}/includes/exception/UserNotLoggedInTest.php (83%) rename tests/phpunit/{ => unit}/includes/externalstore/ExternalStoreFactoryTest.php (100%) rename tests/phpunit/{ => unit}/includes/filebackend/SwiftFileBackendTest.php (98%) rename tests/phpunit/{ => unit}/includes/filerepo/FileBackendDBRepoWrapperTest.php (98%) rename tests/phpunit/{ => unit}/includes/filerepo/FileRepoTest.php (95%) rename tests/phpunit/{ => unit}/includes/htmlform/HTMLAutoCompleteSelectFieldTest.php (96%) rename tests/phpunit/{ => unit}/includes/htmlform/HTMLCheckMatrixTest.php (98%) rename tests/phpunit/{ => unit}/includes/htmlform/HTMLFormTest.php (96%) rename tests/phpunit/{ => unit}/includes/htmlform/HTMLRestrictionsFieldTest.php (100%) rename tests/phpunit/{ => unit}/includes/http/GuzzleHttpRequestTest.php (98%) rename tests/phpunit/{ => unit}/includes/http/HttpRequestFactoryTest.php (97%) rename tests/phpunit/{ => unit}/includes/installer/InstallDocFormatterTest.php (97%) rename tests/phpunit/{ => unit}/includes/installer/OracleInstallerTest.php (96%) rename tests/phpunit/{ => unit}/includes/interwiki/InterwikiLookupAdapterTest.php (98%) rename tests/phpunit/{ => unit}/includes/jobqueue/JobQueueMemoryTest.php (100%) rename tests/phpunit/{ => unit}/includes/json/FormatJsonTest.php (99%) rename tests/phpunit/{ => unit}/includes/libs/ArrayUtilsTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/CookieTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/DeferredStringifierTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/DnsSrvDiscovererTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/EasyDeflateTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/GenericArrayObjectTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/HashRingTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/HtmlArmorTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/IEUrlExtensionTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/IPTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/JavaScriptMinifierTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/MapCacheLRUTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/MemoizedCallableTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/ProcessCacheLRUTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/SamplingStatsdClientTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/StaticArrayWriterTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/StringUtilsTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/TimingTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/XhprofDataTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/XhprofTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/XmlTypeCheckTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/composer/ComposerInstalledTest.php (99%) rename tests/phpunit/{ => unit}/includes/libs/composer/ComposerJsonTest.php (85%) rename tests/phpunit/{ => unit}/includes/libs/composer/ComposerLockTest.php (97%) rename tests/phpunit/{ => unit}/includes/libs/http/HttpAcceptNegotiatorTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/http/HttpAcceptParserTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/mime/MSCompoundFileReaderTest.php (90%) rename tests/phpunit/{ => unit}/includes/libs/mime/MimeAnalyzerTest.php (86%) rename tests/phpunit/{ => unit}/includes/libs/objectcache/CachedBagOStuffTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/objectcache/HashBagOStuffTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/objectcache/ReplicatedBagOStuffTest.php (95%) rename tests/phpunit/{ => unit}/includes/libs/objectcache/WANObjectCacheTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/rdbms/ChronologyProtectorTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/rdbms/TransactionProfilerTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/rdbms/connectionmanager/ConnectionManagerTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/rdbms/connectionmanager/SessionConsistentConnectionManagerTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/rdbms/database/DBConnRefTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/rdbms/database/DatabaseDomainTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/rdbms/database/DatabaseMssqlTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/rdbms/database/DatabaseMysqlBaseTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/rdbms/database/DatabaseSQLTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/rdbms/database/DatabaseSqliteRdbmsTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/rdbms/database/DatabaseTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/services/ServiceContainerTest.php (100%) rename tests/phpunit/{ => unit}/includes/libs/services/TestWiring1.php (100%) rename tests/phpunit/{ => unit}/includes/libs/services/TestWiring2.php (100%) rename tests/phpunit/{ => unit}/includes/libs/stats/PrefixingStatsdDataFactoryProxyTest.php (100%) rename tests/phpunit/{ => unit}/includes/media/GIFMetadataExtractorTest.php (97%) rename tests/phpunit/{ => unit}/includes/media/IPTCTest.php (98%) rename tests/phpunit/{ => unit}/includes/media/JpegMetadataExtractorTest.php (97%) rename tests/phpunit/{ => unit}/includes/media/MediaHandlerTest.php (96%) rename tests/phpunit/{ => unit}/includes/media/SVGMetadataExtractorTest.php (96%) rename tests/phpunit/{ => unit}/includes/media/WebPHandlerTest.php (92%) rename tests/phpunit/{ => unit}/includes/objectcache/MemcachedBagOStuffTest.php (98%) rename tests/phpunit/{ => unit}/includes/objectcache/RESTBagOStuffTest.php (98%) rename tests/phpunit/{ => unit}/includes/objectcache/RedisBagOStuffTest.php (100%) rename tests/phpunit/{ => unit}/includes/page/ArticleTest.php (96%) rename tests/phpunit/{ => unit}/includes/parser/ParserPreloadTest.php (97%) rename tests/phpunit/{ => unit}/includes/parser/PreprocessorTest.php (99%) rename tests/phpunit/{ => unit}/includes/parser/TidyTest.php (97%) rename tests/phpunit/{ => unit}/includes/password/PasswordFactoryTest.php (98%) rename tests/phpunit/{ => unit}/includes/password/PasswordTest.php (95%) rename tests/phpunit/{ => unit}/includes/preferences/FiltersTest.php (98%) rename tests/phpunit/{ => unit}/includes/registration/ExtensionJsonValidatorTest.php (95%) rename tests/phpunit/{ => unit}/includes/registration/ExtensionProcessorTest.php (99%) rename tests/phpunit/{ => unit}/includes/registration/VersionCheckerTest.php (100%) rename tests/phpunit/{ => unit}/includes/resourceloader/DerivativeResourceLoaderContextTest.php (100%) rename tests/phpunit/{ => unit}/includes/resourceloader/MessageBlobStoreTest.php (92%) rename tests/phpunit/{ => unit}/includes/resourceloader/ResourceLoaderClientHtmlTest.php (100%) rename tests/phpunit/{ => unit}/includes/resourceloader/ResourceLoaderContextTest.php (100%) rename tests/phpunit/{ => unit}/includes/search/SearchIndexFieldTest.php (95%) rename tests/phpunit/{ => unit}/includes/search/SearchSuggestionSetTest.php (100%) rename tests/phpunit/{ => unit}/includes/session/MetadataMergeExceptionTest.php (88%) rename tests/phpunit/{ => unit}/includes/session/SessionIdTest.php (83%) rename tests/phpunit/{ => unit}/includes/session/SessionInfoTest.php (98%) rename tests/phpunit/{ => unit}/includes/session/SessionProviderTest.php (98%) rename tests/phpunit/{ => unit}/includes/session/SessionTest.php (99%) rename tests/phpunit/{ => unit}/includes/session/TokenTest.php (96%) rename tests/phpunit/{ => unit}/includes/shell/CommandFactoryTest.php (100%) rename tests/phpunit/{ => unit}/includes/shell/CommandTest.php (100%) rename tests/phpunit/{ => unit}/includes/shell/FirejailCommandTest.php (94%) rename tests/phpunit/{ => unit}/includes/site/CachingSiteStoreTest.php (98%) rename tests/phpunit/{ => unit}/includes/site/HashSiteStoreTest.php (97%) rename tests/phpunit/{ => unit}/includes/site/MediaWikiPageNameNormalizerTest.php (100%) rename tests/phpunit/{ => unit}/includes/site/SiteExporterTest.php (98%) rename tests/phpunit/{ => unit}/includes/site/SiteImporterTest.php (100%) rename tests/phpunit/{ => unit}/includes/site/SiteImporterTest.xml (100%) rename tests/phpunit/{ => unit}/includes/skins/SkinFactoryTest.php (97%) rename tests/phpunit/{ => unit}/includes/skins/SkinTemplateTest.php (97%) rename tests/phpunit/{ => unit}/includes/skins/SkinTest.php (89%) rename tests/phpunit/{ => unit}/includes/sparql/SparqlClientTest.php (100%) rename tests/phpunit/{ => unit}/includes/specials/ImageListPagerTest.php (70%) rename tests/phpunit/{ => unit}/includes/specials/SpecialUploadTest.php (91%) rename tests/phpunit/{ => unit}/includes/specials/UncategorizedCategoriesPageTest.php (75%) rename tests/phpunit/{ => unit}/includes/tidy/RemexDriverTest.php (99%) rename tests/phpunit/{ => unit}/includes/tidy/html5lib-tests.json (100%) rename tests/phpunit/{ => unit}/includes/title/ForeignTitleTest.php (98%) rename tests/phpunit/{ => unit}/includes/title/NaiveForeignTitleFactoryTest.php (97%) rename tests/phpunit/{ => unit}/includes/title/NamespaceAwareForeignTitleFactoryTest.php (97%) rename tests/phpunit/{ => unit}/includes/title/TitleValueTest.php (98%) rename tests/phpunit/{ => unit}/includes/user/UserArrayFromResultTest.php (97%) rename tests/phpunit/{ => unit}/includes/utils/AvroValidatorTest.php (100%) rename tests/phpunit/{ => unit}/includes/utils/BatchRowUpdateTest.php (91%) rename tests/phpunit/{ => unit}/includes/utils/ClassCollectorTest.php (100%) rename tests/phpunit/{ => unit}/includes/utils/FileContentsHasherTest.php (96%) rename tests/phpunit/{ => unit}/includes/utils/MWCryptHashTest.php (100%) rename tests/phpunit/{ => unit}/includes/utils/MWRestrictionsTest.php (100%) rename tests/phpunit/{ => unit}/includes/utils/UIDGeneratorTest.php (100%) rename tests/phpunit/{ => unit}/includes/utils/ZipDirectoryReaderTest.php (97%) rename tests/phpunit/{ => unit}/includes/watcheditem/NoWriteWatchedItemStoreUnitTest.php (99%) create mode 100644 tests/phpunit/unit/initUnitTests.php rename tests/phpunit/{ => unit}/languages/SpecialPageAliasTest.php (95%) rename tests/phpunit/{ => unit}/structure/ApiPrefixUniquenessTest.php (94%) rename tests/phpunit/{ => unit}/structure/AutoLoaderStructureTest.php (97%) rename tests/phpunit/{ => unit}/structure/ContentHandlerSanityTest.php (95%) rename tests/phpunit/{ => unit}/structure/PasswordPolicyStructureTest.php (92%) diff --git a/.phpcs.xml b/.phpcs.xml index 9ccf5657b7..1d5ce0b12c 100644 --- a/.phpcs.xml +++ b/.phpcs.xml @@ -179,6 +179,7 @@ */maintenance/storage/trackBlobs\.php */tests/phpunit/includes/GlobalFunctions/*\.php + */tests/phpunit/unit/includes/GlobalFunctions/*\.php */tests/phpunit/maintenance/*\.php diff --git a/tests/common/TestSetup.php b/tests/common/TestSetup.php index e24c4c5442..6d250be096 100644 --- a/tests/common/TestSetup.php +++ b/tests/common/TestSetup.php @@ -18,6 +18,9 @@ class TestSetup { global $wgSessionProviders, $wgSessionPbkdf2Iterations; global $wgJobTypeConf; global $wgAuthManagerConfig; + global $wgSecretKey; + + $wgSecretKey = 'secretsecretsecretsecretsecretsecretsecretsecretsecretsecretsecretsecretsecret'; // wfWarn should cause tests to fail $wgDevelopmentWarnings = true; diff --git a/tests/common/TestsAutoLoader.php b/tests/common/TestsAutoLoader.php index 861111a775..3eb8c9a721 100644 --- a/tests/common/TestsAutoLoader.php +++ b/tests/common/TestsAutoLoader.php @@ -60,6 +60,7 @@ $wgAutoloadClasses += [ 'MediaWikiPHPUnitResultPrinter' => "$testDir/phpunit/MediaWikiPHPUnitResultPrinter.php", 'MediaWikiPHPUnitTestListener' => "$testDir/phpunit/MediaWikiPHPUnitTestListener.php", 'MediaWikiTestCase' => "$testDir/phpunit/MediaWikiTestCase.php", + 'MediaWikiUnitTestCase' => "$testDir/phpunit/MediaWikiUnitTestCase.php", 'MediaWikiTestResult' => "$testDir/phpunit/MediaWikiTestResult.php", 'MediaWikiTestRunner' => "$testDir/phpunit/MediaWikiTestRunner.php", 'PHPUnit4And6Compat' => "$testDir/phpunit/PHPUnit4And6Compat.php", @@ -177,7 +178,7 @@ $wgAutoloadClasses += [ 'LanguageClassesTestCase' => "$testDir/phpunit/languages/LanguageClassesTestCase.php", # tests/phpunit/includes/libs - 'GenericArrayObjectTest' => "$testDir/phpunit/includes/libs/GenericArrayObjectTest.php", + 'GenericArrayObjectTest' => "$testDir/phpunit/unit/includes/libs/GenericArrayObjectTest.php", # tests/phpunit/maintenance 'MediaWiki\Tests\Maintenance\DumpAsserter' => "$testDir/phpunit/maintenance/DumpAsserter.php", diff --git a/tests/phpunit/MediaWikiUnitTestCase.php b/tests/phpunit/MediaWikiUnitTestCase.php new file mode 100644 index 0000000000..9ecc043187 --- /dev/null +++ b/tests/phpunit/MediaWikiUnitTestCase.php @@ -0,0 +1,36 @@ + $factory ) { + $services->disableService( $serviceName ); + $services->redefineService( $serviceName, $factory ); + } + + $this->mwServicesBackup = MediaWikiServices::forceGlobalInstance( $services ); + } + + protected function tearDown() { + parent::tearDown(); + + if ( $this->mwServicesBackup ) { + MediaWikiServices::forceGlobalInstance( $this->mwServicesBackup ); + } + } +} diff --git a/tests/phpunit/includes/api/ApiBlockInfoTraitTest.php b/tests/phpunit/includes/api/ApiBlockInfoTraitTest.php deleted file mode 100644 index ba5c003776..0000000000 --- a/tests/phpunit/includes/api/ApiBlockInfoTraitTest.php +++ /dev/null @@ -1,43 +0,0 @@ -getMockForTrait( ApiBlockInfoTrait::class ); - $info = TestingAccessWrapper::newFromObject( $mock )->getBlockDetails( $block ); - $subset = array_merge( [ - 'blockid' => null, - 'blockedby' => '', - 'blockedbyid' => 0, - 'blockreason' => '', - 'blockexpiry' => 'infinite', - ], $expectedInfo ); - $this->assertArraySubset( $subset, $info ); - } - - public static function provideGetBlockDetails() { - return [ - 'Sitewide block' => [ - new DatabaseBlock(), - [ 'blockpartial' => false ], - ], - 'Partial block' => [ - new DatabaseBlock( [ 'sitewide' => false ] ), - [ 'blockpartial' => true ], - ], - 'System block' => [ - new SystemBlock( [ 'systemBlock' => 'proxy' ] ), - [ 'systemblocktype' => 'proxy' ] - ], - ]; - } -} diff --git a/tests/phpunit/includes/exception/ReadOnlyErrorTest.php b/tests/phpunit/includes/exception/ReadOnlyErrorTest.php deleted file mode 100644 index ee5becffc6..0000000000 --- a/tests/phpunit/includes/exception/ReadOnlyErrorTest.php +++ /dev/null @@ -1,16 +0,0 @@ -assertEquals( 'readonly', $e->title ); - $this->assertEquals( 'readonlytext', $e->msg ); - $this->assertEquals( wfReadOnlyReason() ?: [], $e->params ); - } - -} diff --git a/tests/phpunit/structure/StructureTest.php b/tests/phpunit/structure/StructureTest.php index 412ee991f9..45eb216088 100644 --- a/tests/phpunit/structure/StructureTest.php +++ b/tests/phpunit/structure/StructureTest.php @@ -21,6 +21,7 @@ class StructureTest extends MediaWikiTestCase { 'ApiQueryContinueTestBase', 'MediaWikiLangTestCase', 'MediaWikiMediaTestCase', + 'MediaWikiUnitTestCase', 'MediaWikiTestCase', 'ResourceLoaderTestCase', 'PHPUnit_Framework_TestCase', diff --git a/tests/phpunit/suite.xml b/tests/phpunit/suite.xml index de68fec17e..6bec661933 100644 --- a/tests/phpunit/suite.xml +++ b/tests/phpunit/suite.xml @@ -56,6 +56,17 @@ documentation + + + + unit/includes + + + unit/languages + + + unit/structure + diff --git a/tests/phpunit/unit-tests.xml b/tests/phpunit/unit-tests.xml new file mode 100644 index 0000000000..149f1f25d3 --- /dev/null +++ b/tests/phpunit/unit-tests.xml @@ -0,0 +1,49 @@ + + + + + unit/includes + + + unit/languages + + + unit/structure + + + + + Utility + Broken + Stub + + + + + ../../includes + ../../languages + ../../maintenance + + ../../languages/messages + ../../languages/data/normalize-ar.php + ../../languages/data/normalize-ml.php + + + + diff --git a/tests/phpunit/documentation/ReleaseNotesTest.php b/tests/phpunit/unit/documentation/ReleaseNotesTest.php similarity index 96% rename from tests/phpunit/documentation/ReleaseNotesTest.php rename to tests/phpunit/unit/documentation/ReleaseNotesTest.php index d20fcff7b8..701cb56635 100644 --- a/tests/phpunit/documentation/ReleaseNotesTest.php +++ b/tests/phpunit/unit/documentation/ReleaseNotesTest.php @@ -3,7 +3,7 @@ /** * James doesn't like having to manually fix these things. */ -class ReleaseNotesTest extends MediaWikiTestCase { +class ReleaseNotesTest extends \MediaWikiUnitTestCase { /** * Verify that at least one Release Notes file exists, have content, and * aren't overly long. diff --git a/tests/phpunit/includes/CommentStoreCommentTest.php b/tests/phpunit/unit/includes/CommentStoreCommentTest.php similarity index 100% rename from tests/phpunit/includes/CommentStoreCommentTest.php rename to tests/phpunit/unit/includes/CommentStoreCommentTest.php diff --git a/tests/phpunit/includes/DerivativeRequestTest.php b/tests/phpunit/unit/includes/DerivativeRequestTest.php similarity index 100% rename from tests/phpunit/includes/DerivativeRequestTest.php rename to tests/phpunit/unit/includes/DerivativeRequestTest.php diff --git a/tests/phpunit/includes/FauxRequestTest.php b/tests/phpunit/unit/includes/FauxRequestTest.php similarity index 100% rename from tests/phpunit/includes/FauxRequestTest.php rename to tests/phpunit/unit/includes/FauxRequestTest.php diff --git a/tests/phpunit/includes/FauxResponseTest.php b/tests/phpunit/unit/includes/FauxResponseTest.php similarity index 98% rename from tests/phpunit/includes/FauxResponseTest.php rename to tests/phpunit/unit/includes/FauxResponseTest.php index 8085bc710c..5e208aceda 100644 --- a/tests/phpunit/includes/FauxResponseTest.php +++ b/tests/phpunit/unit/includes/FauxResponseTest.php @@ -20,7 +20,7 @@ * @file */ -class FauxResponseTest extends MediaWikiTestCase { +class FauxResponseTest extends \MediaWikiUnitTestCase { /** @var FauxResponse */ protected $response; diff --git a/tests/phpunit/includes/FormOptionsInitializationTest.php b/tests/phpunit/unit/includes/FormOptionsInitializationTest.php similarity index 94% rename from tests/phpunit/includes/FormOptionsInitializationTest.php rename to tests/phpunit/unit/includes/FormOptionsInitializationTest.php index 2c78618aa1..708956d260 100644 --- a/tests/phpunit/includes/FormOptionsInitializationTest.php +++ b/tests/phpunit/unit/includes/FormOptionsInitializationTest.php @@ -10,7 +10,7 @@ use Wikimedia\TestingAccessWrapper; * * @author Antoine Musso */ -class FormOptionsInitializationTest extends MediaWikiTestCase { +class FormOptionsInitializationTest extends \MediaWikiUnitTestCase { /** * @var FormOptions */ diff --git a/tests/phpunit/includes/FormOptionsTest.php b/tests/phpunit/unit/includes/FormOptionsTest.php similarity index 97% rename from tests/phpunit/includes/FormOptionsTest.php rename to tests/phpunit/unit/includes/FormOptionsTest.php index da08670f57..c14595bc4a 100644 --- a/tests/phpunit/includes/FormOptionsTest.php +++ b/tests/phpunit/unit/includes/FormOptionsTest.php @@ -15,7 +15,7 @@ * * @author Antoine Musso */ -class FormOptionsTest extends MediaWikiTestCase { +class FormOptionsTest extends \MediaWikiUnitTestCase { /** * @var FormOptions */ diff --git a/tests/phpunit/includes/GlobalFunctions/wfAppendQueryTest.php b/tests/phpunit/unit/includes/GlobalFunctions/wfAppendQueryTest.php similarity index 97% rename from tests/phpunit/includes/GlobalFunctions/wfAppendQueryTest.php rename to tests/phpunit/unit/includes/GlobalFunctions/wfAppendQueryTest.php index bb71610b64..27ac239b82 100644 --- a/tests/phpunit/includes/GlobalFunctions/wfAppendQueryTest.php +++ b/tests/phpunit/unit/includes/GlobalFunctions/wfAppendQueryTest.php @@ -4,7 +4,7 @@ * @group GlobalFunctions * @covers ::wfAppendQuery */ -class WfAppendQueryTest extends MediaWikiTestCase { +class WfAppendQueryTest extends \MediaWikiUnitTestCase { /** * @dataProvider provideAppendQuery */ diff --git a/tests/phpunit/includes/GlobalFunctions/wfArrayPlus2dTest.php b/tests/phpunit/unit/includes/GlobalFunctions/wfArrayPlus2dTest.php similarity index 96% rename from tests/phpunit/includes/GlobalFunctions/wfArrayPlus2dTest.php rename to tests/phpunit/unit/includes/GlobalFunctions/wfArrayPlus2dTest.php index 65b56ef4b3..3e65af5212 100644 --- a/tests/phpunit/includes/GlobalFunctions/wfArrayPlus2dTest.php +++ b/tests/phpunit/unit/includes/GlobalFunctions/wfArrayPlus2dTest.php @@ -3,7 +3,7 @@ * @group GlobalFunctions * @covers ::wfArrayPlus2d */ -class WfArrayPlus2dTest extends MediaWikiTestCase { +class WfArrayPlus2dTest extends \MediaWikiUnitTestCase { /** * @dataProvider provideArrays */ diff --git a/tests/phpunit/includes/GlobalFunctions/wfAssembleUrlTest.php b/tests/phpunit/unit/includes/GlobalFunctions/wfAssembleUrlTest.php similarity index 97% rename from tests/phpunit/includes/GlobalFunctions/wfAssembleUrlTest.php rename to tests/phpunit/unit/includes/GlobalFunctions/wfAssembleUrlTest.php index 7ddad369bd..f28646eb3a 100644 --- a/tests/phpunit/includes/GlobalFunctions/wfAssembleUrlTest.php +++ b/tests/phpunit/unit/includes/GlobalFunctions/wfAssembleUrlTest.php @@ -3,7 +3,7 @@ * @group GlobalFunctions * @covers ::wfAssembleUrl */ -class WfAssembleUrlTest extends MediaWikiTestCase { +class WfAssembleUrlTest extends \MediaWikiUnitTestCase { /** * @dataProvider provideURLParts */ diff --git a/tests/phpunit/includes/GlobalFunctions/wfBaseNameTest.php b/tests/phpunit/unit/includes/GlobalFunctions/wfBaseNameTest.php similarity index 94% rename from tests/phpunit/includes/GlobalFunctions/wfBaseNameTest.php rename to tests/phpunit/unit/includes/GlobalFunctions/wfBaseNameTest.php index 78e09e60ba..ac42f3f82d 100644 --- a/tests/phpunit/includes/GlobalFunctions/wfBaseNameTest.php +++ b/tests/phpunit/unit/includes/GlobalFunctions/wfBaseNameTest.php @@ -3,7 +3,7 @@ * @group GlobalFunctions * @covers ::wfBaseName */ -class WfBaseNameTest extends MediaWikiTestCase { +class WfBaseNameTest extends \MediaWikiUnitTestCase { /** * @dataProvider providePaths */ diff --git a/tests/phpunit/includes/GlobalFunctions/wfEscapeShellArgTest.php b/tests/phpunit/unit/includes/GlobalFunctions/wfEscapeShellArgTest.php similarity index 93% rename from tests/phpunit/includes/GlobalFunctions/wfEscapeShellArgTest.php rename to tests/phpunit/unit/includes/GlobalFunctions/wfEscapeShellArgTest.php index 7402054ea4..7e818dfbda 100644 --- a/tests/phpunit/includes/GlobalFunctions/wfEscapeShellArgTest.php +++ b/tests/phpunit/unit/includes/GlobalFunctions/wfEscapeShellArgTest.php @@ -4,7 +4,7 @@ * @group GlobalFunctions * @covers ::wfEscapeShellArg */ -class WfEscapeShellArgTest extends MediaWikiTestCase { +class WfEscapeShellArgTest extends \MediaWikiUnitTestCase { public function testSingleInput() { if ( wfIsWindows() ) { $expected = '"blah"'; diff --git a/tests/phpunit/includes/GlobalFunctions/wfGetCallerTest.php b/tests/phpunit/unit/includes/GlobalFunctions/wfGetCallerTest.php similarity index 94% rename from tests/phpunit/includes/GlobalFunctions/wfGetCallerTest.php rename to tests/phpunit/unit/includes/GlobalFunctions/wfGetCallerTest.php index 8a7bfa5a8c..c77c35133c 100644 --- a/tests/phpunit/includes/GlobalFunctions/wfGetCallerTest.php +++ b/tests/phpunit/unit/includes/GlobalFunctions/wfGetCallerTest.php @@ -4,7 +4,7 @@ * @group GlobalFunctions * @covers ::wfGetCaller */ -class WfGetCallerTest extends MediaWikiTestCase { +class WfGetCallerTest extends \MediaWikiUnitTestCase { public function testZero() { $this->assertEquals( 'WfGetCallerTest->testZero', wfGetCaller( 1 ) ); } diff --git a/tests/phpunit/includes/GlobalFunctions/wfRemoveDotSegmentsTest.php b/tests/phpunit/unit/includes/GlobalFunctions/wfRemoveDotSegmentsTest.php similarity index 96% rename from tests/phpunit/includes/GlobalFunctions/wfRemoveDotSegmentsTest.php rename to tests/phpunit/unit/includes/GlobalFunctions/wfRemoveDotSegmentsTest.php index eae5588b94..085bfed3d3 100644 --- a/tests/phpunit/includes/GlobalFunctions/wfRemoveDotSegmentsTest.php +++ b/tests/phpunit/unit/includes/GlobalFunctions/wfRemoveDotSegmentsTest.php @@ -4,7 +4,7 @@ * @group GlobalFunctions * @covers ::wfRemoveDotSegments */ -class WfRemoveDotSegmentsTest extends MediaWikiTestCase { +class WfRemoveDotSegmentsTest extends \MediaWikiUnitTestCase { /** * @dataProvider providePaths */ diff --git a/tests/phpunit/includes/GlobalFunctions/wfShellExecTest.php b/tests/phpunit/unit/includes/GlobalFunctions/wfShellExecTest.php similarity index 89% rename from tests/phpunit/includes/GlobalFunctions/wfShellExecTest.php rename to tests/phpunit/unit/includes/GlobalFunctions/wfShellExecTest.php index 6279cf6eee..09ce624dc1 100644 --- a/tests/phpunit/includes/GlobalFunctions/wfShellExecTest.php +++ b/tests/phpunit/unit/includes/GlobalFunctions/wfShellExecTest.php @@ -4,7 +4,7 @@ * @group GlobalFunctions * @covers ::wfShellExec */ -class WfShellExecTest extends MediaWikiTestCase { +class WfShellExecTest extends \MediaWikiUnitTestCase { public function testT69870() { $command = wfIsWindows() // 333 = 331 + CRLF diff --git a/tests/phpunit/includes/GlobalFunctions/wfShorthandToIntegerTest.php b/tests/phpunit/unit/includes/GlobalFunctions/wfShorthandToIntegerTest.php similarity index 91% rename from tests/phpunit/includes/GlobalFunctions/wfShorthandToIntegerTest.php rename to tests/phpunit/unit/includes/GlobalFunctions/wfShorthandToIntegerTest.php index 40b2e636c9..3bb8b985a7 100644 --- a/tests/phpunit/includes/GlobalFunctions/wfShorthandToIntegerTest.php +++ b/tests/phpunit/unit/includes/GlobalFunctions/wfShorthandToIntegerTest.php @@ -4,7 +4,7 @@ * @group GlobalFunctions * @covers ::wfShorthandToInteger */ -class WfShorthandToIntegerTest extends MediaWikiTestCase { +class WfShorthandToIntegerTest extends \MediaWikiUnitTestCase { /** * @dataProvider provideABunchOfShorthands */ diff --git a/tests/phpunit/includes/GlobalFunctions/wfStringToBoolTest.php b/tests/phpunit/unit/includes/GlobalFunctions/wfStringToBoolTest.php similarity index 93% rename from tests/phpunit/includes/GlobalFunctions/wfStringToBoolTest.php rename to tests/phpunit/unit/includes/GlobalFunctions/wfStringToBoolTest.php index 7f56b60529..bc010d5b50 100644 --- a/tests/phpunit/includes/GlobalFunctions/wfStringToBoolTest.php +++ b/tests/phpunit/unit/includes/GlobalFunctions/wfStringToBoolTest.php @@ -4,7 +4,7 @@ * @group GlobalFunctions * @covers ::wfStringToBool */ -class WfStringToBoolTest extends MediaWikiTestCase { +class WfStringToBoolTest extends \MediaWikiUnitTestCase { public function getTestCases() { return [ diff --git a/tests/phpunit/includes/GlobalFunctions/wfTimestampTest.php b/tests/phpunit/unit/includes/GlobalFunctions/wfTimestampTest.php similarity index 99% rename from tests/phpunit/includes/GlobalFunctions/wfTimestampTest.php rename to tests/phpunit/unit/includes/GlobalFunctions/wfTimestampTest.php index a70f136a1c..78b9172c6e 100644 --- a/tests/phpunit/includes/GlobalFunctions/wfTimestampTest.php +++ b/tests/phpunit/unit/includes/GlobalFunctions/wfTimestampTest.php @@ -4,7 +4,7 @@ * @group GlobalFunctions * @covers ::wfTimestamp */ -class WfTimestampTest extends MediaWikiTestCase { +class WfTimestampTest extends \MediaWikiUnitTestCase { /** * @dataProvider provideNormalTimestamps */ diff --git a/tests/phpunit/includes/GlobalFunctions/wfUrlencodeTest.php b/tests/phpunit/unit/includes/GlobalFunctions/wfUrlencodeTest.php similarity index 98% rename from tests/phpunit/includes/GlobalFunctions/wfUrlencodeTest.php rename to tests/phpunit/unit/includes/GlobalFunctions/wfUrlencodeTest.php index 5d9f63daa7..a5992d4c83 100644 --- a/tests/phpunit/includes/GlobalFunctions/wfUrlencodeTest.php +++ b/tests/phpunit/unit/includes/GlobalFunctions/wfUrlencodeTest.php @@ -6,7 +6,7 @@ * @group GlobalFunctions * @covers ::wfUrlencode */ -class WfUrlencodeTest extends MediaWikiTestCase { +class WfUrlencodeTest extends \MediaWikiUnitTestCase { # ### TESTS ############################################################## /** diff --git a/tests/phpunit/includes/HooksTest.php b/tests/phpunit/unit/includes/HooksTest.php similarity index 99% rename from tests/phpunit/includes/HooksTest.php rename to tests/phpunit/unit/includes/HooksTest.php index c66b712b83..9380546c84 100644 --- a/tests/phpunit/includes/HooksTest.php +++ b/tests/phpunit/unit/includes/HooksTest.php @@ -1,6 +1,6 @@ hideDeprecated( MediaWikiServices::class . "::$getter" ); } - // Test against the default instance, since the dummy will not know the default services. - $services = MediaWikiServices::getInstance(); + // Check all services via an instance using the global configuration, not a dummy instance! + $services = $this->newMediaWikiServices( new GlobalVarConfig() ); $service = $services->$getter(); $this->assertInstanceOf( $type, $service ); } @@ -317,18 +317,18 @@ class MediaWikiServicesTest extends MediaWikiTestCase { * @dataProvider provideGetService */ public function testGetService( $name, $type ) { - // Test against the default instance, since the dummy will not know the default services. - $services = MediaWikiServices::getInstance(); + // Check all services via an instance using the global configuration, not a dummy instance! + $services = $this->newMediaWikiServices( new GlobalVarConfig() ); $service = $services->getService( $name ); $this->assertInstanceOf( $type, $service ); } public function testDefaultServiceInstantiation() { - // Check all services in the default instance, not a dummy instance! + // Check all services via an instance using the global configuration, not a dummy instance! // Note that we instantiate all services here, including any that // were registered by extensions. - $services = MediaWikiServices::getInstance(); + $services = $this->newMediaWikiServices( new GlobalVarConfig() ); $names = $services->getServiceNames(); foreach ( $names as $name ) { diff --git a/tests/phpunit/includes/MediaWikiVersionFetcherTest.php b/tests/phpunit/unit/includes/MediaWikiVersionFetcherTest.php similarity index 88% rename from tests/phpunit/includes/MediaWikiVersionFetcherTest.php rename to tests/phpunit/unit/includes/MediaWikiVersionFetcherTest.php index 9803081869..dfdbfa7344 100644 --- a/tests/phpunit/includes/MediaWikiVersionFetcherTest.php +++ b/tests/phpunit/unit/includes/MediaWikiVersionFetcherTest.php @@ -10,7 +10,7 @@ * * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ -class MediaWikiVersionFetcherTest extends MediaWikiTestCase { +class MediaWikiVersionFetcherTest extends \MediaWikiUnitTestCase { public function testReturnsResult() { global $wgVersion; diff --git a/tests/phpunit/includes/PathRouterTest.php b/tests/phpunit/unit/includes/PathRouterTest.php similarity index 99% rename from tests/phpunit/includes/PathRouterTest.php rename to tests/phpunit/unit/includes/PathRouterTest.php index d8916751c0..0cb6c81822 100644 --- a/tests/phpunit/includes/PathRouterTest.php +++ b/tests/phpunit/unit/includes/PathRouterTest.php @@ -5,7 +5,7 @@ * * @covers PathRouter */ -class PathRouterTest extends MediaWikiTestCase { +class PathRouterTest extends \MediaWikiUnitTestCase { /** * @var PathRouter diff --git a/tests/phpunit/includes/Revision/FallbackSlotRoleHandlerTest.php b/tests/phpunit/unit/includes/Revision/FallbackSlotRoleHandlerTest.php similarity index 96% rename from tests/phpunit/includes/Revision/FallbackSlotRoleHandlerTest.php rename to tests/phpunit/unit/includes/Revision/FallbackSlotRoleHandlerTest.php index aedf292eca..9b23c6e17e 100644 --- a/tests/phpunit/includes/Revision/FallbackSlotRoleHandlerTest.php +++ b/tests/phpunit/unit/includes/Revision/FallbackSlotRoleHandlerTest.php @@ -3,13 +3,12 @@ namespace MediaWiki\Tests\Revision; use MediaWiki\Revision\FallbackSlotRoleHandler; -use MediaWikiTestCase; use Title; /** * @covers \MediaWiki\Revision\FallbackSlotRoleHandler */ -class FallbackSlotRoleHandlerTest extends MediaWikiTestCase { +class FallbackSlotRoleHandlerTest extends \MediaWikiUnitTestCase { private function makeBlankTitleObject() { /** @var Title $title */ diff --git a/tests/phpunit/includes/Revision/MainSlotRoleHandlerTest.php b/tests/phpunit/unit/includes/Revision/MainSlotRoleHandlerTest.php similarity index 96% rename from tests/phpunit/includes/Revision/MainSlotRoleHandlerTest.php rename to tests/phpunit/unit/includes/Revision/MainSlotRoleHandlerTest.php index 5e32574d40..afd748f761 100644 --- a/tests/phpunit/includes/Revision/MainSlotRoleHandlerTest.php +++ b/tests/phpunit/unit/includes/Revision/MainSlotRoleHandlerTest.php @@ -3,14 +3,13 @@ namespace MediaWiki\Tests\Revision; use MediaWiki\Revision\MainSlotRoleHandler; -use MediaWikiTestCase; use PHPUnit\Framework\MockObject\MockObject; use Title; /** * @covers \MediaWiki\Revision\MainSlotRoleHandler */ -class MainSlotRoleHandlerTest extends MediaWikiTestCase { +class MainSlotRoleHandlerTest extends \MediaWikiUnitTestCase { private function makeTitleObject( $ns ) { /** @var Title|MockObject $title */ diff --git a/tests/phpunit/includes/Revision/RevisionStoreFactoryTest.php b/tests/phpunit/unit/includes/Revision/RevisionStoreFactoryTest.php similarity index 98% rename from tests/phpunit/includes/Revision/RevisionStoreFactoryTest.php rename to tests/phpunit/unit/includes/Revision/RevisionStoreFactoryTest.php index 138d6bcba1..77228081d0 100644 --- a/tests/phpunit/includes/Revision/RevisionStoreFactoryTest.php +++ b/tests/phpunit/unit/includes/Revision/RevisionStoreFactoryTest.php @@ -13,7 +13,6 @@ 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; @@ -21,7 +20,7 @@ use Wikimedia\Rdbms\ILBFactory; use Wikimedia\Rdbms\ILoadBalancer; use Wikimedia\TestingAccessWrapper; -class RevisionStoreFactoryTest extends MediaWikiTestCase { +class RevisionStoreFactoryTest extends \MediaWikiUnitTestCase { /** * @covers \MediaWiki\Revision\RevisionStoreFactory::__construct diff --git a/tests/phpunit/includes/Revision/SlotRecordTest.php b/tests/phpunit/unit/includes/Revision/SlotRecordTest.php similarity index 99% rename from tests/phpunit/includes/Revision/SlotRecordTest.php rename to tests/phpunit/unit/includes/Revision/SlotRecordTest.php index 1b6ff2aace..58c1035231 100644 --- a/tests/phpunit/includes/Revision/SlotRecordTest.php +++ b/tests/phpunit/unit/includes/Revision/SlotRecordTest.php @@ -7,13 +7,12 @@ use LogicException; use MediaWiki\Revision\IncompleteRevisionException; use MediaWiki\Revision\SlotRecord; use MediaWiki\Revision\SuppressedDataException; -use MediaWikiTestCase; use WikitextContent; /** * @covers \MediaWiki\Revision\SlotRecord */ -class SlotRecordTest extends MediaWikiTestCase { +class SlotRecordTest extends \MediaWikiUnitTestCase { private function makeRow( $data = [] ) { $data = $data + [ diff --git a/tests/phpunit/includes/Revision/SlotRoleHandlerTest.php b/tests/phpunit/unit/includes/Revision/SlotRoleHandlerTest.php similarity index 96% rename from tests/phpunit/includes/Revision/SlotRoleHandlerTest.php rename to tests/phpunit/unit/includes/Revision/SlotRoleHandlerTest.php index 67e9464f33..ed3053c070 100644 --- a/tests/phpunit/includes/Revision/SlotRoleHandlerTest.php +++ b/tests/phpunit/unit/includes/Revision/SlotRoleHandlerTest.php @@ -3,13 +3,12 @@ namespace MediaWiki\Tests\Revision; use MediaWiki\Revision\SlotRoleHandler; -use MediaWikiTestCase; use Title; /** * @covers \MediaWiki\Revision\SlotRoleHandler */ -class SlotRoleHandlerTest extends MediaWikiTestCase { +class SlotRoleHandlerTest extends \MediaWikiUnitTestCase { private function makeBlankTitleObject() { /** @var Title $title */ diff --git a/tests/phpunit/includes/SanitizerValidateEmailTest.php b/tests/phpunit/unit/includes/SanitizerValidateEmailTest.php similarity index 100% rename from tests/phpunit/includes/SanitizerValidateEmailTest.php rename to tests/phpunit/unit/includes/SanitizerValidateEmailTest.php diff --git a/tests/phpunit/includes/ServiceWiringTest.php b/tests/phpunit/unit/includes/ServiceWiringTest.php similarity index 85% rename from tests/phpunit/includes/ServiceWiringTest.php rename to tests/phpunit/unit/includes/ServiceWiringTest.php index 02e06f8dda..25b0214db1 100644 --- a/tests/phpunit/includes/ServiceWiringTest.php +++ b/tests/phpunit/unit/includes/ServiceWiringTest.php @@ -3,7 +3,7 @@ /** * @coversNothing */ -class ServiceWiringTest extends MediaWikiTestCase { +class ServiceWiringTest extends \MediaWikiUnitTestCase { public function testServicesAreSorted() { global $IP; $services = array_keys( require "$IP/includes/ServiceWiring.php" ); diff --git a/tests/phpunit/includes/SiteConfigurationTest.php b/tests/phpunit/unit/includes/SiteConfigurationTest.php similarity index 99% rename from tests/phpunit/includes/SiteConfigurationTest.php rename to tests/phpunit/unit/includes/SiteConfigurationTest.php index 3b7226245f..b992a86471 100644 --- a/tests/phpunit/includes/SiteConfigurationTest.php +++ b/tests/phpunit/unit/includes/SiteConfigurationTest.php @@ -1,6 +1,6 @@ lbFactoryMock = $this->createMock( LBFactory::class ); + + $lbFactoryMockProvider = function (): LBFactory { + return $this->lbFactoryMock; + }; + + $this->overrideMwServices( [ 'DBLoadBalancerFactory' => $lbFactoryMockProvider ] ); + } public function provideWikiIds() { yield [ false ]; @@ -22,6 +37,11 @@ class BlobStoreFactoryTest extends MediaWikiTestCase { * @dataProvider provideWikiIds */ public function testNewBlobStore( $wikiId ) { + $this->lbFactoryMock->expects( $this->any() ) + ->method( 'getMainLB' ) + ->with( $wikiId ) + ->willReturn( $this->createMock( \LoadBalancer::class ) ); + $factory = MediaWikiServices::getInstance()->getBlobStoreFactory(); $store = $factory->newBlobStore( $wikiId ); $this->assertInstanceOf( BlobStore::class, $store ); @@ -35,6 +55,11 @@ class BlobStoreFactoryTest extends MediaWikiTestCase { * @dataProvider provideWikiIds */ public function testNewSqlBlobStore( $wikiId ) { + $this->lbFactoryMock->expects( $this->any() ) + ->method( 'getMainLB' ) + ->with( $wikiId ) + ->willReturn( $this->createMock( \LoadBalancer::class ) ); + $factory = MediaWikiServices::getInstance()->getBlobStoreFactory(); $store = $factory->newSqlBlobStore( $wikiId ); $this->assertInstanceOf( SqlBlobStore::class, $store ); @@ -42,5 +67,4 @@ class BlobStoreFactoryTest extends MediaWikiTestCase { $wrapper = TestingAccessWrapper::newFromObject( $store ); $this->assertEquals( $wikiId, $wrapper->wikiId ); } - } diff --git a/tests/phpunit/includes/Storage/PreparedEditTest.php b/tests/phpunit/unit/includes/Storage/PreparedEditTest.php similarity index 83% rename from tests/phpunit/includes/Storage/PreparedEditTest.php rename to tests/phpunit/unit/includes/Storage/PreparedEditTest.php index 29999ee535..e3249e74bc 100644 --- a/tests/phpunit/includes/Storage/PreparedEditTest.php +++ b/tests/phpunit/unit/includes/Storage/PreparedEditTest.php @@ -3,12 +3,11 @@ namespace MediaWiki\Edit; use ParserOutput; -use MediaWikiTestCase; /** * @covers \MediaWiki\Edit\PreparedEdit */ -class PreparedEditTest extends MediaWikiTestCase { +class PreparedEditTest extends \MediaWikiUnitTestCase { function testCallback() { $output = new ParserOutput(); $edit = new PreparedEdit(); diff --git a/tests/phpunit/includes/TitleArrayFromResultTest.php b/tests/phpunit/unit/includes/TitleArrayFromResultTest.php similarity index 100% rename from tests/phpunit/includes/TitleArrayFromResultTest.php rename to tests/phpunit/unit/includes/TitleArrayFromResultTest.php diff --git a/tests/phpunit/includes/WikiReferenceTest.php b/tests/phpunit/unit/includes/WikiReferenceTest.php similarity index 100% rename from tests/phpunit/includes/WikiReferenceTest.php rename to tests/phpunit/unit/includes/WikiReferenceTest.php diff --git a/tests/phpunit/includes/XmlJsTest.php b/tests/phpunit/unit/includes/XmlJsTest.php similarity index 100% rename from tests/phpunit/includes/XmlJsTest.php rename to tests/phpunit/unit/includes/XmlJsTest.php diff --git a/tests/phpunit/includes/XmlSelectTest.php b/tests/phpunit/unit/includes/XmlSelectTest.php similarity index 98% rename from tests/phpunit/includes/XmlSelectTest.php rename to tests/phpunit/unit/includes/XmlSelectTest.php index 52e20bdb99..54d269e0ce 100644 --- a/tests/phpunit/includes/XmlSelectTest.php +++ b/tests/phpunit/unit/includes/XmlSelectTest.php @@ -3,7 +3,7 @@ /** * @group Xml */ -class XmlSelectTest extends MediaWikiTestCase { +class XmlSelectTest extends \MediaWikiUnitTestCase { /** * @var XmlSelect diff --git a/tests/phpunit/includes/actions/ViewActionTest.php b/tests/phpunit/unit/includes/actions/ViewActionTest.php similarity index 92% rename from tests/phpunit/includes/actions/ViewActionTest.php rename to tests/phpunit/unit/includes/actions/ViewActionTest.php index 5f659c07a2..99d61b6e4b 100644 --- a/tests/phpunit/includes/actions/ViewActionTest.php +++ b/tests/phpunit/unit/includes/actions/ViewActionTest.php @@ -7,7 +7,7 @@ * * @author Derick N. Alangi */ -class ViewActionTest extends MediaWikiTestCase { +class ViewActionTest extends \MediaWikiUnitTestCase { /** * @return ViewAction */ diff --git a/tests/phpunit/unit/includes/api/ApiBlockInfoTraitTest.php b/tests/phpunit/unit/includes/api/ApiBlockInfoTraitTest.php new file mode 100644 index 0000000000..ed5a184743 --- /dev/null +++ b/tests/phpunit/unit/includes/api/ApiBlockInfoTraitTest.php @@ -0,0 +1,66 @@ +createMock( LoadBalancer::class ); + $lbMock->expects( $this->any() ) + ->method( 'getConnection' ) + ->willReturn( $this->createMock( Database::class ) ); + + $loadBalancerMockFactory = function () use ( $lbMock ): LoadBalancer { + return $lbMock; + }; + + $this->overrideMwServices( [ 'DBLoadBalancer' => $loadBalancerMockFactory ] ); + } + + /** + * @dataProvider provideGetBlockDetails + */ + public function testGetBlockDetails( $blockFactory, $expectedInfo ) { + $mock = $this->getMockForTrait( ApiBlockInfoTrait::class ); + $info = TestingAccessWrapper::newFromObject( $mock )->getBlockDetails( $blockFactory() ); + $subset = array_merge( [ + 'blockid' => null, + 'blockedby' => '', + 'blockedbyid' => 0, + 'blockreason' => '', + 'blockexpiry' => 'infinite', + ], $expectedInfo ); + $this->assertArraySubset( $subset, $info ); + } + + public static function provideGetBlockDetails() { + return [ + 'Sitewide block' => [ + // Defer instantiation to avoid connecting to DB + function () { + return new DatabaseBlock(); + }, + [ 'blockpartial' => false ], + ], + 'Partial block' => [ + function () { + return new DatabaseBlock( [ 'sitewide' => false ] ); + }, + [ 'blockpartial' => true ], + ], + 'System block' => [ + function () { + return new SystemBlock( [ 'systemBlock' => 'proxy' ] ); + }, + [ 'systemblocktype' => 'proxy' ] + ], + ]; + } +} diff --git a/tests/phpunit/includes/api/ApiContinuationManagerTest.php b/tests/phpunit/unit/includes/api/ApiContinuationManagerTest.php similarity index 99% rename from tests/phpunit/includes/api/ApiContinuationManagerTest.php rename to tests/phpunit/unit/includes/api/ApiContinuationManagerTest.php index 788d120c6b..cc1351b12a 100644 --- a/tests/phpunit/includes/api/ApiContinuationManagerTest.php +++ b/tests/phpunit/unit/includes/api/ApiContinuationManagerTest.php @@ -4,7 +4,7 @@ * @covers ApiContinuationManager * @group API */ -class ApiContinuationManagerTest extends MediaWikiTestCase { +class ApiContinuationManagerTest extends \MediaWikiUnitTestCase { private static function getManager( $continue, $allModules, $generatedModules ) { $context = new DerivativeContext( RequestContext::getMain() ); diff --git a/tests/phpunit/includes/api/ApiMessageTest.php b/tests/phpunit/unit/includes/api/ApiMessageTest.php similarity index 99% rename from tests/phpunit/includes/api/ApiMessageTest.php rename to tests/phpunit/unit/includes/api/ApiMessageTest.php index 70114c2593..d6fa7809d0 100644 --- a/tests/phpunit/includes/api/ApiMessageTest.php +++ b/tests/phpunit/unit/includes/api/ApiMessageTest.php @@ -5,7 +5,7 @@ use Wikimedia\TestingAccessWrapper; /** * @group API */ -class ApiMessageTest extends MediaWikiTestCase { +class ApiMessageTest extends \MediaWikiUnitTestCase { private function compareMessages( Message $msg, Message $msg2 ) { $this->assertSame( $msg->getKey(), $msg2->getKey(), 'getKey' ); diff --git a/tests/phpunit/includes/api/ApiResultTest.php b/tests/phpunit/unit/includes/api/ApiResultTest.php similarity index 99% rename from tests/phpunit/includes/api/ApiResultTest.php rename to tests/phpunit/unit/includes/api/ApiResultTest.php index 98e24fb666..2d99890d50 100644 --- a/tests/phpunit/includes/api/ApiResultTest.php +++ b/tests/phpunit/unit/includes/api/ApiResultTest.php @@ -4,7 +4,7 @@ * @covers ApiResult * @group API */ -class ApiResultTest extends MediaWikiTestCase { +class ApiResultTest extends \MediaWikiUnitTestCase { /** * @covers ApiResult diff --git a/tests/phpunit/includes/api/ApiUsageExceptionTest.php b/tests/phpunit/unit/includes/api/ApiUsageExceptionTest.php similarity index 96% rename from tests/phpunit/includes/api/ApiUsageExceptionTest.php rename to tests/phpunit/unit/includes/api/ApiUsageExceptionTest.php index bb72021121..51260a67f9 100644 --- a/tests/phpunit/includes/api/ApiUsageExceptionTest.php +++ b/tests/phpunit/unit/includes/api/ApiUsageExceptionTest.php @@ -3,7 +3,7 @@ /** * @covers ApiUsageException */ -class ApiUsageExceptionTest extends MediaWikiTestCase { +class ApiUsageExceptionTest extends \MediaWikiUnitTestCase { public function testCreateWithStatusValue_CanGetAMessageObject() { $messageKey = 'some-message-key'; diff --git a/tests/phpunit/includes/auth/AbstractPreAuthenticationProviderTest.php b/tests/phpunit/unit/includes/auth/AbstractPreAuthenticationProviderTest.php similarity index 93% rename from tests/phpunit/includes/auth/AbstractPreAuthenticationProviderTest.php rename to tests/phpunit/unit/includes/auth/AbstractPreAuthenticationProviderTest.php index 2970a2807c..8ec3380069 100644 --- a/tests/phpunit/includes/auth/AbstractPreAuthenticationProviderTest.php +++ b/tests/phpunit/unit/includes/auth/AbstractPreAuthenticationProviderTest.php @@ -6,7 +6,7 @@ namespace MediaWiki\Auth; * @group AuthManager * @covers \MediaWiki\Auth\AbstractPreAuthenticationProvider */ -class AbstractPreAuthenticationProviderTest extends \MediaWikiTestCase { +class AbstractPreAuthenticationProviderTest extends \MediaWikiUnitTestCase { public function testAbstractPreAuthenticationProvider() { $user = \User::newFromName( 'UTSysop' ); diff --git a/tests/phpunit/includes/auth/AbstractSecondaryAuthenticationProviderTest.php b/tests/phpunit/unit/includes/auth/AbstractSecondaryAuthenticationProviderTest.php similarity index 99% rename from tests/phpunit/includes/auth/AbstractSecondaryAuthenticationProviderTest.php rename to tests/phpunit/unit/includes/auth/AbstractSecondaryAuthenticationProviderTest.php index cd17862838..e933cb8c67 100644 --- a/tests/phpunit/includes/auth/AbstractSecondaryAuthenticationProviderTest.php +++ b/tests/phpunit/unit/includes/auth/AbstractSecondaryAuthenticationProviderTest.php @@ -6,7 +6,7 @@ namespace MediaWiki\Auth; * @group AuthManager * @covers \MediaWiki\Auth\AbstractSecondaryAuthenticationProvider */ -class AbstractSecondaryAuthenticationProviderTest extends \MediaWikiTestCase { +class AbstractSecondaryAuthenticationProviderTest extends \MediaWikiUnitTestCase { public function testAbstractSecondaryAuthenticationProvider() { $user = \User::newFromName( 'UTSysop' ); diff --git a/tests/phpunit/includes/auth/AuthenticationResponseTest.php b/tests/phpunit/unit/includes/auth/AuthenticationResponseTest.php similarity index 97% rename from tests/phpunit/includes/auth/AuthenticationResponseTest.php rename to tests/phpunit/unit/includes/auth/AuthenticationResponseTest.php index c79682275f..44b063153b 100644 --- a/tests/phpunit/includes/auth/AuthenticationResponseTest.php +++ b/tests/phpunit/unit/includes/auth/AuthenticationResponseTest.php @@ -6,7 +6,7 @@ namespace MediaWiki\Auth; * @group AuthManager * @covers \MediaWiki\Auth\AuthenticationResponse */ -class AuthenticationResponseTest extends \MediaWikiTestCase { +class AuthenticationResponseTest extends \MediaWikiUnitTestCase { /** * @dataProvider provideConstructors * @param string $constructor diff --git a/tests/phpunit/includes/auth/ConfirmLinkSecondaryAuthenticationProviderTest.php b/tests/phpunit/unit/includes/auth/ConfirmLinkSecondaryAuthenticationProviderTest.php similarity index 99% rename from tests/phpunit/includes/auth/ConfirmLinkSecondaryAuthenticationProviderTest.php rename to tests/phpunit/unit/includes/auth/ConfirmLinkSecondaryAuthenticationProviderTest.php index b17da2e2cf..7a4490bb67 100644 --- a/tests/phpunit/includes/auth/ConfirmLinkSecondaryAuthenticationProviderTest.php +++ b/tests/phpunit/unit/includes/auth/ConfirmLinkSecondaryAuthenticationProviderTest.php @@ -8,7 +8,7 @@ use Wikimedia\TestingAccessWrapper; * @group AuthManager * @covers \MediaWiki\Auth\ConfirmLinkSecondaryAuthenticationProvider */ -class ConfirmLinkSecondaryAuthenticationProviderTest extends \MediaWikiTestCase { +class ConfirmLinkSecondaryAuthenticationProviderTest extends \MediaWikiUnitTestCase { /** * @dataProvider provideGetAuthenticationRequests * @param string $action diff --git a/tests/phpunit/includes/auth/EmailNotificationSecondaryAuthenticationProviderTest.php b/tests/phpunit/unit/includes/auth/EmailNotificationSecondaryAuthenticationProviderTest.php similarity index 86% rename from tests/phpunit/includes/auth/EmailNotificationSecondaryAuthenticationProviderTest.php rename to tests/phpunit/unit/includes/auth/EmailNotificationSecondaryAuthenticationProviderTest.php index ff22def7f8..fcaf6bf1a3 100644 --- a/tests/phpunit/includes/auth/EmailNotificationSecondaryAuthenticationProviderTest.php +++ b/tests/phpunit/unit/includes/auth/EmailNotificationSecondaryAuthenticationProviderTest.php @@ -3,12 +3,39 @@ namespace MediaWiki\Auth; use Psr\Log\LoggerInterface; +use Wikimedia\Rdbms\IDatabase; +use Wikimedia\Rdbms\LoadBalancer; use Wikimedia\TestingAccessWrapper; /** * @covers \MediaWiki\Auth\EmailNotificationSecondaryAuthenticationProvider */ -class EmailNotificationSecondaryAuthenticationProviderTest extends \PHPUnit\Framework\TestCase { +class EmailNotificationSecondaryAuthenticationProviderTest extends \MediaWikiUnitTestCase { + + protected function setUp() { + parent::setUp(); + + $lbMock = $this->createMock( LoadBalancer::class ); + $dbMock = $this->getMockBuilder( IDatabase::class ) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $lbMock->expects( $this->any() ) + ->method( 'getConnection' ) + ->willReturn( $dbMock ); + $dbMock->expects( $this->any() ) + ->method( 'onTransactionCommitOrIdle' ) + ->willReturnCallback( function ( callable $callback ) { + $callback(); + } ); + + $lbMockFactory = function () use ( $lbMock ): LoadBalancer { + return $lbMock; + }; + + $this->overrideMwServices( [ 'DBLoadBalancer' => $lbMockFactory ] ); + } + public function testConstructor() { $config = new \HashConfig( [ 'EnableEmail' => true, diff --git a/tests/phpunit/includes/changes/ChangesListFilterGroupTest.php b/tests/phpunit/unit/includes/changes/ChangesListFilterGroupTest.php similarity index 95% rename from tests/phpunit/includes/changes/ChangesListFilterGroupTest.php rename to tests/phpunit/unit/includes/changes/ChangesListFilterGroupTest.php index 6190516e68..bd54d508ba 100644 --- a/tests/phpunit/includes/changes/ChangesListFilterGroupTest.php +++ b/tests/phpunit/unit/includes/changes/ChangesListFilterGroupTest.php @@ -3,7 +3,7 @@ /** * @covers ChangesListFilterGroup */ -class ChangesListFilterGroupTest extends MediaWikiTestCase { +class ChangesListFilterGroupTest extends \MediaWikiUnitTestCase { /** * phpcs:disable Generic.Files.LineLength * @expectedException MWException diff --git a/tests/phpunit/includes/collation/CustomUppercaseCollationTest.php b/tests/phpunit/unit/includes/collation/CustomUppercaseCollationTest.php similarity index 95% rename from tests/phpunit/includes/collation/CustomUppercaseCollationTest.php rename to tests/phpunit/unit/includes/collation/CustomUppercaseCollationTest.php index 417b468b1d..0dfe59cb99 100644 --- a/tests/phpunit/includes/collation/CustomUppercaseCollationTest.php +++ b/tests/phpunit/unit/includes/collation/CustomUppercaseCollationTest.php @@ -3,7 +3,7 @@ /** * @covers CustomUppercaseCollation */ -class CustomUppercaseCollationTest extends MediaWikiTestCase { +class CustomUppercaseCollationTest extends \MediaWikiUnitTestCase { public function setUp() { $this->collation = new CustomUppercaseCollation( [ diff --git a/tests/phpunit/includes/composer/ComposerVersionNormalizerTest.php b/tests/phpunit/unit/includes/composer/ComposerVersionNormalizerTest.php similarity index 100% rename from tests/phpunit/includes/composer/ComposerVersionNormalizerTest.php rename to tests/phpunit/unit/includes/composer/ComposerVersionNormalizerTest.php diff --git a/tests/phpunit/includes/config/ConfigFactoryTest.php b/tests/phpunit/unit/includes/config/ConfigFactoryTest.php similarity index 98% rename from tests/phpunit/includes/config/ConfigFactoryTest.php rename to tests/phpunit/unit/includes/config/ConfigFactoryTest.php index ea747afac1..a136018c96 100644 --- a/tests/phpunit/includes/config/ConfigFactoryTest.php +++ b/tests/phpunit/unit/includes/config/ConfigFactoryTest.php @@ -2,7 +2,7 @@ use MediaWiki\MediaWikiServices; -class ConfigFactoryTest extends MediaWikiTestCase { +class ConfigFactoryTest extends \MediaWikiUnitTestCase { /** * @covers ConfigFactory::register diff --git a/tests/phpunit/includes/config/EtcdConfigTest.php b/tests/phpunit/unit/includes/config/EtcdConfigTest.php similarity index 100% rename from tests/phpunit/includes/config/EtcdConfigTest.php rename to tests/phpunit/unit/includes/config/EtcdConfigTest.php diff --git a/tests/phpunit/includes/config/HashConfigTest.php b/tests/phpunit/unit/includes/config/HashConfigTest.php similarity index 96% rename from tests/phpunit/includes/config/HashConfigTest.php rename to tests/phpunit/unit/includes/config/HashConfigTest.php index bac8311cd4..d46ee09d5b 100644 --- a/tests/phpunit/includes/config/HashConfigTest.php +++ b/tests/phpunit/unit/includes/config/HashConfigTest.php @@ -1,6 +1,6 @@ createMock( LoadBalancer::class ); + }; + + $this->overrideMwServices( [ 'DBLoadBalancer' => $loadBalancerMockFactory ] ); + } + + public function testConstruction() { + $e = new ReadOnlyError(); + $this->assertEquals( 'readonly', $e->title ); + $this->assertEquals( 'readonlytext', $e->msg ); + $this->assertEquals( wfReadOnlyReason() ?: [], $e->params ); + } +} diff --git a/tests/phpunit/includes/exception/UserNotLoggedInTest.php b/tests/phpunit/unit/includes/exception/UserNotLoggedInTest.php similarity index 83% rename from tests/phpunit/includes/exception/UserNotLoggedInTest.php rename to tests/phpunit/unit/includes/exception/UserNotLoggedInTest.php index 55ec45a020..3888c8e15c 100644 --- a/tests/phpunit/includes/exception/UserNotLoggedInTest.php +++ b/tests/phpunit/unit/includes/exception/UserNotLoggedInTest.php @@ -4,7 +4,7 @@ * @covers UserNotLoggedIn * @author Addshore */ -class UserNotLoggedInTest extends MediaWikiTestCase { +class UserNotLoggedInTest extends \MediaWikiUnitTestCase { public function testConstruction() { $e = new UserNotLoggedIn(); diff --git a/tests/phpunit/includes/externalstore/ExternalStoreFactoryTest.php b/tests/phpunit/unit/includes/externalstore/ExternalStoreFactoryTest.php similarity index 100% rename from tests/phpunit/includes/externalstore/ExternalStoreFactoryTest.php rename to tests/phpunit/unit/includes/externalstore/ExternalStoreFactoryTest.php diff --git a/tests/phpunit/includes/filebackend/SwiftFileBackendTest.php b/tests/phpunit/unit/includes/filebackend/SwiftFileBackendTest.php similarity index 98% rename from tests/phpunit/includes/filebackend/SwiftFileBackendTest.php rename to tests/phpunit/unit/includes/filebackend/SwiftFileBackendTest.php index 35eca28f7e..fbc1a571c5 100644 --- a/tests/phpunit/includes/filebackend/SwiftFileBackendTest.php +++ b/tests/phpunit/unit/includes/filebackend/SwiftFileBackendTest.php @@ -12,7 +12,7 @@ use Wikimedia\TestingAccessWrapper; * @covers SwiftFileBackendFileList * @covers SwiftFileBackendList */ -class SwiftFileBackendTest extends MediaWikiTestCase { +class SwiftFileBackendTest extends \MediaWikiUnitTestCase { /** @var TestingAccessWrapper Proxy to SwiftFileBackend */ private $backend; diff --git a/tests/phpunit/includes/filerepo/FileBackendDBRepoWrapperTest.php b/tests/phpunit/unit/includes/filerepo/FileBackendDBRepoWrapperTest.php similarity index 98% rename from tests/phpunit/includes/filerepo/FileBackendDBRepoWrapperTest.php rename to tests/phpunit/unit/includes/filerepo/FileBackendDBRepoWrapperTest.php index 346be7afa3..4db9892f9d 100644 --- a/tests/phpunit/includes/filerepo/FileBackendDBRepoWrapperTest.php +++ b/tests/phpunit/unit/includes/filerepo/FileBackendDBRepoWrapperTest.php @@ -1,6 +1,6 @@ 'BGR', diff --git a/tests/phpunit/includes/htmlform/HTMLCheckMatrixTest.php b/tests/phpunit/unit/includes/htmlform/HTMLCheckMatrixTest.php similarity index 98% rename from tests/phpunit/includes/htmlform/HTMLCheckMatrixTest.php rename to tests/phpunit/unit/includes/htmlform/HTMLCheckMatrixTest.php index 05c567df75..9c41ab8275 100644 --- a/tests/phpunit/includes/htmlform/HTMLCheckMatrixTest.php +++ b/tests/phpunit/unit/includes/htmlform/HTMLCheckMatrixTest.php @@ -3,7 +3,7 @@ /** * @covers HTMLCheckMatrix */ -class HTMLCheckMatrixTest extends MediaWikiTestCase { +class HTMLCheckMatrixTest extends \MediaWikiUnitTestCase { private static $defaultOptions = [ 'rows' => [ 'r1', 'r2' ], 'columns' => [ 'c1', 'c2' ], diff --git a/tests/phpunit/includes/htmlform/HTMLFormTest.php b/tests/phpunit/unit/includes/htmlform/HTMLFormTest.php similarity index 96% rename from tests/phpunit/includes/htmlform/HTMLFormTest.php rename to tests/phpunit/unit/includes/htmlform/HTMLFormTest.php index d7dc4112b7..d9d2cb1191 100644 --- a/tests/phpunit/includes/htmlform/HTMLFormTest.php +++ b/tests/phpunit/unit/includes/htmlform/HTMLFormTest.php @@ -6,7 +6,7 @@ * @license GPL-2.0-or-later * @author Gergő Tisza */ -class HTMLFormTest extends MediaWikiTestCase { +class HTMLFormTest extends \MediaWikiUnitTestCase { private function newInstance() { $form = new HTMLForm( [] ); diff --git a/tests/phpunit/includes/htmlform/HTMLRestrictionsFieldTest.php b/tests/phpunit/unit/includes/htmlform/HTMLRestrictionsFieldTest.php similarity index 100% rename from tests/phpunit/includes/htmlform/HTMLRestrictionsFieldTest.php rename to tests/phpunit/unit/includes/htmlform/HTMLRestrictionsFieldTest.php diff --git a/tests/phpunit/includes/http/GuzzleHttpRequestTest.php b/tests/phpunit/unit/includes/http/GuzzleHttpRequestTest.php similarity index 98% rename from tests/phpunit/includes/http/GuzzleHttpRequestTest.php rename to tests/phpunit/unit/includes/http/GuzzleHttpRequestTest.php index c9356b6b10..e271ac6e00 100644 --- a/tests/phpunit/includes/http/GuzzleHttpRequestTest.php +++ b/tests/phpunit/unit/includes/http/GuzzleHttpRequestTest.php @@ -13,7 +13,7 @@ use GuzzleHttp\Psr7\Request; * @covers GuzzleHttpRequest * @covers MWHttpRequest */ -class GuzzleHttpRequestTest extends MediaWikiTestCase { +class GuzzleHttpRequestTest extends \MediaWikiUnitTestCase { /** * Placeholder url to use for various tests. This is never contacted, but we must use * a url of valid format to avoid validation errors. diff --git a/tests/phpunit/includes/http/HttpRequestFactoryTest.php b/tests/phpunit/unit/includes/http/HttpRequestFactoryTest.php similarity index 97% rename from tests/phpunit/includes/http/HttpRequestFactoryTest.php rename to tests/phpunit/unit/includes/http/HttpRequestFactoryTest.php index 7429dcc9dd..61c67fde57 100644 --- a/tests/phpunit/includes/http/HttpRequestFactoryTest.php +++ b/tests/phpunit/unit/includes/http/HttpRequestFactoryTest.php @@ -5,7 +5,7 @@ use MediaWiki\Http\HttpRequestFactory; /** * @covers MediaWiki\Http\HttpRequestFactory */ -class HttpRequestFactoryTest extends MediaWikiTestCase { +class HttpRequestFactoryTest extends \MediaWikiUnitTestCase { /** * @return HttpRequestFactory diff --git a/tests/phpunit/includes/installer/InstallDocFormatterTest.php b/tests/phpunit/unit/includes/installer/InstallDocFormatterTest.php similarity index 97% rename from tests/phpunit/includes/installer/InstallDocFormatterTest.php rename to tests/phpunit/unit/includes/installer/InstallDocFormatterTest.php index 9584d4b8c4..fddc3b8680 100644 --- a/tests/phpunit/includes/installer/InstallDocFormatterTest.php +++ b/tests/phpunit/unit/includes/installer/InstallDocFormatterTest.php @@ -1,6 +1,6 @@ installed = __DIR__ . "/../../../data/composer/installed.json"; + $this->installed = __DIR__ . "/../../../../data/composer/installed.json"; } /** diff --git a/tests/phpunit/includes/libs/composer/ComposerJsonTest.php b/tests/phpunit/unit/includes/libs/composer/ComposerJsonTest.php similarity index 85% rename from tests/phpunit/includes/libs/composer/ComposerJsonTest.php rename to tests/phpunit/unit/includes/libs/composer/ComposerJsonTest.php index 720fa6e8fd..a009a51a9e 100644 --- a/tests/phpunit/includes/libs/composer/ComposerJsonTest.php +++ b/tests/phpunit/unit/includes/libs/composer/ComposerJsonTest.php @@ -6,8 +6,8 @@ class ComposerJsonTest extends PHPUnit\Framework\TestCase { public function setUp() { parent::setUp(); - $this->json = __DIR__ . "/../../../data/composer/composer.json"; - $this->json2 = __DIR__ . "/../../../data/composer/new-composer.json"; + $this->json = __DIR__ . "/../../../../data/composer/composer.json"; + $this->json2 = __DIR__ . "/../../../../data/composer/new-composer.json"; } /** diff --git a/tests/phpunit/includes/libs/composer/ComposerLockTest.php b/tests/phpunit/unit/includes/libs/composer/ComposerLockTest.php similarity index 97% rename from tests/phpunit/includes/libs/composer/ComposerLockTest.php rename to tests/phpunit/unit/includes/libs/composer/ComposerLockTest.php index f5fcdbe018..90c036a472 100644 --- a/tests/phpunit/includes/libs/composer/ComposerLockTest.php +++ b/tests/phpunit/unit/includes/libs/composer/ComposerLockTest.php @@ -6,7 +6,7 @@ class ComposerLockTest extends PHPUnit\Framework\TestCase { public function setUp() { parent::setUp(); - $this->lock = __DIR__ . "/../../../data/composer/composer.lock"; + $this->lock = __DIR__ . "/../../../../data/composer/composer.lock"; } /** diff --git a/tests/phpunit/includes/libs/http/HttpAcceptNegotiatorTest.php b/tests/phpunit/unit/includes/libs/http/HttpAcceptNegotiatorTest.php similarity index 100% rename from tests/phpunit/includes/libs/http/HttpAcceptNegotiatorTest.php rename to tests/phpunit/unit/includes/libs/http/HttpAcceptNegotiatorTest.php diff --git a/tests/phpunit/includes/libs/http/HttpAcceptParserTest.php b/tests/phpunit/unit/includes/libs/http/HttpAcceptParserTest.php similarity index 100% rename from tests/phpunit/includes/libs/http/HttpAcceptParserTest.php rename to tests/phpunit/unit/includes/libs/http/HttpAcceptParserTest.php diff --git a/tests/phpunit/includes/libs/mime/MSCompoundFileReaderTest.php b/tests/phpunit/unit/includes/libs/mime/MSCompoundFileReaderTest.php similarity index 90% rename from tests/phpunit/includes/libs/mime/MSCompoundFileReaderTest.php rename to tests/phpunit/unit/includes/libs/mime/MSCompoundFileReaderTest.php index 4509a61eb7..7cc0525660 100644 --- a/tests/phpunit/includes/libs/mime/MSCompoundFileReaderTest.php +++ b/tests/phpunit/unit/includes/libs/mime/MSCompoundFileReaderTest.php @@ -19,6 +19,17 @@ * @covers MSCompoundFileReader */ class MSCompoundFileReaderTest extends PHPUnit\Framework\TestCase { + + protected function setUp() { + parent::setUp(); + + if ( php_uname( 's' ) === 'Darwin' ) { + $this->markTestSkipped( + 'T225019: Disable this test on macOS for now due to byte-order issues' + ); + } + } + public static function provideValid() { return [ [ 'calc.xls', 'application/vnd.ms-excel' ], diff --git a/tests/phpunit/includes/libs/mime/MimeAnalyzerTest.php b/tests/phpunit/unit/includes/libs/mime/MimeAnalyzerTest.php similarity index 86% rename from tests/phpunit/includes/libs/mime/MimeAnalyzerTest.php rename to tests/phpunit/unit/includes/libs/mime/MimeAnalyzerTest.php index 194781207e..e78489d7bf 100644 --- a/tests/phpunit/includes/libs/mime/MimeAnalyzerTest.php +++ b/tests/phpunit/unit/includes/libs/mime/MimeAnalyzerTest.php @@ -69,7 +69,7 @@ class MimeAnalyzerTest extends PHPUnit\Framework\TestCase { * MEDIATYPE_VIDEO (T65584) */ function testOggRecognize() { - $oggFile = __DIR__ . '/../../../data/media/say-test.ogg'; + $oggFile = __DIR__ . '/../../../../data/media/say-test.ogg'; $actualType = $this->mimeAnalyzer->getMediaType( $oggFile, 'application/ogg' ); $this->assertEquals( MEDIATYPE_AUDIO, $actualType ); } @@ -79,7 +79,7 @@ class MimeAnalyzerTest extends PHPUnit\Framework\TestCase { * MEDIATYPE_MULTIMEDIA (bug T151352) */ function testOpusRecognize() { - $oggFile = __DIR__ . '/../../../data/media/say-test.opus'; + $oggFile = __DIR__ . '/../../../../data/media/say-test.opus'; $actualType = $this->mimeAnalyzer->getMediaType( $oggFile, 'application/ogg' ); $this->assertEquals( MEDIATYPE_AUDIO, $actualType ); } @@ -88,7 +88,7 @@ class MimeAnalyzerTest extends PHPUnit\Framework\TestCase { * Test to make sure that mp3 files are detected as audio type */ function testMP3AsAudio() { - $file = __DIR__ . '/../../../data/media/say-test-with-id3.mp3'; + $file = __DIR__ . '/../../../../data/media/say-test-with-id3.mp3'; $actualType = $this->mimeAnalyzer->getMediaType( $file ); $this->assertEquals( MEDIATYPE_AUDIO, $actualType ); } @@ -97,7 +97,7 @@ class MimeAnalyzerTest extends PHPUnit\Framework\TestCase { * Test to make sure that MP3 with id3 tag is recognized */ function testMP3WithID3Recognize() { - $file = __DIR__ . '/../../../data/media/say-test-with-id3.mp3'; + $file = __DIR__ . '/../../../../data/media/say-test-with-id3.mp3'; $actualType = $this->doGuessMimeType( [ $file, 'mp3' ] ); $this->assertEquals( 'audio/mpeg', $actualType ); } @@ -106,7 +106,7 @@ class MimeAnalyzerTest extends PHPUnit\Framework\TestCase { * Test to make sure that MP3 without id3 tag is recognized (MPEG-1 sample rates) */ function testMP3NoID3RecognizeMPEG1() { - $file = __DIR__ . '/../../../data/media/say-test-mpeg1.mp3'; + $file = __DIR__ . '/../../../../data/media/say-test-mpeg1.mp3'; $actualType = $this->doGuessMimeType( [ $file, 'mp3' ] ); $this->assertEquals( 'audio/mpeg', $actualType ); } @@ -115,7 +115,7 @@ class MimeAnalyzerTest extends PHPUnit\Framework\TestCase { * Test to make sure that MP3 without id3 tag is recognized (MPEG-2 sample rates) */ function testMP3NoID3RecognizeMPEG2() { - $file = __DIR__ . '/../../../data/media/say-test-mpeg2.mp3'; + $file = __DIR__ . '/../../../../data/media/say-test-mpeg2.mp3'; $actualType = $this->doGuessMimeType( [ $file, 'mp3' ] ); $this->assertEquals( 'audio/mpeg', $actualType ); } @@ -124,7 +124,7 @@ class MimeAnalyzerTest extends PHPUnit\Framework\TestCase { * Test to make sure that MP3 without id3 tag is recognized (MPEG-2.5 sample rates) */ function testMP3NoID3RecognizeMPEG2_5() { - $file = __DIR__ . '/../../../data/media/say-test-mpeg2.5.mp3'; + $file = __DIR__ . '/../../../../data/media/say-test-mpeg2.5.mp3'; $actualType = $this->doGuessMimeType( [ $file, 'mp3' ] ); $this->assertEquals( 'audio/mpeg', $actualType ); } @@ -133,7 +133,13 @@ class MimeAnalyzerTest extends PHPUnit\Framework\TestCase { * A ZIP file embedded in the middle of a .doc file is still a Word Document. */ function testZipInDoc() { - $file = __DIR__ . '/../../../data/media/zip-in-doc.doc'; + if ( php_uname( 's' ) === 'Darwin' ) { + $this->markTestSkipped( + 'T225019: Disable this test on macOS for now due to byte-order issues' + ); + } + + $file = __DIR__ . '/../../../../data/media/zip-in-doc.doc'; $actualType = $this->doGuessMimeType( [ $file, 'doc' ] ); $this->assertEquals( 'application/msword', $actualType ); } diff --git a/tests/phpunit/includes/libs/objectcache/CachedBagOStuffTest.php b/tests/phpunit/unit/includes/libs/objectcache/CachedBagOStuffTest.php similarity index 100% rename from tests/phpunit/includes/libs/objectcache/CachedBagOStuffTest.php rename to tests/phpunit/unit/includes/libs/objectcache/CachedBagOStuffTest.php diff --git a/tests/phpunit/includes/libs/objectcache/HashBagOStuffTest.php b/tests/phpunit/unit/includes/libs/objectcache/HashBagOStuffTest.php similarity index 100% rename from tests/phpunit/includes/libs/objectcache/HashBagOStuffTest.php rename to tests/phpunit/unit/includes/libs/objectcache/HashBagOStuffTest.php diff --git a/tests/phpunit/includes/libs/objectcache/ReplicatedBagOStuffTest.php b/tests/phpunit/unit/includes/libs/objectcache/ReplicatedBagOStuffTest.php similarity index 95% rename from tests/phpunit/includes/libs/objectcache/ReplicatedBagOStuffTest.php rename to tests/phpunit/unit/includes/libs/objectcache/ReplicatedBagOStuffTest.php index 550ec0bd09..64d282f487 100644 --- a/tests/phpunit/includes/libs/objectcache/ReplicatedBagOStuffTest.php +++ b/tests/phpunit/unit/includes/libs/objectcache/ReplicatedBagOStuffTest.php @@ -1,6 +1,6 @@ mediaPath = __DIR__ . '/../../data/media/'; + $this->mediaPath = __DIR__ . '/../../../data/media/'; } /** diff --git a/tests/phpunit/includes/media/IPTCTest.php b/tests/phpunit/unit/includes/media/IPTCTest.php similarity index 98% rename from tests/phpunit/includes/media/IPTCTest.php rename to tests/phpunit/unit/includes/media/IPTCTest.php index 4b3ba0755c..430493cd20 100644 --- a/tests/phpunit/includes/media/IPTCTest.php +++ b/tests/phpunit/unit/includes/media/IPTCTest.php @@ -3,7 +3,7 @@ /** * @group Media */ -class IPTCTest extends MediaWikiTestCase { +class IPTCTest extends \MediaWikiUnitTestCase { /** * @covers IPTC::getCharset diff --git a/tests/phpunit/includes/media/JpegMetadataExtractorTest.php b/tests/phpunit/unit/includes/media/JpegMetadataExtractorTest.php similarity index 97% rename from tests/phpunit/includes/media/JpegMetadataExtractorTest.php rename to tests/phpunit/unit/includes/media/JpegMetadataExtractorTest.php index c943cef906..6063f3e9da 100644 --- a/tests/phpunit/includes/media/JpegMetadataExtractorTest.php +++ b/tests/phpunit/unit/includes/media/JpegMetadataExtractorTest.php @@ -9,14 +9,14 @@ * @group Media * @covers JpegMetadataExtractor */ -class JpegMetadataExtractorTest extends MediaWikiTestCase { +class JpegMetadataExtractorTest extends \MediaWikiUnitTestCase { protected $filePath; protected function setUp() { parent::setUp(); - $this->filePath = __DIR__ . '/../../data/media/'; + $this->filePath = __DIR__ . '/../../../data/media/'; } /** diff --git a/tests/phpunit/includes/media/MediaHandlerTest.php b/tests/phpunit/unit/includes/media/MediaHandlerTest.php similarity index 96% rename from tests/phpunit/includes/media/MediaHandlerTest.php rename to tests/phpunit/unit/includes/media/MediaHandlerTest.php index 7a052f6035..eb4ece88c4 100644 --- a/tests/phpunit/includes/media/MediaHandlerTest.php +++ b/tests/phpunit/unit/includes/media/MediaHandlerTest.php @@ -3,7 +3,7 @@ /** * @group Media */ -class MediaHandlerTest extends MediaWikiTestCase { +class MediaHandlerTest extends \MediaWikiUnitTestCase { /** * @covers MediaHandler::fitBoxWidth diff --git a/tests/phpunit/includes/media/SVGMetadataExtractorTest.php b/tests/phpunit/unit/includes/media/SVGMetadataExtractorTest.php similarity index 96% rename from tests/phpunit/includes/media/SVGMetadataExtractorTest.php rename to tests/phpunit/unit/includes/media/SVGMetadataExtractorTest.php index 6b94d0ae6c..30d10083f4 100644 --- a/tests/phpunit/includes/media/SVGMetadataExtractorTest.php +++ b/tests/phpunit/unit/includes/media/SVGMetadataExtractorTest.php @@ -4,7 +4,7 @@ * @group Media * @covers SVGMetadataExtractor */ -class SVGMetadataExtractorTest extends MediaWikiTestCase { +class SVGMetadataExtractorTest extends \MediaWikiUnitTestCase { /** * @dataProvider provideSvgFiles @@ -46,7 +46,7 @@ class SVGMetadataExtractorTest extends MediaWikiTestCase { } public static function provideSvgFiles() { - $base = __DIR__ . '/../../data/media'; + $base = __DIR__ . '/../../../data/media'; return [ [ @@ -143,7 +143,7 @@ class SVGMetadataExtractorTest extends MediaWikiTestCase { } public static function provideSvgFilesWithXMLMetadata() { - $base = __DIR__ . '/../../data/media'; + $base = __DIR__ . '/../../../data/media'; // phpcs:disable Generic.Files.LineLength $metadata = ' diff --git a/tests/phpunit/includes/media/WebPHandlerTest.php b/tests/phpunit/unit/includes/media/WebPHandlerTest.php similarity index 92% rename from tests/phpunit/includes/media/WebPHandlerTest.php rename to tests/phpunit/unit/includes/media/WebPHandlerTest.php index ac0ad98edd..6c8600d188 100644 --- a/tests/phpunit/includes/media/WebPHandlerTest.php +++ b/tests/phpunit/unit/includes/media/WebPHandlerTest.php @@ -3,7 +3,7 @@ /** * @covers WebPHandler */ -class WebPHandlerTest extends MediaWikiTestCase { +class WebPHandlerTest extends \MediaWikiUnitTestCase { public function setUp() { parent::setUp(); // Allocated file for testing @@ -86,14 +86,14 @@ class WebPHandlerTest extends MediaWikiTestCase { public function provideTestWithFileExtractMetaData() { return [ - [ __DIR__ . '/../../data/media/2_webp_ll.webp', + [ __DIR__ . '/../../../data/media/2_webp_ll.webp', [ 'compression' => 'lossless', 'width' => 386, 'height' => 395 ] ], - [ __DIR__ . '/../../data/media/2_webp_a.webp', + [ __DIR__ . '/../../../data/media/2_webp_a.webp', [ 'compression' => 'lossy', 'animated' => false, @@ -116,9 +116,9 @@ class WebPHandlerTest extends MediaWikiTestCase { public function provideTestGetImageSize() { return [ // Public domain files from https://developers.google.com/speed/webp/gallery2 - [ __DIR__ . '/../../data/media/2_webp_a.webp', [ 386, 395 ] ], - [ __DIR__ . '/../../data/media/2_webp_ll.webp', [ 386, 395 ] ], - [ __DIR__ . '/../../data/media/webp_animated.webp', [ 300, 225 ] ], + [ __DIR__ . '/../../../data/media/2_webp_a.webp', [ 386, 395 ] ], + [ __DIR__ . '/../../../data/media/2_webp_ll.webp', [ 386, 395 ] ], + [ __DIR__ . '/../../../data/media/webp_animated.webp', [ 300, 225 ] ], // Error cases [ __FILE__, false ], @@ -139,9 +139,9 @@ class WebPHandlerTest extends MediaWikiTestCase { public function provideTestGetMimeType() { return [ // Public domain files from https://developers.google.com/speed/webp/gallery2 - [ __DIR__ . '/../../data/media/2_webp_a.webp' ], - [ __DIR__ . '/../../data/media/2_webp_ll.webp' ], - [ __DIR__ . '/../../data/media/webp_animated.webp' ], + [ __DIR__ . '/../../../data/media/2_webp_a.webp' ], + [ __DIR__ . '/../../../data/media/2_webp_ll.webp' ], + [ __DIR__ . '/../../../data/media/webp_animated.webp' ], ]; } } diff --git a/tests/phpunit/includes/objectcache/MemcachedBagOStuffTest.php b/tests/phpunit/unit/includes/objectcache/MemcachedBagOStuffTest.php similarity index 98% rename from tests/phpunit/includes/objectcache/MemcachedBagOStuffTest.php rename to tests/phpunit/unit/includes/objectcache/MemcachedBagOStuffTest.php index 45971daced..eb040b4501 100644 --- a/tests/phpunit/includes/objectcache/MemcachedBagOStuffTest.php +++ b/tests/phpunit/unit/includes/objectcache/MemcachedBagOStuffTest.php @@ -2,7 +2,7 @@ /** * @group BagOStuff */ -class MemcachedBagOStuffTest extends MediaWikiTestCase { +class MemcachedBagOStuffTest extends \MediaWikiUnitTestCase { /** @var MemcachedBagOStuff */ private $cache; diff --git a/tests/phpunit/includes/objectcache/RESTBagOStuffTest.php b/tests/phpunit/unit/includes/objectcache/RESTBagOStuffTest.php similarity index 98% rename from tests/phpunit/includes/objectcache/RESTBagOStuffTest.php rename to tests/phpunit/unit/includes/objectcache/RESTBagOStuffTest.php index dfbca706d6..459e3eebc2 100644 --- a/tests/phpunit/includes/objectcache/RESTBagOStuffTest.php +++ b/tests/phpunit/unit/includes/objectcache/RESTBagOStuffTest.php @@ -4,7 +4,7 @@ * * @covers RESTBagOStuff */ -class RESTBagOStuffTest extends MediaWikiTestCase { +class RESTBagOStuffTest extends \MediaWikiUnitTestCase { /** * @var MultiHttpClient diff --git a/tests/phpunit/includes/objectcache/RedisBagOStuffTest.php b/tests/phpunit/unit/includes/objectcache/RedisBagOStuffTest.php similarity index 100% rename from tests/phpunit/includes/objectcache/RedisBagOStuffTest.php rename to tests/phpunit/unit/includes/objectcache/RedisBagOStuffTest.php diff --git a/tests/phpunit/includes/page/ArticleTest.php b/tests/phpunit/unit/includes/page/ArticleTest.php similarity index 96% rename from tests/phpunit/includes/page/ArticleTest.php rename to tests/phpunit/unit/includes/page/ArticleTest.php index df4a281701..61fb4b6055 100644 --- a/tests/phpunit/includes/page/ArticleTest.php +++ b/tests/phpunit/unit/includes/page/ArticleTest.php @@ -1,6 +1,6 @@ preprocessToXml( $className, $wikiText ); diff --git a/tests/phpunit/includes/parser/TidyTest.php b/tests/phpunit/unit/includes/parser/TidyTest.php similarity index 97% rename from tests/phpunit/includes/parser/TidyTest.php rename to tests/phpunit/unit/includes/parser/TidyTest.php index 898ef2d163..1adb6a6444 100644 --- a/tests/phpunit/includes/parser/TidyTest.php +++ b/tests/phpunit/unit/includes/parser/TidyTest.php @@ -4,7 +4,7 @@ * @group Parser * @covers MWTidy */ -class TidyTest extends MediaWikiTestCase { +class TidyTest extends \MediaWikiUnitTestCase { protected function setUp() { parent::setUp(); diff --git a/tests/phpunit/includes/password/PasswordFactoryTest.php b/tests/phpunit/unit/includes/password/PasswordFactoryTest.php similarity index 98% rename from tests/phpunit/includes/password/PasswordFactoryTest.php rename to tests/phpunit/unit/includes/password/PasswordFactoryTest.php index a7b3557516..96e74b1072 100644 --- a/tests/phpunit/includes/password/PasswordFactoryTest.php +++ b/tests/phpunit/unit/includes/password/PasswordFactoryTest.php @@ -3,7 +3,7 @@ /** * @covers PasswordFactory */ -class PasswordFactoryTest extends MediaWikiTestCase { +class PasswordFactoryTest extends \MediaWikiUnitTestCase { public function testConstruct() { $pf = new PasswordFactory(); $this->assertEquals( [ '' ], array_keys( $pf->getTypes() ) ); diff --git a/tests/phpunit/includes/password/PasswordTest.php b/tests/phpunit/unit/includes/password/PasswordTest.php similarity index 95% rename from tests/phpunit/includes/password/PasswordTest.php rename to tests/phpunit/unit/includes/password/PasswordTest.php index 61a5147277..b41c0f4150 100644 --- a/tests/phpunit/includes/password/PasswordTest.php +++ b/tests/phpunit/unit/includes/password/PasswordTest.php @@ -23,7 +23,7 @@ /** * @covers InvalidPassword */ -class PasswordTest extends MediaWikiTestCase { +class PasswordTest extends \MediaWikiUnitTestCase { public function testInvalidPlaintext() { $passwordFactory = new PasswordFactory(); $invalid = $passwordFactory->newFromPlaintext( null ); diff --git a/tests/phpunit/includes/preferences/FiltersTest.php b/tests/phpunit/unit/includes/preferences/FiltersTest.php similarity index 98% rename from tests/phpunit/includes/preferences/FiltersTest.php rename to tests/phpunit/unit/includes/preferences/FiltersTest.php index 60b01b880c..d2b5d05bb3 100644 --- a/tests/phpunit/includes/preferences/FiltersTest.php +++ b/tests/phpunit/unit/includes/preferences/FiltersTest.php @@ -25,7 +25,7 @@ use MediaWiki\Preferences\TimezoneFilter; /** * @group Preferences */ -class FiltersTest extends MediaWikiTestCase { +class FiltersTest extends \MediaWikiUnitTestCase { /** * @covers MediaWiki\Preferences\IntvalFilter::filterFromForm() * @covers MediaWiki\Preferences\IntvalFilter::filterForForm() diff --git a/tests/phpunit/includes/registration/ExtensionJsonValidatorTest.php b/tests/phpunit/unit/includes/registration/ExtensionJsonValidatorTest.php similarity index 95% rename from tests/phpunit/includes/registration/ExtensionJsonValidatorTest.php rename to tests/phpunit/unit/includes/registration/ExtensionJsonValidatorTest.php index 46c697f8ba..77bc23b1a7 100644 --- a/tests/phpunit/includes/registration/ExtensionJsonValidatorTest.php +++ b/tests/phpunit/unit/includes/registration/ExtensionJsonValidatorTest.php @@ -21,7 +21,7 @@ /** * @covers ExtensionJsonValidator */ -class ExtensionJsonValidatorTest extends MediaWikiTestCase { +class ExtensionJsonValidatorTest extends \MediaWikiUnitTestCase { /** * @dataProvider provideValidate @@ -39,7 +39,7 @@ class ExtensionJsonValidatorTest extends MediaWikiTestCase { ); } - $dir = __DIR__ . '/../../data/registration/'; + $dir = __DIR__ . '/../../../data/registration/'; $this->assertSame( $expected, $validator->validate( $dir . $file ) diff --git a/tests/phpunit/includes/registration/ExtensionProcessorTest.php b/tests/phpunit/unit/includes/registration/ExtensionProcessorTest.php similarity index 99% rename from tests/phpunit/includes/registration/ExtensionProcessorTest.php rename to tests/phpunit/unit/includes/registration/ExtensionProcessorTest.php index cdd5c63eff..13de142ae6 100644 --- a/tests/phpunit/includes/registration/ExtensionProcessorTest.php +++ b/tests/phpunit/unit/includes/registration/ExtensionProcessorTest.php @@ -5,7 +5,7 @@ use Wikimedia\TestingAccessWrapper; /** * @covers ExtensionProcessor */ -class ExtensionProcessorTest extends MediaWikiTestCase { +class ExtensionProcessorTest extends \MediaWikiUnitTestCase { private $dir, $dirname; diff --git a/tests/phpunit/includes/registration/VersionCheckerTest.php b/tests/phpunit/unit/includes/registration/VersionCheckerTest.php similarity index 100% rename from tests/phpunit/includes/registration/VersionCheckerTest.php rename to tests/phpunit/unit/includes/registration/VersionCheckerTest.php diff --git a/tests/phpunit/includes/resourceloader/DerivativeResourceLoaderContextTest.php b/tests/phpunit/unit/includes/resourceloader/DerivativeResourceLoaderContextTest.php similarity index 100% rename from tests/phpunit/includes/resourceloader/DerivativeResourceLoaderContextTest.php rename to tests/phpunit/unit/includes/resourceloader/DerivativeResourceLoaderContextTest.php diff --git a/tests/phpunit/includes/resourceloader/MessageBlobStoreTest.php b/tests/phpunit/unit/includes/resourceloader/MessageBlobStoreTest.php similarity index 92% rename from tests/phpunit/includes/resourceloader/MessageBlobStoreTest.php rename to tests/phpunit/unit/includes/resourceloader/MessageBlobStoreTest.php index e094d92b9d..d8a94e735d 100644 --- a/tests/phpunit/includes/resourceloader/MessageBlobStoreTest.php +++ b/tests/phpunit/unit/includes/resourceloader/MessageBlobStoreTest.php @@ -1,12 +1,14 @@ clock = 1301655600.000; $this->wanCache->setMockTime( $this->clock ); + + $lbMock = $this->createMock( LoadBalancer::class ); + $dbMock = $this->getMockBuilder( Database::class ) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $lbMock->expects( $this->any() ) + ->method( 'getConnection' ) + ->willReturn( $dbMock ); + + $lbMockFactory = function () use ( $lbMock ): LoadBalancer { + return $lbMock; + }; + + $this->overrideMwServices( [ 'DBLoadBalancer' => $lbMockFactory ] ); } public function testBlobCreation() { diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php b/tests/phpunit/unit/includes/resourceloader/ResourceLoaderClientHtmlTest.php similarity index 100% rename from tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php rename to tests/phpunit/unit/includes/resourceloader/ResourceLoaderClientHtmlTest.php diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderContextTest.php b/tests/phpunit/unit/includes/resourceloader/ResourceLoaderContextTest.php similarity index 100% rename from tests/phpunit/includes/resourceloader/ResourceLoaderContextTest.php rename to tests/phpunit/unit/includes/resourceloader/ResourceLoaderContextTest.php diff --git a/tests/phpunit/includes/search/SearchIndexFieldTest.php b/tests/phpunit/unit/includes/search/SearchIndexFieldTest.php similarity index 95% rename from tests/phpunit/includes/search/SearchIndexFieldTest.php rename to tests/phpunit/unit/includes/search/SearchIndexFieldTest.php index 8b4119e0d3..a640c967cc 100644 --- a/tests/phpunit/includes/search/SearchIndexFieldTest.php +++ b/tests/phpunit/unit/includes/search/SearchIndexFieldTest.php @@ -4,7 +4,7 @@ * @group Search * @covers SearchIndexFieldDefinition */ -class SearchIndexFieldTest extends MediaWikiTestCase { +class SearchIndexFieldTest extends \MediaWikiUnitTestCase { public function getMergeCases() { return [ diff --git a/tests/phpunit/includes/search/SearchSuggestionSetTest.php b/tests/phpunit/unit/includes/search/SearchSuggestionSetTest.php similarity index 100% rename from tests/phpunit/includes/search/SearchSuggestionSetTest.php rename to tests/phpunit/unit/includes/search/SearchSuggestionSetTest.php diff --git a/tests/phpunit/includes/session/MetadataMergeExceptionTest.php b/tests/phpunit/unit/includes/session/MetadataMergeExceptionTest.php similarity index 88% rename from tests/phpunit/includes/session/MetadataMergeExceptionTest.php rename to tests/phpunit/unit/includes/session/MetadataMergeExceptionTest.php index 8cb4302a4e..707adfe5b0 100644 --- a/tests/phpunit/includes/session/MetadataMergeExceptionTest.php +++ b/tests/phpunit/unit/includes/session/MetadataMergeExceptionTest.php @@ -2,13 +2,11 @@ namespace MediaWiki\Session; -use MediaWikiTestCase; - /** * @group Session * @covers MediaWiki\Session\MetadataMergeException */ -class MetadataMergeExceptionTest extends MediaWikiTestCase { +class MetadataMergeExceptionTest extends \MediaWikiUnitTestCase { public function testBasics() { $data = [ 'foo' => 'bar' ]; diff --git a/tests/phpunit/includes/session/SessionIdTest.php b/tests/phpunit/unit/includes/session/SessionIdTest.php similarity index 83% rename from tests/phpunit/includes/session/SessionIdTest.php rename to tests/phpunit/unit/includes/session/SessionIdTest.php index 2b06d971a6..3c7f8cbfdf 100644 --- a/tests/phpunit/includes/session/SessionIdTest.php +++ b/tests/phpunit/unit/includes/session/SessionIdTest.php @@ -2,13 +2,11 @@ namespace MediaWiki\Session; -use MediaWikiTestCase; - /** * @group Session * @covers MediaWiki\Session\SessionId */ -class SessionIdTest extends MediaWikiTestCase { +class SessionIdTest extends \MediaWikiUnitTestCase { public function testEverything() { $id = new SessionId( 'foo' ); diff --git a/tests/phpunit/includes/session/SessionInfoTest.php b/tests/phpunit/unit/includes/session/SessionInfoTest.php similarity index 98% rename from tests/phpunit/includes/session/SessionInfoTest.php rename to tests/phpunit/unit/includes/session/SessionInfoTest.php index 8f7b2a6e70..a3a6365fbb 100644 --- a/tests/phpunit/includes/session/SessionInfoTest.php +++ b/tests/phpunit/unit/includes/session/SessionInfoTest.php @@ -2,19 +2,20 @@ namespace MediaWiki\Session; -use MediaWikiTestCase; - /** * @group Session * @group Database * @covers MediaWiki\Session\SessionInfo */ -class SessionInfoTest extends MediaWikiTestCase { +class SessionInfoTest extends \MediaWikiUnitTestCase { public function testBasics() { + $sysopUser = new \User(); + $sysopUser->setName( 'UTSysop' ); + $anonInfo = UserInfo::newAnonymous(); - $userInfo = UserInfo::newFromName( 'UTSysop', true ); - $unverifiedUserInfo = UserInfo::newFromName( 'UTSysop', false ); + $userInfo = UserInfo::newFromUser( $sysopUser, true ); + $unverifiedUserInfo = UserInfo::newFromUser( $sysopUser, false ); try { new SessionInfo( SessionInfo::MIN_PRIORITY - 1, [] ); diff --git a/tests/phpunit/includes/session/SessionProviderTest.php b/tests/phpunit/unit/includes/session/SessionProviderTest.php similarity index 98% rename from tests/phpunit/includes/session/SessionProviderTest.php rename to tests/phpunit/unit/includes/session/SessionProviderTest.php index 6ff6a97b8f..114fa24a3d 100644 --- a/tests/phpunit/includes/session/SessionProviderTest.php +++ b/tests/phpunit/unit/includes/session/SessionProviderTest.php @@ -2,7 +2,6 @@ namespace MediaWiki\Session; -use MediaWikiTestCase; use Wikimedia\TestingAccessWrapper; /** @@ -10,7 +9,7 @@ use Wikimedia\TestingAccessWrapper; * @group Database * @covers MediaWiki\Session\SessionProvider */ -class SessionProviderTest extends MediaWikiTestCase { +class SessionProviderTest extends \MediaWikiUnitTestCase { public function testBasics() { $manager = new SessionManager(); diff --git a/tests/phpunit/includes/session/SessionTest.php b/tests/phpunit/unit/includes/session/SessionTest.php similarity index 99% rename from tests/phpunit/includes/session/SessionTest.php rename to tests/phpunit/unit/includes/session/SessionTest.php index a74056d0ca..73bf060638 100644 --- a/tests/phpunit/includes/session/SessionTest.php +++ b/tests/phpunit/unit/includes/session/SessionTest.php @@ -3,7 +3,6 @@ namespace MediaWiki\Session; use Psr\Log\LogLevel; -use MediaWikiTestCase; use User; use Wikimedia\TestingAccessWrapper; @@ -11,7 +10,7 @@ use Wikimedia\TestingAccessWrapper; * @group Session * @covers MediaWiki\Session\Session */ -class SessionTest extends MediaWikiTestCase { +class SessionTest extends \MediaWikiUnitTestCase { public function testConstructor() { $backend = TestUtils::getDummySessionBackend(); diff --git a/tests/phpunit/includes/session/TokenTest.php b/tests/phpunit/unit/includes/session/TokenTest.php similarity index 96% rename from tests/phpunit/includes/session/TokenTest.php rename to tests/phpunit/unit/includes/session/TokenTest.php index 47976527ca..cab962b3c6 100644 --- a/tests/phpunit/includes/session/TokenTest.php +++ b/tests/phpunit/unit/includes/session/TokenTest.php @@ -2,14 +2,13 @@ namespace MediaWiki\Session; -use MediaWikiTestCase; use Wikimedia\TestingAccessWrapper; /** * @group Session * @covers MediaWiki\Session\Token */ -class TokenTest extends MediaWikiTestCase { +class TokenTest extends \MediaWikiUnitTestCase { public function testBasics() { $token = $this->getMockBuilder( Token::class ) diff --git a/tests/phpunit/includes/shell/CommandFactoryTest.php b/tests/phpunit/unit/includes/shell/CommandFactoryTest.php similarity index 100% rename from tests/phpunit/includes/shell/CommandFactoryTest.php rename to tests/phpunit/unit/includes/shell/CommandFactoryTest.php diff --git a/tests/phpunit/includes/shell/CommandTest.php b/tests/phpunit/unit/includes/shell/CommandTest.php similarity index 100% rename from tests/phpunit/includes/shell/CommandTest.php rename to tests/phpunit/unit/includes/shell/CommandTest.php diff --git a/tests/phpunit/includes/shell/FirejailCommandTest.php b/tests/phpunit/unit/includes/shell/FirejailCommandTest.php similarity index 94% rename from tests/phpunit/includes/shell/FirejailCommandTest.php rename to tests/phpunit/unit/includes/shell/FirejailCommandTest.php index 681c3dcda0..b87271fd31 100644 --- a/tests/phpunit/includes/shell/FirejailCommandTest.php +++ b/tests/phpunit/unit/includes/shell/FirejailCommandTest.php @@ -29,10 +29,11 @@ class FirejailCommandTest extends PHPUnit\Framework\TestCase { public function provideBuildFinalCommand() { global $IP; + $basePath = realpath( $IP ); // phpcs:ignore Generic.Files.LineLength $env = "'MW_INCLUDE_STDERR=;MW_CPU_LIMIT=180; MW_CGROUP='\'''\''; MW_MEM_LIMIT=307200; MW_FILE_SIZE_LIMIT=102400; MW_WALL_CLOCK_LIMIT=180; MW_USE_LOG_PIPE=yes'"; - $limit = "/bin/bash '$IP/includes/shell/limit.sh'"; - $profile = "--profile=$IP/includes/shell/firejail.profile"; + $limit = "/bin/bash '$basePath/includes/shell/limit.sh'"; + $profile = "--profile=$basePath/includes/shell/firejail.profile"; $blacklist = '--blacklist=' . realpath( MW_CONFIG_FILE ); $default = "$blacklist --noroot --seccomp --private-dev"; return [ diff --git a/tests/phpunit/includes/site/CachingSiteStoreTest.php b/tests/phpunit/unit/includes/site/CachingSiteStoreTest.php similarity index 98% rename from tests/phpunit/includes/site/CachingSiteStoreTest.php rename to tests/phpunit/unit/includes/site/CachingSiteStoreTest.php index f04d35ca02..92ed1f53e8 100644 --- a/tests/phpunit/includes/site/CachingSiteStoreTest.php +++ b/tests/phpunit/unit/includes/site/CachingSiteStoreTest.php @@ -27,7 +27,7 @@ * * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ -class CachingSiteStoreTest extends MediaWikiTestCase { +class CachingSiteStoreTest extends \MediaWikiUnitTestCase { /** * @covers CachingSiteStore::getSites diff --git a/tests/phpunit/includes/site/HashSiteStoreTest.php b/tests/phpunit/unit/includes/site/HashSiteStoreTest.php similarity index 97% rename from tests/phpunit/includes/site/HashSiteStoreTest.php rename to tests/phpunit/unit/includes/site/HashSiteStoreTest.php index 6269fd39dc..8b0d4e080b 100644 --- a/tests/phpunit/includes/site/HashSiteStoreTest.php +++ b/tests/phpunit/unit/includes/site/HashSiteStoreTest.php @@ -24,7 +24,7 @@ * * @author Katie Filbert < aude.wiki@gmail.com > */ -class HashSiteStoreTest extends MediaWikiTestCase { +class HashSiteStoreTest extends \MediaWikiUnitTestCase { /** * @covers HashSiteStore::getSites diff --git a/tests/phpunit/includes/site/MediaWikiPageNameNormalizerTest.php b/tests/phpunit/unit/includes/site/MediaWikiPageNameNormalizerTest.php similarity index 100% rename from tests/phpunit/includes/site/MediaWikiPageNameNormalizerTest.php rename to tests/phpunit/unit/includes/site/MediaWikiPageNameNormalizerTest.php diff --git a/tests/phpunit/includes/site/SiteExporterTest.php b/tests/phpunit/unit/includes/site/SiteExporterTest.php similarity index 98% rename from tests/phpunit/includes/site/SiteExporterTest.php rename to tests/phpunit/unit/includes/site/SiteExporterTest.php index 97a43f8d5b..707be45ba3 100644 --- a/tests/phpunit/includes/site/SiteExporterTest.php +++ b/tests/phpunit/unit/includes/site/SiteExporterTest.php @@ -67,7 +67,7 @@ class SiteExporterTest extends PHPUnit\Framework\TestCase { $this->assertContains( '', $xml ); // NOTE: HHVM (at least on wmf Jenkins) doesn't like file URLs. - $xsdFile = __DIR__ . '/../../../../docs/sitelist-1.0.xsd'; + $xsdFile = __DIR__ . '/../../../../../docs/sitelist-1.0.xsd'; $xsdData = file_get_contents( $xsdFile ); $document = new DOMDocument(); diff --git a/tests/phpunit/includes/site/SiteImporterTest.php b/tests/phpunit/unit/includes/site/SiteImporterTest.php similarity index 100% rename from tests/phpunit/includes/site/SiteImporterTest.php rename to tests/phpunit/unit/includes/site/SiteImporterTest.php diff --git a/tests/phpunit/includes/site/SiteImporterTest.xml b/tests/phpunit/unit/includes/site/SiteImporterTest.xml similarity index 100% rename from tests/phpunit/includes/site/SiteImporterTest.xml rename to tests/phpunit/unit/includes/site/SiteImporterTest.xml diff --git a/tests/phpunit/includes/skins/SkinFactoryTest.php b/tests/phpunit/unit/includes/skins/SkinFactoryTest.php similarity index 97% rename from tests/phpunit/includes/skins/SkinFactoryTest.php rename to tests/phpunit/unit/includes/skins/SkinFactoryTest.php index 4289fd9188..8443c8d1f6 100644 --- a/tests/phpunit/includes/skins/SkinFactoryTest.php +++ b/tests/phpunit/unit/includes/skins/SkinFactoryTest.php @@ -1,6 +1,6 @@ */ -class SkinTemplateTest extends MediaWikiTestCase { +class SkinTemplateTest extends \MediaWikiUnitTestCase { /** * @dataProvider makeListItemProvider */ diff --git a/tests/phpunit/includes/skins/SkinTest.php b/tests/phpunit/unit/includes/skins/SkinTest.php similarity index 89% rename from tests/phpunit/includes/skins/SkinTest.php rename to tests/phpunit/unit/includes/skins/SkinTest.php index 41ef2b796a..da42437da3 100644 --- a/tests/phpunit/includes/skins/SkinTest.php +++ b/tests/phpunit/unit/includes/skins/SkinTest.php @@ -1,5 +1,5 @@ getMockBuilder( ImageListPager::class ) + ->disableOriginalConstructor() + ->setMethods( null ) + ->getMock(); + $page->formatValue( 'invalid_field', 'invalid_value' ); } } diff --git a/tests/phpunit/includes/specials/SpecialUploadTest.php b/tests/phpunit/unit/includes/specials/SpecialUploadTest.php similarity index 91% rename from tests/phpunit/includes/specials/SpecialUploadTest.php rename to tests/phpunit/unit/includes/specials/SpecialUploadTest.php index 95026c18d0..a8e3ded611 100644 --- a/tests/phpunit/includes/specials/SpecialUploadTest.php +++ b/tests/phpunit/unit/includes/specials/SpecialUploadTest.php @@ -1,6 +1,6 @@ createMock( LoadBalancer::class ); + + $loadBalancerMock->expects( $this->any() ) + ->method( 'getConnection' ) + ->willReturn( new DatabaseTestHelper( __CLASS__ ) ); + + $loadBalancerMockFactory = function () use ( $loadBalancerMock ): LoadBalancer { + return $loadBalancerMock; + }; + + $this->overrideMwServices( [ 'DBLoadBalancer' => $loadBalancerMockFactory ] ); + } + /** * @dataProvider provideTestGetQueryInfoData * @covers UncategorizedCategoriesPage::getQueryInfo diff --git a/tests/phpunit/includes/tidy/RemexDriverTest.php b/tests/phpunit/unit/includes/tidy/RemexDriverTest.php similarity index 99% rename from tests/phpunit/includes/tidy/RemexDriverTest.php rename to tests/phpunit/unit/includes/tidy/RemexDriverTest.php index 5ad8416b81..24a5b25770 100644 --- a/tests/phpunit/includes/tidy/RemexDriverTest.php +++ b/tests/phpunit/unit/includes/tidy/RemexDriverTest.php @@ -1,6 +1,6 @@ getMockBuilder( Wikimedia\Rdbms\ResultWrapper::class ) diff --git a/tests/phpunit/includes/utils/AvroValidatorTest.php b/tests/phpunit/unit/includes/utils/AvroValidatorTest.php similarity index 100% rename from tests/phpunit/includes/utils/AvroValidatorTest.php rename to tests/phpunit/unit/includes/utils/AvroValidatorTest.php diff --git a/tests/phpunit/includes/utils/BatchRowUpdateTest.php b/tests/phpunit/unit/includes/utils/BatchRowUpdateTest.php similarity index 91% rename from tests/phpunit/includes/utils/BatchRowUpdateTest.php rename to tests/phpunit/unit/includes/utils/BatchRowUpdateTest.php index 52b143393f..92b0d7a4a4 100644 --- a/tests/phpunit/includes/utils/BatchRowUpdateTest.php +++ b/tests/phpunit/unit/includes/utils/BatchRowUpdateTest.php @@ -1,5 +1,7 @@ createMock( ILBFactory::class ); + $lbFactoryMockProvider = function () use ( $lbFactoryMock ): ILBFactory { + return $lbFactoryMock; + }; + + $this->overrideMwServices( [ 'DBLoadBalancerFactory' => $lbFactoryMockProvider ] ); + $db = $this->mockDb( [ 'update' ] ); $writer = new BatchRowWriter( $db, 'echo_event' ); @@ -21,8 +30,16 @@ class BatchRowUpdateTest extends MediaWikiTestCase { self::mockUpdate( [ 'and' => 'something', 'else' => 'changed' ] ), ]; + $ticketMock = 'transaction-ticket'; + $db->expects( $this->exactly( count( $updates ) ) ) ->method( 'update' ); + $lbFactoryMock->expects( $this->any() ) + ->method( 'getEmptyTransactionTicket' ) + ->willReturn( $ticketMock ); + $lbFactoryMock->expects( $this->once() ) + ->method( 'commitAndWaitForReplication' ) + ->with( $this->anything(), $ticketMock ); $writer->write( $updates ); } diff --git a/tests/phpunit/includes/utils/ClassCollectorTest.php b/tests/phpunit/unit/includes/utils/ClassCollectorTest.php similarity index 100% rename from tests/phpunit/includes/utils/ClassCollectorTest.php rename to tests/phpunit/unit/includes/utils/ClassCollectorTest.php diff --git a/tests/phpunit/includes/utils/FileContentsHasherTest.php b/tests/phpunit/unit/includes/utils/FileContentsHasherTest.php similarity index 96% rename from tests/phpunit/includes/utils/FileContentsHasherTest.php rename to tests/phpunit/unit/includes/utils/FileContentsHasherTest.php index 316d9f429a..8bf6779587 100644 --- a/tests/phpunit/includes/utils/FileContentsHasherTest.php +++ b/tests/phpunit/unit/includes/utils/FileContentsHasherTest.php @@ -10,7 +10,7 @@ class FileContentsHasherTest extends PHPUnit\Framework\TestCase { public function provideSingleFile() { return array_map( function ( $file ) { return [ $file, file_get_contents( $file ) ]; - }, glob( __DIR__ . '/../../data/filecontentshasher/*.*' ) ); + }, glob( __DIR__ . '/../../../data/filecontentshasher/*.*' ) ); } public function provideMultipleFiles() { diff --git a/tests/phpunit/includes/utils/MWCryptHashTest.php b/tests/phpunit/unit/includes/utils/MWCryptHashTest.php similarity index 100% rename from tests/phpunit/includes/utils/MWCryptHashTest.php rename to tests/phpunit/unit/includes/utils/MWCryptHashTest.php diff --git a/tests/phpunit/includes/utils/MWRestrictionsTest.php b/tests/phpunit/unit/includes/utils/MWRestrictionsTest.php similarity index 100% rename from tests/phpunit/includes/utils/MWRestrictionsTest.php rename to tests/phpunit/unit/includes/utils/MWRestrictionsTest.php diff --git a/tests/phpunit/includes/utils/UIDGeneratorTest.php b/tests/phpunit/unit/includes/utils/UIDGeneratorTest.php similarity index 100% rename from tests/phpunit/includes/utils/UIDGeneratorTest.php rename to tests/phpunit/unit/includes/utils/UIDGeneratorTest.php diff --git a/tests/phpunit/includes/utils/ZipDirectoryReaderTest.php b/tests/phpunit/unit/includes/utils/ZipDirectoryReaderTest.php similarity index 97% rename from tests/phpunit/includes/utils/ZipDirectoryReaderTest.php rename to tests/phpunit/unit/includes/utils/ZipDirectoryReaderTest.php index a1a3fd7309..e8252a19ed 100644 --- a/tests/phpunit/includes/utils/ZipDirectoryReaderTest.php +++ b/tests/phpunit/unit/includes/utils/ZipDirectoryReaderTest.php @@ -13,7 +13,7 @@ class ZipDirectoryReaderTest extends PHPUnit\Framework\TestCase { protected function setUp() { parent::setUp(); - $this->zipDir = __DIR__ . '/../../data/zip'; + $this->zipDir = __DIR__ . '/../../../data/zip'; } function zipCallback( $entry ) { diff --git a/tests/phpunit/includes/watcheditem/NoWriteWatchedItemStoreUnitTest.php b/tests/phpunit/unit/includes/watcheditem/NoWriteWatchedItemStoreUnitTest.php similarity index 99% rename from tests/phpunit/includes/watcheditem/NoWriteWatchedItemStoreUnitTest.php rename to tests/phpunit/unit/includes/watcheditem/NoWriteWatchedItemStoreUnitTest.php index f424b21b3e..556f518e54 100644 --- a/tests/phpunit/includes/watcheditem/NoWriteWatchedItemStoreUnitTest.php +++ b/tests/phpunit/unit/includes/watcheditem/NoWriteWatchedItemStoreUnitTest.php @@ -7,7 +7,7 @@ use MediaWiki\User\UserIdentityValue; * * @covers NoWriteWatchedItemStore */ -class NoWriteWatchedItemStoreUnitTest extends MediaWikiTestCase { +class NoWriteWatchedItemStoreUnitTest extends \MediaWikiUnitTestCase { public function testAddWatch() { /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */ diff --git a/tests/phpunit/unit/initUnitTests.php b/tests/phpunit/unit/initUnitTests.php new file mode 100644 index 0000000000..ef32cabae7 --- /dev/null +++ b/tests/phpunit/unit/initUnitTests.php @@ -0,0 +1,56 @@ + $value ) { + $GLOBALS[$varName] = $value; + } +} + +define( 'MEDIAWIKI', true ); +define( 'MW_PHPUNIT_TEST', true ); + +// Inject test configuration via callback, bypassing LocalSettings.php +define( 'MW_CONFIG_CALLBACK', '\TestSetup::applyInitialConfig' ); +// We don't use a settings file here but some code still assumes that one exists +define( 'MW_CONFIG_FILE', 'LocalSettings.php' ); + +$IP = realpath( __DIR__ . '/../../..' ); + +// these variables must be defined before setup runs +$GLOBALS['IP'] = $IP; +$GLOBALS['wgCommandLineMode'] = true; + +// Bypass Setup.php's scope test +$GLOBALS['wgScopeTest'] = 'MediaWiki Setup.php scope test'; +// Avoid PHP Notice in Setup.php +$GLOBALS['self'] = 'Unit tests'; + +require_once "$IP/tests/common/TestSetup.php"; + +wfRequireOnceInGlobalScope( "$IP/includes/AutoLoader.php" ); +wfRequireOnceInGlobalScope( "$IP/includes/Defines.php" ); +wfRequireOnceInGlobalScope( "$IP/includes/DefaultSettings.php" ); +wfRequireOnceInGlobalScope( "$IP/includes/Setup.php" ); + +require_once "$IP/tests/common/TestsAutoLoader.php"; + +// Remove MWExceptionHandler's handling of PHP errors to allow PHPUnit to replace them +restore_error_handler(); + +unset( $GLOBALS['wgScopeTest'] ); + +// Disable all database connections +\MediaWiki\MediaWikiServices::disableStorageBackend(); diff --git a/tests/phpunit/languages/SpecialPageAliasTest.php b/tests/phpunit/unit/languages/SpecialPageAliasTest.php similarity index 95% rename from tests/phpunit/languages/SpecialPageAliasTest.php rename to tests/phpunit/unit/languages/SpecialPageAliasTest.php index d406c88933..cce9d0eb0f 100644 --- a/tests/phpunit/languages/SpecialPageAliasTest.php +++ b/tests/phpunit/unit/languages/SpecialPageAliasTest.php @@ -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/structure/ApiPrefixUniquenessTest.php b/tests/phpunit/unit/structure/ApiPrefixUniquenessTest.php similarity index 94% rename from tests/phpunit/structure/ApiPrefixUniquenessTest.php rename to tests/phpunit/unit/structure/ApiPrefixUniquenessTest.php index 4329867030..b937fabddb 100644 --- a/tests/phpunit/structure/ApiPrefixUniquenessTest.php +++ b/tests/phpunit/unit/structure/ApiPrefixUniquenessTest.php @@ -4,8 +4,9 @@ * Checks that all API query modules, core and extensions, have unique prefixes. * * @group API + * @coversNothing */ -class ApiPrefixUniquenessTest extends MediaWikiTestCase { +class ApiPrefixUniquenessTest extends \MediaWikiUnitTestCase { public function testPrefixes() { $main = new ApiMain( new FauxRequest() ); diff --git a/tests/phpunit/structure/AutoLoaderStructureTest.php b/tests/phpunit/unit/structure/AutoLoaderStructureTest.php similarity index 97% rename from tests/phpunit/structure/AutoLoaderStructureTest.php rename to tests/phpunit/unit/structure/AutoLoaderStructureTest.php index 37babcef14..e91159d74b 100644 --- a/tests/phpunit/structure/AutoLoaderStructureTest.php +++ b/tests/phpunit/unit/structure/AutoLoaderStructureTest.php @@ -1,6 +1,10 @@ setPsr4Namespaces( AutoLoader::getAutoloadNamespaces() ); diff --git a/tests/phpunit/structure/ContentHandlerSanityTest.php b/tests/phpunit/unit/structure/ContentHandlerSanityTest.php similarity index 95% rename from tests/phpunit/structure/ContentHandlerSanityTest.php rename to tests/phpunit/unit/structure/ContentHandlerSanityTest.php index c8bcd60de3..7541e59105 100644 --- a/tests/phpunit/structure/ContentHandlerSanityTest.php +++ b/tests/phpunit/unit/structure/ContentHandlerSanityTest.php @@ -19,7 +19,10 @@ use Wikimedia\TestingAccessWrapper; * http://www.gnu.org/copyleft/gpl.html */ -class ContentHandlerSanityTest extends MediaWikiTestCase { +/** + * @coversNothing + */ +class ContentHandlerSanityTest extends \MediaWikiUnitTestCase { public static function provideHandlers() { $models = ContentHandler::getContentModels(); diff --git a/tests/phpunit/structure/PasswordPolicyStructureTest.php b/tests/phpunit/unit/structure/PasswordPolicyStructureTest.php similarity index 92% rename from tests/phpunit/structure/PasswordPolicyStructureTest.php rename to tests/phpunit/unit/structure/PasswordPolicyStructureTest.php index d7f865d2e7..7867722099 100644 --- a/tests/phpunit/structure/PasswordPolicyStructureTest.php +++ b/tests/phpunit/unit/structure/PasswordPolicyStructureTest.php @@ -1,6 +1,9 @@