MediaWiki REL1_31
|
Inherits PHPUnit\Framework\TestCase.
Inherited by AbstractChangesListSpecialPageTestCase, ActionTest, ApiContinuationManagerTest, ApiFormatTestBase, ApiMessageTest, ApiModuleManagerTest, ApiOpenSearchTest, ApiResultTest, ApiStructureTest, ApiUsageExceptionTest, ArrayDiffFormatterTest, ArticleTest, AutoLoaderTest, AutopromoteTest, BadTitleErrorTest, BagOStuffTest, BalancerTest, BaseBlacklistTest, BatchRowUpdateTest, BitmapMetadataHandlerTest, BitmapScalingTest, BotPasswordTest, CSSMinTest, CachingSiteStoreTest, CaptchaPreAuthenticationProviderTest, CaptchaTest, CategoryMembershipChangeJobTest, CdnCacheUpdateTest, CentralIdLookupTest, ChangeTagsTest, ChangesListBooleanFilterGroupTest, ChangesListBooleanFilterTest, ChangesListFilterGroupTest, ChangesListFilterTest, ChangesListStringOptionsFilterGroupTest, ClassicInterwikiLookupTest, ClearUserWatchlistJobTest, CollationFaTest, ComposerInstalledTest, ComposerJsonTest, ComposerLockTest, ConfigFactoryTest, ContentHandlerSanityTest, ContentHandlerTest, ContribsPagerTest, CoreParserFunctionsTest, CustomUppercaseCollationTest, DBSiteStoreTest, DatabaseIntegrationTest, DatabaseLogEntryTest, DatabasePostgresTest, DatabaseSqliteTest, DefaultPreferencesFactoryTest, DeferredUpdatesTest, DeprecatedGlobalTest, DiffHistoryBlobTest, DiffOpTest, DiffTest, DifferenceEngineTest, DummyExtensionsTest, ErrorPageErrorTest, ExifTest, ExpressionTest, ExtensionJsonValidatorTest, ExtensionProcessorTest, ExtensionRegistryTest, ExternalStoreTest, ExternalUserNamesTest, ExtraParserTest, FauxResponseTest, FileBackendDBRepoWrapperTest, FileBackendTest, FileRepoTest, ForeignTitleTest, FormOptionsInitializationTest, FormOptionsTest, FormatJsonTest, GIFMetadataExtractorTest, GadgetTest, GitInfoTest, GlobalTest, GlobalVarConfigTest, GlobalWithDBTest, HTMLAutoCompleteSelectFieldTest, HTMLCheckMatrixTest, HTMLFormTest, HashConfigTest, HashSiteStoreTest, HooksTest, HtmlTest, HttpErrorTest, HttpTest, IPTCTest, ImageListPagerTest, ImportLinkCacheIntegrationTest, InstallDocFormatterTest, InterwikiLookupAdapterTest, InterwikiTest, JobQueueTest, JobTest, JpegMetadataExtractorTest, JsonContentHandlerTest, LBFactoryTest, LanguageClassesTestCase, LicensesTest, ListToggleTest, LoadBalancerTest, LocalFileTest, LocalIdLookupTest, LocalisationCacheTest, MWCryptHKDFTest, MWDebugTest, MWExceptionHandlerTest, MWExceptionTest, MWGrantsTest, MWNamespaceTest, MagicVariableTest, MailAddressTest, MediaHandlerTest, MediaWiki\Auth\AbstractAuthenticationProviderTest, MediaWiki\Auth\AbstractPasswordPrimaryAuthenticationProviderTest, MediaWiki\Auth\AbstractPreAuthenticationProviderTest, MediaWiki\Auth\AbstractPrimaryAuthenticationProviderTest, MediaWiki\Auth\AbstractSecondaryAuthenticationProviderTest, MediaWiki\Auth\AuthManagerTest, MediaWiki\Auth\AuthPluginPrimaryAuthenticationProviderTest, MediaWiki\Auth\AuthenticationRequestTest, MediaWiki\Auth\AuthenticationRequestTestCase, MediaWiki\Auth\AuthenticationResponseTest, MediaWiki\Auth\CheckBlocksSecondaryAuthenticationProviderTest, MediaWiki\Auth\ConfirmLinkSecondaryAuthenticationProviderTest, MediaWiki\Auth\LegacyHookPreAuthenticationProviderTest, MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProviderTest, MediaWiki\Auth\ResetPasswordSecondaryAuthenticationProviderTest, MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProviderTest, MediaWiki\Auth\ThrottlePreAuthenticationProviderTest, MediaWiki\Auth\ThrottlerTest, MediaWiki\Logger\LegacyLoggerTest, MediaWiki\Logger\Monolog\AvroFormatterTest, MediaWiki\Logger\Monolog\KafkaHandlerTest, MediaWiki\Logger\Monolog\LineFormatterTest, MediaWiki\Logger\MonologSpiTest, MediaWiki\Session\BotPasswordSessionProviderTest, MediaWiki\Session\CookieSessionProviderTest, MediaWiki\Session\ImmutableSessionProviderWithCookieTest, MediaWiki\Session\MetadataMergeExceptionTest, MediaWiki\Session\PHPSessionHandlerTest, MediaWiki\Session\SessionBackendTest, MediaWiki\Session\SessionIdTest, MediaWiki\Session\SessionInfoTest, MediaWiki\Session\SessionManagerTest, MediaWiki\Session\SessionProviderTest, MediaWiki\Session\SessionTest, MediaWiki\Session\TokenTest, MediaWiki\Session\UserInfoTest, MediaWiki\Tests\EditPage\TextboxBuilderTest, MediaWiki\Tests\Maintenance\BaseDumpTest, MediaWiki\Tests\Maintenance\FetchTextTest, MediaWiki\Tests\Maintenance\MaintenanceBaseTestCase, MediaWiki\Tests\Storage\BlobStoreFactoryTest, MediaWiki\Tests\Storage\MutableRevisionRecordTest, MediaWiki\Tests\Storage\NameTableStoreTest, MediaWiki\Tests\Storage\RevisionArchiveRecordTest, MediaWiki\Tests\Storage\RevisionSlotsTest, MediaWiki\Tests\Storage\RevisionStoreDbTest, MediaWiki\Tests\Storage\RevisionStoreRecordTest, MediaWiki\Tests\Storage\RevisionStoreTest, MediaWiki\Tests\Storage\SlotRecordTest, MediaWiki\Tests\Storage\SqlBlobStoreTest, MediaWikiLangTestCase, MediaWikiMediaTestCase, MediaWikiServicesTest, MediaWikiTest, MediaWikiTestCaseSchema1Test, MediaWikiTestCaseSchema2Test, MediaWikiTestCaseTest, MediaWikiTitleCodecTest, MemcachedBagOStuffTest, MergeHistoryTest, MigrateFileRepoLayoutTest, MovePageTest, MultiConfigTest, MultiWriteBagOStuffTest, NaiveForeignTitleFactoryTest, NaiveImportTitleFactoryTest, NamespaceAwareForeignTitleFactoryTest, NamespaceImportTitleFactoryTest, NoWriteWatchedItemStoreUnitTest, ObjectCacheTest, OracleInstallerTest, OutputPageTest, PNGMetadataExtractorTest, PageArchiveTest, PageDataRequestHandlerTest, ParserOptionsTest, ParserOutputTest, ParserPreloadTest, PasswordFactoryTest, PasswordPolicyChecksTest, PasswordResetTest, PasswordTest, PasswordTestCase, PathRouterTest, PoolCounterTest, PreferencesTest, PrefixUniquenessTest, PreprocessorTest, QueryAllSpecialPagesTest, QuestyCaptchaTest, RCFeedIntegrationTest, RESTBagOStuffTest, ReadOnlyErrorTest, ReadOnlyModeTest, RecentChangeTest, RefreshLinksPartitionTest, RemexDriverTest, ReplicatedBagOStuffTest, RepoGroupTest, RequestContextTest, ResourceLoaderTestCase, ResourcesTest, RevisionDbTestBase, RevisionTest, SVGMetadataExtractorTest, SearchIndexFieldTest, SearchUpdateTest, ShellTest, SiteConfigurationTest, SiteListTest, SiteStatsTest, SiteStatsUpdateTest, SiteTest, SkinFactoryTest, SkinTemplateTest, SpamBlacklistTest, SpecialMIMESearchTest, SpecialMyLanguageTest, SpecialPageAliasTest, SpecialPageFactoryTest, SpecialPageTest, SpecialPageTestBase, SpecialPreferencesTest, SpecialRedirectTest, SpecialSearchTest, SpecialShortpagesTest, SpecialUploadTest, StoreBatchTest, StripStateTest, StructureTest, SubpageImportTitleFactoryTest, SwiftFileBackendTest, TagHooksTest, TemplateParserTest, ThrottledErrorTest, TidyTest, TiffTest, TitleBlacklistPreAuthenticationProviderTest, TitleTest, TitleValueTest, UncategorizedCategoriesPageTest, UploadBaseTest, UploadStashTest, UserArrayFromResultTest, UserGroupMembershipTest, UserNotLoggedInTest, UserPasswordPolicyTest, UserTest, WatchedItemQueryServiceUnitTest, WatchedItemStoreIntegrationTest, WatchedItemStoreUnitTest, WebPHandlerTest, WebRequestTest, WfAppendQueryTest, WfArrayPlus2dTest, WfAssembleUrlTest, WfBaseNameTest, WfEscapeShellArgTest, WfExpandUrlTest, WfGetCallerTest, WfParseUrlTest, WfRemoveDotSegmentsTest, WfShellExecTest, WfShorthandToIntegerTest, WfStringToBoolTest, WfThumbIsStandardTest, WfTimestampTest, WfUrlencodeTest, XmlSelectTest, and XmlTest.
Public Member Functions | |
__construct ( $name=null, array $data=[], $dataName='') | |
__destruct () | |
addDBData () | |
Stub. | |
addDBDataOnce () | |
Stub. | |
dbPrefix () | |
getCliArg ( $offset) | |
hideDeprecated ( $function) | |
Don't throw a warning if $function is deprecated and called later. | |
needsDB () | |
run (PHPUnit_Framework_TestResult $result=null) | |
setCliArg ( $offset, $value) | |
setContentLang ( $lang) | |
setGroupPermissions ( $newPerms, $newKey=null, $newValue=null) | |
Alters $wgGroupPermissions for the duration of the test. | |
setupAllTestDBs () | |
Set up all test DBs. | |
setUserLang ( $lang) | |
testMediaWikiTestCaseParentSetupCalled () | |
Make sure MediaWikiTestCase extending classes have called their parent setUp method. | |
usesTemporaryTables () | |
Static Public Member Functions | |
static | getMutableTestUser ( $groups=[]) |
Convenience method for getting a mutable test user. | |
static | getTestSysop () |
Convenience method for getting an immutable admin test user. | |
static | getTestUser ( $groups=[]) |
Convenience method for getting an immutable test user. | |
static | listTables (IMaintainableDatabase $db) |
static | prepareServices (Config $bootstrapConfig) |
Prepare service configuration for unit testing. | |
static | setUpBeforeClass () |
static | setupTestDB (Database $db, $prefix) |
Creates an empty skeleton of the wiki database by cloning its structure to equivalent tables using the given $prefix. | |
static | teardownTestDB () |
Restores MediaWiki to using the table set (table prefix) it was using before setupTestDB() was called. | |
static | wfResetOutputBuffersBarrier ( $buffer) |
Used as a marker to prevent wfResetOutputBuffers from breaking PHPUnit. | |
Public Attributes | |
const | DB_PREFIX = 'unittest_' |
Table name prefixes. | |
const | ORA_DB_PREFIX = 'ut_' |
Static Public Attributes | |
static TestUser[] | $users |
Protected Member Functions | |
addTmpFiles ( $files) | |
arrayWrap (array $elements) | |
Utility method taking an array of elements and wrapping each element in its own array. | |
assertArrayEquals (array $expected, array $actual, $ordered=false, $named=false) | |
Assert that two arrays are equal. | |
assertFileContains ( $fileName, $actualData, $createIfMissing=true, $msg='') | |
Check whether file contains given data. | |
assertHTMLEquals ( $expected, $actual, $msg='') | |
Put each HTML element on its own line and then equals() the results. | |
assertSelect ( $table, $fields, $condition, array $expectedRows, array $options=[], array $join_conds=[]) | |
Asserts that the given database query yields the rows given by $expectedRows. | |
assertType ( $type, $actual, $message='') | |
Asserts the type of the provided value. | |
assertTypeOrValue ( $type, $actual, $value=false, $message='') | |
Asserts that the provided variable is of the specified internal type or equals the $value argument. | |
checkDbIsSupported () | |
checkPHPExtension ( $extName) | |
Check if $extName is a loaded PHP extension, will skip the test whenever it is not loaded. | |
getDefaultWikitextNS () | |
Returns the ID of a namespace that defaults to Wikitext. | |
getNewTempDirectory () | |
obtains a new temporary directory | |
getNewTempFile () | |
Obtains a new temporary file name. | |
getSchemaOverrides (IMaintainableDatabase $db) | |
Stub. | |
insertPage ( $pageName, $text='Sample page for unit test.', $namespace=null) | |
Insert a new page. | |
isWikitextNS ( $ns) | |
Returns true if the given namespace defaults to Wikitext according to $wgNamespaceContentModels. | |
markTestSkippedIfNoDiff3 () | |
Check, if $wgDiff3 is set and ready to merge Will mark the calling test as skipped, if not ready. | |
mergeMwGlobalArrayValue ( $name, $values) | |
Merges the given values into a MW global array variable. | |
objectAssociativeSort (array &$array) | |
Does an associative sort that works for objects. | |
overrideMwServices (Config $configOverrides=null, array $services=[]) | |
Stashes the global instance of MediaWikiServices, and installs a new one, allowing test cases to override settings and services. | |
setLogger ( $channel, LoggerInterface $logger) | |
Sets the logger for a specified channel, for the duration of the test. | |
setMwGlobals ( $pairs, $value=null) | |
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown. | |
setService ( $name, $object) | |
Sets a service, maintaining a stashed version of the previous service to be restored in tearDown. | |
setTemporaryHook ( $hookName, $handler) | |
Create a temporary hook handler which will be reset by tearDown. | |
setUp () | |
stashMwGlobals ( $globalKeys) | |
Stashes the global, will be restored in tearDown() | |
tearDown () | |
Static Protected Member Functions | |
static | getExternalStoreDatabaseConnections () |
Gets master database connections for all of the ExternalStoreDB stores configured in $wgDefaultExternalStore. | |
static | isUsingExternalStoreDB () |
Check whether ExternalStoreDB is being used. | |
static | resetGlobalServices (Config $bootstrapConfig=null) |
Reset global services, and install testing environment. | |
static | setupDatabaseWithTestPrefix (IMaintainableDatabase $db, $prefix) |
Setups a database with the given prefix. | |
static | setupExternalStoreTestDBs ( $testPrefix) |
Clones the External Store database(s) for testing. | |
static | stripStringKeys (&$r) |
Utility function for eliminating all string keys from an array. | |
Protected Attributes | |
Database | $db |
Primary database. | |
array | $supportedDBs |
array | $tablesUsed = [] |
Private Member Functions | |
addCoreDBData () | |
containsClosure ( $var, $maxDepth=15) | |
doLightweightServiceReset () | |
Resets some well known services that typically have state that may interfere with unit tests. | |
dropMockTables (IMaintainableDatabase $db, array $tables) | |
Drops the given mock tables. | |
ensureMockDatabaseConnection (IDatabase $db) | |
listOriginalTables (IMaintainableDatabase $db) | |
Lists all tables in the live database schema. | |
mungeSchemaUpdateQuery ( $cmd) | |
oncePerClass () | |
recloneMockTables (IMaintainableDatabase $db, array $tables) | |
Re-clones the given mock tables to restore them based on the live database schema. | |
resetDB ( $db, $tablesUsed) | |
Empty all tables so they can be repopulated for tests. | |
restoreLoggers () | |
Restores loggers replaced by setLogger(). | |
setUpSchema (IMaintainableDatabase $db) | |
Applies the schema overrides returned by getSchemaOverrides(), after undoing any previously applied schema overrides. | |
undoSchemaOverrides (IMaintainableDatabase $db, $oldOverrides) | |
Undoes the dpecified schema overrides. | |
Static Private Member Functions | |
static | canShallowCopy ( $value) |
Check if we can back up a value by performing a shallow copy. | |
static | installTestServices (ConfigFactory $oldConfigFactory, LBFactory $oldLoadBalancerFactory, MediaWikiServices $newServices) |
static | isNotUnittest ( $table) |
static | makeTestConfig (Config $baseConfig=null, Config $customOverrides=null) |
Create a config suitable for testing, based on a base config, default overrides, and custom overrides. | |
static | makeTestConfigFactoryInstantiator (ConfigFactory $oldFactory, array $configurations) |
static | unprefixTable (&$tableName, $ind, $prefix) |
Private Attributes | |
$called = [] | |
$called tracks whether the setUp and tearDown method has been called. | |
LoggerInterface[] | $loggers = [] |
Holds original loggers which have been replaced by setLogger() | |
array | $mwGlobals = [] |
Holds original values of MediaWiki configuration settings to be restored in tearDown(). | |
array | $mwGlobalsToUnset = [] |
Holds list of MediaWiki configuration settings to be unset in tearDown(). | |
int | $phpErrorLevel |
Original value of PHP's error_reporting setting. | |
array | $tmpFiles = [] |
Holds the paths of temporary files/directories created through getNewTempFile, and getNewTempDirectory. | |
Static Private Attributes | |
static | $dbSetup = false |
static | $oldTablePrefix = '' |
static | $reuseDB = false |
static | $schemaOverrideDefaults |
static MediaWikiServices null | $serviceLocator = null |
The service locator created by prepareServices(). | |
static | $useTemporaryTables = true |
Definition at line 17 of file MediaWikiTestCase.php.
MediaWikiTestCase::__construct | ( | $name = null, | |
array | $data = [], | ||
$dataName = '' ) |
Reimplemented in ApiQueryRecentChangesIntegrationTest, ApiQueryWatchlistIntegrationTest, EnhancedChangesListTest, OldChangesListTest, RCCacheEntryFactoryTest, LinksUpdateTest, JobQueueTest, RefreshLinksPartitionTest, WikiPageDbTestBase, PageArchiveTest, and RevisionDbTestBase.
Definition at line 123 of file MediaWikiTestCase.php.
MediaWikiTestCase::__destruct | ( | ) |
Definition at line 130 of file MediaWikiTestCase.php.
|
private |
Definition at line 1086 of file MediaWikiTestCase.php.
References SiteStatsInit\doPlaceholderInit(), EDIT_NEW, EDIT_SUPPRESS_RC, User\resetIdByNameCache(), and JobQueueGroup\singleton().
MediaWikiTestCase::addDBData | ( | ) |
Stub.
Subclasses may override this to prepare the database. Called before every test run (test function or data set).
Reimplemented in BotPasswordTest, LocalIdLookupTest, MediaWiki\Tests\Maintenance\BackupDumperLoggerTest, MediaWiki\Tests\Maintenance\BackupDumperPageTest, and MediaWiki\Tests\Maintenance\TextPassDumperDatabaseTest.
Definition at line 1083 of file MediaWikiTestCase.php.
Referenced by run().
MediaWikiTestCase::addDBDataOnce | ( | ) |
Stub.
If a test suite needs to add additional data to the database, it should implement this method and do so. This method is called once per test suite (i.e. once per class).
Note data added by this method may be removed by resetDB() depending on the contents of $tablesUsed.
To add additional data between test function runs, override prepareDB().
Reimplemented in ApiComparePagesTest, ApiParseTest, ApiQueryBasicTest, ApiQueryContinue2Test, ApiQueryContinueTest, ApiQueryContributionsTest, GenderCacheTest, MessageCacheTest, CategoryMembershipChangeTest, ContentHandlerTest, LinksUpdateTest, CategoryMembershipChangeJobTest, MergeHistoryTest, PrefixSearchTest, SearchEnginePrefixTest, SearchEngineTest, MediaWiki\Session\BotPasswordSessionProviderTest, SpecialMyLanguageTest, and MediaWiki\Tests\Maintenance\FetchTextTest.
Definition at line 1071 of file MediaWikiTestCase.php.
Referenced by run().
|
protected |
Definition at line 530 of file MediaWikiTestCase.php.
Referenced by FileBackendTest\doTestDoOperationsPipeline(), CSSMinTest\testGetMimeType(), and FileBackendTest\testStore().
|
protected |
Utility method taking an array of elements and wrapping each element in its own array.
Useful for data providers that only return a single argument.
array | $elements |
Definition at line 1750 of file MediaWikiTestCase.php.
Referenced by SiteTest\instanceProvider(), SiteListTest\siteArrayProvider(), and SiteListTest\siteListProvider().
|
protected |
Assert that two arrays are equal.
By default this means that both arrays need to hold the same set of values. Using additional arguments, order and associated key can also be set as relevant.
array | $expected | |
array | $actual | |
bool | $ordered | If the order of the values should match |
bool | $named | If the keys should match |
Definition at line 1771 of file MediaWikiTestCase.php.
References objectAssociativeSort().
Referenced by BotPasswordTest\testCanonicalizeLoginData(), ResourcesTest\testCommentedLocalFileReferences(), SpecialWatchlistTest\testFetchOptionsFromRequest(), ChangesListSpecialPageTest\testFilterUserExpLevel(), WikiMapTest\testGetCanonicalServerInfoForAllWikis(), RangeChronologicalPagerTest\testGetDateRangeCond(), SiteListTest\testGetGlobalIdentifiers(), ApiModuleManagerTest\testGetGroups(), DjVuTest\testGetImageSize(), ComposerInstalledTest\testGetInstalledDependencies(), ComposerLockTest\testGetInstalledDependencies(), ChangesListBooleanFilterGroupTest\testGetJsData(), ChangesListBooleanFilterTest\testGetJsData(), ChangesListStringOptionsFilterGroupTest\testGetJsData(), ApiModuleManagerTest\testGetNames(), ApiModuleManagerTest\testGetNamesWithClasses(), DjVuTest\testGetPageDimensions(), TextContentTest\testGetParserOutput(), UserPasswordPolicyTest\testGetPoliciesForGroups(), UserPasswordPolicyTest\testGetPoliciesForUser(), ComposerJsonTest\testGetRequiredDependencies(), ChangesListSpecialPageTest\testGetStructuredFilterJsData(), MediaWiki\Session\CookieSessionProviderTest\testGetVaryCookies(), PoolCounterTest\testHashKeyIntoSlots(), WikitextStructureTest\testHeadingsNone(), UserPasswordPolicyTest\testMaxOfPolicies(), ChangeTagsTest\testModifyDisplayQuery(), StatusTest\testOkAndErrorsGetters(), AbstractChangesListSpecialPageTestCase\testParseParameters(), SiteListTest\testSerialization(), ChangesListFilterTest\testSetAsSupersetOf(), LinksUpdateTest\testUpdate_pagelinks(), and AbstractChangesListSpecialPageTestCase\testValidateOptions().
|
protected |
Check whether file contains given data.
string | $fileName | |
string | $actualData | |
bool | $createIfMissing | If true, and file does not exist, create it with given data and skip the test. |
string | $msg |
Definition at line 2027 of file MediaWikiTestCase.php.
Referenced by MediaWiki\Tests\Maintenance\CategoriesRdfTest\testCategoriesDump().
|
protected |
Put each HTML element on its own line and then equals() the results.
Use for nicely formatting of PHPUnit diff output when comparing very simple HTML
string | $expected | HTML on oneline |
string | $actual | HTML on oneline |
string | $msg | Optional message |
Definition at line 1802 of file MediaWikiTestCase.php.
|
protected |
Asserts that the given database query yields the rows given by $expectedRows.
The expected rows should be given as indexed (not associative) arrays, with the values given in the order of the columns in the $fields parameter. Note that the rows are sorted by the columns given in $fields.
string | array | $table | The table(s) to query |
string | array | $fields | The columns to include in the result (and to sort by) |
string | array | $condition | "where" condition(s) |
array | $expectedRows | An array of arrays giving the expected rows. |
array | $options | Options for the query |
array | $join_conds | Join conditions for the query |
MWException | If this test cases's needsDB() method doesn't return true. Test cases can use " Database" to enable database test support, or list the tables under testing in $this->tablesUsed, or override the needsDB() method. |
Definition at line 1701 of file MediaWikiTestCase.php.
References $options, $res, DB_REPLICA, Wikimedia\Rdbms\IDatabase\lastError(), needsDB(), Wikimedia\Rdbms\Database\select(), wfGetCaller(), and wfGetDB().
Referenced by LinksUpdateTest\assertLinksUpdate(), LinksUpdateTest\assertRecentChangeByCategorization(), and RevisionDbTestBase\testInsertOn_success().
|
protected |
Asserts the type of the provided value.
This can be either in internal type such as boolean or integer, or a class or interface the value extends or implements.
string | $type | |
mixed | $actual | |
string | $message |
Definition at line 1878 of file MediaWikiTestCase.php.
References $type.
Referenced by assertTypeOrValue(), MediaWiki\Auth\AbstractAuthenticationProviderTest\testAbstractAuthenticationProvider(), ActionTest\testActionFactory(), MediaWiki\Auth\AuthenticationRequestTest\testBasics(), JobQueueTest\testDeduplicationWhileClaimed(), LanguageTest\testFormatNum(), MediaWiki\Auth\AuthenticationRequestTestCase\testGetFieldInfo(), BagOStuffTest\testGetScopedLock(), ShellTest\testMakeScriptCommand(), and ApiStructureTest\validateType().
|
protected |
Asserts that the provided variable is of the specified internal type or equals the $value argument.
This is useful for testing return types of functions that return a certain type or value when not set or on error.
string | $type | |
mixed | $actual | |
mixed | $value | |
string | $message |
Definition at line 1859 of file MediaWikiTestCase.php.
References $type, $value, and assertType().
Referenced by SiteTest\testGetGlobalId(), SiteTest\testGetLanguageCode(), and SiteTest\testGetPath().
|
staticprivate |
Check if we can back up a value by performing a shallow copy.
Values which fail this test are copied recursively.
mixed | $value |
Definition at line 698 of file MediaWikiTestCase.php.
References $value.
|
protected |
MWException |
Definition at line 1640 of file MediaWikiTestCase.php.
Referenced by run().
|
protected |
Check if $extName is a loaded PHP extension, will skip the test whenever it is not loaded.
string | $extName |
Definition at line 1989 of file MediaWikiTestCase.php.
Referenced by CollationFaTest\setUp(), CollationTest\setUp(), DiffHistoryBlobTest\setUp(), ExifBitmapTest\setUp(), ExifRotationTest\setUp(), ExifTest\setUp(), FormatMetadataTest\setUp(), JpegTest\setUp(), TiffTest\setUp(), RevisionTest\testCompressRevisionTextUtf8Gzip(), MediaWiki\Tests\Storage\SqlBlobStoreTest\testCompressRevisionTextUtf8Gzip(), HttpTest\testCurlConstants(), RevisionTest\testGetRevisionWithGzipAndLegacyEncoding(), RevisionTest\testGetRevisionWithZlibExtension(), BitmapMetadataHandlerTest\testMultilingualCascade(), and PNGMetadataExtractorTest\testPngNativetZtxt().
|
private |
mixed | $var | |
int | $maxDepth |
Definition at line 782 of file MediaWikiTestCase.php.
References $value, and containsClosure().
Referenced by containsClosure(), and stashMwGlobals().
MediaWikiTestCase::dbPrefix | ( | ) |
Definition at line 998 of file MediaWikiTestCase.php.
Referenced by LoadBalancerTest\makeServerConfig(), setupAllTestDBs(), LoadBalancerTest\testOpenConnection(), LoadBalancerTest\testWithoutReplica(), and LoadBalancerTest\testWithReplica().
|
private |
Resets some well known services that typically have state that may interfere with unit tests.
This is a lightweight alternative to resetGlobalServices().
MWException | if called outside of PHPUnit tests. |
Definition at line 362 of file MediaWikiTestCase.php.
References $services, $wgRequest, FileBackendGroup\destroySingleton(), JobQueueGroup\destroySingletons(), and RequestContext\resetMain().
Referenced by run().
|
private |
Drops the given mock tables.
IMaintainableDatabase | $db | |
array | $tables |
Definition at line 1480 of file MediaWikiTestCase.php.
References $tables, ensureMockDatabaseConnection(), Wikimedia\Rdbms\IDatabase\query(), and Wikimedia\Rdbms\IMaintainableDatabase\tableName().
Referenced by setUpSchema(), and undoSchemaOverrides().
|
private |
LogicException | if the given database connection is not a set up to use mock tables. |
Definition at line 1339 of file MediaWikiTestCase.php.
References Wikimedia\Rdbms\IDatabase\tablePrefix().
Referenced by dropMockTables(), recloneMockTables(), setUpSchema(), and undoSchemaOverrides().
MediaWikiTestCase::getCliArg | ( | $offset | ) |
string | $offset |
Definition at line 1651 of file MediaWikiTestCase.php.
References PHPUnitMaintClass\$additionalOptions.
Referenced by run(), FileBackendTest\setUp(), StoreBatchTest\setUp(), JobQueueTest\setUp(), BagOStuffTest\setUp(), and BagOStuffTest\testMerge().
|
protected |
Returns the ID of a namespace that defaults to Wikitext.
MWException | If there is none. |
Definition at line 1912 of file MediaWikiTestCase.php.
References $namespaces, $wgNamespaceContentModels, CONTENT_MODEL_WIKITEXT, NS_CATEGORY, NS_FILE, NS_HELP, NS_MAIN, and NS_PROJECT.
Referenced by MediaWiki\Tests\Maintenance\BackupDumperPageTest\addDBData(), MediaWiki\Tests\Maintenance\TextPassDumperDatabaseTest\addDBData(), MediaWiki\Tests\Maintenance\FetchTextTest\addDBDataOnce(), PagePropsTest\createPage(), RevisionDbTestBase\createPage(), RevisionTest\getMockTitle(), DifferenceEngineTest\getTitle(), WikiPageDbTestBase\newPage(), TextContentTest\testDeletionUpdates(), WikitextContentTest\testGetSecondaryDataUpdates(), and RevisionDbTestBase\testUserWasLastToEdit().
|
staticprotected |
Gets master database connections for all of the ExternalStoreDB stores configured in $wgDefaultExternalStore.
Definition at line 1295 of file MediaWikiTestCase.php.
References $wgDefaultExternalStore, array(), and list.
|
static |
Convenience method for getting a mutable test user.
string[] | $groups | Groups the test user should be added in. |
Definition at line 165 of file MediaWikiTestCase.php.
Referenced by LocalIdLookupTest\addDBData(), GenderCacheTest\addDBDataOnce(), ApiUserrightsTest\doFailedRightsChange(), ApiUserrightsTest\doSuccessfulRightsChange(), EnhancedChangesListTest\getCategorizationChange(), OldChangesListTest\getContext(), RCCacheEntryFactoryTest\getContext(), EnhancedChangesListTest\getEditChange(), OldChangesListTest\getEditChange(), OldChangesListTest\getLogChange(), EnhancedChangesListTest\getLogChange(), ApiUserrightsTest\getMockForProcessingExpiries(), OldChangesListTest\getNewBotEditChange(), BlockTest\getUserForBlocking(), ApiBlockTest\setUp(), ApiQueryRecentChangesIntegrationTest\setUp(), ApiQueryWatchlistIntegrationTest\setUp(), ApiQueryWatchlistRawIntegrationTest\setUp(), BotPasswordTest\setUp(), MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProviderTest\testAccountCreation(), MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProviderTest\testAccountCreationEmail(), UserGroupMembershipTest\testAddAndRemoveGroups(), ApiUserrightsTest\testAddAndRemoveGroups(), ApiMainTest\testAssert(), MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProviderTest\testAuthentication(), MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProviderTest\testAuthentication(), MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProviderTest\testBasics(), ApiBlockTest\testBlockByBlockedUser(), UserTest\testBlockInstanceCache(), UserTest\testCheckAndSetTouched(), UserTest\testEquals(), ApiBaseTest\testErrorArrayToStatus(), UserTest\testFindUsersByGroup(), UserTest\testGetEditCount(), UserTest\testIncEditCount(), UserTest\testLoggedIn(), RCCacheEntryFactoryTest\testNewForDeleteChange(), RCCacheEntryFactoryTest\testNewForRevUserDeleteChange(), RCCacheEntryFactoryTest\testNewFromRecentChange(), UserTest\testOptions(), MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProviderTest\testProviderChangeAuthenticationData(), MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProviderTest\testProviderChangeAuthenticationDataEmail(), MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProviderTest\testSetPasswordResetFlag(), MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProviderTest\testTestUserCanAuthenticate(), MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProviderTest\testTestUserCanAuthenticate(), ApiUserrightsTest\testWebToken(), and ApiUserrightsTest\testWithTag().
|
protected |
obtains a new temporary directory
The obtained directory is enlisted to be removed (recursively with all its contained files) upon tearDown.
Definition at line 479 of file MediaWikiTestCase.php.
References getNewTempFile(), and wfMkdirParents().
Referenced by MediaWiki\Tests\Maintenance\TextPassDumperDatabaseTest\checkpointHelper(), FileBackendTest\setUp(), MigrateFileRepoLayoutTest\setUp(), StoreBatchTest\setUp(), MediaWikiMediaTestCase\setUp(), ApiUploadTest\testUpload(), ApiUploadTest\testUploadChunks(), ApiUploadTest\testUploadSameContent(), ApiUploadTest\testUploadSameFileName(), and ApiUploadTest\testUploadStash().
|
protected |
Obtains a new temporary file name.
The obtained filename is enlisted to be removed upon tearDown
Definition at line 462 of file MediaWikiTestCase.php.
References wfTempDir().
Referenced by MediaWiki\Tests\Maintenance\TextPassDumperDatabaseTest\checkpointHelper(), ReadOnlyModeTest\createFile(), UploadBaseTest\createFileOfSize(), FileBackendTest\doTestConcatenate(), ApiUploadTestCase\fakeUploadChunk(), ApiUploadTestCase\fakeUploadFile(), getNewTempDirectory(), GlobalTest\setUp(), UploadStashTest\setUp(), MediaWiki\Tests\Maintenance\BaseDumpTest\setUpPrefetch(), MediaWiki\Tests\Maintenance\TextPassDumperDatabaseTest\setUpStub(), UploadBaseTest\testCheckXMLEncodingMissmatch(), ReadOnlyModeTest\testClearCache(), MediaWiki\Tests\Maintenance\BackupDumperPageTest\testCurrentStubGzip(), MediaWiki\Tests\Maintenance\BackupDumperPageTest\testCurrentStubPlain(), GlobalTest\testDebugFunctionTest(), MediaWiki\Tests\Maintenance\BackupDumperPageTest\testFullStubPlain(), MediaWiki\Tests\Maintenance\BackupDumperPageTest\testFullTextPlain(), ApiMainTest\testNonWhitelistedCorsWithCookies(), MediaWiki\Tests\Maintenance\BackupDumperLoggerTest\testPlain(), MediaWiki\Tests\Maintenance\TextPassDumperDatabaseTest\testPlain(), MediaWiki\Tests\Maintenance\TextPassDumperDatabaseTest\testPrefetchPlain(), JpegTest\testSwappingICCProfile(), ApiUploadTest\testUploadZeroLength(), GlobalTest\testWfMkdirParents(), MediaWiki\Tests\Maintenance\BackupDumperPageTest\testXmlDumpsBackupUseCase(), and MediaWiki\Tests\Maintenance\BackupDumperLoggerTest\testXmlDumpsBackupUseCaseLogging().
|
protected |
Stub.
If a test suite needs to test against a specific database schema, it should override this method and return the appropriate information from it.
IMaintainableDatabase | $db | The DB connection to use for the mock schema. May be used to check the current state of the schema, to determine what overrides are needed. |
Reimplemented in MediaWikiTestCaseSchema1Test.
Definition at line 1368 of file MediaWikiTestCase.php.
Referenced by setUpSchema().
|
static |
Convenience method for getting an immutable admin test user.
string[] | $groups | Groups the test user should be added to. |
Definition at line 177 of file MediaWikiTestCase.php.
Referenced by BlockTest\addBlockForUser(), MediaWiki\Auth\CheckBlocksSecondaryAuthenticationProviderTest\getBlockedUser(), ApiUserrightsTest\getMockForProcessingExpiries(), NoWriteWatchedItemStoreUnitTest\testAddWatch(), NoWriteWatchedItemStoreUnitTest\testAddWatchBatchForUser(), UserTest\testAutoblockCookieInauthentic(), UserTest\testAutoblockCookieInfiniteExpiry(), UserTest\testAutoblockCookieNoSecretKey(), UserTest\testAutoblockCookies(), UserTest\testAutoblockCookiesDisabled(), ApiUserrightsTest\testBlockedWithoutUserrights(), UserTest\testBlockInstanceCache(), MediaWiki\Auth\AuthManagerTest\testCheckAccountCreatePermissions(), NoWriteWatchedItemStoreUnitTest\testCountUnreadNotifications(), NoWriteWatchedItemStoreUnitTest\testCountWatchedItems(), BlockTest\testDeprecatedConstructor(), NoWriteWatchedItemStoreUnitTest\testGetNotificationTimestampsBatch(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testGetRcIdIfUnpatrolled_returnsZeroIfPatrolled(), RevisionDbTestBase\testGetUserAndText(), NoWriteWatchedItemStoreUnitTest\testGetWatchedItem(), NoWriteWatchedItemStoreUnitTest\testGetWatchedItemsForUser(), RevisionDbTestBase\testIsMinor_true(), RevisionDbTestBase\testIsUnpatrolled_returnsZeroIfPatrolled(), NoWriteWatchedItemStoreUnitTest\testIsWatched(), NoWriteWatchedItemStoreUnitTest\testLoadWatchedItem(), RCFeedIntegrationTest\testNotify(), MediaWiki\Auth\CheckBlocksSecondaryAuthenticationProviderTest\testRangeBlock(), ChangesListSpecialPageTest\testRcHidepatrolledFilter(), ChangesListSpecialPageTest\testRcHideunpatrolledFilter(), ChangesListSpecialPageTest\testRcReviewStatusFilter(), NoWriteWatchedItemStoreUnitTest\testRemoveWatch(), NoWriteWatchedItemStoreUnitTest\testResetNotificationTimestamp(), MediaWiki\Tests\Storage\MutableRevisionRecordTest\testSetGetUser(), NoWriteWatchedItemStoreUnitTest\testSetNotificationTimestampsForUser(), NoWriteWatchedItemStoreUnitTest\testUpdateNotificationTimestamp(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testUserWasLastToEdit_false(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testUserWasLastToEdit_true(), AbstractChangesListSpecialPageTestCase\testValidateOptions(), and ApiUserrightsTest\testWebToken().
|
static |
Convenience method for getting an immutable test user.
string[] | $groups | Groups the test user should be in. |
Definition at line 153 of file MediaWikiTestCase.php.
Referenced by BlockTest\addXffBlocks(), MediaWiki\Tests\Storage\RevisionStoreDbTest\getRevisionRecordFromDetailsArray(), RevisionDbTestBase\makeRevisionWithProps(), AbstractChangesListSpecialPageTestCase\setUp(), UserTest\setUp(), ApiMainTest\testAssertUser(), UserTest\testAutoblockCookieInauthentic(), UserTest\testAutoblockCookieInfiniteExpiry(), UserTest\testAutoblockCookieNoSecretKey(), UserTest\testAutoblockCookies(), UserTest\testAutoblockCookiesDisabled(), RevisionTest\testConstructFromArray_userSetAsExpected(), UserTest\testExperienceLevel(), SpecialWatchlistTest\testFetchOptionsFromRequest(), DefaultPreferencesFactoryTest\testGetForm(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testGetKnownCurrentRevision(), MediaWiki\Tests\Storage\RevisionStoreRecordTest\testGetSlot_audience_latest(), ActorMigrationTest\testInsertRoundTrip(), ActorMigrationTest\testInsertUserIdentity(), ActorMigrationTest\testInsertWithTempTableCallbackMissingFields(), ActorMigrationTest\testInsertWithTempTableDeprecated(), ActorMigrationTest\testInsertWithTempTableWrong(), ActorMigrationTest\testInsertWrong(), UserTest\testNewFromAnyId(), RecentChangeTest\testNewFromRow(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testNewRevisionFromRow_userEdit(), ChangesListSpecialPageTest\testRcHidebyothersFilter(), ChangesListSpecialPageTest\testRcHidemyselfFilter(), ChangesListSpecialPageTest\testRcHidepatrolledDisabledFilter(), ChangesListSpecialPageTest\testRcHideunpatrolledDisabledFilter(), UserTest\testSoftBlockRanges(), ApiPageSetTest\testSpecialRedirects(), MediaWiki\Auth\LegacyHookPreAuthenticationProviderTest\testTestUserForCreation(), ImportTest\testUnknownUserHandling(), RevisionDbTestBase\testUserCan(), RevisionDbTestBase\testUserCanBitfield(), and UserTest\testUserGetRightsHooks().
MediaWikiTestCase::hideDeprecated | ( | $function | ) |
Don't throw a warning if $function is deprecated and called later.
string | $function |
Definition at line 1675 of file MediaWikiTestCase.php.
References wfDeprecated().
Referenced by UserTest\testActorId(), MediaWiki\Auth\AuthManagerTest\testAutoAccountCreation(), BlockTest\testDeprecatedConstructor(), RevisionDbTestBase\testFetchRevision(), LBFactoryTest\testGetLBFactoryClass(), LinkerTest\testGetLinkColour(), ApiErrorFormatterTest\testGetMessageFromException(), ActorMigrationTest\testInsertWithTempTableDeprecated(), CommentStoreTest\testInsertWithTempTableDeprecated(), UserTest\testIsLocallyBlockedProxy(), DeprecatedGlobalTest\testLazyLoad(), RevisionDbTestBase\testLoadFromId(), DeprecatedGlobalTest\testObjectDeStub(), HooksTest\testOldStyleHooks(), RevisionTest\testPageJoinCond(), RevisionTest\testSelectArchiveFields(), RevisionTest\testSelectFields(), RevisionTest\testSelectPageFields(), RevisionTest\testSelectTextFields(), RevisionTest\testSelectUserFields(), MediaWiki\Session\PHPSessionHandlerTest\testSessionHandling(), and RevisionTest\testUserJoinCond().
|
protected |
Insert a new page.
Should be called from addDBData().
string | title | $pageName | Page name or title |
string | $text | Page's content |
int | $namespace | Namespace id (name cannot already contain namespace) |
Definition at line 1033 of file MediaWikiTestCase.php.
References $title.
Referenced by CategoryMembershipChangeTest\addDBDataOnce(), ContentHandlerTest\addDBDataOnce(), LinksUpdateTest\addDBDataOnce(), CategoryMembershipChangeJobTest\addDBDataOnce(), MergeHistoryTest\addDBDataOnce(), PrefixSearchTest\addDBDataOnce(), SearchEnginePrefixTest\addDBDataOnce(), SearchEngineTest\addDBDataOnce(), and SpamBlacklistTest\setUp().
|
staticprivate |
ConfigFactory | $oldConfigFactory | |
LBFactory | $oldLoadBalancerFactory | |
MediaWikiServices | $newServices |
MWException |
Definition at line 295 of file MediaWikiTestCase.php.
References $services.
|
staticprivate |
Definition at line 1596 of file MediaWikiTestCase.php.
|
staticprotected |
Check whether ExternalStoreDB is being used.
Definition at line 1319 of file MediaWikiTestCase.php.
References $wgDefaultExternalStore, and array().
|
protected |
Returns true if the given namespace defaults to Wikitext according to $wgNamespaceContentModels.
int | $ns | The namespace ID to check |
Definition at line 1895 of file MediaWikiTestCase.php.
References $wgNamespaceContentModels, and CONTENT_MODEL_WIKITEXT.
Referenced by PrefixSearchTest\addDBDataOnce(), SearchEnginePrefixTest\addDBDataOnce(), SearchEngineTest\addDBDataOnce(), SearchEngineTest\fetchIds(), PrefixSearchTest\setUp(), SearchEnginePrefixTest\setUp(), and TitlePermissionTest\testQuickPermissions().
|
private |
Lists all tables in the live database schema.
IMaintainableDatabase | $db |
Definition at line 1501 of file MediaWikiTestCase.php.
References Wikimedia\Rdbms\IMaintainableDatabase\listTables().
Referenced by recloneMockTables(), setUpSchema(), and undoSchemaOverrides().
|
static |
IMaintainableDatabase | $db |
Definition at line 1607 of file MediaWikiTestCase.php.
References $tables, Wikimedia\Rdbms\IDatabase\getType(), Wikimedia\Rdbms\IMaintainableDatabase\listTables(), Wikimedia\Rdbms\IMaintainableDatabase\listViews(), and Wikimedia\Rdbms\IDatabase\tablePrefix().
|
staticprivate |
Create a config suitable for testing, based on a base config, default overrides, and custom overrides.
Definition at line 250 of file MediaWikiTestCase.php.
References CACHE_ACCEL, CACHE_DB, CACHE_MEMCACHED, CACHE_NONE, and false.
|
staticprivate |
ConfigFactory | $oldFactory | |
Config[] | $configurations |
Definition at line 326 of file MediaWikiTestCase.php.
References $services.
|
protected |
Check, if $wgDiff3 is set and ready to merge Will mark the calling test as skipped, if not ready.
Definition at line 1967 of file MediaWikiTestCase.php.
References $wgDiff3.
Referenced by GlobalTest\testMerge(), WikitextContentHandlerTest\testMerge3(), and GlobalTest\testMerge_worksWithLessParameters().
|
protected |
Merges the given values into a MW global array variable.
Useful for setting some entries in a configuration array, instead of setting the entire array.
string | $name | The name of the global, as in wgFooBar |
array | $values | The array containing the entries to set in that global |
MWException | If the designated global is not an array. |
Definition at line 813 of file MediaWikiTestCase.php.
References $GLOBALS, $name, and setMwGlobals().
Referenced by MediaWiki\Tests\Maintenance\TextPassDumperDatabaseTest\addDBData(), GenderCacheTest\addDBDataOnce(), MediaWiki\Auth\LegacyHookPreAuthenticationProviderTest\hook(), CaptchaPreAuthenticationProviderTest\setMwHook(), setTemporaryHook(), QuestyCaptchaTest\setUp(), ApiOptionsTest\setUp(), ApiRevisionDeleteTest\setUp(), NewUsersLogFormatterTest\setUp(), PageLangLogFormatterTest\setUp(), RevisionDbTestBase\setUp(), TitleMethodsTest\setUp(), BotPasswordTest\setUp(), AutoLoaderTest\setUp(), SearchEngineTest\testAugmentorSearch(), UserTest\testAutoblockCookieInauthentic(), UserTest\testAutoblockCookieInfiniteExpiry(), UserTest\testAutoblockCookieNoSecretKey(), UserTest\testAutoblockCookies(), UserTest\testAutoblockCookiesDisabled(), ApiBlockTest\testBlockWithHide(), TitleTest\testCreateFragmentTitle(), MediaWiki\Session\SessionBackendTest\testDelaySave(), ApiDisabledTest\testDisabled(), PasswordResetTest\testExecute_email(), SpecialMyLanguageTest\testFindTitle(), SpecialPageFactoryTest\testGetAliasListRecursion(), UserTest\testGetCanonicalName(), SpecialPageFactoryTest\testGetNames(), MediaWiki\Auth\AbstractPasswordPrimaryAuthenticationProviderTest\testGetNewPasswordExpiry(), SpecialPageFactoryTest\testGetPage(), SpecialPageFactoryTest\testHookNotCalledTwice(), JobTest\testJobFactory(), ApiMainTest\testLacksSameOriginSecurity(), MediaWiki\Session\SessionManagerTest\testLoadSessionInfoFromStore(), ApiMainTest\testNonWhitelistedCorsWithCookies(), MediaWiki\Session\CookieSessionProviderTest\testPersistSession(), MediaWiki\Session\CookieSessionProviderTest\testPersistSessionWithHook(), CaptchaPreAuthenticationProviderTest\testPingLimiter(), MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProviderTest\testProviderChangeAuthenticationData(), MediaWiki\Auth\AbstractPrimaryAuthenticationProviderTest\testProviderNormalizeUsername(), LocalisationCacheTest\testRecacheFallbacksWithHooks(), MediaWiki\Session\SessionBackendTest\testRenew(), MediaWiki\Session\SessionBackendTest\testSave(), ApiParseTest\testSerializationError(), MediaWiki\Session\PHPSessionHandlerTest\testSessionHandling(), MediaWiki\Auth\ThrottlePreAuthenticationProviderTest\testTestForAccountCreation(), UserTest\testUserGetRightsHooks(), and MediaWiki\Auth\LegacyHookPreAuthenticationProviderTest\unhook().
|
private |
Definition at line 1468 of file MediaWikiTestCase.php.
Referenced by setUpSchema().
MediaWikiTestCase::needsDB | ( | ) |
Definition at line 1006 of file MediaWikiTestCase.php.
Referenced by assertSelect(), run(), setUp(), and tearDown().
|
protected |
Does an associative sort that works for objects.
array | &$array |
Definition at line 1816 of file MediaWikiTestCase.php.
References serialize().
Referenced by assertArrayEquals().
|
private |
|
protected |
Stashes the global instance of MediaWikiServices, and installs a new one, allowing test cases to override settings and services.
The previous instance of MediaWikiServices will be restored on tearDown.
Config | $configOverrides | Configuration overrides for the new MediaWikiServices instance. |
callable[] | $services | An associative array of services to re-define. Keys are service names, values are callables. |
MWException |
Definition at line 845 of file MediaWikiTestCase.php.
References $services.
Referenced by ApiQueryContributionsTest\addDBDataOnce(), setService(), PageArchiveTest\setUp(), UserTest\setUp(), InterwikiTest\setWgInterwikiCache(), RevisionTest\testConstructFromRowWithBadPageId(), ChangesListSpecialPageTest\testFilterUserExpLevelAllExperienceLevels(), ChangesListSpecialPageTest\testFilterUserExpLevelRegistrered(), ChangesListSpecialPageTest\testFilterUserExpLevelRegistreredOrLearner(), ChangesListSpecialPageTest\testFilterUserExpLevelUnregistrered(), ChangesListSpecialPageTest\testFilterUserExpLevelUnregistreredOrExperienced(), MediaWiki\Tests\Storage\RevisionStoreTest\testGetArchiveQueryInfo_contentHandlerDb(), MediaWiki\Tests\Storage\RevisionStoreTest\testGetArchiveQueryInfo_noContentHandlerDb(), MediaWiki\Tests\Storage\RevisionStoreTest\testGetQueryInfo(), ApiQueryContributionsTest\testInterwikiUser(), PageArchiveTest\testListRevisions(), RevisionTest\testLoadFromTitle(), ObjectCacheTest\testNewAnythingNoAccelNoDb(), ObjectCacheTest\testNewAnythingNothingNoDb(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testNewRevisionFromArchiveRow_legacyEncoding(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testNewRevisionFromRow_anonEdit(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testNewRevisionFromRow_anonEdit_legacyEncoding(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testNewRevisionFromRow_userEdit(), MediaWikiTestCaseTest\testOverrideMwServices(), ChangesListSpecialPageTest\testRcHidebyothersFilter(), ChangesListSpecialPageTest\testRcHidemyselfFilter(), ApiQueryContributionsTest\testSorting(), and RevisionTest\testUserJoinCond().
|
static |
Prepare service configuration for unit testing.
This calls MediaWikiServices::resetGlobalInstance() to allow some critical services to be overridden for testing.
prepareServices() only needs to be called once, but should be called as early as possible, before any class has a chance to grab a reference to any of the global services instances that get discarded by prepareServices(). Only the first call has any effect, later calls are ignored.
Config | $bootstrapConfig | The bootstrap config to use with the new MediaWikiServices. Only used for the first call to this method. |
Definition at line 200 of file MediaWikiTestCase.php.
References $services.
|
private |
Re-clones the given mock tables to restore them based on the live database schema.
The tables listed in $tables are expected to currently not exist, so dropMockTables() should be called first.
IMaintainableDatabase | $db | |
array | $tables |
Definition at line 1518 of file MediaWikiTestCase.php.
References $tables, ensureMockDatabaseConnection(), listOriginalTables(), and Wikimedia\Rdbms\IDatabase\tablePrefix().
Referenced by undoSchemaOverrides().
|
private |
Empty all tables so they can be repopulated for tests.
Database | $db,|null | Database to reset |
array | $tablesUsed | Tables to reset |
Definition at line 1540 of file MediaWikiTestCase.php.
References addCoreDBData(), Wikimedia\Rdbms\Database\delete(), Wikimedia\Rdbms\IDatabase\getType(), Wikimedia\Rdbms\Database\query(), Wikimedia\Rdbms\Database\tableExists(), and Wikimedia\Rdbms\Database\tableName().
Referenced by run().
|
staticprotected |
Reset global services, and install testing environment.
This is the testing equivalent of MediaWikiServices::resetGlobalInstance(). This should only be used to set up the testing environment, not when running unit tests. Use MediaWikiTestCase::overrideMwServices() for that.
Config | null | $bootstrapConfig | The bootstrap config to use with the new MediaWikiServices. |
Definition at line 223 of file MediaWikiTestCase.php.
References $serviceLocator.
|
private |
Restores loggers replaced by setLogger().
Definition at line 971 of file MediaWikiTestCase.php.
Referenced by tearDown().
MediaWikiTestCase::run | ( | PHPUnit_Framework_TestResult | $result = null | ) |
Definition at line 384 of file MediaWikiTestCase.php.
References addCoreDBData(), addDBData(), addDBDataOnce(), checkDbIsSupported(), DB_MASTER, doLightweightServiceReset(), getCliArg(), needsDB(), oncePerClass(), resetDB(), setupAllTestDBs(), setUpSchema(), and wfGetDB().
MediaWikiTestCase::setCliArg | ( | $offset, | |
$value ) |
string | $offset | |
mixed | $value |
Definition at line 1664 of file MediaWikiTestCase.php.
References PHPUnitMaintClass\$additionalOptions, and $value.
MediaWikiTestCase::setContentLang | ( | $lang | ) |
string | Language | $lang |
Definition at line 892 of file MediaWikiTestCase.php.
References $lang, and setMwGlobals().
Referenced by MessageCacheTest\configureLanguages(), CategoryMembershipChangeTest\setUp(), ExtraParserTest\setUp(), HtmlTest\setUp(), CategoryMembershipChangeJobTest\setUp(), StripStateTest\setUp(), MediaWikiTitleCodecTest\setUp(), TitleTest\setUp(), MediaWikiLangTestCase\setUp(), DifferenceEngineTest\testAddLocalisedTitleTooltips(), InterwikiTest\testConstructor(), TitleTest\testGetPageViewLanguage(), SpecialPageDataTest\testSpecialPageWithoutParameters(), and ArticleTablesTest\testTemplatelinksUsesContentLanguage().
MediaWikiTestCase::setGroupPermissions | ( | $newPerms, | |
$newKey = null, | |||
$newValue = null ) |
Alters $wgGroupPermissions for the duration of the test.
Can be called with an array, like [ '*' => [ 'read' => false ], 'user' => [ 'read' => false ] ] or three values to set a single permission, like $this->setGroupPermissions( '*', 'read', false );
array | string | $newPerms | Either an array of permissions to change, in which case the next two parameters are ignored; or a single string identifying a group, to use with the next two parameters. |
string | null | $newKey | |
mixed | $newValue |
Definition at line 920 of file MediaWikiTestCase.php.
References $value, $wgGroupPermissions, and stashMwGlobals().
Referenced by ApiUserrightsTest\setPermissions(), ApiMainTest\testCheckExecutePermissionsReadProhibited(), ApiMainTest\testCheckExecutePermissionWriteApiProhibited(), ApiMainTest\testSetCacheModePrivateWiki(), ApiParseTest\testSuppressed(), ApiMoveTest\testSuppressRedirectNoPermission(), and ApiMoveTest\testTagsNoPermission().
|
protected |
Sets the logger for a specified channel, for the duration of the test.
string | $channel | |
LoggerInterface | $logger |
Definition at line 942 of file MediaWikiTestCase.php.
Referenced by ResourceLoaderStartUpModuleTest\testGetModuleRegistrations(), MediaWikiTestCaseTest\testLoggersAreRestoredOnTearDown_replacingExistingLogger(), MediaWikiTestCaseTest\testLoggersAreRestoredOnTearDown_replacingNonExistingLogger(), MediaWikiTestCaseTest\testLoggersAreRestoredOnTearDown_replacingSameLoggerTwice(), ResourceLoaderTest\testMakeModuleResponseError(), ResourceLoaderTest\testMakeModuleResponseStartupError(), ApiMainTest\testNonWhitelistedCorsWithCookies(), and MediaWikiTest\testPostSendJobDoesNotSetCookie().
|
protected |
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
The key is added to the array of globals that will be reset afterwards in the tearDown().
array | string | $pairs | Key to the global variable, or an array of key/value pairs. |
mixed | $value | Value to set the global to (ignored if an array is given as first argument). |
Definition at line 678 of file MediaWikiTestCase.php.
References $GLOBALS, $value, and stashMwGlobals().
Referenced by MediaWiki\Tests\Maintenance\BackupDumperPageTest\addDBData(), SearchEngineTest\addDBDataOnce(), OutputPageTest\assertTransformCssMediaCase(), ApiFormatBaseTest\encodeData(), UserTest\installMockContralIdProvider(), mergeMwGlobalArrayValue(), PrefixSearchTest\searchProvision(), SearchEnginePrefixTest\searchProvision(), TitleTest\secureAndSplitGlobals(), ObjectCacheTest\setCacheConfig(), setContentLang(), CaptchaPreAuthenticationProviderTest\setTriggers(), CaptchaAuthenticationRequestTest\setUp(), CaptchaPreAuthenticationProviderTest\setUp(), SpamBlacklistTest\setUp(), ApiQueryTitleBlacklistTest\setUp(), ActionTest\setUp(), ApiBlockTest\setUp(), ApiComparePagesTest\setUp(), ApiEditPageTest\setUp(), ApiTestCase\setUp(), ApiUploadTestCase\setUp(), ApiQueryTest\setUp(), MediaWiki\Auth\AuthManagerTest\setUp(), MediaWiki\Auth\UserDataAuthenticationRequestTest\setUp(), LocalisationCacheTest\setUp(), OldChangesListTest\setUp(), RCCacheEntryFactoryTest\setUp(), ContentHandlerTest\setUp(), CssContentTest\setUp(), TextContentTest\setUp(), LinksUpdateTest\setUp(), SearchUpdateTest\setUp(), EditPageTest\setUp(), ExportTest\setUp(), ExtraParserTest\setUp(), LocalFileTest\setUp(), GitInfoTest\setUp(), GlobalTest\setUp(), WfParseUrlTest\setUp(), WfThumbIsStandardTest\setUp(), HtmlTest\setUp(), CategoryMembershipChangeJobTest\setUp(), CSSMinTest\setUp(), LinkRendererTest\setUp(), LinkFilterTest\setUp(), LogFormatterTest\setUp(), PageLangLogFormatterTest\setUp(), BitmapMetadataHandlerTest\setUp(), BitmapScalingTest\setUp(), ExifBitmapTest\setUp(), ExifRotationTest\setUp(), ExifTest\setUp(), FormatMetadataTest\setUp(), JpegTest\setUp(), SVGTest\setUp(), TiffTest\setUp(), MediaWikiTest\setUp(), MessageTest\setUp(), MWNamespaceTest\setUp(), MWTimestampTest\setUp(), ObjectCacheTest\setUp(), ImagePage404Test\setUp(), ImagePageTest\setUp(), WikiPageDbTestBase\setUp(), PageArchiveTest\setUp(), MagicVariableTest\setUp(), ParserOptionsTest\setUp(), DefaultPreferencesFactoryTest\setUp(), PreferencesTest\setUp(), PrefixSearchTest\setUp(), RCFeedIntegrationTest\setUp(), ResourceLoaderTest\setUp(), RevisionDbTestBase\setUp(), SampleTest\setUp(), SearchEnginePrefixTest\setUp(), SearchEngineTest\setUp(), MediaWiki\Session\BotPasswordSessionProviderTest\setUp(), AbstractChangesListSpecialPageTestCase\setUp(), ChangesListSpecialPageTest\setUp(), SpecialPageTest\setUp(), SpecialWatchlistTest\setUp(), TemplateParserTest\setUp(), MediaWikiTitleCodecTest\setUp(), NaiveImportTitleFactoryTest\setUp(), NamespaceImportTitleFactoryTest\setUp(), SubpageImportTitleFactoryTest\setUp(), TitlePermissionTest\setUp(), TitleTest\setUp(), UploadBaseTest\setUp(), UploadFromUrlTest\setUp(), BotPasswordTest\setUp(), UserGroupMembershipTest\setUp(), UserTest\setUp(), MWCryptHKDFTest\setUp(), MWGrantsTest\setUp(), WikiMapTest\setUp(), XmlTest\setUp(), LanguageConverterTest\setUp(), MediaWiki\Tests\Maintenance\DumpTestCase\setUp(), ResourceLoaderTestCase\setUp(), RepoGroupTest\setUpForeignRepo(), ApiParseTest\setupInterwiki(), setUserLang(), InterwikiTest\setWgInterwikiCache(), DeferredUpdatesTest\testAddCallableUpdate(), DeferredUpdatesTest\testAddMergeable(), ApiFormatBaseTest\testApiFrameOptions(), FileBackendTest\testAsyncWrites(), MediaWiki\Auth\AuthManagerTest\testAutoAccountCreation(), UserTest\testAutoblockCookieInauthentic(), UserTest\testAutoblockCookieInfiniteExpiry(), UserTest\testAutoblockCookieNoSecretKey(), UserTest\testAutoblockCookies(), UserTest\testAutoblockCookiesDisabled(), BotPasswordTest\testBasics(), ApiBlockTest\testBlockWithProhibitedEmailBlock(), ApiBlockTest\testBlockWithProhibitedTag(), ApiLoginTest\testBotPassword(), UploadStashTest\testBug29408(), SpecialPreferencesTest\testBug41337(), OutputPageTest\testBuildExemptModules(), FileTest\testCanAnimateThumbIfAppropriate(), CaptchaTest\testCaptchaTriggersAttributeGetsOverwritten(), MediaWiki\Tests\Maintenance\CategoriesRdfTest\testCategoriesDump(), MediaWiki\Auth\AuthManagerTest\testCheckAccountCreatePermissions(), ApiMainTest\testCheckConditionalRequestHeaders(), ApiMainTest\testCheckConditionalRequestHeadersFailed(), ApiMainTest\testCheckMaxLagExceeded(), ApiMainTest\testCheckMaxLagExceededWithHostNames(), MediaWiki\Auth\AbstractPasswordPrimaryAuthenticationProviderTest\testCheckPasswordValidity(), UserTest\testCheckPasswordValidity(), PasswordPolicyChecksTest\testCheckPopularPasswordBlacklist(), ExtraParserTest\testCleanSigDisabled(), SpecialPageFactoryTest\testConflictResolution(), RevisionTest\testConstructFromArray_userSetAsExpected(), RevisionTest\testConstructFromRowWithBadPageId(), MediaWiki\Auth\ThrottlerTest\testConstructor(), ResourceLoaderTest\testConstructRegistrationHook(), MediaWiki\Session\CookieSessionProviderTest\testCookieData(), GlobalTest\testDebugFunctionTest(), ApiDeleteTest\testDeleteWithoutTagPermission(), WebRequestTest\testDetectServer(), ApiFormatBaseTest\testDisable(), ApiParseTest\testDisableTidy(), ApiStructureTest\testDocumentationExists(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testDomainCheck(), SiteStatsUpdateTest\testDoUpdate(), DeferredUpdatesTest\testDoUpdatesCLI(), DeferredUpdatesTest\testDoUpdatesWeb(), AutopromoteTest\testEditCountLookupIsSkippedIfRequirementIsZero(), BadTitleErrorTest\testExceptionSetsStatusCode(), ThrottledErrorTest\testExceptionSetsStatusCode(), UserTest\testExperienceLevel(), ExtensionRegistryTest\testExportExtractedDataGlobals(), SideBarTest\testExternalUrlsRequireADescription(), CentralIdLookupTest\testFactory(), ChangesListSpecialPageTest\testFilterUserExpLevel(), ChangesListSpecialPageTest\testFilterUserExpLevelAllExperienceLevels(), ChangesListSpecialPageTest\testFilterUserExpLevelRegistrered(), ChangesListSpecialPageTest\testFilterUserExpLevelRegistreredOrLearner(), ChangesListSpecialPageTest\testFilterUserExpLevelUnregistrered(), ChangesListSpecialPageTest\testFilterUserExpLevelUnregistreredOrExperienced(), SpecialMyLanguageTest\testFindTitle(), RepoGroupTest\testForEachForeignRepoNone(), LinkerTest\testFormatComment(), LinkerTest\testFormatLinksInComment(), LanguageTest\testFormatNum(), FileTest\testGenerateBucketsIfNeeded(), RevisionTest\testGetArchiveQueryInfo(), MediaWiki\Tests\Storage\RevisionStoreTest\testGetArchiveQueryInfo_contentHandlerDb(), MediaWiki\Tests\Storage\RevisionStoreTest\testGetArchiveQueryInfo_noContentHandlerDb(), ContentHandlerTest\testGetAutosummary(), QuestyCaptchaTest\testGetCaptcha(), WikitextContentHandlerTest\testGetChangeTag(), ContentHandlerTest\testGetChangeTag(), ContentHandlerTest\testGetContentText_NonTextContent_fail(), ContentHandlerTest\testGetContentText_NonTextContent_ignore(), ContentHandlerTest\testGetContentText_NonTextContent_serialize(), ContentHandlerTest\testGetContentText_Null(), ContentHandlerTest\testGetContentText_TextContent(), TitleTest\testGetFragmentForURL(), WebRequestTest\testGetIP(), WebRequestTest\testGetIpLackOfRemoteAddrThrowAnException(), ResourceLoaderTest\testGetLoadScript(), SpecialPageFactoryTest\testGetLocalNameFor(), ResourceLoaderStartUpModuleTest\testGetModuleRegistrations(), TitleTest\testGetPageViewLanguage(), DeferredUpdatesTest\testGetPendingUpdates(), HttpTest\testGetProxy(), MediaWiki\Tests\Storage\RevisionStoreTest\testGetQueryInfo(), RevisionTest\testGetQueryInfo(), SpecialShortpagesTest\testGetQueryInfoRespectsContentNS(), WikiPageDbTestBase\testGetRedirectTarget(), CssContentTest\testGetRedirectTarget(), JavaScriptContentTest\testGetRedirectTarget(), MediaWiki\Session\ImmutableSessionProviderWithCookieTest\testGetSessionIdFromCookie(), ChangeTagsTest\testGetSoftwareTags(), ParserOutputTest\testGetText(), MediaWiki\Tests\EditPage\TextboxBuilderTest\testGetTextboxProtectionCSSClasses(), FileTest\testGetThumbnailBucket(), SpecialPageFactoryTest\testGetTitleForAlias(), WikiMapTest\testGetWiki(), RepoGroupTest\testHasForeignRepoNegative(), RequestContextTest\testImportScopedSession(), MessageTest\testInContentLanguageOverride(), RevisionDbTestBase\testInsertOn_exceptionOnNoPage(), RevisionDbTestBase\testInsertOn_success(), ImportLogFormatterTest\testInterwikiLogDatabaseRows(), ApiQueryContributionsTest\testInterwikiUser(), LocalIdLookupTest\testIsAttachedShared(), MWExceptionTest\testisCommandLine(), TextContentTest\testIsCountable(), WikiPageDbTestBase\testIsCountable(), RecentChangeTest\testIsInRCLifespan(), UserTest\testIsLocallyBlockedProxy(), UserTest\testIsPingLimitable(), MergeHistoryTest\testIsValidMerge(), MovePageTest\testIsValidMove(), TitleTest\testIsValidMoveOperation(), MWExceptionTest\testJsonserializeexceptionBacktracingDisabled(), MWExceptionTest\testJsonserializeexceptionBacktracingEnabled(), MWExceptionTest\testJsonserializeexceptionKeys(), LinkerTest\testLinkBeginHook(), LinkerTest\testLinkEndHook(), PageArchiveTest\testListRevisions(), MediaWiki\Auth\UserDataAuthenticationRequestTest\testLoadFromSubmission(), RevisionTest\testLoadFromTitle(), BotPasswordTest\testLogin(), ResourceLoaderTest\testMakeLoaderImplementScript(), ResourceLoaderTest\testMakeModuleResponseConcat(), CssContentHandlerTest\testMakeRedirectContent(), JavaScriptContentHandlerTest\testMakeRedirectContent(), OutputPageTest\testMakeResourceLoaderLink(), ShellTest\testMakeScriptCommand(), UploadBaseTest\testMaxUploadSize(), MessageTest\testMessageAsParam(), ExifRotationTest\testMetadataAutoRotate(), ExifRotationTest\testMetadataAutoRotateUnsupported(), ExifRotationTest\testMetadataNoAutoRotate(), ChangeTagsTest\testModifyDisplayQuery(), BitmapMetadataHandlerTest\testMultilingualCascade(), CaptchaTest\testNamespaceTriggersOverwrite(), ObjectCacheTest\testNewAnythingAccel(), ObjectCacheTest\testNewAnythingHash(), ObjectCacheTest\testNewAnythingNoAccel(), ObjectCacheTest\testNewAnythingNoAccelNoDb(), DatabaseLogEntryTest\testNewFromId(), MailAddressTest\testNewFromUser(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testNewRevisionFromArchiveRow_legacyEncoding(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testNewRevisionFromRow_anonEdit(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testNewRevisionFromRow_anonEdit_legacyEncoding(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testNewRevisionFromRow_userEdit(), MediaWikiSiteTest\testNormalizePageTitle(), RCFeedIntegrationTest\testNotify(), ApiFormatBaseTest\testNullMimeType(), LinksUpdateTest\testOnAddingAndRemovingCategory_recentChangesRowIsAdded(), LinksUpdateTest\testOnAddingAndRemovingCategoryToTemplates_embeddingPagesAreIgnored(), ParserOptionsTest\testOptionsHash(), MediaWiki\Session\CookieSessionProviderTest\testPersistSession(), MediaWiki\Session\ImmutableSessionProviderWithCookieTest\testPersistSession(), MediaWiki\Session\CookieSessionProviderTest\testPersistSessionWithHook(), ApiMoveTest\testPingLimiter(), UserTest\testPingLimiterGlobal(), JpegPixelFormatTest\testPixelFormatRendering(), ResourceLoaderModuleTest\testPlaceholderize(), MediaWikiTest\testPostSendJobDoesNotSetCookie(), OutputPageTest\testPreloadLinkHeaders(), DeferredUpdatesTest\testPresendAddOnPostsendRun(), CdnCacheUpdateTest\testPurgeMergeWeb(), ContribsPagerTest\testQueryableRanges(), MediaWiki\Auth\CheckBlocksSecondaryAuthenticationProviderTest\testRangeBlock(), MessageTest\testRawHtmlInMsg(), ChangesListSpecialPageTest\testRcHidebyothersFilter(), ChangesListSpecialPageTest\testRcHidemyselfFilter(), ChangesListSpecialPageTest\testRcHidepatrolledDisabledFilter(), ChangesListSpecialPageTest\testRcHideunpatrolledDisabledFilter(), GlobalTest\testReadOnlyGlobalChange(), ResourceLoaderStartUpModuleTest\testRegistrationsMinified(), ErrorPageErrorTest\testReport(), SpecialPageFactoryTest\testResolveAlias(), SideBarTest\testRespectExternallinktarget(), SideBarTest\testRespectWgnofollowlinks(), ExifRotationTest\testRotationRenderingNoAutoRotate(), ClearUserWatchlistJobTest\testRun(), DeferredUpdatesTest\testRunOuterScopeUpdate(), DeferredUpdatesTest\testRunUpdateTransactionScope(), SpecialSearchTest\testSearchTermIsNotExpanded(), RevisionTest\testSelectArchiveFields(), RevisionTest\testSelectFields(), MediaWiki\Session\PHPSessionHandlerTest\testSessionHandling(), MediaWiki\Auth\AuthManagerTest\testSetDefaultUserOptions(), MediaWikiTestCaseTest\testSetGlobalsAreRestoredOnTearDown(), MediaWikiTestCaseTest\testSetNonExistentGlobalsAreUnsetOnTearDown(), MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProviderTest\testSetPasswordResetFlag(), MediaWiki\Logger\LegacyLoggerTest\testShouldEmit(), UserTest\testSoftBlockRanges(), ApiQueryContributionsTest\testSorting(), SpecialSearchTest\testSubPageRedirect(), JpegTest\testSwappingICCProfile(), SideBarTest\testTestAttributesAssertionHelper(), CaptchaPreAuthenticationProviderTest\testTestForAuthentication(), ApiQueryTest\testTitlePartToKey(), ApiQueryTest\testTitlesGetNormalized(), MailAddressTest\testToString(), OutputPageTest\testTransformResourcePath(), CaptchaTest\testTriggersCaptcha(), ImportTest\testUnknownUserHandling(), ContribsPagerTest\testUnqueryableRanges(), LinksUpdateTest\testUpdate_categorylinks(), LinksUpdateTest\testUpdate_langlinks(), LinksUpdateTest\testUpdate_page_props_without_sortkey(), JavaScriptContentTest\testUpdateRedirect(), ApiUploadTest\testUploadChunks(), ApiUploadTest\testUploadStash(), MWExceptionTest\testUseMessageCache(), MWExceptionTest\testUseOutputPage(), TimeAdjustTest\testUserAdjust(), TitlePermissionTest\testUserBlock(), RevisionDbTestBase\testUserCan(), RevisionDbTestBase\testUserCanBitfield(), RevisionTest\testUserJoinCond(), LinkerTest\testUserLink(), ResourceLoaderModuleTest\testValidateScriptFile(), WfExpandUrlTest\testWfExpandUrl(), TitleTest\testWgWhitelistReadRegexp(), AutoLoaderTest\testWrongCaseClass(), AutoLoaderTest\testWrongCaseSerializedClass(), and GlobalTest\wfWikiID().
|
protected |
Sets a service, maintaining a stashed version of the previous service to be restored in tearDown.
string | $name | |
object | $object |
Definition at line 628 of file MediaWikiTestCase.php.
References overrideMwServices().
Referenced by ApiMainTest\doTestCheckMaxLag(), RevisionTest\overrideCommentStoreAndActorMigration(), ApiOpenSearchTest\replaceSearchEngine(), ApiOpenSearchTest\replaceSearchEngineConfig(), TitleTest\secureAndSplitGlobals(), CaptchaPreAuthenticationProviderTest\setUp(), ApiParseTest\setupSkin(), RevisionTest\testCompressRevisionTextUtf8Gzip(), RevisionTest\testConstructFromRow(), RevisionTest\testDecompressRevisionText(), ExternalStoreTest\testExternalFetchFromURL_noExternalStores(), ExternalStoreTest\testExternalFetchFromURL_someExternalStore(), RevisionTest\testGetArchiveQueryInfo(), WebRequestTest\testGetIP(), WebRequestTest\testGetIpLackOfRemoteAddrThrowAnException(), RevisionTest\testGetQueryInfo(), RevisionTest\testGetRevisionText_external_noOldId(), RevisionTest\testGetRevisionText_external_oldId(), RevisionTest\testGetRevisionWithGzipAndLegacyEncoding(), RevisionTest\testGetRevisionWithLegacyEncoding(), MediaWiki\Tests\Storage\RevisionStoreTest\testGetTitle_correctFallbackAndthrowsExceptionAfterFallbacks(), MediaWiki\Tests\Storage\RevisionStoreTest\testGetTitle_successFromPageId(), MediaWiki\Tests\Storage\RevisionStoreTest\testGetTitle_successFromPageIdOnFallback(), MediaWiki\Tests\Storage\RevisionStoreTest\testGetTitle_successFromRevId(), MediaWiki\Tests\Storage\RevisionStoreTest\testGetTitle_successFromRevIdOnFallback(), ExternalUserNamesTest\testGetUserLinkTitle(), WfThumbIsStandardTest\testIsStandard(), SiteStatsTest\testJobsCountGetCached(), ResourceLoaderTest\testMeasureResponseTime(), RevisionDbTestBase\testNewFromArchiveRow(), RevisionDbTestBase\testNewKnownCurrent(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testNewMutableRevisionFromArray_legacyEncoding(), and MediaWikiTestCaseTest\testSetService().
|
protected |
Create a temporary hook handler which will be reset by tearDown.
This replaces other handlers for the same hook.
string | $hookName | Hook name |
mixed | $handler | Value suitable for a hook handler |
Definition at line 2014 of file MediaWikiTestCase.php.
References $handler, and mergeMwGlobalArrayValue().
Referenced by SpecialWatchlistTest\provideFetchOptionsFromRequest(), AbstractChangesListSpecialPageTestCase\setUp(), SpecialWatchlistTest\setUp(), ApiMainTest\testCheckExecutePermissionHookAbort(), ContentHandlerTest\testDataIndexFields(), ApiDeleteTest\testDeleteAbortedByHook(), ApiParseTest\testEffectiveLangLinks(), ContentHandlerTest\testGetContentModelsHook(), SpecialShortpagesTest\testGetQueryInfoRespectsContentNS(), ApiLoginTest\testLoginWithNoSameOriginSecurity(), ShellTest\testMakeScriptCommand(), ApiParseTest\testModules(), MediaWikiTest\testPostSendJobDoesNotSetCookie(), DefaultPreferencesFactoryTest\testPreferencesFormPreSaveHookHasCorrectData(), SearchEngineTest\testSearchIndexFields(), and AbstractChangesListSpecialPageTestCase\testValidateOptions().
|
protected |
Reimplemented in CaptchaAuthenticationRequestTest, CaptchaPreAuthenticationProviderTest, QuestyCaptchaTest, ExpressionTest, SpamBlacklistTest, ApiQueryTitleBlacklistTest, TitleBlacklistAuthenticationRequestTest, TitleBlacklistPreAuthenticationProviderTest, ActionTest, ApiBlockTest, ApiComparePagesTest, ApiEditPageTest, ApiLogoutTest, ApiOptionsTest, ApiQueryRecentChangesIntegrationTest, ApiQueryWatchlistIntegrationTest, ApiQueryWatchlistRawIntegrationTest, ApiRevisionDeleteTest, ApiSetNotificationTimestampIntegrationTest, ApiTestCase, ApiUploadTestCase, ApiQueryTest, MediaWiki\Auth\AuthManagerTest, MediaWiki\Auth\UserDataAuthenticationRequestTest, LocalisationCacheTest, MessageCacheTest, CategoryMembershipChangeTest, ChangesListFilterTest, OldChangesListTest, RCCacheEntryFactoryTest, RecentChangeTest, CollationFaTest, CollationTest, CustomUppercaseCollationTest, ContentHandlerTest, CssContentTest, FileContentHandlerTest, TextContentTest, WikitextContentHandlerTest, DatabaseSqliteTest, MediaWiki\Logger\Monolog\AvroFormatterTest, MediaWiki\Logger\Monolog\KafkaHandlerTest, MediaWiki\Logger\Monolog\LineFormatterTest, MWDebugTest, LinksUpdateTest, SearchUpdateTest, DeprecatedGlobalTest, DifferenceEngineTest, DiffHistoryBlobTest, EditPageTest, ExportTest, ExtraParserTest, FauxResponseTest, FileBackendTest, SwiftFileBackendTest, LocalFileTest, MigrateFileRepoLayoutTest, StoreBatchTest, FormOptionsInitializationTest, FormOptionsTest, GitInfoTest, GlobalTest, WfParseUrlTest, WfThumbIsStandardTest, HooksTest, HtmlTest, ImportLinkCacheIntegrationTest, InterwikiLookupAdapterTest, JobQueueTest, CategoryMembershipChangeJobTest, ClearUserWatchlistJobTest, ComposerInstalledTest, ComposerJsonTest, ComposerLockTest, CSSMinTest, BagOStuffTest, MultiWriteBagOStuffTest, ReplicatedBagOStuffTest, PageDataRequestHandlerTest, LinkRendererFactoryTest, LinkRendererTest, LinkFilterTest, DatabaseLogEntryTest, LogFormatterTest, NewUsersLogFormatterTest, PageLangLogFormatterTest, BitmapMetadataHandlerTest, BitmapScalingTest, DjVuTest, ExifBitmapTest, ExifRotationTest, ExifTest, FormatMetadataTest, GIFMetadataExtractorTest, GIFHandlerTest, JpegMetadataExtractorTest, JpegPixelFormatTest, JpegTest, MediaWikiMediaTestCase, PNGMetadataExtractorTest, PNGHandlerTest, SVGTest, TiffTest, WebPHandlerTest, XCFHandlerTest, MediaWikiTest, MessageTest, MWNamespaceTest, MWTimestampTest, MemcachedBagOStuffTest, ObjectCacheTest, RESTBagOStuffTest, ArticleTest, ImagePage404Test, ImagePageTest, WikiPageDbTestBase, PageArchiveTest, PagePropsTest, MagicVariableTest, ParserOptionsTest, ParserPreloadTest, PreprocessorTest, StripStateTest, TidyTest, PasswordTestCase, PathRouterTest, DefaultPreferencesFactoryTest, PreferencesTest, PrefixSearchTest, RCFeedIntegrationTest, ExtensionProcessorTest, ExtensionRegistryTest, ResourceLoaderFileModuleTest, ResourceLoaderImageTest, ResourceLoaderTest, RevisionDbTestBase, SampleTest, SearchEnginePrefixTest, SearchEngineTest, MediaWiki\Session\BotPasswordSessionProviderTest, SiteConfigurationTest, AbstractChangesListSpecialPageTestCase, ChangesListSpecialPageTest, SpecialPageTest, ContribsPagerTest, SpecialMIMESearchTest, SpecialPageTestBase, SpecialWatchlistTest, MediaWiki\Tests\Storage\NameTableStoreTest, MediaWiki\Tests\Storage\RevisionStoreDbTest, TemplateParserTest, BalancerTest, TimeAdjustTest, MediaWikiTitleCodecTest, NaiveImportTitleFactoryTest, NamespaceImportTitleFactoryTest, SubpageImportTitleFactoryTest, TitleMethodsTest, TitlePermissionTest, TitleTest, UploadBaseTest, UploadFromUrlTest, UploadStashTest, BotPasswordTest, LocalIdLookupTest, UserGroupMembershipTest, UserTest, MWCryptHKDFTest, MWGrantsTest, WatchedItemStoreIntegrationTest, WebRequestTest, WikiMapTest, XmlSelectTest, XmlTest, LanguageClassesTestCase, LanguageConverterTest, MediaWiki\Tests\Maintenance\BackupDumperPageTest, MediaWiki\Tests\Maintenance\TextPassDumperDatabaseTest, MediaWiki\Tests\Maintenance\DeleteAutoPatrolLogsTest, MediaWiki\Tests\Maintenance\DumpTestCase, MediaWiki\Tests\Maintenance\FetchTextTest, MediaWiki\Tests\Maintenance\MaintenanceBaseTestCase, MediaWikiLangTestCase, ResourceLoaderTestCase, SideBarTest, AutoLoaderTest, and DatabaseIntegrationTest.
Definition at line 492 of file MediaWikiTestCase.php.
References $services, needsDB(), Maintenance\setLBFactoryTriggers(), and wfRecursiveRemoveDir().
MediaWikiTestCase::setupAllTestDBs | ( | ) |
Set up all test DBs.
Definition at line 1205 of file MediaWikiTestCase.php.
References $wgDBprefix, and dbPrefix().
Referenced by run().
|
static |
Reimplemented in ApiFormatXmlTest, MWDebugTest, GitInfoTest, LogFormatterTest, and MediaWikiTestCaseTest.
Definition at line 138 of file MediaWikiTestCase.php.
|
staticprotected |
Setups a database with the given prefix.
If reuseDB is true and certain conditions apply, it will just change the prefix. Otherwise, it will clone the tables and change the prefix.
Clones all tables in the given database (whatever database that connection has open), to versions with the test prefix.
IMaintainableDatabase | $db | Database to use |
string | $prefix | Prefix to use for test tables |
Definition at line 1185 of file MediaWikiTestCase.php.
References CloneDatabase\changePrefix(), Wikimedia\Rdbms\IDatabase\getType(), and Wikimedia\Rdbms\IDatabase\tablePrefix().
|
staticprotected |
Clones the External Store database(s) for testing.
string | $testPrefix | Prefix for test tables |
Definition at line 1274 of file MediaWikiTestCase.php.
|
private |
Applies the schema overrides returned by getSchemaOverrides(), after undoing any previously applied schema overrides.
Called once per test class, just before addDataOnce().
Definition at line 1407 of file MediaWikiTestCase.php.
References dropMockTables(), ensureMockDatabaseConnection(), getSchemaOverrides(), listOriginalTables(), mungeSchemaUpdateQuery(), Wikimedia\Rdbms\IMaintainableDatabase\sourceFile(), and undoSchemaOverrides().
Referenced by run().
|
static |
Creates an empty skeleton of the wiki database by cloning its structure to equivalent tables using the given $prefix.
Then sets MediaWiki to use the new set of tables (aka schema) instead of the original set.
This is used to generate a dummy table set, typically consisting of temporary tables, that will be used by tests instead of the original wiki database tables.
Database | $db | The database connection |
string | $prefix | The prefix to use for the new table set (aka schema). |
MWException | If the database table prefix is already $prefix |
Definition at line 1241 of file MediaWikiTestCase.php.
References Wikimedia\Rdbms\IDatabase\getType(), Wikimedia\Rdbms\Database\query(), and Wikimedia\Rdbms\Database\tablePrefix().
MediaWikiTestCase::setUserLang | ( | $lang | ) |
string | Language | $lang |
Definition at line 883 of file MediaWikiTestCase.php.
References $lang, RequestContext\getMain(), and setMwGlobals().
Referenced by MessageCacheTest\configureLanguages(), OldChangesListTest\setUp(), ExtraParserTest\setUp(), HtmlTest\setUp(), MessageTest\setUp(), MediaWikiTitleCodecTest\setUp(), TitleTest\setUp(), MediaWikiLangTestCase\setUp(), TitleTest\testGetPageViewLanguage(), MessageTest\testInContentLanguage(), MessageTest\testInContentLanguageOverride(), and ArticleTablesTest\testTemplatelinksUsesContentLanguage().
|
protected |
Stashes the global, will be restored in tearDown()
Individual test functions may override globals through the setMwGlobals() function or directly. When directly overriding globals their keys should first be passed to this method in setUp to avoid breaking global state for other tests
That way all other tests are executed with the same settings (instead of using the unreliable local settings for most tests and fix it only for some tests).
array | string | $globalKeys | Key to the global variable, or an array of keys. |
Definition at line 730 of file MediaWikiTestCase.php.
References $e, $GLOBALS, containsClosure(), serialize(), and unserialize().
Referenced by GlobalVarConfigTest\maybeStashGlobal(), setGroupPermissions(), setMwGlobals(), ApiUserrightsTest\setPermissions(), MediaWiki\Auth\AuthManagerTest\setUp(), LocalIdLookupTest\setUp(), MediaWiki\Auth\AuthManagerTest\testAutoAccountCreation(), MediaWiki\Auth\AuthManagerTest\testCheckAccountCreatePermissions(), ApiMoveTest\testMoveSubpages(), MediaWiki\Auth\TemporaryPasswordAuthenticationRequestTest\testNewRandom(), ApiMoveTest\testPingLimiter(), MediaWikiTestCaseTest\testStashedGlobalsAreRestoredOnTearDown(), ApiQueryTitleBlacklistTest\testTboverride(), and ApiUserrightsTest\testWithoutTagPermission().
|
staticprotected |
Utility function for eliminating all string keys from an array.
Useful to turn a database result row as returned by fetchRow() into a pure indexed array.
mixed | &$r | The array to remove string keys from. |
Definition at line 1834 of file MediaWikiTestCase.php.
|
protected |
Reimplemented in CaptchaPreAuthenticationProviderTest, GadgetTest, SpamBlacklistTest, ApiQueryTitleBlacklistTest, ApiBlockTest, ApiEditPageTest, ApiTestCase, ContentHandlerTest, TextContentTest, DeprecatedGlobalTest, EditPageTest, MigrateFileRepoLayoutTest, StoreBatchTest, JobQueueTest, PageDataRequestHandlerTest, DatabaseLogEntryTest, WebPHandlerTest, ArticleTest, WikiPageDbTestBase, PagePropsTest, ParserOptionsTest, ParserPreloadTest, PrefixSearchTest, RevisionDbTestBase, SampleTest, SearchEnginePrefixTest, SearchEngineTest, AbstractChangesListSpecialPageTestCase, SpecialPageFactoryTest, SpecialPageTestBase, TitleMethodsTest, WebRequestTest, XmlSelectTest, XmlTest, LanguageClassesTestCase, LanguageConverterTest, MediaWiki\Tests\Maintenance\BaseDumpTest, MediaWiki\Tests\Maintenance\MaintenanceBaseTestCase, and DatabaseIntegrationTest.
Definition at line 534 of file MediaWikiTestCase.php.
References $GLOBALS, $value, $wgRequest, $wgSQLMode, needsDB(), RequestContext\resetMain(), restoreLoggers(), and wfRecursiveRemoveDir().
Referenced by MediaWikiTestCaseTest\testLoggersAreRestoredOnTearDown_replacingExistingLogger(), MediaWikiTestCaseTest\testLoggersAreRestoredOnTearDown_replacingNonExistingLogger(), MediaWikiTestCaseTest\testLoggersAreRestoredOnTearDown_replacingSameLoggerTwice(), MediaWikiTestCaseTest\testOverrideMwServices(), MediaWikiTestCaseTest\testSetGlobalsAreRestoredOnTearDown(), MediaWikiTestCaseTest\testSetNonExistentGlobalsAreUnsetOnTearDown(), MediaWikiTestCaseTest\testSetService(), and MediaWikiTestCaseTest\testStashedGlobalsAreRestoredOnTearDown().
|
static |
Restores MediaWiki to using the table set (table prefix) it was using before setupTestDB() was called.
Useful if we need to perform database operations after the test run has finished (such as saving logs or profiling info).
Definition at line 1152 of file MediaWikiTestCase.php.
References $type, $wgJobClasses, CloneDatabase\changePrefix(), and JobQueueGroup\singleton().
|
final |
Make sure MediaWikiTestCase extending classes have called their parent setUp method.
With strict coverage activated in PHP_CodeCoverage, this test would be marked as risky without the following annotation (T152923). @coversNothing
Definition at line 613 of file MediaWikiTestCase.php.
|
private |
Undoes the dpecified schema overrides.
Called once per test class, just before addDataOnce().
IMaintainableDatabase | $db | |
array | $oldOverrides |
Definition at line 1379 of file MediaWikiTestCase.php.
References dropMockTables(), ensureMockDatabaseConnection(), listOriginalTables(), and recloneMockTables().
Referenced by setUpSchema().
|
staticprivate |
Definition at line 1592 of file MediaWikiTestCase.php.
MediaWikiTestCase::usesTemporaryTables | ( | ) |
|
static |
Used as a marker to prevent wfResetOutputBuffers from breaking PHPUnit.
string | $buffer |
Definition at line 2003 of file MediaWikiTestCase.php.
References $buffer.
|
private |
$called tracks whether the setUp and tearDown method has been called.
class extending MediaWikiTestCase usually override setUp and tearDown but forget to call the parent.
The array format takes a method name as key and anything as a value. By asserting the key exist, we know the child class has called the parent.
This property must be private, we do not want child to override it, they should call the appropriate parent method instead.
Definition at line 43 of file MediaWikiTestCase.php.
Referenced by SpecialPageFactoryTest\testGetAliasListRecursion(), DeprecatedGlobalTest\testLazyLoad(), MediaWiki\Session\SessionManagerTest\testLoadSessionInfoFromStore(), HTMLCheckMatrixTest\testValidateCallsUserDefinedValidationCallback(), and LoadBalancerTest\testWithoutReplica().
|
protected |
Primary database.
Definition at line 57 of file MediaWikiTestCase.php.
Referenced by LoadBalancerTest\assertWriteAllowed(), LoadBalancerTest\assertWriteForbidden(), MediaWiki\Tests\Storage\RevisionStoreDbTest\getDatabaseMock(), RangeChronologicalPagerTest\getDateRangeCondProvider(), MediaWiki\Tests\Storage\NameTableStoreTest\getMockLoadBalancer(), BatchRowUpdateTest\mockDbConsecutiveSelect(), ActorMigrationTest\provideInsertRoundTrip(), CommentStoreTest\provideInsertRoundTrip(), LBFactoryTest\quoteTable(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testDomainCheck(), UserTest\testExperienceLevel(), ReverseChronologicalPagerTest\testGetDateCond(), MediaWiki\Tests\Storage\RevisionStoreTest\testGetTitle_correctFallbackAndthrowsExceptionAfterFallbacks(), MediaWiki\Tests\Storage\RevisionStoreTest\testGetTitle_successFromPageId(), MediaWiki\Tests\Storage\RevisionStoreTest\testGetTitle_successFromPageIdOnFallback(), MediaWiki\Tests\Storage\RevisionStoreTest\testGetTitle_successFromRevId(), MediaWiki\Tests\Storage\RevisionStoreTest\testGetTitle_successFromRevIdOnFallback(), WatchedItemQueryServiceUnitTest\testGetWatchedItemsWithRecentChangeInfo_extension(), LBFactoryTest\testInvalidSelectDB(), RevisionTest\testLoadFromTitle(), DatabaseLogEntryTest\testNewFromId(), RevisionDbTestBase\testNewKnownCurrent(), RevisionDbTestBase\testNewKnownCurrent_returnsFalseWhenTitleDoesntExist(), RevisionDbTestBase\testNewKnownCurrent_withPageId(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testNewRevisionFromArchiveRow(), MediaWiki\Tests\Storage\RevisionStoreDbTest\testNewRevisionFromArchiveRow_legacyEncoding(), LBFactoryTest\testNiceDomains(), BatchRowUpdateTest\testReaderBasicIterate(), BatchRowUpdateTest\testReaderSelectConditionsMultiplePrimaryKeys(), BatchRowUpdateTest\testReaderSetFetchColumns(), LBFactoryTest\testTrickyDomain(), ImportTest\testUnknownUserHandling(), and BatchRowUpdateTest\testWriterBasicFunctionality().
|
staticprivate |
Definition at line 67 of file MediaWikiTestCase.php.
|
private |
Holds original loggers which have been replaced by setLogger()
Definition at line 104 of file MediaWikiTestCase.php.
|
private |
Holds original values of MediaWiki configuration settings to be restored in tearDown().
See also setMwGlobals().
Definition at line 91 of file MediaWikiTestCase.php.
|
private |
Holds list of MediaWiki configuration settings to be unset in tearDown().
See also setMwGlobals().
Definition at line 98 of file MediaWikiTestCase.php.
|
staticprivate |
Definition at line 68 of file MediaWikiTestCase.php.
|
private |
Original value of PHP's error_reporting setting.
Definition at line 75 of file MediaWikiTestCase.php.
|
staticprivate |
Definition at line 66 of file MediaWikiTestCase.php.
|
staticprivate |
Definition at line 1347 of file MediaWikiTestCase.php.
|
staticprivate |
The service locator created by prepareServices().
This service locator will be restored after each test. Tests that pollute the global service locator instance should use overrideMwServices() to isolate the test.
Definition at line 29 of file MediaWikiTestCase.php.
Referenced by resetGlobalServices().
|
protected |
Definition at line 116 of file MediaWikiTestCase.php.
|
protected |
Definition at line 63 of file MediaWikiTestCase.php.
|
private |
Holds the paths of temporary files/directories created through getNewTempFile, and getNewTempDirectory.
Definition at line 83 of file MediaWikiTestCase.php.
Referenced by FileBackendTest\doTestGetLocalCopy(), and FileBackendTest\doTestGetLocalReference().
|
static |
Definition at line 49 of file MediaWikiTestCase.php.
Referenced by ApiQueryContributionsTest\addDBDataOnce(), ApiQueryContributionsTest\provideSorting(), UserTest\testFindUsersByGroup(), and ActorMigrationTest\testGetWhere().
|
staticprivate |
Definition at line 65 of file MediaWikiTestCase.php.
const MediaWikiTestCase::DB_PREFIX = 'unittest_' |
const MediaWikiTestCase::ORA_DB_PREFIX = 'ut_' |
Definition at line 110 of file MediaWikiTestCase.php.