From 4e35134f7a3228a8195a07f49c85188e57ab8487 Mon Sep 17 00:00:00 2001 From: Legoktm Date: Thu, 13 Jun 2019 23:00:08 +0000 Subject: [PATCH] Revert "Separate MediaWiki unit and integration tests" This reverts commit 0a2b996278e57a8b8c5377cd3a3eaa54f993d4a9. Reason for revert: Broke postgres tests. Change-Id: I27d8e0c807ad5f0748b9611a4f3df84cc213fbe1 --- .phpcs.xml | 1 - tests/common/TestSetup.php | 3 - tests/common/TestsAutoLoader.php | 3 +- tests/phpunit/MediaWikiUnitTestCase.php | 36 ---------- .../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 | 43 ++++++++++++ .../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 | 16 +++++ .../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 +- .../languages/SpecialPageAliasTest.php | 2 +- .../structure/ApiPrefixUniquenessTest.php | 3 +- .../structure/AutoLoaderStructureTest.php | 8 +-- .../structure/ContentHandlerSanityTest.php | 5 +- .../structure/PasswordPolicyStructureTest.php | 5 +- tests/phpunit/structure/StructureTest.php | 1 - tests/phpunit/suite.xml | 11 ---- tests/phpunit/unit-tests.xml | 49 -------------- .../includes/api/ApiBlockInfoTraitTest.php | 66 ------------------- .../includes/exception/ReadOnlyErrorTest.php | 25 ------- tests/phpunit/unit/initUnitTests.php | 56 ---------------- 219 files changed, 242 insertions(+), 551 deletions(-) delete mode 100644 tests/phpunit/MediaWikiUnitTestCase.php 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/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/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%) 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%) delete mode 100644 tests/phpunit/unit-tests.xml delete mode 100644 tests/phpunit/unit/includes/api/ApiBlockInfoTraitTest.php delete mode 100644 tests/phpunit/unit/includes/exception/ReadOnlyErrorTest.php delete mode 100644 tests/phpunit/unit/initUnitTests.php diff --git a/.phpcs.xml b/.phpcs.xml index 1d5ce0b12c..9ccf5657b7 100644 --- a/.phpcs.xml +++ b/.phpcs.xml @@ -179,7 +179,6 @@ */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 6d250be096..e24c4c5442 100644 --- a/tests/common/TestSetup.php +++ b/tests/common/TestSetup.php @@ -18,9 +18,6 @@ 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 3eb8c9a721..861111a775 100644 --- a/tests/common/TestsAutoLoader.php +++ b/tests/common/TestsAutoLoader.php @@ -60,7 +60,6 @@ $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", @@ -178,7 +177,7 @@ $wgAutoloadClasses += [ 'LanguageClassesTestCase' => "$testDir/phpunit/languages/LanguageClassesTestCase.php", # tests/phpunit/includes/libs - 'GenericArrayObjectTest' => "$testDir/phpunit/unit/includes/libs/GenericArrayObjectTest.php", + 'GenericArrayObjectTest' => "$testDir/phpunit/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 deleted file mode 100644 index 9ecc043187..0000000000 --- a/tests/phpunit/MediaWikiUnitTestCase.php +++ /dev/null @@ -1,36 +0,0 @@ - $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/unit/documentation/ReleaseNotesTest.php b/tests/phpunit/documentation/ReleaseNotesTest.php similarity index 96% rename from tests/phpunit/unit/documentation/ReleaseNotesTest.php rename to tests/phpunit/documentation/ReleaseNotesTest.php index 701cb56635..d20fcff7b8 100644 --- a/tests/phpunit/unit/documentation/ReleaseNotesTest.php +++ b/tests/phpunit/documentation/ReleaseNotesTest.php @@ -3,7 +3,7 @@ /** * James doesn't like having to manually fix these things. */ -class ReleaseNotesTest extends \MediaWikiUnitTestCase { +class ReleaseNotesTest extends MediaWikiTestCase { /** * Verify that at least one Release Notes file exists, have content, and * aren't overly long. diff --git a/tests/phpunit/unit/includes/CommentStoreCommentTest.php b/tests/phpunit/includes/CommentStoreCommentTest.php similarity index 100% rename from tests/phpunit/unit/includes/CommentStoreCommentTest.php rename to tests/phpunit/includes/CommentStoreCommentTest.php diff --git a/tests/phpunit/unit/includes/DerivativeRequestTest.php b/tests/phpunit/includes/DerivativeRequestTest.php similarity index 100% rename from tests/phpunit/unit/includes/DerivativeRequestTest.php rename to tests/phpunit/includes/DerivativeRequestTest.php diff --git a/tests/phpunit/unit/includes/FauxRequestTest.php b/tests/phpunit/includes/FauxRequestTest.php similarity index 100% rename from tests/phpunit/unit/includes/FauxRequestTest.php rename to tests/phpunit/includes/FauxRequestTest.php diff --git a/tests/phpunit/unit/includes/FauxResponseTest.php b/tests/phpunit/includes/FauxResponseTest.php similarity index 98% rename from tests/phpunit/unit/includes/FauxResponseTest.php rename to tests/phpunit/includes/FauxResponseTest.php index 5e208aceda..8085bc710c 100644 --- a/tests/phpunit/unit/includes/FauxResponseTest.php +++ b/tests/phpunit/includes/FauxResponseTest.php @@ -20,7 +20,7 @@ * @file */ -class FauxResponseTest extends \MediaWikiUnitTestCase { +class FauxResponseTest extends MediaWikiTestCase { /** @var FauxResponse */ protected $response; diff --git a/tests/phpunit/unit/includes/FormOptionsInitializationTest.php b/tests/phpunit/includes/FormOptionsInitializationTest.php similarity index 94% rename from tests/phpunit/unit/includes/FormOptionsInitializationTest.php rename to tests/phpunit/includes/FormOptionsInitializationTest.php index 708956d260..2c78618aa1 100644 --- a/tests/phpunit/unit/includes/FormOptionsInitializationTest.php +++ b/tests/phpunit/includes/FormOptionsInitializationTest.php @@ -10,7 +10,7 @@ use Wikimedia\TestingAccessWrapper; * * @author Antoine Musso */ -class FormOptionsInitializationTest extends \MediaWikiUnitTestCase { +class FormOptionsInitializationTest extends MediaWikiTestCase { /** * @var FormOptions */ diff --git a/tests/phpunit/unit/includes/FormOptionsTest.php b/tests/phpunit/includes/FormOptionsTest.php similarity index 97% rename from tests/phpunit/unit/includes/FormOptionsTest.php rename to tests/phpunit/includes/FormOptionsTest.php index c14595bc4a..da08670f57 100644 --- a/tests/phpunit/unit/includes/FormOptionsTest.php +++ b/tests/phpunit/includes/FormOptionsTest.php @@ -15,7 +15,7 @@ * * @author Antoine Musso */ -class FormOptionsTest extends \MediaWikiUnitTestCase { +class FormOptionsTest extends MediaWikiTestCase { /** * @var FormOptions */ diff --git a/tests/phpunit/unit/includes/GlobalFunctions/wfAppendQueryTest.php b/tests/phpunit/includes/GlobalFunctions/wfAppendQueryTest.php similarity index 97% rename from tests/phpunit/unit/includes/GlobalFunctions/wfAppendQueryTest.php rename to tests/phpunit/includes/GlobalFunctions/wfAppendQueryTest.php index 27ac239b82..bb71610b64 100644 --- a/tests/phpunit/unit/includes/GlobalFunctions/wfAppendQueryTest.php +++ b/tests/phpunit/includes/GlobalFunctions/wfAppendQueryTest.php @@ -4,7 +4,7 @@ * @group GlobalFunctions * @covers ::wfAppendQuery */ -class WfAppendQueryTest extends \MediaWikiUnitTestCase { +class WfAppendQueryTest extends MediaWikiTestCase { /** * @dataProvider provideAppendQuery */ diff --git a/tests/phpunit/unit/includes/GlobalFunctions/wfArrayPlus2dTest.php b/tests/phpunit/includes/GlobalFunctions/wfArrayPlus2dTest.php similarity index 96% rename from tests/phpunit/unit/includes/GlobalFunctions/wfArrayPlus2dTest.php rename to tests/phpunit/includes/GlobalFunctions/wfArrayPlus2dTest.php index 3e65af5212..65b56ef4b3 100644 --- a/tests/phpunit/unit/includes/GlobalFunctions/wfArrayPlus2dTest.php +++ b/tests/phpunit/includes/GlobalFunctions/wfArrayPlus2dTest.php @@ -3,7 +3,7 @@ * @group GlobalFunctions * @covers ::wfArrayPlus2d */ -class WfArrayPlus2dTest extends \MediaWikiUnitTestCase { +class WfArrayPlus2dTest extends MediaWikiTestCase { /** * @dataProvider provideArrays */ diff --git a/tests/phpunit/unit/includes/GlobalFunctions/wfAssembleUrlTest.php b/tests/phpunit/includes/GlobalFunctions/wfAssembleUrlTest.php similarity index 97% rename from tests/phpunit/unit/includes/GlobalFunctions/wfAssembleUrlTest.php rename to tests/phpunit/includes/GlobalFunctions/wfAssembleUrlTest.php index f28646eb3a..7ddad369bd 100644 --- a/tests/phpunit/unit/includes/GlobalFunctions/wfAssembleUrlTest.php +++ b/tests/phpunit/includes/GlobalFunctions/wfAssembleUrlTest.php @@ -3,7 +3,7 @@ * @group GlobalFunctions * @covers ::wfAssembleUrl */ -class WfAssembleUrlTest extends \MediaWikiUnitTestCase { +class WfAssembleUrlTest extends MediaWikiTestCase { /** * @dataProvider provideURLParts */ diff --git a/tests/phpunit/unit/includes/GlobalFunctions/wfBaseNameTest.php b/tests/phpunit/includes/GlobalFunctions/wfBaseNameTest.php similarity index 94% rename from tests/phpunit/unit/includes/GlobalFunctions/wfBaseNameTest.php rename to tests/phpunit/includes/GlobalFunctions/wfBaseNameTest.php index ac42f3f82d..78e09e60ba 100644 --- a/tests/phpunit/unit/includes/GlobalFunctions/wfBaseNameTest.php +++ b/tests/phpunit/includes/GlobalFunctions/wfBaseNameTest.php @@ -3,7 +3,7 @@ * @group GlobalFunctions * @covers ::wfBaseName */ -class WfBaseNameTest extends \MediaWikiUnitTestCase { +class WfBaseNameTest extends MediaWikiTestCase { /** * @dataProvider providePaths */ diff --git a/tests/phpunit/unit/includes/GlobalFunctions/wfEscapeShellArgTest.php b/tests/phpunit/includes/GlobalFunctions/wfEscapeShellArgTest.php similarity index 93% rename from tests/phpunit/unit/includes/GlobalFunctions/wfEscapeShellArgTest.php rename to tests/phpunit/includes/GlobalFunctions/wfEscapeShellArgTest.php index 7e818dfbda..7402054ea4 100644 --- a/tests/phpunit/unit/includes/GlobalFunctions/wfEscapeShellArgTest.php +++ b/tests/phpunit/includes/GlobalFunctions/wfEscapeShellArgTest.php @@ -4,7 +4,7 @@ * @group GlobalFunctions * @covers ::wfEscapeShellArg */ -class WfEscapeShellArgTest extends \MediaWikiUnitTestCase { +class WfEscapeShellArgTest extends MediaWikiTestCase { public function testSingleInput() { if ( wfIsWindows() ) { $expected = '"blah"'; diff --git a/tests/phpunit/unit/includes/GlobalFunctions/wfGetCallerTest.php b/tests/phpunit/includes/GlobalFunctions/wfGetCallerTest.php similarity index 94% rename from tests/phpunit/unit/includes/GlobalFunctions/wfGetCallerTest.php rename to tests/phpunit/includes/GlobalFunctions/wfGetCallerTest.php index c77c35133c..8a7bfa5a8c 100644 --- a/tests/phpunit/unit/includes/GlobalFunctions/wfGetCallerTest.php +++ b/tests/phpunit/includes/GlobalFunctions/wfGetCallerTest.php @@ -4,7 +4,7 @@ * @group GlobalFunctions * @covers ::wfGetCaller */ -class WfGetCallerTest extends \MediaWikiUnitTestCase { +class WfGetCallerTest extends MediaWikiTestCase { public function testZero() { $this->assertEquals( 'WfGetCallerTest->testZero', wfGetCaller( 1 ) ); } diff --git a/tests/phpunit/unit/includes/GlobalFunctions/wfRemoveDotSegmentsTest.php b/tests/phpunit/includes/GlobalFunctions/wfRemoveDotSegmentsTest.php similarity index 96% rename from tests/phpunit/unit/includes/GlobalFunctions/wfRemoveDotSegmentsTest.php rename to tests/phpunit/includes/GlobalFunctions/wfRemoveDotSegmentsTest.php index 085bfed3d3..eae5588b94 100644 --- a/tests/phpunit/unit/includes/GlobalFunctions/wfRemoveDotSegmentsTest.php +++ b/tests/phpunit/includes/GlobalFunctions/wfRemoveDotSegmentsTest.php @@ -4,7 +4,7 @@ * @group GlobalFunctions * @covers ::wfRemoveDotSegments */ -class WfRemoveDotSegmentsTest extends \MediaWikiUnitTestCase { +class WfRemoveDotSegmentsTest extends MediaWikiTestCase { /** * @dataProvider providePaths */ diff --git a/tests/phpunit/unit/includes/GlobalFunctions/wfShellExecTest.php b/tests/phpunit/includes/GlobalFunctions/wfShellExecTest.php similarity index 89% rename from tests/phpunit/unit/includes/GlobalFunctions/wfShellExecTest.php rename to tests/phpunit/includes/GlobalFunctions/wfShellExecTest.php index 09ce624dc1..6279cf6eee 100644 --- a/tests/phpunit/unit/includes/GlobalFunctions/wfShellExecTest.php +++ b/tests/phpunit/includes/GlobalFunctions/wfShellExecTest.php @@ -4,7 +4,7 @@ * @group GlobalFunctions * @covers ::wfShellExec */ -class WfShellExecTest extends \MediaWikiUnitTestCase { +class WfShellExecTest extends MediaWikiTestCase { public function testT69870() { $command = wfIsWindows() // 333 = 331 + CRLF diff --git a/tests/phpunit/unit/includes/GlobalFunctions/wfShorthandToIntegerTest.php b/tests/phpunit/includes/GlobalFunctions/wfShorthandToIntegerTest.php similarity index 91% rename from tests/phpunit/unit/includes/GlobalFunctions/wfShorthandToIntegerTest.php rename to tests/phpunit/includes/GlobalFunctions/wfShorthandToIntegerTest.php index 3bb8b985a7..40b2e636c9 100644 --- a/tests/phpunit/unit/includes/GlobalFunctions/wfShorthandToIntegerTest.php +++ b/tests/phpunit/includes/GlobalFunctions/wfShorthandToIntegerTest.php @@ -4,7 +4,7 @@ * @group GlobalFunctions * @covers ::wfShorthandToInteger */ -class WfShorthandToIntegerTest extends \MediaWikiUnitTestCase { +class WfShorthandToIntegerTest extends MediaWikiTestCase { /** * @dataProvider provideABunchOfShorthands */ diff --git a/tests/phpunit/unit/includes/GlobalFunctions/wfStringToBoolTest.php b/tests/phpunit/includes/GlobalFunctions/wfStringToBoolTest.php similarity index 93% rename from tests/phpunit/unit/includes/GlobalFunctions/wfStringToBoolTest.php rename to tests/phpunit/includes/GlobalFunctions/wfStringToBoolTest.php index bc010d5b50..7f56b60529 100644 --- a/tests/phpunit/unit/includes/GlobalFunctions/wfStringToBoolTest.php +++ b/tests/phpunit/includes/GlobalFunctions/wfStringToBoolTest.php @@ -4,7 +4,7 @@ * @group GlobalFunctions * @covers ::wfStringToBool */ -class WfStringToBoolTest extends \MediaWikiUnitTestCase { +class WfStringToBoolTest extends MediaWikiTestCase { public function getTestCases() { return [ diff --git a/tests/phpunit/unit/includes/GlobalFunctions/wfTimestampTest.php b/tests/phpunit/includes/GlobalFunctions/wfTimestampTest.php similarity index 99% rename from tests/phpunit/unit/includes/GlobalFunctions/wfTimestampTest.php rename to tests/phpunit/includes/GlobalFunctions/wfTimestampTest.php index 78b9172c6e..a70f136a1c 100644 --- a/tests/phpunit/unit/includes/GlobalFunctions/wfTimestampTest.php +++ b/tests/phpunit/includes/GlobalFunctions/wfTimestampTest.php @@ -4,7 +4,7 @@ * @group GlobalFunctions * @covers ::wfTimestamp */ -class WfTimestampTest extends \MediaWikiUnitTestCase { +class WfTimestampTest extends MediaWikiTestCase { /** * @dataProvider provideNormalTimestamps */ diff --git a/tests/phpunit/unit/includes/GlobalFunctions/wfUrlencodeTest.php b/tests/phpunit/includes/GlobalFunctions/wfUrlencodeTest.php similarity index 98% rename from tests/phpunit/unit/includes/GlobalFunctions/wfUrlencodeTest.php rename to tests/phpunit/includes/GlobalFunctions/wfUrlencodeTest.php index a5992d4c83..5d9f63daa7 100644 --- a/tests/phpunit/unit/includes/GlobalFunctions/wfUrlencodeTest.php +++ b/tests/phpunit/includes/GlobalFunctions/wfUrlencodeTest.php @@ -6,7 +6,7 @@ * @group GlobalFunctions * @covers ::wfUrlencode */ -class WfUrlencodeTest extends \MediaWikiUnitTestCase { +class WfUrlencodeTest extends MediaWikiTestCase { # ### TESTS ############################################################## /** diff --git a/tests/phpunit/unit/includes/HooksTest.php b/tests/phpunit/includes/HooksTest.php similarity index 99% rename from tests/phpunit/unit/includes/HooksTest.php rename to tests/phpunit/includes/HooksTest.php index 9380546c84..c66b712b83 100644 --- a/tests/phpunit/unit/includes/HooksTest.php +++ b/tests/phpunit/includes/HooksTest.php @@ -1,6 +1,6 @@ hideDeprecated( MediaWikiServices::class . "::$getter" ); } - // Check all services via an instance using the global configuration, not a dummy instance! - $services = $this->newMediaWikiServices( new GlobalVarConfig() ); + // Test against the default instance, since the dummy will not know the default services. + $services = MediaWikiServices::getInstance(); $service = $services->$getter(); $this->assertInstanceOf( $type, $service ); } @@ -317,18 +317,18 @@ class MediaWikiServicesTest extends \MediaWikiUnitTestCase { * @dataProvider provideGetService */ public function testGetService( $name, $type ) { - // Check all services via an instance using the global configuration, not a dummy instance! - $services = $this->newMediaWikiServices( new GlobalVarConfig() ); + // Test against the default instance, since the dummy will not know the default services. + $services = MediaWikiServices::getInstance(); $service = $services->getService( $name ); $this->assertInstanceOf( $type, $service ); } public function testDefaultServiceInstantiation() { - // Check all services via an instance using the global configuration, not a dummy instance! + // Check all services in the default instance, not a dummy instance! // Note that we instantiate all services here, including any that // were registered by extensions. - $services = $this->newMediaWikiServices( new GlobalVarConfig() ); + $services = MediaWikiServices::getInstance(); $names = $services->getServiceNames(); foreach ( $names as $name ) { diff --git a/tests/phpunit/unit/includes/MediaWikiVersionFetcherTest.php b/tests/phpunit/includes/MediaWikiVersionFetcherTest.php similarity index 88% rename from tests/phpunit/unit/includes/MediaWikiVersionFetcherTest.php rename to tests/phpunit/includes/MediaWikiVersionFetcherTest.php index dfdbfa7344..9803081869 100644 --- a/tests/phpunit/unit/includes/MediaWikiVersionFetcherTest.php +++ b/tests/phpunit/includes/MediaWikiVersionFetcherTest.php @@ -10,7 +10,7 @@ * * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ -class MediaWikiVersionFetcherTest extends \MediaWikiUnitTestCase { +class MediaWikiVersionFetcherTest extends MediaWikiTestCase { public function testReturnsResult() { global $wgVersion; diff --git a/tests/phpunit/unit/includes/PathRouterTest.php b/tests/phpunit/includes/PathRouterTest.php similarity index 99% rename from tests/phpunit/unit/includes/PathRouterTest.php rename to tests/phpunit/includes/PathRouterTest.php index 0cb6c81822..d8916751c0 100644 --- a/tests/phpunit/unit/includes/PathRouterTest.php +++ b/tests/phpunit/includes/PathRouterTest.php @@ -5,7 +5,7 @@ * * @covers PathRouter */ -class PathRouterTest extends \MediaWikiUnitTestCase { +class PathRouterTest extends MediaWikiTestCase { /** * @var PathRouter diff --git a/tests/phpunit/unit/includes/Revision/FallbackSlotRoleHandlerTest.php b/tests/phpunit/includes/Revision/FallbackSlotRoleHandlerTest.php similarity index 96% rename from tests/phpunit/unit/includes/Revision/FallbackSlotRoleHandlerTest.php rename to tests/phpunit/includes/Revision/FallbackSlotRoleHandlerTest.php index 9b23c6e17e..aedf292eca 100644 --- a/tests/phpunit/unit/includes/Revision/FallbackSlotRoleHandlerTest.php +++ b/tests/phpunit/includes/Revision/FallbackSlotRoleHandlerTest.php @@ -3,12 +3,13 @@ namespace MediaWiki\Tests\Revision; use MediaWiki\Revision\FallbackSlotRoleHandler; +use MediaWikiTestCase; use Title; /** * @covers \MediaWiki\Revision\FallbackSlotRoleHandler */ -class FallbackSlotRoleHandlerTest extends \MediaWikiUnitTestCase { +class FallbackSlotRoleHandlerTest extends MediaWikiTestCase { private function makeBlankTitleObject() { /** @var Title $title */ diff --git a/tests/phpunit/unit/includes/Revision/MainSlotRoleHandlerTest.php b/tests/phpunit/includes/Revision/MainSlotRoleHandlerTest.php similarity index 96% rename from tests/phpunit/unit/includes/Revision/MainSlotRoleHandlerTest.php rename to tests/phpunit/includes/Revision/MainSlotRoleHandlerTest.php index afd748f761..5e32574d40 100644 --- a/tests/phpunit/unit/includes/Revision/MainSlotRoleHandlerTest.php +++ b/tests/phpunit/includes/Revision/MainSlotRoleHandlerTest.php @@ -3,13 +3,14 @@ namespace MediaWiki\Tests\Revision; use MediaWiki\Revision\MainSlotRoleHandler; +use MediaWikiTestCase; use PHPUnit\Framework\MockObject\MockObject; use Title; /** * @covers \MediaWiki\Revision\MainSlotRoleHandler */ -class MainSlotRoleHandlerTest extends \MediaWikiUnitTestCase { +class MainSlotRoleHandlerTest extends MediaWikiTestCase { private function makeTitleObject( $ns ) { /** @var Title|MockObject $title */ diff --git a/tests/phpunit/unit/includes/Revision/RevisionStoreFactoryTest.php b/tests/phpunit/includes/Revision/RevisionStoreFactoryTest.php similarity index 98% rename from tests/phpunit/unit/includes/Revision/RevisionStoreFactoryTest.php rename to tests/phpunit/includes/Revision/RevisionStoreFactoryTest.php index 77228081d0..138d6bcba1 100644 --- a/tests/phpunit/unit/includes/Revision/RevisionStoreFactoryTest.php +++ b/tests/phpunit/includes/Revision/RevisionStoreFactoryTest.php @@ -13,6 +13,7 @@ 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; @@ -20,7 +21,7 @@ use Wikimedia\Rdbms\ILBFactory; use Wikimedia\Rdbms\ILoadBalancer; use Wikimedia\TestingAccessWrapper; -class RevisionStoreFactoryTest extends \MediaWikiUnitTestCase { +class RevisionStoreFactoryTest extends MediaWikiTestCase { /** * @covers \MediaWiki\Revision\RevisionStoreFactory::__construct diff --git a/tests/phpunit/unit/includes/Revision/SlotRecordTest.php b/tests/phpunit/includes/Revision/SlotRecordTest.php similarity index 99% rename from tests/phpunit/unit/includes/Revision/SlotRecordTest.php rename to tests/phpunit/includes/Revision/SlotRecordTest.php index 58c1035231..1b6ff2aace 100644 --- a/tests/phpunit/unit/includes/Revision/SlotRecordTest.php +++ b/tests/phpunit/includes/Revision/SlotRecordTest.php @@ -7,12 +7,13 @@ 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 \MediaWikiUnitTestCase { +class SlotRecordTest extends MediaWikiTestCase { private function makeRow( $data = [] ) { $data = $data + [ diff --git a/tests/phpunit/unit/includes/Revision/SlotRoleHandlerTest.php b/tests/phpunit/includes/Revision/SlotRoleHandlerTest.php similarity index 96% rename from tests/phpunit/unit/includes/Revision/SlotRoleHandlerTest.php rename to tests/phpunit/includes/Revision/SlotRoleHandlerTest.php index ed3053c070..67e9464f33 100644 --- a/tests/phpunit/unit/includes/Revision/SlotRoleHandlerTest.php +++ b/tests/phpunit/includes/Revision/SlotRoleHandlerTest.php @@ -3,12 +3,13 @@ namespace MediaWiki\Tests\Revision; use MediaWiki\Revision\SlotRoleHandler; +use MediaWikiTestCase; use Title; /** * @covers \MediaWiki\Revision\SlotRoleHandler */ -class SlotRoleHandlerTest extends \MediaWikiUnitTestCase { +class SlotRoleHandlerTest extends MediaWikiTestCase { private function makeBlankTitleObject() { /** @var Title $title */ diff --git a/tests/phpunit/unit/includes/SanitizerValidateEmailTest.php b/tests/phpunit/includes/SanitizerValidateEmailTest.php similarity index 100% rename from tests/phpunit/unit/includes/SanitizerValidateEmailTest.php rename to tests/phpunit/includes/SanitizerValidateEmailTest.php diff --git a/tests/phpunit/unit/includes/ServiceWiringTest.php b/tests/phpunit/includes/ServiceWiringTest.php similarity index 85% rename from tests/phpunit/unit/includes/ServiceWiringTest.php rename to tests/phpunit/includes/ServiceWiringTest.php index 25b0214db1..02e06f8dda 100644 --- a/tests/phpunit/unit/includes/ServiceWiringTest.php +++ b/tests/phpunit/includes/ServiceWiringTest.php @@ -3,7 +3,7 @@ /** * @coversNothing */ -class ServiceWiringTest extends \MediaWikiUnitTestCase { +class ServiceWiringTest extends MediaWikiTestCase { public function testServicesAreSorted() { global $IP; $services = array_keys( require "$IP/includes/ServiceWiring.php" ); diff --git a/tests/phpunit/unit/includes/SiteConfigurationTest.php b/tests/phpunit/includes/SiteConfigurationTest.php similarity index 99% rename from tests/phpunit/unit/includes/SiteConfigurationTest.php rename to tests/phpunit/includes/SiteConfigurationTest.php index b992a86471..3b7226245f 100644 --- a/tests/phpunit/unit/includes/SiteConfigurationTest.php +++ b/tests/phpunit/includes/SiteConfigurationTest.php @@ -1,6 +1,6 @@ lbFactoryMock = $this->createMock( LBFactory::class ); - - $lbFactoryMockProvider = function (): LBFactory { - return $this->lbFactoryMock; - }; - - $this->overrideMwServices( [ 'DBLoadBalancerFactory' => $lbFactoryMockProvider ] ); - } +class BlobStoreFactoryTest extends MediaWikiTestCase { public function provideWikiIds() { yield [ false ]; @@ -37,11 +22,6 @@ class BlobStoreFactoryTest extends \MediaWikiUnitTestCase { * @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 ); @@ -55,11 +35,6 @@ class BlobStoreFactoryTest extends \MediaWikiUnitTestCase { * @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 ); @@ -67,4 +42,5 @@ class BlobStoreFactoryTest extends \MediaWikiUnitTestCase { $wrapper = TestingAccessWrapper::newFromObject( $store ); $this->assertEquals( $wikiId, $wrapper->wikiId ); } + } diff --git a/tests/phpunit/unit/includes/Storage/PreparedEditTest.php b/tests/phpunit/includes/Storage/PreparedEditTest.php similarity index 83% rename from tests/phpunit/unit/includes/Storage/PreparedEditTest.php rename to tests/phpunit/includes/Storage/PreparedEditTest.php index e3249e74bc..29999ee535 100644 --- a/tests/phpunit/unit/includes/Storage/PreparedEditTest.php +++ b/tests/phpunit/includes/Storage/PreparedEditTest.php @@ -3,11 +3,12 @@ namespace MediaWiki\Edit; use ParserOutput; +use MediaWikiTestCase; /** * @covers \MediaWiki\Edit\PreparedEdit */ -class PreparedEditTest extends \MediaWikiUnitTestCase { +class PreparedEditTest extends MediaWikiTestCase { function testCallback() { $output = new ParserOutput(); $edit = new PreparedEdit(); diff --git a/tests/phpunit/unit/includes/TitleArrayFromResultTest.php b/tests/phpunit/includes/TitleArrayFromResultTest.php similarity index 100% rename from tests/phpunit/unit/includes/TitleArrayFromResultTest.php rename to tests/phpunit/includes/TitleArrayFromResultTest.php diff --git a/tests/phpunit/unit/includes/WikiReferenceTest.php b/tests/phpunit/includes/WikiReferenceTest.php similarity index 100% rename from tests/phpunit/unit/includes/WikiReferenceTest.php rename to tests/phpunit/includes/WikiReferenceTest.php diff --git a/tests/phpunit/unit/includes/XmlJsTest.php b/tests/phpunit/includes/XmlJsTest.php similarity index 100% rename from tests/phpunit/unit/includes/XmlJsTest.php rename to tests/phpunit/includes/XmlJsTest.php diff --git a/tests/phpunit/unit/includes/XmlSelectTest.php b/tests/phpunit/includes/XmlSelectTest.php similarity index 98% rename from tests/phpunit/unit/includes/XmlSelectTest.php rename to tests/phpunit/includes/XmlSelectTest.php index 54d269e0ce..52e20bdb99 100644 --- a/tests/phpunit/unit/includes/XmlSelectTest.php +++ b/tests/phpunit/includes/XmlSelectTest.php @@ -3,7 +3,7 @@ /** * @group Xml */ -class XmlSelectTest extends \MediaWikiUnitTestCase { +class XmlSelectTest extends MediaWikiTestCase { /** * @var XmlSelect diff --git a/tests/phpunit/unit/includes/actions/ViewActionTest.php b/tests/phpunit/includes/actions/ViewActionTest.php similarity index 92% rename from tests/phpunit/unit/includes/actions/ViewActionTest.php rename to tests/phpunit/includes/actions/ViewActionTest.php index 99d61b6e4b..5f659c07a2 100644 --- a/tests/phpunit/unit/includes/actions/ViewActionTest.php +++ b/tests/phpunit/includes/actions/ViewActionTest.php @@ -7,7 +7,7 @@ * * @author Derick N. Alangi */ -class ViewActionTest extends \MediaWikiUnitTestCase { +class ViewActionTest extends MediaWikiTestCase { /** * @return ViewAction */ diff --git a/tests/phpunit/includes/api/ApiBlockInfoTraitTest.php b/tests/phpunit/includes/api/ApiBlockInfoTraitTest.php new file mode 100644 index 0000000000..ba5c003776 --- /dev/null +++ b/tests/phpunit/includes/api/ApiBlockInfoTraitTest.php @@ -0,0 +1,43 @@ +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/unit/includes/api/ApiContinuationManagerTest.php b/tests/phpunit/includes/api/ApiContinuationManagerTest.php similarity index 99% rename from tests/phpunit/unit/includes/api/ApiContinuationManagerTest.php rename to tests/phpunit/includes/api/ApiContinuationManagerTest.php index cc1351b12a..788d120c6b 100644 --- a/tests/phpunit/unit/includes/api/ApiContinuationManagerTest.php +++ b/tests/phpunit/includes/api/ApiContinuationManagerTest.php @@ -4,7 +4,7 @@ * @covers ApiContinuationManager * @group API */ -class ApiContinuationManagerTest extends \MediaWikiUnitTestCase { +class ApiContinuationManagerTest extends MediaWikiTestCase { private static function getManager( $continue, $allModules, $generatedModules ) { $context = new DerivativeContext( RequestContext::getMain() ); diff --git a/tests/phpunit/unit/includes/api/ApiMessageTest.php b/tests/phpunit/includes/api/ApiMessageTest.php similarity index 99% rename from tests/phpunit/unit/includes/api/ApiMessageTest.php rename to tests/phpunit/includes/api/ApiMessageTest.php index d6fa7809d0..70114c2593 100644 --- a/tests/phpunit/unit/includes/api/ApiMessageTest.php +++ b/tests/phpunit/includes/api/ApiMessageTest.php @@ -5,7 +5,7 @@ use Wikimedia\TestingAccessWrapper; /** * @group API */ -class ApiMessageTest extends \MediaWikiUnitTestCase { +class ApiMessageTest extends MediaWikiTestCase { private function compareMessages( Message $msg, Message $msg2 ) { $this->assertSame( $msg->getKey(), $msg2->getKey(), 'getKey' ); diff --git a/tests/phpunit/unit/includes/api/ApiResultTest.php b/tests/phpunit/includes/api/ApiResultTest.php similarity index 99% rename from tests/phpunit/unit/includes/api/ApiResultTest.php rename to tests/phpunit/includes/api/ApiResultTest.php index 2d99890d50..98e24fb666 100644 --- a/tests/phpunit/unit/includes/api/ApiResultTest.php +++ b/tests/phpunit/includes/api/ApiResultTest.php @@ -4,7 +4,7 @@ * @covers ApiResult * @group API */ -class ApiResultTest extends \MediaWikiUnitTestCase { +class ApiResultTest extends MediaWikiTestCase { /** * @covers ApiResult diff --git a/tests/phpunit/unit/includes/api/ApiUsageExceptionTest.php b/tests/phpunit/includes/api/ApiUsageExceptionTest.php similarity index 96% rename from tests/phpunit/unit/includes/api/ApiUsageExceptionTest.php rename to tests/phpunit/includes/api/ApiUsageExceptionTest.php index 51260a67f9..bb72021121 100644 --- a/tests/phpunit/unit/includes/api/ApiUsageExceptionTest.php +++ b/tests/phpunit/includes/api/ApiUsageExceptionTest.php @@ -3,7 +3,7 @@ /** * @covers ApiUsageException */ -class ApiUsageExceptionTest extends \MediaWikiUnitTestCase { +class ApiUsageExceptionTest extends MediaWikiTestCase { public function testCreateWithStatusValue_CanGetAMessageObject() { $messageKey = 'some-message-key'; diff --git a/tests/phpunit/unit/includes/auth/AbstractPreAuthenticationProviderTest.php b/tests/phpunit/includes/auth/AbstractPreAuthenticationProviderTest.php similarity index 93% rename from tests/phpunit/unit/includes/auth/AbstractPreAuthenticationProviderTest.php rename to tests/phpunit/includes/auth/AbstractPreAuthenticationProviderTest.php index 8ec3380069..2970a2807c 100644 --- a/tests/phpunit/unit/includes/auth/AbstractPreAuthenticationProviderTest.php +++ b/tests/phpunit/includes/auth/AbstractPreAuthenticationProviderTest.php @@ -6,7 +6,7 @@ namespace MediaWiki\Auth; * @group AuthManager * @covers \MediaWiki\Auth\AbstractPreAuthenticationProvider */ -class AbstractPreAuthenticationProviderTest extends \MediaWikiUnitTestCase { +class AbstractPreAuthenticationProviderTest extends \MediaWikiTestCase { public function testAbstractPreAuthenticationProvider() { $user = \User::newFromName( 'UTSysop' ); diff --git a/tests/phpunit/unit/includes/auth/AbstractSecondaryAuthenticationProviderTest.php b/tests/phpunit/includes/auth/AbstractSecondaryAuthenticationProviderTest.php similarity index 99% rename from tests/phpunit/unit/includes/auth/AbstractSecondaryAuthenticationProviderTest.php rename to tests/phpunit/includes/auth/AbstractSecondaryAuthenticationProviderTest.php index e933cb8c67..cd17862838 100644 --- a/tests/phpunit/unit/includes/auth/AbstractSecondaryAuthenticationProviderTest.php +++ b/tests/phpunit/includes/auth/AbstractSecondaryAuthenticationProviderTest.php @@ -6,7 +6,7 @@ namespace MediaWiki\Auth; * @group AuthManager * @covers \MediaWiki\Auth\AbstractSecondaryAuthenticationProvider */ -class AbstractSecondaryAuthenticationProviderTest extends \MediaWikiUnitTestCase { +class AbstractSecondaryAuthenticationProviderTest extends \MediaWikiTestCase { public function testAbstractSecondaryAuthenticationProvider() { $user = \User::newFromName( 'UTSysop' ); diff --git a/tests/phpunit/unit/includes/auth/AuthenticationResponseTest.php b/tests/phpunit/includes/auth/AuthenticationResponseTest.php similarity index 97% rename from tests/phpunit/unit/includes/auth/AuthenticationResponseTest.php rename to tests/phpunit/includes/auth/AuthenticationResponseTest.php index 44b063153b..c79682275f 100644 --- a/tests/phpunit/unit/includes/auth/AuthenticationResponseTest.php +++ b/tests/phpunit/includes/auth/AuthenticationResponseTest.php @@ -6,7 +6,7 @@ namespace MediaWiki\Auth; * @group AuthManager * @covers \MediaWiki\Auth\AuthenticationResponse */ -class AuthenticationResponseTest extends \MediaWikiUnitTestCase { +class AuthenticationResponseTest extends \MediaWikiTestCase { /** * @dataProvider provideConstructors * @param string $constructor diff --git a/tests/phpunit/unit/includes/auth/ConfirmLinkSecondaryAuthenticationProviderTest.php b/tests/phpunit/includes/auth/ConfirmLinkSecondaryAuthenticationProviderTest.php similarity index 99% rename from tests/phpunit/unit/includes/auth/ConfirmLinkSecondaryAuthenticationProviderTest.php rename to tests/phpunit/includes/auth/ConfirmLinkSecondaryAuthenticationProviderTest.php index 7a4490bb67..b17da2e2cf 100644 --- a/tests/phpunit/unit/includes/auth/ConfirmLinkSecondaryAuthenticationProviderTest.php +++ b/tests/phpunit/includes/auth/ConfirmLinkSecondaryAuthenticationProviderTest.php @@ -8,7 +8,7 @@ use Wikimedia\TestingAccessWrapper; * @group AuthManager * @covers \MediaWiki\Auth\ConfirmLinkSecondaryAuthenticationProvider */ -class ConfirmLinkSecondaryAuthenticationProviderTest extends \MediaWikiUnitTestCase { +class ConfirmLinkSecondaryAuthenticationProviderTest extends \MediaWikiTestCase { /** * @dataProvider provideGetAuthenticationRequests * @param string $action diff --git a/tests/phpunit/unit/includes/auth/EmailNotificationSecondaryAuthenticationProviderTest.php b/tests/phpunit/includes/auth/EmailNotificationSecondaryAuthenticationProviderTest.php similarity index 86% rename from tests/phpunit/unit/includes/auth/EmailNotificationSecondaryAuthenticationProviderTest.php rename to tests/phpunit/includes/auth/EmailNotificationSecondaryAuthenticationProviderTest.php index fcaf6bf1a3..ff22def7f8 100644 --- a/tests/phpunit/unit/includes/auth/EmailNotificationSecondaryAuthenticationProviderTest.php +++ b/tests/phpunit/includes/auth/EmailNotificationSecondaryAuthenticationProviderTest.php @@ -3,39 +3,12 @@ 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 \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 ] ); - } - +class EmailNotificationSecondaryAuthenticationProviderTest extends \PHPUnit\Framework\TestCase { public function testConstructor() { $config = new \HashConfig( [ 'EnableEmail' => true, diff --git a/tests/phpunit/unit/includes/changes/ChangesListFilterGroupTest.php b/tests/phpunit/includes/changes/ChangesListFilterGroupTest.php similarity index 95% rename from tests/phpunit/unit/includes/changes/ChangesListFilterGroupTest.php rename to tests/phpunit/includes/changes/ChangesListFilterGroupTest.php index bd54d508ba..6190516e68 100644 --- a/tests/phpunit/unit/includes/changes/ChangesListFilterGroupTest.php +++ b/tests/phpunit/includes/changes/ChangesListFilterGroupTest.php @@ -3,7 +3,7 @@ /** * @covers ChangesListFilterGroup */ -class ChangesListFilterGroupTest extends \MediaWikiUnitTestCase { +class ChangesListFilterGroupTest extends MediaWikiTestCase { /** * phpcs:disable Generic.Files.LineLength * @expectedException MWException diff --git a/tests/phpunit/unit/includes/collation/CustomUppercaseCollationTest.php b/tests/phpunit/includes/collation/CustomUppercaseCollationTest.php similarity index 95% rename from tests/phpunit/unit/includes/collation/CustomUppercaseCollationTest.php rename to tests/phpunit/includes/collation/CustomUppercaseCollationTest.php index 0dfe59cb99..417b468b1d 100644 --- a/tests/phpunit/unit/includes/collation/CustomUppercaseCollationTest.php +++ b/tests/phpunit/includes/collation/CustomUppercaseCollationTest.php @@ -3,7 +3,7 @@ /** * @covers CustomUppercaseCollation */ -class CustomUppercaseCollationTest extends \MediaWikiUnitTestCase { +class CustomUppercaseCollationTest extends MediaWikiTestCase { public function setUp() { $this->collation = new CustomUppercaseCollation( [ diff --git a/tests/phpunit/unit/includes/composer/ComposerVersionNormalizerTest.php b/tests/phpunit/includes/composer/ComposerVersionNormalizerTest.php similarity index 100% rename from tests/phpunit/unit/includes/composer/ComposerVersionNormalizerTest.php rename to tests/phpunit/includes/composer/ComposerVersionNormalizerTest.php diff --git a/tests/phpunit/unit/includes/config/ConfigFactoryTest.php b/tests/phpunit/includes/config/ConfigFactoryTest.php similarity index 98% rename from tests/phpunit/unit/includes/config/ConfigFactoryTest.php rename to tests/phpunit/includes/config/ConfigFactoryTest.php index a136018c96..ea747afac1 100644 --- a/tests/phpunit/unit/includes/config/ConfigFactoryTest.php +++ b/tests/phpunit/includes/config/ConfigFactoryTest.php @@ -2,7 +2,7 @@ use MediaWiki\MediaWikiServices; -class ConfigFactoryTest extends \MediaWikiUnitTestCase { +class ConfigFactoryTest extends MediaWikiTestCase { /** * @covers ConfigFactory::register diff --git a/tests/phpunit/unit/includes/config/EtcdConfigTest.php b/tests/phpunit/includes/config/EtcdConfigTest.php similarity index 100% rename from tests/phpunit/unit/includes/config/EtcdConfigTest.php rename to tests/phpunit/includes/config/EtcdConfigTest.php diff --git a/tests/phpunit/unit/includes/config/HashConfigTest.php b/tests/phpunit/includes/config/HashConfigTest.php similarity index 96% rename from tests/phpunit/unit/includes/config/HashConfigTest.php rename to tests/phpunit/includes/config/HashConfigTest.php index d46ee09d5b..bac8311cd4 100644 --- a/tests/phpunit/unit/includes/config/HashConfigTest.php +++ b/tests/phpunit/includes/config/HashConfigTest.php @@ -1,6 +1,6 @@ assertEquals( 'readonly', $e->title ); + $this->assertEquals( 'readonlytext', $e->msg ); + $this->assertEquals( wfReadOnlyReason() ?: [], $e->params ); + } + +} diff --git a/tests/phpunit/unit/includes/exception/UserNotLoggedInTest.php b/tests/phpunit/includes/exception/UserNotLoggedInTest.php similarity index 83% rename from tests/phpunit/unit/includes/exception/UserNotLoggedInTest.php rename to tests/phpunit/includes/exception/UserNotLoggedInTest.php index 3888c8e15c..55ec45a020 100644 --- a/tests/phpunit/unit/includes/exception/UserNotLoggedInTest.php +++ b/tests/phpunit/includes/exception/UserNotLoggedInTest.php @@ -4,7 +4,7 @@ * @covers UserNotLoggedIn * @author Addshore */ -class UserNotLoggedInTest extends \MediaWikiUnitTestCase { +class UserNotLoggedInTest extends MediaWikiTestCase { public function testConstruction() { $e = new UserNotLoggedIn(); diff --git a/tests/phpunit/unit/includes/externalstore/ExternalStoreFactoryTest.php b/tests/phpunit/includes/externalstore/ExternalStoreFactoryTest.php similarity index 100% rename from tests/phpunit/unit/includes/externalstore/ExternalStoreFactoryTest.php rename to tests/phpunit/includes/externalstore/ExternalStoreFactoryTest.php diff --git a/tests/phpunit/unit/includes/filebackend/SwiftFileBackendTest.php b/tests/phpunit/includes/filebackend/SwiftFileBackendTest.php similarity index 98% rename from tests/phpunit/unit/includes/filebackend/SwiftFileBackendTest.php rename to tests/phpunit/includes/filebackend/SwiftFileBackendTest.php index fbc1a571c5..35eca28f7e 100644 --- a/tests/phpunit/unit/includes/filebackend/SwiftFileBackendTest.php +++ b/tests/phpunit/includes/filebackend/SwiftFileBackendTest.php @@ -12,7 +12,7 @@ use Wikimedia\TestingAccessWrapper; * @covers SwiftFileBackendFileList * @covers SwiftFileBackendList */ -class SwiftFileBackendTest extends \MediaWikiUnitTestCase { +class SwiftFileBackendTest extends MediaWikiTestCase { /** @var TestingAccessWrapper Proxy to SwiftFileBackend */ private $backend; diff --git a/tests/phpunit/unit/includes/filerepo/FileBackendDBRepoWrapperTest.php b/tests/phpunit/includes/filerepo/FileBackendDBRepoWrapperTest.php similarity index 98% rename from tests/phpunit/unit/includes/filerepo/FileBackendDBRepoWrapperTest.php rename to tests/phpunit/includes/filerepo/FileBackendDBRepoWrapperTest.php index 4db9892f9d..346be7afa3 100644 --- a/tests/phpunit/unit/includes/filerepo/FileBackendDBRepoWrapperTest.php +++ b/tests/phpunit/includes/filerepo/FileBackendDBRepoWrapperTest.php @@ -1,6 +1,6 @@ 'BGR', diff --git a/tests/phpunit/unit/includes/htmlform/HTMLCheckMatrixTest.php b/tests/phpunit/includes/htmlform/HTMLCheckMatrixTest.php similarity index 98% rename from tests/phpunit/unit/includes/htmlform/HTMLCheckMatrixTest.php rename to tests/phpunit/includes/htmlform/HTMLCheckMatrixTest.php index 9c41ab8275..05c567df75 100644 --- a/tests/phpunit/unit/includes/htmlform/HTMLCheckMatrixTest.php +++ b/tests/phpunit/includes/htmlform/HTMLCheckMatrixTest.php @@ -3,7 +3,7 @@ /** * @covers HTMLCheckMatrix */ -class HTMLCheckMatrixTest extends \MediaWikiUnitTestCase { +class HTMLCheckMatrixTest extends MediaWikiTestCase { private static $defaultOptions = [ 'rows' => [ 'r1', 'r2' ], 'columns' => [ 'c1', 'c2' ], diff --git a/tests/phpunit/unit/includes/htmlform/HTMLFormTest.php b/tests/phpunit/includes/htmlform/HTMLFormTest.php similarity index 96% rename from tests/phpunit/unit/includes/htmlform/HTMLFormTest.php rename to tests/phpunit/includes/htmlform/HTMLFormTest.php index d9d2cb1191..d7dc4112b7 100644 --- a/tests/phpunit/unit/includes/htmlform/HTMLFormTest.php +++ b/tests/phpunit/includes/htmlform/HTMLFormTest.php @@ -6,7 +6,7 @@ * @license GPL-2.0-or-later * @author Gergő Tisza */ -class HTMLFormTest extends \MediaWikiUnitTestCase { +class HTMLFormTest extends MediaWikiTestCase { private function newInstance() { $form = new HTMLForm( [] ); diff --git a/tests/phpunit/unit/includes/htmlform/HTMLRestrictionsFieldTest.php b/tests/phpunit/includes/htmlform/HTMLRestrictionsFieldTest.php similarity index 100% rename from tests/phpunit/unit/includes/htmlform/HTMLRestrictionsFieldTest.php rename to tests/phpunit/includes/htmlform/HTMLRestrictionsFieldTest.php diff --git a/tests/phpunit/unit/includes/http/GuzzleHttpRequestTest.php b/tests/phpunit/includes/http/GuzzleHttpRequestTest.php similarity index 98% rename from tests/phpunit/unit/includes/http/GuzzleHttpRequestTest.php rename to tests/phpunit/includes/http/GuzzleHttpRequestTest.php index e271ac6e00..c9356b6b10 100644 --- a/tests/phpunit/unit/includes/http/GuzzleHttpRequestTest.php +++ b/tests/phpunit/includes/http/GuzzleHttpRequestTest.php @@ -13,7 +13,7 @@ use GuzzleHttp\Psr7\Request; * @covers GuzzleHttpRequest * @covers MWHttpRequest */ -class GuzzleHttpRequestTest extends \MediaWikiUnitTestCase { +class GuzzleHttpRequestTest extends MediaWikiTestCase { /** * 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/unit/includes/http/HttpRequestFactoryTest.php b/tests/phpunit/includes/http/HttpRequestFactoryTest.php similarity index 97% rename from tests/phpunit/unit/includes/http/HttpRequestFactoryTest.php rename to tests/phpunit/includes/http/HttpRequestFactoryTest.php index 61c67fde57..7429dcc9dd 100644 --- a/tests/phpunit/unit/includes/http/HttpRequestFactoryTest.php +++ b/tests/phpunit/includes/http/HttpRequestFactoryTest.php @@ -5,7 +5,7 @@ use MediaWiki\Http\HttpRequestFactory; /** * @covers MediaWiki\Http\HttpRequestFactory */ -class HttpRequestFactoryTest extends \MediaWikiUnitTestCase { +class HttpRequestFactoryTest extends MediaWikiTestCase { /** * @return HttpRequestFactory diff --git a/tests/phpunit/unit/includes/installer/InstallDocFormatterTest.php b/tests/phpunit/includes/installer/InstallDocFormatterTest.php similarity index 97% rename from tests/phpunit/unit/includes/installer/InstallDocFormatterTest.php rename to tests/phpunit/includes/installer/InstallDocFormatterTest.php index fddc3b8680..9584d4b8c4 100644 --- a/tests/phpunit/unit/includes/installer/InstallDocFormatterTest.php +++ b/tests/phpunit/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/unit/includes/libs/composer/ComposerJsonTest.php b/tests/phpunit/includes/libs/composer/ComposerJsonTest.php similarity index 85% rename from tests/phpunit/unit/includes/libs/composer/ComposerJsonTest.php rename to tests/phpunit/includes/libs/composer/ComposerJsonTest.php index a009a51a9e..720fa6e8fd 100644 --- a/tests/phpunit/unit/includes/libs/composer/ComposerJsonTest.php +++ b/tests/phpunit/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/unit/includes/libs/composer/ComposerLockTest.php b/tests/phpunit/includes/libs/composer/ComposerLockTest.php similarity index 97% rename from tests/phpunit/unit/includes/libs/composer/ComposerLockTest.php rename to tests/phpunit/includes/libs/composer/ComposerLockTest.php index 90c036a472..f5fcdbe018 100644 --- a/tests/phpunit/unit/includes/libs/composer/ComposerLockTest.php +++ b/tests/phpunit/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/unit/includes/libs/http/HttpAcceptNegotiatorTest.php b/tests/phpunit/includes/libs/http/HttpAcceptNegotiatorTest.php similarity index 100% rename from tests/phpunit/unit/includes/libs/http/HttpAcceptNegotiatorTest.php rename to tests/phpunit/includes/libs/http/HttpAcceptNegotiatorTest.php diff --git a/tests/phpunit/unit/includes/libs/http/HttpAcceptParserTest.php b/tests/phpunit/includes/libs/http/HttpAcceptParserTest.php similarity index 100% rename from tests/phpunit/unit/includes/libs/http/HttpAcceptParserTest.php rename to tests/phpunit/includes/libs/http/HttpAcceptParserTest.php diff --git a/tests/phpunit/unit/includes/libs/mime/MSCompoundFileReaderTest.php b/tests/phpunit/includes/libs/mime/MSCompoundFileReaderTest.php similarity index 90% rename from tests/phpunit/unit/includes/libs/mime/MSCompoundFileReaderTest.php rename to tests/phpunit/includes/libs/mime/MSCompoundFileReaderTest.php index 7cc0525660..4509a61eb7 100644 --- a/tests/phpunit/unit/includes/libs/mime/MSCompoundFileReaderTest.php +++ b/tests/phpunit/includes/libs/mime/MSCompoundFileReaderTest.php @@ -19,17 +19,6 @@ * @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/unit/includes/libs/mime/MimeAnalyzerTest.php b/tests/phpunit/includes/libs/mime/MimeAnalyzerTest.php similarity index 86% rename from tests/phpunit/unit/includes/libs/mime/MimeAnalyzerTest.php rename to tests/phpunit/includes/libs/mime/MimeAnalyzerTest.php index e78489d7bf..194781207e 100644 --- a/tests/phpunit/unit/includes/libs/mime/MimeAnalyzerTest.php +++ b/tests/phpunit/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,13 +133,7 @@ class MimeAnalyzerTest extends PHPUnit\Framework\TestCase { * A ZIP file embedded in the middle of a .doc file is still a Word Document. */ function testZipInDoc() { - 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'; + $file = __DIR__ . '/../../../data/media/zip-in-doc.doc'; $actualType = $this->doGuessMimeType( [ $file, 'doc' ] ); $this->assertEquals( 'application/msword', $actualType ); } diff --git a/tests/phpunit/unit/includes/libs/objectcache/CachedBagOStuffTest.php b/tests/phpunit/includes/libs/objectcache/CachedBagOStuffTest.php similarity index 100% rename from tests/phpunit/unit/includes/libs/objectcache/CachedBagOStuffTest.php rename to tests/phpunit/includes/libs/objectcache/CachedBagOStuffTest.php diff --git a/tests/phpunit/unit/includes/libs/objectcache/HashBagOStuffTest.php b/tests/phpunit/includes/libs/objectcache/HashBagOStuffTest.php similarity index 100% rename from tests/phpunit/unit/includes/libs/objectcache/HashBagOStuffTest.php rename to tests/phpunit/includes/libs/objectcache/HashBagOStuffTest.php diff --git a/tests/phpunit/unit/includes/libs/objectcache/ReplicatedBagOStuffTest.php b/tests/phpunit/includes/libs/objectcache/ReplicatedBagOStuffTest.php similarity index 95% rename from tests/phpunit/unit/includes/libs/objectcache/ReplicatedBagOStuffTest.php rename to tests/phpunit/includes/libs/objectcache/ReplicatedBagOStuffTest.php index 64d282f487..550ec0bd09 100644 --- a/tests/phpunit/unit/includes/libs/objectcache/ReplicatedBagOStuffTest.php +++ b/tests/phpunit/includes/libs/objectcache/ReplicatedBagOStuffTest.php @@ -1,6 +1,6 @@ mediaPath = __DIR__ . '/../../../data/media/'; + $this->mediaPath = __DIR__ . '/../../data/media/'; } /** diff --git a/tests/phpunit/unit/includes/media/IPTCTest.php b/tests/phpunit/includes/media/IPTCTest.php similarity index 98% rename from tests/phpunit/unit/includes/media/IPTCTest.php rename to tests/phpunit/includes/media/IPTCTest.php index 430493cd20..4b3ba0755c 100644 --- a/tests/phpunit/unit/includes/media/IPTCTest.php +++ b/tests/phpunit/includes/media/IPTCTest.php @@ -3,7 +3,7 @@ /** * @group Media */ -class IPTCTest extends \MediaWikiUnitTestCase { +class IPTCTest extends MediaWikiTestCase { /** * @covers IPTC::getCharset diff --git a/tests/phpunit/unit/includes/media/JpegMetadataExtractorTest.php b/tests/phpunit/includes/media/JpegMetadataExtractorTest.php similarity index 97% rename from tests/phpunit/unit/includes/media/JpegMetadataExtractorTest.php rename to tests/phpunit/includes/media/JpegMetadataExtractorTest.php index 6063f3e9da..c943cef906 100644 --- a/tests/phpunit/unit/includes/media/JpegMetadataExtractorTest.php +++ b/tests/phpunit/includes/media/JpegMetadataExtractorTest.php @@ -9,14 +9,14 @@ * @group Media * @covers JpegMetadataExtractor */ -class JpegMetadataExtractorTest extends \MediaWikiUnitTestCase { +class JpegMetadataExtractorTest extends MediaWikiTestCase { protected $filePath; protected function setUp() { parent::setUp(); - $this->filePath = __DIR__ . '/../../../data/media/'; + $this->filePath = __DIR__ . '/../../data/media/'; } /** diff --git a/tests/phpunit/unit/includes/media/MediaHandlerTest.php b/tests/phpunit/includes/media/MediaHandlerTest.php similarity index 96% rename from tests/phpunit/unit/includes/media/MediaHandlerTest.php rename to tests/phpunit/includes/media/MediaHandlerTest.php index eb4ece88c4..7a052f6035 100644 --- a/tests/phpunit/unit/includes/media/MediaHandlerTest.php +++ b/tests/phpunit/includes/media/MediaHandlerTest.php @@ -3,7 +3,7 @@ /** * @group Media */ -class MediaHandlerTest extends \MediaWikiUnitTestCase { +class MediaHandlerTest extends MediaWikiTestCase { /** * @covers MediaHandler::fitBoxWidth diff --git a/tests/phpunit/unit/includes/media/SVGMetadataExtractorTest.php b/tests/phpunit/includes/media/SVGMetadataExtractorTest.php similarity index 96% rename from tests/phpunit/unit/includes/media/SVGMetadataExtractorTest.php rename to tests/phpunit/includes/media/SVGMetadataExtractorTest.php index 30d10083f4..6b94d0ae6c 100644 --- a/tests/phpunit/unit/includes/media/SVGMetadataExtractorTest.php +++ b/tests/phpunit/includes/media/SVGMetadataExtractorTest.php @@ -4,7 +4,7 @@ * @group Media * @covers SVGMetadataExtractor */ -class SVGMetadataExtractorTest extends \MediaWikiUnitTestCase { +class SVGMetadataExtractorTest extends MediaWikiTestCase { /** * @dataProvider provideSvgFiles @@ -46,7 +46,7 @@ class SVGMetadataExtractorTest extends \MediaWikiUnitTestCase { } public static function provideSvgFiles() { - $base = __DIR__ . '/../../../data/media'; + $base = __DIR__ . '/../../data/media'; return [ [ @@ -143,7 +143,7 @@ class SVGMetadataExtractorTest extends \MediaWikiUnitTestCase { } public static function provideSvgFilesWithXMLMetadata() { - $base = __DIR__ . '/../../../data/media'; + $base = __DIR__ . '/../../data/media'; // phpcs:disable Generic.Files.LineLength $metadata = ' diff --git a/tests/phpunit/unit/includes/media/WebPHandlerTest.php b/tests/phpunit/includes/media/WebPHandlerTest.php similarity index 92% rename from tests/phpunit/unit/includes/media/WebPHandlerTest.php rename to tests/phpunit/includes/media/WebPHandlerTest.php index 6c8600d188..ac0ad98edd 100644 --- a/tests/phpunit/unit/includes/media/WebPHandlerTest.php +++ b/tests/phpunit/includes/media/WebPHandlerTest.php @@ -3,7 +3,7 @@ /** * @covers WebPHandler */ -class WebPHandlerTest extends \MediaWikiUnitTestCase { +class WebPHandlerTest extends MediaWikiTestCase { public function setUp() { parent::setUp(); // Allocated file for testing @@ -86,14 +86,14 @@ class WebPHandlerTest extends \MediaWikiUnitTestCase { 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 \MediaWikiUnitTestCase { 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 \MediaWikiUnitTestCase { 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/unit/includes/objectcache/MemcachedBagOStuffTest.php b/tests/phpunit/includes/objectcache/MemcachedBagOStuffTest.php similarity index 98% rename from tests/phpunit/unit/includes/objectcache/MemcachedBagOStuffTest.php rename to tests/phpunit/includes/objectcache/MemcachedBagOStuffTest.php index eb040b4501..45971daced 100644 --- a/tests/phpunit/unit/includes/objectcache/MemcachedBagOStuffTest.php +++ b/tests/phpunit/includes/objectcache/MemcachedBagOStuffTest.php @@ -2,7 +2,7 @@ /** * @group BagOStuff */ -class MemcachedBagOStuffTest extends \MediaWikiUnitTestCase { +class MemcachedBagOStuffTest extends MediaWikiTestCase { /** @var MemcachedBagOStuff */ private $cache; diff --git a/tests/phpunit/unit/includes/objectcache/RESTBagOStuffTest.php b/tests/phpunit/includes/objectcache/RESTBagOStuffTest.php similarity index 98% rename from tests/phpunit/unit/includes/objectcache/RESTBagOStuffTest.php rename to tests/phpunit/includes/objectcache/RESTBagOStuffTest.php index 459e3eebc2..dfbca706d6 100644 --- a/tests/phpunit/unit/includes/objectcache/RESTBagOStuffTest.php +++ b/tests/phpunit/includes/objectcache/RESTBagOStuffTest.php @@ -4,7 +4,7 @@ * * @covers RESTBagOStuff */ -class RESTBagOStuffTest extends \MediaWikiUnitTestCase { +class RESTBagOStuffTest extends MediaWikiTestCase { /** * @var MultiHttpClient diff --git a/tests/phpunit/unit/includes/objectcache/RedisBagOStuffTest.php b/tests/phpunit/includes/objectcache/RedisBagOStuffTest.php similarity index 100% rename from tests/phpunit/unit/includes/objectcache/RedisBagOStuffTest.php rename to tests/phpunit/includes/objectcache/RedisBagOStuffTest.php diff --git a/tests/phpunit/unit/includes/page/ArticleTest.php b/tests/phpunit/includes/page/ArticleTest.php similarity index 96% rename from tests/phpunit/unit/includes/page/ArticleTest.php rename to tests/phpunit/includes/page/ArticleTest.php index 61fb4b6055..df4a281701 100644 --- a/tests/phpunit/unit/includes/page/ArticleTest.php +++ b/tests/phpunit/includes/page/ArticleTest.php @@ -1,6 +1,6 @@ preprocessToXml( $className, $wikiText ); diff --git a/tests/phpunit/unit/includes/parser/TidyTest.php b/tests/phpunit/includes/parser/TidyTest.php similarity index 97% rename from tests/phpunit/unit/includes/parser/TidyTest.php rename to tests/phpunit/includes/parser/TidyTest.php index 1adb6a6444..898ef2d163 100644 --- a/tests/phpunit/unit/includes/parser/TidyTest.php +++ b/tests/phpunit/includes/parser/TidyTest.php @@ -4,7 +4,7 @@ * @group Parser * @covers MWTidy */ -class TidyTest extends \MediaWikiUnitTestCase { +class TidyTest extends MediaWikiTestCase { protected function setUp() { parent::setUp(); diff --git a/tests/phpunit/unit/includes/password/PasswordFactoryTest.php b/tests/phpunit/includes/password/PasswordFactoryTest.php similarity index 98% rename from tests/phpunit/unit/includes/password/PasswordFactoryTest.php rename to tests/phpunit/includes/password/PasswordFactoryTest.php index 96e74b1072..a7b3557516 100644 --- a/tests/phpunit/unit/includes/password/PasswordFactoryTest.php +++ b/tests/phpunit/includes/password/PasswordFactoryTest.php @@ -3,7 +3,7 @@ /** * @covers PasswordFactory */ -class PasswordFactoryTest extends \MediaWikiUnitTestCase { +class PasswordFactoryTest extends MediaWikiTestCase { public function testConstruct() { $pf = new PasswordFactory(); $this->assertEquals( [ '' ], array_keys( $pf->getTypes() ) ); diff --git a/tests/phpunit/unit/includes/password/PasswordTest.php b/tests/phpunit/includes/password/PasswordTest.php similarity index 95% rename from tests/phpunit/unit/includes/password/PasswordTest.php rename to tests/phpunit/includes/password/PasswordTest.php index b41c0f4150..61a5147277 100644 --- a/tests/phpunit/unit/includes/password/PasswordTest.php +++ b/tests/phpunit/includes/password/PasswordTest.php @@ -23,7 +23,7 @@ /** * @covers InvalidPassword */ -class PasswordTest extends \MediaWikiUnitTestCase { +class PasswordTest extends MediaWikiTestCase { public function testInvalidPlaintext() { $passwordFactory = new PasswordFactory(); $invalid = $passwordFactory->newFromPlaintext( null ); diff --git a/tests/phpunit/unit/includes/preferences/FiltersTest.php b/tests/phpunit/includes/preferences/FiltersTest.php similarity index 98% rename from tests/phpunit/unit/includes/preferences/FiltersTest.php rename to tests/phpunit/includes/preferences/FiltersTest.php index d2b5d05bb3..60b01b880c 100644 --- a/tests/phpunit/unit/includes/preferences/FiltersTest.php +++ b/tests/phpunit/includes/preferences/FiltersTest.php @@ -25,7 +25,7 @@ use MediaWiki\Preferences\TimezoneFilter; /** * @group Preferences */ -class FiltersTest extends \MediaWikiUnitTestCase { +class FiltersTest extends MediaWikiTestCase { /** * @covers MediaWiki\Preferences\IntvalFilter::filterFromForm() * @covers MediaWiki\Preferences\IntvalFilter::filterForForm() diff --git a/tests/phpunit/unit/includes/registration/ExtensionJsonValidatorTest.php b/tests/phpunit/includes/registration/ExtensionJsonValidatorTest.php similarity index 95% rename from tests/phpunit/unit/includes/registration/ExtensionJsonValidatorTest.php rename to tests/phpunit/includes/registration/ExtensionJsonValidatorTest.php index 77bc23b1a7..46c697f8ba 100644 --- a/tests/phpunit/unit/includes/registration/ExtensionJsonValidatorTest.php +++ b/tests/phpunit/includes/registration/ExtensionJsonValidatorTest.php @@ -21,7 +21,7 @@ /** * @covers ExtensionJsonValidator */ -class ExtensionJsonValidatorTest extends \MediaWikiUnitTestCase { +class ExtensionJsonValidatorTest extends MediaWikiTestCase { /** * @dataProvider provideValidate @@ -39,7 +39,7 @@ class ExtensionJsonValidatorTest extends \MediaWikiUnitTestCase { ); } - $dir = __DIR__ . '/../../../data/registration/'; + $dir = __DIR__ . '/../../data/registration/'; $this->assertSame( $expected, $validator->validate( $dir . $file ) diff --git a/tests/phpunit/unit/includes/registration/ExtensionProcessorTest.php b/tests/phpunit/includes/registration/ExtensionProcessorTest.php similarity index 99% rename from tests/phpunit/unit/includes/registration/ExtensionProcessorTest.php rename to tests/phpunit/includes/registration/ExtensionProcessorTest.php index 13de142ae6..cdd5c63eff 100644 --- a/tests/phpunit/unit/includes/registration/ExtensionProcessorTest.php +++ b/tests/phpunit/includes/registration/ExtensionProcessorTest.php @@ -5,7 +5,7 @@ use Wikimedia\TestingAccessWrapper; /** * @covers ExtensionProcessor */ -class ExtensionProcessorTest extends \MediaWikiUnitTestCase { +class ExtensionProcessorTest extends MediaWikiTestCase { private $dir, $dirname; diff --git a/tests/phpunit/unit/includes/registration/VersionCheckerTest.php b/tests/phpunit/includes/registration/VersionCheckerTest.php similarity index 100% rename from tests/phpunit/unit/includes/registration/VersionCheckerTest.php rename to tests/phpunit/includes/registration/VersionCheckerTest.php diff --git a/tests/phpunit/unit/includes/resourceloader/DerivativeResourceLoaderContextTest.php b/tests/phpunit/includes/resourceloader/DerivativeResourceLoaderContextTest.php similarity index 100% rename from tests/phpunit/unit/includes/resourceloader/DerivativeResourceLoaderContextTest.php rename to tests/phpunit/includes/resourceloader/DerivativeResourceLoaderContextTest.php diff --git a/tests/phpunit/unit/includes/resourceloader/MessageBlobStoreTest.php b/tests/phpunit/includes/resourceloader/MessageBlobStoreTest.php similarity index 92% rename from tests/phpunit/unit/includes/resourceloader/MessageBlobStoreTest.php rename to tests/phpunit/includes/resourceloader/MessageBlobStoreTest.php index d8a94e735d..e094d92b9d 100644 --- a/tests/phpunit/unit/includes/resourceloader/MessageBlobStoreTest.php +++ b/tests/phpunit/includes/resourceloader/MessageBlobStoreTest.php @@ -1,14 +1,12 @@ 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/unit/includes/resourceloader/ResourceLoaderClientHtmlTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php similarity index 100% rename from tests/phpunit/unit/includes/resourceloader/ResourceLoaderClientHtmlTest.php rename to tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php diff --git a/tests/phpunit/unit/includes/resourceloader/ResourceLoaderContextTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderContextTest.php similarity index 100% rename from tests/phpunit/unit/includes/resourceloader/ResourceLoaderContextTest.php rename to tests/phpunit/includes/resourceloader/ResourceLoaderContextTest.php diff --git a/tests/phpunit/unit/includes/search/SearchIndexFieldTest.php b/tests/phpunit/includes/search/SearchIndexFieldTest.php similarity index 95% rename from tests/phpunit/unit/includes/search/SearchIndexFieldTest.php rename to tests/phpunit/includes/search/SearchIndexFieldTest.php index a640c967cc..8b4119e0d3 100644 --- a/tests/phpunit/unit/includes/search/SearchIndexFieldTest.php +++ b/tests/phpunit/includes/search/SearchIndexFieldTest.php @@ -4,7 +4,7 @@ * @group Search * @covers SearchIndexFieldDefinition */ -class SearchIndexFieldTest extends \MediaWikiUnitTestCase { +class SearchIndexFieldTest extends MediaWikiTestCase { public function getMergeCases() { return [ diff --git a/tests/phpunit/unit/includes/search/SearchSuggestionSetTest.php b/tests/phpunit/includes/search/SearchSuggestionSetTest.php similarity index 100% rename from tests/phpunit/unit/includes/search/SearchSuggestionSetTest.php rename to tests/phpunit/includes/search/SearchSuggestionSetTest.php diff --git a/tests/phpunit/unit/includes/session/MetadataMergeExceptionTest.php b/tests/phpunit/includes/session/MetadataMergeExceptionTest.php similarity index 88% rename from tests/phpunit/unit/includes/session/MetadataMergeExceptionTest.php rename to tests/phpunit/includes/session/MetadataMergeExceptionTest.php index 707adfe5b0..8cb4302a4e 100644 --- a/tests/phpunit/unit/includes/session/MetadataMergeExceptionTest.php +++ b/tests/phpunit/includes/session/MetadataMergeExceptionTest.php @@ -2,11 +2,13 @@ namespace MediaWiki\Session; +use MediaWikiTestCase; + /** * @group Session * @covers MediaWiki\Session\MetadataMergeException */ -class MetadataMergeExceptionTest extends \MediaWikiUnitTestCase { +class MetadataMergeExceptionTest extends MediaWikiTestCase { public function testBasics() { $data = [ 'foo' => 'bar' ]; diff --git a/tests/phpunit/unit/includes/session/SessionIdTest.php b/tests/phpunit/includes/session/SessionIdTest.php similarity index 83% rename from tests/phpunit/unit/includes/session/SessionIdTest.php rename to tests/phpunit/includes/session/SessionIdTest.php index 3c7f8cbfdf..2b06d971a6 100644 --- a/tests/phpunit/unit/includes/session/SessionIdTest.php +++ b/tests/phpunit/includes/session/SessionIdTest.php @@ -2,11 +2,13 @@ namespace MediaWiki\Session; +use MediaWikiTestCase; + /** * @group Session * @covers MediaWiki\Session\SessionId */ -class SessionIdTest extends \MediaWikiUnitTestCase { +class SessionIdTest extends MediaWikiTestCase { public function testEverything() { $id = new SessionId( 'foo' ); diff --git a/tests/phpunit/unit/includes/session/SessionInfoTest.php b/tests/phpunit/includes/session/SessionInfoTest.php similarity index 98% rename from tests/phpunit/unit/includes/session/SessionInfoTest.php rename to tests/phpunit/includes/session/SessionInfoTest.php index a3a6365fbb..8f7b2a6e70 100644 --- a/tests/phpunit/unit/includes/session/SessionInfoTest.php +++ b/tests/phpunit/includes/session/SessionInfoTest.php @@ -2,20 +2,19 @@ namespace MediaWiki\Session; +use MediaWikiTestCase; + /** * @group Session * @group Database * @covers MediaWiki\Session\SessionInfo */ -class SessionInfoTest extends \MediaWikiUnitTestCase { +class SessionInfoTest extends MediaWikiTestCase { public function testBasics() { - $sysopUser = new \User(); - $sysopUser->setName( 'UTSysop' ); - $anonInfo = UserInfo::newAnonymous(); - $userInfo = UserInfo::newFromUser( $sysopUser, true ); - $unverifiedUserInfo = UserInfo::newFromUser( $sysopUser, false ); + $userInfo = UserInfo::newFromName( 'UTSysop', true ); + $unverifiedUserInfo = UserInfo::newFromName( 'UTSysop', false ); try { new SessionInfo( SessionInfo::MIN_PRIORITY - 1, [] ); diff --git a/tests/phpunit/unit/includes/session/SessionProviderTest.php b/tests/phpunit/includes/session/SessionProviderTest.php similarity index 98% rename from tests/phpunit/unit/includes/session/SessionProviderTest.php rename to tests/phpunit/includes/session/SessionProviderTest.php index 114fa24a3d..6ff6a97b8f 100644 --- a/tests/phpunit/unit/includes/session/SessionProviderTest.php +++ b/tests/phpunit/includes/session/SessionProviderTest.php @@ -2,6 +2,7 @@ namespace MediaWiki\Session; +use MediaWikiTestCase; use Wikimedia\TestingAccessWrapper; /** @@ -9,7 +10,7 @@ use Wikimedia\TestingAccessWrapper; * @group Database * @covers MediaWiki\Session\SessionProvider */ -class SessionProviderTest extends \MediaWikiUnitTestCase { +class SessionProviderTest extends MediaWikiTestCase { public function testBasics() { $manager = new SessionManager(); diff --git a/tests/phpunit/unit/includes/session/SessionTest.php b/tests/phpunit/includes/session/SessionTest.php similarity index 99% rename from tests/phpunit/unit/includes/session/SessionTest.php rename to tests/phpunit/includes/session/SessionTest.php index 73bf060638..a74056d0ca 100644 --- a/tests/phpunit/unit/includes/session/SessionTest.php +++ b/tests/phpunit/includes/session/SessionTest.php @@ -3,6 +3,7 @@ namespace MediaWiki\Session; use Psr\Log\LogLevel; +use MediaWikiTestCase; use User; use Wikimedia\TestingAccessWrapper; @@ -10,7 +11,7 @@ use Wikimedia\TestingAccessWrapper; * @group Session * @covers MediaWiki\Session\Session */ -class SessionTest extends \MediaWikiUnitTestCase { +class SessionTest extends MediaWikiTestCase { public function testConstructor() { $backend = TestUtils::getDummySessionBackend(); diff --git a/tests/phpunit/unit/includes/session/TokenTest.php b/tests/phpunit/includes/session/TokenTest.php similarity index 96% rename from tests/phpunit/unit/includes/session/TokenTest.php rename to tests/phpunit/includes/session/TokenTest.php index cab962b3c6..47976527ca 100644 --- a/tests/phpunit/unit/includes/session/TokenTest.php +++ b/tests/phpunit/includes/session/TokenTest.php @@ -2,13 +2,14 @@ namespace MediaWiki\Session; +use MediaWikiTestCase; use Wikimedia\TestingAccessWrapper; /** * @group Session * @covers MediaWiki\Session\Token */ -class TokenTest extends \MediaWikiUnitTestCase { +class TokenTest extends MediaWikiTestCase { public function testBasics() { $token = $this->getMockBuilder( Token::class ) diff --git a/tests/phpunit/unit/includes/shell/CommandFactoryTest.php b/tests/phpunit/includes/shell/CommandFactoryTest.php similarity index 100% rename from tests/phpunit/unit/includes/shell/CommandFactoryTest.php rename to tests/phpunit/includes/shell/CommandFactoryTest.php diff --git a/tests/phpunit/unit/includes/shell/CommandTest.php b/tests/phpunit/includes/shell/CommandTest.php similarity index 100% rename from tests/phpunit/unit/includes/shell/CommandTest.php rename to tests/phpunit/includes/shell/CommandTest.php diff --git a/tests/phpunit/unit/includes/shell/FirejailCommandTest.php b/tests/phpunit/includes/shell/FirejailCommandTest.php similarity index 94% rename from tests/phpunit/unit/includes/shell/FirejailCommandTest.php rename to tests/phpunit/includes/shell/FirejailCommandTest.php index b87271fd31..681c3dcda0 100644 --- a/tests/phpunit/unit/includes/shell/FirejailCommandTest.php +++ b/tests/phpunit/includes/shell/FirejailCommandTest.php @@ -29,11 +29,10 @@ 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 '$basePath/includes/shell/limit.sh'"; - $profile = "--profile=$basePath/includes/shell/firejail.profile"; + $limit = "/bin/bash '$IP/includes/shell/limit.sh'"; + $profile = "--profile=$IP/includes/shell/firejail.profile"; $blacklist = '--blacklist=' . realpath( MW_CONFIG_FILE ); $default = "$blacklist --noroot --seccomp --private-dev"; return [ diff --git a/tests/phpunit/unit/includes/site/CachingSiteStoreTest.php b/tests/phpunit/includes/site/CachingSiteStoreTest.php similarity index 98% rename from tests/phpunit/unit/includes/site/CachingSiteStoreTest.php rename to tests/phpunit/includes/site/CachingSiteStoreTest.php index 92ed1f53e8..f04d35ca02 100644 --- a/tests/phpunit/unit/includes/site/CachingSiteStoreTest.php +++ b/tests/phpunit/includes/site/CachingSiteStoreTest.php @@ -27,7 +27,7 @@ * * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ -class CachingSiteStoreTest extends \MediaWikiUnitTestCase { +class CachingSiteStoreTest extends MediaWikiTestCase { /** * @covers CachingSiteStore::getSites diff --git a/tests/phpunit/unit/includes/site/HashSiteStoreTest.php b/tests/phpunit/includes/site/HashSiteStoreTest.php similarity index 97% rename from tests/phpunit/unit/includes/site/HashSiteStoreTest.php rename to tests/phpunit/includes/site/HashSiteStoreTest.php index 8b0d4e080b..6269fd39dc 100644 --- a/tests/phpunit/unit/includes/site/HashSiteStoreTest.php +++ b/tests/phpunit/includes/site/HashSiteStoreTest.php @@ -24,7 +24,7 @@ * * @author Katie Filbert < aude.wiki@gmail.com > */ -class HashSiteStoreTest extends \MediaWikiUnitTestCase { +class HashSiteStoreTest extends MediaWikiTestCase { /** * @covers HashSiteStore::getSites diff --git a/tests/phpunit/unit/includes/site/MediaWikiPageNameNormalizerTest.php b/tests/phpunit/includes/site/MediaWikiPageNameNormalizerTest.php similarity index 100% rename from tests/phpunit/unit/includes/site/MediaWikiPageNameNormalizerTest.php rename to tests/phpunit/includes/site/MediaWikiPageNameNormalizerTest.php diff --git a/tests/phpunit/unit/includes/site/SiteExporterTest.php b/tests/phpunit/includes/site/SiteExporterTest.php similarity index 98% rename from tests/phpunit/unit/includes/site/SiteExporterTest.php rename to tests/phpunit/includes/site/SiteExporterTest.php index 707be45ba3..97a43f8d5b 100644 --- a/tests/phpunit/unit/includes/site/SiteExporterTest.php +++ b/tests/phpunit/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/unit/includes/site/SiteImporterTest.php b/tests/phpunit/includes/site/SiteImporterTest.php similarity index 100% rename from tests/phpunit/unit/includes/site/SiteImporterTest.php rename to tests/phpunit/includes/site/SiteImporterTest.php diff --git a/tests/phpunit/unit/includes/site/SiteImporterTest.xml b/tests/phpunit/includes/site/SiteImporterTest.xml similarity index 100% rename from tests/phpunit/unit/includes/site/SiteImporterTest.xml rename to tests/phpunit/includes/site/SiteImporterTest.xml diff --git a/tests/phpunit/unit/includes/skins/SkinFactoryTest.php b/tests/phpunit/includes/skins/SkinFactoryTest.php similarity index 97% rename from tests/phpunit/unit/includes/skins/SkinFactoryTest.php rename to tests/phpunit/includes/skins/SkinFactoryTest.php index 8443c8d1f6..4289fd9188 100644 --- a/tests/phpunit/unit/includes/skins/SkinFactoryTest.php +++ b/tests/phpunit/includes/skins/SkinFactoryTest.php @@ -1,6 +1,6 @@ */ -class SkinTemplateTest extends \MediaWikiUnitTestCase { +class SkinTemplateTest extends MediaWikiTestCase { /** * @dataProvider makeListItemProvider */ diff --git a/tests/phpunit/unit/includes/skins/SkinTest.php b/tests/phpunit/includes/skins/SkinTest.php similarity index 89% rename from tests/phpunit/unit/includes/skins/SkinTest.php rename to tests/phpunit/includes/skins/SkinTest.php index da42437da3..41ef2b796a 100644 --- a/tests/phpunit/unit/includes/skins/SkinTest.php +++ b/tests/phpunit/includes/skins/SkinTest.php @@ -1,5 +1,5 @@ getMockBuilder( ImageListPager::class ) - ->disableOriginalConstructor() - ->setMethods( null ) - ->getMock(); - + $page = new ImageListPager( RequestContext::getMain() ); $page->formatValue( 'invalid_field', 'invalid_value' ); } } diff --git a/tests/phpunit/unit/includes/specials/SpecialUploadTest.php b/tests/phpunit/includes/specials/SpecialUploadTest.php similarity index 91% rename from tests/phpunit/unit/includes/specials/SpecialUploadTest.php rename to tests/phpunit/includes/specials/SpecialUploadTest.php index a8e3ded611..95026c18d0 100644 --- a/tests/phpunit/unit/includes/specials/SpecialUploadTest.php +++ b/tests/phpunit/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 ] ); - } - +class UncategorizedCategoriesPageTest extends MediaWikiTestCase { /** * @dataProvider provideTestGetQueryInfoData * @covers UncategorizedCategoriesPage::getQueryInfo diff --git a/tests/phpunit/unit/includes/tidy/RemexDriverTest.php b/tests/phpunit/includes/tidy/RemexDriverTest.php similarity index 99% rename from tests/phpunit/unit/includes/tidy/RemexDriverTest.php rename to tests/phpunit/includes/tidy/RemexDriverTest.php index 24a5b25770..5ad8416b81 100644 --- a/tests/phpunit/unit/includes/tidy/RemexDriverTest.php +++ b/tests/phpunit/includes/tidy/RemexDriverTest.php @@ -1,6 +1,6 @@ getMockBuilder( Wikimedia\Rdbms\ResultWrapper::class ) diff --git a/tests/phpunit/unit/includes/utils/AvroValidatorTest.php b/tests/phpunit/includes/utils/AvroValidatorTest.php similarity index 100% rename from tests/phpunit/unit/includes/utils/AvroValidatorTest.php rename to tests/phpunit/includes/utils/AvroValidatorTest.php diff --git a/tests/phpunit/unit/includes/utils/BatchRowUpdateTest.php b/tests/phpunit/includes/utils/BatchRowUpdateTest.php similarity index 91% rename from tests/phpunit/unit/includes/utils/BatchRowUpdateTest.php rename to tests/phpunit/includes/utils/BatchRowUpdateTest.php index 92b0d7a4a4..52b143393f 100644 --- a/tests/phpunit/unit/includes/utils/BatchRowUpdateTest.php +++ b/tests/phpunit/includes/utils/BatchRowUpdateTest.php @@ -1,7 +1,5 @@ createMock( ILBFactory::class ); - $lbFactoryMockProvider = function () use ( $lbFactoryMock ): ILBFactory { - return $lbFactoryMock; - }; - - $this->overrideMwServices( [ 'DBLoadBalancerFactory' => $lbFactoryMockProvider ] ); - $db = $this->mockDb( [ 'update' ] ); $writer = new BatchRowWriter( $db, 'echo_event' ); @@ -30,16 +21,8 @@ class BatchRowUpdateTest extends \MediaWikiUnitTestCase { 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/unit/includes/utils/ClassCollectorTest.php b/tests/phpunit/includes/utils/ClassCollectorTest.php similarity index 100% rename from tests/phpunit/unit/includes/utils/ClassCollectorTest.php rename to tests/phpunit/includes/utils/ClassCollectorTest.php diff --git a/tests/phpunit/unit/includes/utils/FileContentsHasherTest.php b/tests/phpunit/includes/utils/FileContentsHasherTest.php similarity index 96% rename from tests/phpunit/unit/includes/utils/FileContentsHasherTest.php rename to tests/phpunit/includes/utils/FileContentsHasherTest.php index 8bf6779587..316d9f429a 100644 --- a/tests/phpunit/unit/includes/utils/FileContentsHasherTest.php +++ b/tests/phpunit/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/unit/includes/utils/MWCryptHashTest.php b/tests/phpunit/includes/utils/MWCryptHashTest.php similarity index 100% rename from tests/phpunit/unit/includes/utils/MWCryptHashTest.php rename to tests/phpunit/includes/utils/MWCryptHashTest.php diff --git a/tests/phpunit/unit/includes/utils/MWRestrictionsTest.php b/tests/phpunit/includes/utils/MWRestrictionsTest.php similarity index 100% rename from tests/phpunit/unit/includes/utils/MWRestrictionsTest.php rename to tests/phpunit/includes/utils/MWRestrictionsTest.php diff --git a/tests/phpunit/unit/includes/utils/UIDGeneratorTest.php b/tests/phpunit/includes/utils/UIDGeneratorTest.php similarity index 100% rename from tests/phpunit/unit/includes/utils/UIDGeneratorTest.php rename to tests/phpunit/includes/utils/UIDGeneratorTest.php diff --git a/tests/phpunit/unit/includes/utils/ZipDirectoryReaderTest.php b/tests/phpunit/includes/utils/ZipDirectoryReaderTest.php similarity index 97% rename from tests/phpunit/unit/includes/utils/ZipDirectoryReaderTest.php rename to tests/phpunit/includes/utils/ZipDirectoryReaderTest.php index e8252a19ed..a1a3fd7309 100644 --- a/tests/phpunit/unit/includes/utils/ZipDirectoryReaderTest.php +++ b/tests/phpunit/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/unit/includes/watcheditem/NoWriteWatchedItemStoreUnitTest.php b/tests/phpunit/includes/watcheditem/NoWriteWatchedItemStoreUnitTest.php similarity index 99% rename from tests/phpunit/unit/includes/watcheditem/NoWriteWatchedItemStoreUnitTest.php rename to tests/phpunit/includes/watcheditem/NoWriteWatchedItemStoreUnitTest.php index 556f518e54..f424b21b3e 100644 --- a/tests/phpunit/unit/includes/watcheditem/NoWriteWatchedItemStoreUnitTest.php +++ b/tests/phpunit/includes/watcheditem/NoWriteWatchedItemStoreUnitTest.php @@ -7,7 +7,7 @@ use MediaWiki\User\UserIdentityValue; * * @covers NoWriteWatchedItemStore */ -class NoWriteWatchedItemStoreUnitTest extends \MediaWikiUnitTestCase { +class NoWriteWatchedItemStoreUnitTest extends MediaWikiTestCase { public function testAddWatch() { /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */ diff --git a/tests/phpunit/unit/languages/SpecialPageAliasTest.php b/tests/phpunit/languages/SpecialPageAliasTest.php similarity index 95% rename from tests/phpunit/unit/languages/SpecialPageAliasTest.php rename to tests/phpunit/languages/SpecialPageAliasTest.php index cce9d0eb0f..d406c88933 100644 --- a/tests/phpunit/unit/languages/SpecialPageAliasTest.php +++ b/tests/phpunit/languages/SpecialPageAliasTest.php @@ -11,7 +11,7 @@ * * @author Katie Filbert < aude.wiki@gmail.com > */ -class SpecialPageAliasTest extends \MediaWikiUnitTestCase { +class SpecialPageAliasTest extends MediaWikiTestCase { /** * @coversNothing diff --git a/tests/phpunit/unit/structure/ApiPrefixUniquenessTest.php b/tests/phpunit/structure/ApiPrefixUniquenessTest.php similarity index 94% rename from tests/phpunit/unit/structure/ApiPrefixUniquenessTest.php rename to tests/phpunit/structure/ApiPrefixUniquenessTest.php index b937fabddb..4329867030 100644 --- a/tests/phpunit/unit/structure/ApiPrefixUniquenessTest.php +++ b/tests/phpunit/structure/ApiPrefixUniquenessTest.php @@ -4,9 +4,8 @@ * Checks that all API query modules, core and extensions, have unique prefixes. * * @group API - * @coversNothing */ -class ApiPrefixUniquenessTest extends \MediaWikiUnitTestCase { +class ApiPrefixUniquenessTest extends MediaWikiTestCase { public function testPrefixes() { $main = new ApiMain( new FauxRequest() ); diff --git a/tests/phpunit/unit/structure/AutoLoaderStructureTest.php b/tests/phpunit/structure/AutoLoaderStructureTest.php similarity index 97% rename from tests/phpunit/unit/structure/AutoLoaderStructureTest.php rename to tests/phpunit/structure/AutoLoaderStructureTest.php index e91159d74b..37babcef14 100644 --- a/tests/phpunit/unit/structure/AutoLoaderStructureTest.php +++ b/tests/phpunit/structure/AutoLoaderStructureTest.php @@ -1,10 +1,6 @@ setPsr4Namespaces( AutoLoader::getAutoloadNamespaces() ); diff --git a/tests/phpunit/unit/structure/ContentHandlerSanityTest.php b/tests/phpunit/structure/ContentHandlerSanityTest.php similarity index 95% rename from tests/phpunit/unit/structure/ContentHandlerSanityTest.php rename to tests/phpunit/structure/ContentHandlerSanityTest.php index 7541e59105..c8bcd60de3 100644 --- a/tests/phpunit/unit/structure/ContentHandlerSanityTest.php +++ b/tests/phpunit/structure/ContentHandlerSanityTest.php @@ -19,10 +19,7 @@ use Wikimedia\TestingAccessWrapper; * http://www.gnu.org/copyleft/gpl.html */ -/** - * @coversNothing - */ -class ContentHandlerSanityTest extends \MediaWikiUnitTestCase { +class ContentHandlerSanityTest extends MediaWikiTestCase { public static function provideHandlers() { $models = ContentHandler::getContentModels(); diff --git a/tests/phpunit/unit/structure/PasswordPolicyStructureTest.php b/tests/phpunit/structure/PasswordPolicyStructureTest.php similarity index 92% rename from tests/phpunit/unit/structure/PasswordPolicyStructureTest.php rename to tests/phpunit/structure/PasswordPolicyStructureTest.php index 7867722099..d7f865d2e7 100644 --- a/tests/phpunit/unit/structure/PasswordPolicyStructureTest.php +++ b/tests/phpunit/structure/PasswordPolicyStructureTest.php @@ -1,9 +1,6 @@ documentation - - - - unit/includes - - - unit/languages - - - unit/structure - diff --git a/tests/phpunit/unit-tests.xml b/tests/phpunit/unit-tests.xml deleted file mode 100644 index 149f1f25d3..0000000000 --- a/tests/phpunit/unit-tests.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - 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/unit/includes/api/ApiBlockInfoTraitTest.php b/tests/phpunit/unit/includes/api/ApiBlockInfoTraitTest.php deleted file mode 100644 index ed5a184743..0000000000 --- a/tests/phpunit/unit/includes/api/ApiBlockInfoTraitTest.php +++ /dev/null @@ -1,66 +0,0 @@ -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/unit/includes/exception/ReadOnlyErrorTest.php b/tests/phpunit/unit/includes/exception/ReadOnlyErrorTest.php deleted file mode 100644 index c8460c97ea..0000000000 --- a/tests/phpunit/unit/includes/exception/ReadOnlyErrorTest.php +++ /dev/null @@ -1,25 +0,0 @@ -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/unit/initUnitTests.php b/tests/phpunit/unit/initUnitTests.php deleted file mode 100644 index ef32cabae7..0000000000 --- a/tests/phpunit/unit/initUnitTests.php +++ /dev/null @@ -1,56 +0,0 @@ - $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(); -- 2.20.1