MediaWiki
1.28.0
|
Inherits PHPUnit_Framework_TestCase.
Inherited by ActionTest, ApiContinuationManagerTest, ApiDocumentationTest, ApiFormatTestBase, ApiMessageTest, ApiModuleManagerTest, ApiOpenSearchTest, ApiResultTest, ArrayDiffFormatterTest, ArticleTest, AutoLoaderTest, BadTitleErrorTest, BagOStuffTest, BalancerTest, BaseDumpTest, BatchRowUpdateTest, BitmapMetadataHandlerTest, BitmapScalingTest, BotPasswordTest, CachingSiteStoreTest, CategoryMembershipChangeJobTest, CdnCacheUpdateTest, CentralIdLookupTest, ClassicInterwikiLookupTest, ComposerJsonTest, ComposerLockTest, ConfigFactoryTest, ContentHandlerSanityTest, ContentHandlerTest, CSSMinTest, DatabaseMysqlBaseTest, DatabaseSqliteTest, DatabaseSQLTest, DatabaseTest, DatabaseUpdaterTest, DBSiteStoreTest, DeferredUpdatesTest, DifferenceEngineTest, DiffHistoryBlobTest, DiffOpTest, DiffTest, DummyExtensionsTest, ErrorPageErrorTest, ExifTest, ExtensionProcessorTest, ExtensionRegistryTest, ExternalStoreTest, ExtraParserTest, FauxResponseTest, FetchTextTest, FileBackendDBRepoWrapperTest, FileBackendTest, FileRepoTest, ForeignTitleTest, FormatJsonTest, FormOptionsInitializationTest, FormOptionsTest, GIFMetadataExtractorTest, GitInfoTest, GlobalTest, GlobalVarConfigTest, GlobalWithDBTest, HashConfigTest, HashSiteStoreTest, HooksTest, HtmlAutoCompleteSelectFieldTest, HtmlCheckMatrixTest, HTMLFormTest, HtmlTest, HttpErrorTest, HttpTest, ImageListPagerTest, ImportLinkCacheIntegrationTest, InstallDocFormatterTest, InterwikiTest, IPTCTest, JobQueueTest, JobTest, JpegMetadataExtractorTest, JsonContentHandlerTest, LanguageClassesTestCase, LBFactoryTest, LicensesTest, LocalFileTest, LocalIdLookupTest, LocalisationCacheTest, MagicVariableTest, MailAddressTest, MaintenanceTest, MediaHandlerTest, MediaWiki\Auth\AbstractAuthenticationProviderTest, MediaWiki\Auth\AbstractPasswordPrimaryAuthenticationProviderTest, MediaWiki\Auth\AbstractPreAuthenticationProviderTest, MediaWiki\Auth\AbstractPrimaryAuthenticationProviderTest, MediaWiki\Auth\AbstractSecondaryAuthenticationProviderTest, MediaWiki\Auth\AuthenticationRequestTest, MediaWiki\Auth\AuthenticationRequestTestCase, MediaWiki\Auth\AuthenticationResponseTest, MediaWiki\Auth\AuthManagerTest, MediaWiki\Auth\AuthPluginPrimaryAuthenticationProviderTest, 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, MediaWikiLangTestCase, MediaWikiMediaTestCase, MediaWikiServicesTest, MediaWikiTest, MediaWikiTestCaseTest, MediaWikiTitleCodecTest, MemcachedBagOStuffTest, MergeHistoryTest, MigrateFileRepoLayoutTest, MovePageTest, MultiConfigTest, MultiWriteBagOStuffTest, MWCryptHKDFTest, MWDebugTest, MWExceptionHandlerTest, MWExceptionTest, MWGrantsTest, MWNamespaceTest, NaiveForeignTitleFactoryTest, NaiveImportTitleFactoryTest, NamespaceAwareForeignTitleFactoryTest, NamespaceImportTitleFactoryTest, OracleInstallerTest, OutputPageTest, ParserOutputTest, ParserPreloadTest, PasswordPolicyChecksTest, PasswordTest, PasswordTestCase, PathRouterTest, PNGMetadataExtractorTest, PoolCounterTest, PreferencesTest, PrefixUniquenessTest, PreprocessorTest, QueryAllSpecialPagesTest, ReadOnlyErrorTest, RecentChangeTest, RefreshLinksPartitionTest, ReplicatedBagOStuffTest, RepoGroupTest, RequestContextTest, ResourceLoaderTestCase, ResourcesTest, RESTBagOStuffTest, RevisionStorageTest, RevisionTest, SanitizerTest, SearchIndexFieldTest, SearchUpdateTest, SiteConfigurationTest, SiteListTest, SiteTest, SkinFactoryTest, SkinTemplateTest, SpecialMIMESearchTest, SpecialMyLanguageTest, SpecialPageAliasTest, SpecialPageFactoryTest, SpecialPageTest, SpecialPageTestBase, SpecialPreferencesTest, SpecialRecentchangesTest, SpecialSearchTest, StoreBatchTest, StructureTest, SubpageImportTitleFactoryTest, SVGMetadataExtractorTest, SwiftFileBackendTest, TagHookTest, TemplateParserTest, TestingAccessWrapperTest, ThrottledErrorTest, TidyTest, TiffTest, TitleTest, TitleValueTest, UploadBaseTest, UploadStashTest, UserArrayFromResultTest, UserNotLoggedInTest, UserPasswordPolicyTest, UserTest, WatchedItemIntegrationTest, WatchedItemStoreIntegrationTest, WatchedItemStoreUnitTest, WatchedItemUnitTest, WebPHandlerTest, WebRequestTest, WfAppendQueryTest, WfArrayPlus2dTest, WfAssembleUrlTest, WfBaseNameTest, WfBCP47Test, WfEscapeShellArgTest, WfExpandUrlTest, WfGetCallerTest, WfParseUrlTest, WfRemoveDotSegmentsTest, WfShellExecTest, WfShorthandToIntegerTest, WfThumbIsStandardTest, WfTimestampTest, WfUrlencodeTest, XmlSelectTest, and XmlTest.
Public Member Functions | |
__call ($func, $args) | |
__construct ($name=null, array $data=[], $dataName= '') | |
__destruct () | |
addDBData () | |
Stub. More... | |
addDBDataOnce () | |
Stub. More... | |
dbPrefix () | |
getCliArg ($offset) | |
hideDeprecated ($function) | |
Don't throw a warning if $function is deprecated and called later. More... | |
needsDB () | |
run (PHPUnit_Framework_TestResult $result=null) | |
setCliArg ($offset, $value) | |
setContentLang ($lang) | |
setupAllTestDBs () | |
Set up all test DBs. More... | |
setUserLang ($lang) | |
testMediaWikiTestCaseParentSetupCalled () | |
Make sure MediaWikiTestCase extending classes have called their parent setUp method. More... | |
usesTemporaryTables () | |
Static Public Member Functions | |
static | assertNotTag ($matcher, $actual, $message= '', $isHtml=true) |
static | assertTag ($matcher, $actual, $message= '', $isHtml=true) |
Note: we are overriding this method to remove the deprecated error. More... | |
static | getMutableTestUser ($groups=[]) |
Convenience method for getting a mutable test user. More... | |
static | getTestSysop () |
Convenience method for getting an immutable admin test user. More... | |
static | getTestUser ($groups=[]) |
Convenience method for getting an immutable test user. More... | |
static | listTables (Database $db) |
static | prepareServices (Config $bootstrapConfig) |
Prepare service configuration for unit testing. More... | |
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. More... | |
static | teardownTestDB () |
Restores MediaWiki to using the table set (table prefix) it was using before setupTestDB() was called. More... | |
static | wfResetOutputBuffersBarrier ($buffer) |
Used as a marker to prevent wfResetOutputBuffers from breaking PHPUnit. More... | |
Public Attributes | |
const | DB_PREFIX = 'unittest_' |
Table name prefixes. More... | |
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. More... | |
assertArrayEquals (array $expected, array $actual, $ordered=false, $named=false) | |
Assert that two arrays are equal. More... | |
assertHTMLEquals ($expected, $actual, $msg= '') | |
Put each HTML element on its own line and then equals() the results. More... | |
assertSelect ($table, $fields, $condition, array $expectedRows) | |
Asserts that the given database query yields the rows given by $expectedRows. More... | |
assertType ($type, $actual, $message= '') | |
Asserts the type of the provided value. More... | |
assertTypeOrValue ($type, $actual, $value=false, $message= '') | |
Asserts that the provided variable is of the specified internal type or equals the $value argument. More... | |
assertValidHtmlDocument ($html) | |
Asserts that the given string is valid HTML document. More... | |
assertValidHtmlSnippet ($html) | |
Asserts that the given string is a valid HTML snippet. More... | |
checkDbIsSupported () | |
checkPHPExtension ($extName) | |
Check if $extName is a loaded PHP extension, will skip the test whenever it is not loaded. More... | |
getDefaultWikitextNS () | |
Returns the ID of a namespace that defaults to Wikitext. More... | |
getNewTempDirectory () | |
obtains a new temporary directory More... | |
getNewTempFile () | |
Obtains a new temporary file name. More... | |
insertPage ($pageName, $text= 'Sample page for unit test.', $namespace=null) | |
Insert a new page. More... | |
isWikitextNS ($ns) | |
Returns true if the given namespace defaults to Wikitext according to $wgNamespaceContentModels. More... | |
markTestSkippedIfNoDiff3 () | |
Check, if $wgDiff3 is set and ready to merge Will mark the calling test as skipped, if not ready. More... | |
mergeMwGlobalArrayValue ($name, $values) | |
Merges the given values into a MW global array variable. More... | |
objectAssociativeSort (array &$array) | |
Does an associative sort that works for objects. More... | |
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. More... | |
setLogger ($channel, LoggerInterface $logger) | |
Sets the logger for a specified channel, for the duration of the test. More... | |
setMwGlobals ($pairs, $value=null) | |
setService ($name, $object) | |
Sets a service, maintaining a stashed version of the previous service to be restored in tearDown. More... | |
setTemporaryHook ($hookName, $handler) | |
Create a temporary hook handler which will be reset by tearDown. More... | |
setUp () | |
stashMwGlobals ($globalKeys) | |
Stashes the global, will be restored in tearDown() More... | |
tearDown () | |
Static Protected Member Functions | |
static | getExternalStoreDatabaseConnections () |
Gets master database connections for all of the ExternalStoreDB stores configured in $wgDefaultExternalStore. More... | |
static | isUsingExternalStoreDB () |
Check whether ExternalStoreDB is being used. More... | |
static | resetGlobalServices (Config $bootstrapConfig=null) |
Reset global services, and install testing environment. More... | |
static | setupDatabaseWithTestPrefix (Database $db, $prefix) |
Setups a database with the given prefix. More... | |
static | setupExternalStoreTestDBs ($testPrefix) |
Clones the External Store database(s) for testing. More... | |
static | stripStringKeys (&$r) |
Utility function for eliminating all string keys from an array. More... | |
Protected Attributes | |
Database | $db |
Primary database. More... | |
array | $supportedDBs |
array | $tablesUsed = [] |
Private Member Functions | |
addCoreDBData () | |
assertEmpty2 ($value, $msg) | |
Used as a compatibility method for phpunit < 3.7.32. More... | |
doLightweightServiceReset () | |
Resets some well known services that typically have state that may interfere with unit tests. More... | |
oncePerClass () | |
resetDB ($db, $tablesUsed) | |
Empty all tables so they can be repopulated for tests. More... | |
restoreLoggers () | |
Restores loggers replaced by setLogger(). More... | |
Static Private Member Functions | |
static | canShallowCopy ($value) |
Check if we can back up a value by performing a shallow copy. More... | |
static | installTestServices (ConfigFactory $oldConfigFactory, 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. More... | |
static | makeTestConfigFactoryInstantiator (ConfigFactory $oldFactory, array $configurations) |
static | tagMatch ($matcher, $actual, $isHtml=true) |
static | unprefixTable (&$tableName, $ind, $prefix) |
Private Attributes | |
$called = [] | |
$called tracks whether the setUp and tearDown method has been called. More... | |
LoggerInterface[] | $loggers = [] |
Holds original loggers which have been replaced by setLogger() More... | |
array | $mwGlobals = [] |
Holds original values of MediaWiki configuration settings to be restored in tearDown(). More... | |
int | $phpErrorLevel |
Original value of PHP's error_reporting setting. More... | |
array | $tmpFiles = [] |
Holds the paths of temporary files/directories created through getNewTempFile, and getNewTempDirectory. More... | |
Static Private Attributes | |
static | $dbSetup = false |
static | $oldTablePrefix = '' |
static | $reuseDB = false |
static MediaWikiServices null | $serviceLocator = null |
The service locator created by prepareServices(). More... | |
static | $useTemporaryTables = true |
Definition at line 11 of file MediaWikiTestCase.php.
MediaWikiTestCase::__construct | ( | $name = null , |
|
array | $data = [] , |
||
$dataName = '' |
|||
) |
Definition at line 107 of file MediaWikiTestCase.php.
References $name.
MediaWikiTestCase::__destruct | ( | ) |
Definition at line 114 of file MediaWikiTestCase.php.
References class.
MediaWikiTestCase::__call | ( | $func, | |
$args | |||
) |
string | $func | |
array | $args |
MWException |
Definition at line 1283 of file MediaWikiTestCase.php.
References $args.
|
private |
Definition at line 990 of file MediaWikiTestCase.php.
References $page, $user, EDIT_NEW, WikiPage\factory(), Title\newFromText(), and User\resetIdByNameCache().
MediaWikiTestCase::addDBData | ( | ) |
Stub.
Subclasses may override this to prepare the database. Called before every test run (test function or data set).
Definition at line 987 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().
Definition at line 975 of file MediaWikiTestCase.php.
Referenced by run().
|
protected |
Definition at line 500 of file MediaWikiTestCase.php.
References $files, and array().
Referenced by FileBackendTest\doTestDoOperationsPipeline(), 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 1450 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 1471 of file MediaWikiTestCase.php.
References objectAssociativeSort().
Referenced by BotPasswordTest\testCanonicalizeLoginData(), ResourcesTest\testCommentedLocalFileReferences(), SiteListTest\testGetGlobalIdentifiers(), ApiModuleManagerTest\testGetGroups(), DjVuTest\testGetImageSize(), ComposerLockTest\testGetInstalledDependencies(), ApiModuleManagerTest\testGetNames(), ApiModuleManagerTest\testGetNamesWithClasses(), DjVuTest\testGetPageDimensions(), TextContentTest\testGetParserOutput(), UserPasswordPolicyTest\testGetPoliciesForGroups(), UserPasswordPolicyTest\testGetPoliciesForUser(), ComposerJsonTest\testGetRequiredDependencies(), MediaWiki\Session\CookieSessionProviderTest\testGetVaryCookies(), PoolCounterTest\testHashKeyIntoSlots(), WikitextStructureTest\testHeadingsNone(), UserPasswordPolicyTest\testMaxOfPolicies(), StatusTest\testOkAndErrorsGetters(), SiteListTest\testSerialization(), and LinksUpdateTest\testUpdate_pagelinks().
|
private |
Used as a compatibility method for phpunit < 3.7.32.
string | $value | |
string | $msg |
Definition at line 1301 of file MediaWikiTestCase.php.
References $value.
|
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 1502 of file MediaWikiTestCase.php.
|
static |
array | $matcher | |
string | $actual | |
string | $message | |
bool | $isHtml |
Definition at line 1793 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. |
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 1410 of file MediaWikiTestCase.php.
References $res, as, DB_SLAVE, IDatabase\lastError(), needsDB(), Database\select(), wfGetCaller(), and wfGetDB().
Referenced by LinksUpdateTest\assertLinksUpdate(), and LinksUpdateTest\assertRecentChangeByCategorization().
|
static |
Note: we are overriding this method to remove the deprecated error.
array | $matcher | |
string | $actual | |
string | $message | |
bool | $isHtml |
Definition at line 1778 of file MediaWikiTestCase.php.
Referenced by RCCacheEntryFactoryTest\assertDeleteLogLink(), RCCacheEntryFactoryTest\assertQueryLink(), RCCacheEntryFactoryTest\assertRevDel(), RCCacheEntryFactoryTest\assertTitleLink(), and RCCacheEntryFactoryTest\assertUserLinks().
|
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 1578 of file MediaWikiTestCase.php.
References $type.
Referenced by assertTypeOrValue(), MediaWiki\Auth\AbstractAuthenticationProviderTest\testAbstractAuthenticationProvider(), ActionTest\testActionFactory(), MediaWiki\Auth\AuthenticationRequestTest\testBasics(), JobQueueTest\testDeduplicationWhileClaimed(), MediaWiki\Auth\AuthenticationRequestTestCase\testGetFieldInfo(), BagOStuffTest\testGetScopedLock(), and DatabaseTest\testMutators().
|
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 1559 of file MediaWikiTestCase.php.
References $type, $value, and assertType().
Referenced by SiteTest\testGetGlobalId(), SiteTest\testGetLanguageCode(), and SiteTest\testGetPath().
|
protected |
Asserts that the given string is valid HTML document.
string | $html | A complete HTML document |
Definition at line 1729 of file MediaWikiTestCase.php.
References $GLOBALS, $html, MWTidy\checkErrors(), and MWTidy\isEnabled().
Referenced by assertValidHtmlSnippet().
|
protected |
Asserts that the given string is a valid HTML snippet.
Wraps the given string in the required top level tags and then calls assertValidHtmlDocument(). The snippet is expected to be HTML 5.
string | $html | An HTML snippet (treated as the contents of the body tag). |
Definition at line 1713 of file MediaWikiTestCase.php.
References $html, and assertValidHtmlDocument().
|
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 660 of file MediaWikiTestCase.php.
|
protected |
MWException |
Definition at line 1353 of file MediaWikiTestCase.php.
References $supportedDBs.
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 1690 of file MediaWikiTestCase.php.
Referenced by DiffHistoryBlobTest\setUp(), FormatMetadataTest\setUp(), JpegTest\setUp(), CollationTest\setUp(), ExifRotationTest\setUp(), ExifTest\setUp(), ExifBitmapTest\setUp(), TiffTest\setUp(), RevisionTest\testCompressRevisionTextUtf8Gzip(), RevisionTest\testGetRevisionTextGzip(), RevisionTest\testGetRevisionTextUtf8LegacyGzip(), RevisionTest\testGetRevisionTextUtf8NativeGzip(), BitmapMetadataHandlerTest\testMultilingualCascade(), and PNGMetadataExtractorTest\testPngNativetZtxt().
MediaWikiTestCase::dbPrefix | ( | ) |
Definition at line 899 of file MediaWikiTestCase.php.
Referenced by DatabaseTest\prefixAndQuote(), and setupAllTestDBs().
|
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 334 of file MediaWikiTestCase.php.
References $services, $wgRequest, ObjectCache\clear(), FileBackendGroup\destroySingleton(), JobQueueGroup\destroySingletons(), global, MediaWiki\Session\SessionManager\resetCache(), and RequestContext\resetMain().
Referenced by run().
MediaWikiTestCase::getCliArg | ( | $offset | ) |
string | $offset |
Definition at line 1364 of file MediaWikiTestCase.php.
References PHPUnitMaintClass\$additionalOptions.
Referenced by run(), BagOStuffTest\setUp(), StoreBatchTest\setUp(), FileBackendTest\setUp(), JobQueueTest\setUp(), and BagOStuffTest\testMerge().
|
protected |
Returns the ID of a namespace that defaults to Wikitext.
MWException | If there is none. |
Definition at line 1612 of file MediaWikiTestCase.php.
References $namespaces, as, CONTENT_MODEL_WIKITEXT, MWNamespace\getContentNamespaces(), MWNamespace\getValidNamespaces(), global, MWNamespace\isTalk(), NS_CATEGORY, NS_FILE, NS_HELP, NS_MAIN, NS_MEDIAWIKI, NS_PROJECT, and NS_USER.
Referenced by TextPassDumperDatabaseTest\addDBData(), FetchTextTest\addDBData(), EditPageTest\assertEdit(), RevisionStorageTest\createPage(), TestPageProps\createPage(), DifferenceEngineTest\getTitle(), WikiPageTest\newPage(), EditPageTest\testAutoMerge(), TextContentTest\testDeletionUpdates(), WikitextContentTest\testGetSecondaryDataUpdates(), and RevisionStorageTest\testUserWasLastToEdit().
|
staticprotected |
Gets master database connections for all of the ExternalStoreDB stores configured in $wgDefaultExternalStore.
Definition at line 1188 of file MediaWikiTestCase.php.
References $wgDefaultExternalStore, array(), as, DB_MASTER, ExternalStore\getStoreObject(), global, and list.
|
static |
Convenience method for getting a mutable test user.
string[] | $groups Groups the test user should be added in. |
Definition at line 149 of file MediaWikiTestCase.php.
References TestUserRegistry\getMutableTestUser().
Referenced by LocalIdLookupTest\addDBData(), GenderCacheTest\addDBDataOnce(), EnhancedChangesListTest\getCategorizationChange(), OldChangesListTest\getContext(), RCCacheEntryFactoryTest\getContext(), EnhancedChangesListTest\getEditChange(), OldChangesListTest\getEditChange(), OldChangesListTest\getLogChange(), OldChangesListTest\getNewBotEditChange(), ApiQueryWatchlistRawIntegrationTest\setUp(), BotPasswordTest\setUp(), ApiQueryWatchlistIntegrationTest\setUp(), MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProviderTest\testAuthentication(), MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProviderTest\testBasics(), UserTest\testCheckAndSetTouched(), UserTest\testEquals(), UserTest\testFindUsersByGroup(), UserTest\testGetEditCount(), UserTest\testIncEditCount(), UserTest\testLoggedIn(), RCCacheEntryFactoryTest\testNewForDeleteChange(), RCCacheEntryFactoryTest\testNewForRevUserDeleteChange(), RCCacheEntryFactoryTest\testNewFromRecentChange(), UserTest\testOptions(), MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProviderTest\testProviderChangeAuthenticationData(), MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProviderTest\testSetPasswordResetFlag(), and MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProviderTest\testTestUserCanAuthenticate().
|
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 450 of file MediaWikiTestCase.php.
References getNewTempFile(), and wfMkdirParents().
Referenced by TextPassDumperDatabaseTest\checkpointHelper(), MigrateFileRepoLayoutTest\setUp(), MediaWikiMediaTestCase\setUp(), StoreBatchTest\setUp(), FileBackendTest\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 433 of file MediaWikiTestCase.php.
References wfTempDir().
Referenced by TextPassDumperDatabaseTest\checkpointHelper(), UploadBaseTest\createFileOfSize(), FileBackendTest\doTestConcatenate(), ApiTestCaseUpload\fakeUploadChunk(), ApiTestCaseUpload\fakeUploadFile(), getNewTempDirectory(), GlobalTest\setUp(), BaseDumpTest\setUpPrefetch(), TextPassDumperDatabaseTest\setUpStub(), UploadBaseTest\testCheckXMLEncodingMissmatch(), BackupDumperPageTest\testCurrentStubGzip(), BackupDumperPageTest\testCurrentStubPlain(), GlobalTest\testDebugFunctionTest(), BackupDumperPageTest\testFullStubPlain(), BackupDumperPageTest\testFullTextPlain(), TextPassDumperDatabaseTest\testPlain(), BackupDumperLoggerTest\testPlain(), TextPassDumperDatabaseTest\testPrefetchPlain(), ExifBitmapTest\testSwappingICCProfile(), ApiUploadTest\testUploadZeroLength(), GlobalTest\testWfMkdirParents(), BackupDumperPageTest\testXmlDumpsBackupUseCase(), and BackupDumperLoggerTest\testXmlDumpsBackupUseCaseLogging().
|
static |
Convenience method for getting an immutable admin test user.
string[] | $groups Groups the test user should be added to. |
Definition at line 161 of file MediaWikiTestCase.php.
|
static |
Convenience method for getting an immutable test user.
string[] | $groups Groups the test user should be in. |
Definition at line 137 of file MediaWikiTestCase.php.
References TestUserRegistry\getImmutableTestUser().
Referenced by ApiMainTest\testAssertUser().
MediaWikiTestCase::hideDeprecated | ( | $function | ) |
Don't throw a warning if $function is deprecated and called later.
string | $function |
Definition at line 1386 of file MediaWikiTestCase.php.
References wfDeprecated().
Referenced by WatchedItemIntegrationTest\setUp(), MediaWiki\Auth\AuthManagerTest\testAutoAccountCreation(), RevisionTest\testConstructWithContent(), RevisionTest\testConstructWithText(), BlockTest\testDeprecatedConstructor(), WikiPageTest\testDoEdit(), LBFactoryTest\testGetLBFactoryClass(), LinkerTest\testGetLinkColour(), RevisionStorageTest\testGetText(), RevisionTest\testGetText(), WikiPageTest\testGetText(), MediaWiki\Session\PHPSessionHandlerTest\testSessionHandling(), and ArticleTest\testStaticFunctions().
|
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 933 of file MediaWikiTestCase.php.
References $comment, $page, $title, $user, WikiPage\factory(), ContentHandler\makeContent(), and Title\newFromText().
Referenced by MergeHistoryTest\addDBDataOnce(), PrefixSearchTest\addDBDataOnce(), SearchEnginePrefixTest\addDBDataOnce(), CategoryMembershipChangeJobTest\addDBDataOnce(), SearchEngineTest\addDBDataOnce(), LinksUpdateTest\addDBDataOnce(), ContentHandlerTest\addDBDataOnce(), and CategoryMembershipChangeTest\addDBDataOnce().
|
staticprivate |
ConfigFactory | $oldConfigFactory | |
MediaWikiServices | $newServices |
MWException |
Definition at line 275 of file MediaWikiTestCase.php.
References MediaWiki\MediaWikiServices\getBootstrapConfig(), MediaWiki\Services\ServiceContainer\redefineService(), and MediaWiki\MediaWikiServices\resetServiceForTesting().
|
staticprivate |
Definition at line 1309 of file MediaWikiTestCase.php.
|
staticprotected |
Check whether ExternalStoreDB is being used.
Definition at line 1214 of file MediaWikiTestCase.php.
References $wgDefaultExternalStore, array(), as, and global.
|
protected |
Returns true if the given namespace defaults to Wikitext according to $wgNamespaceContentModels.
int | $ns | The namespace ID to check |
Definition at line 1595 of file MediaWikiTestCase.php.
References CONTENT_MODEL_WIKITEXT, and global.
Referenced by PrefixSearchTest\addDBDataOnce(), SearchEnginePrefixTest\addDBDataOnce(), SearchEngineTest\addDBDataOnce(), SearchEngineTest\fetchIds(), SearchEnginePrefixTest\setUp(), PrefixSearchTest\setUp(), and TitlePermissionTest\testQuickPermissions().
|
static |
Database | $db |
Definition at line 1320 of file MediaWikiTestCase.php.
References $tables, IDatabase\getType(), Database\listTables(), Database\listViews(), and Database\tablePrefix().
|
staticprivate |
Create a config suitable for testing, based on a base config, default overrides, and custom overrides.
Definition at line 231 of file MediaWikiTestCase.php.
References CACHE_ACCEL, CACHE_DB, CACHE_MEMCACHED, CACHE_NONE, and false.
|
staticprivate |
ConfigFactory | $oldFactory | |
Config[] | $configurations |
Definition at line 298 of file MediaWikiTestCase.php.
References $name, $services, as, ConfigFactory\getConfigNames(), ConfigFactory\makeConfig(), and use.
|
protected |
Check, if $wgDiff3 is set and ready to merge Will mark the calling test as skipped, if not ready.
Definition at line 1668 of file MediaWikiTestCase.php.
References global.
Referenced by EditPageTest\testAutoMerge(), GlobalTest\testMerge(), and WikitextContentHandlerTest\testMerge3().
|
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 746 of file MediaWikiTestCase.php.
References $GLOBALS, $name, as, and setMwGlobals().
Referenced by TextPassDumperDatabaseTest\addDBData(), GenderCacheTest\addDBDataOnce(), MediaWiki\Auth\LegacyHookPreAuthenticationProviderTest\hook(), setTemporaryHook(), AutoLoaderTest\setUp(), PageLangLogFormatterTest\setUp(), RevisionTest\setUp(), NewUsersLogFormatterTest\setUp(), TitleMethodsTest\setUp(), ApiRevisionDeleteTest\setUp(), BotPasswordTest\setUp(), ApiOptionsTest\setUp(), SearchEngineTest\testAugmentorSearch(), TitleTest\testCreateFragmentTitle(), MediaWiki\Session\SessionBackendTest\testDelaySave(), SpecialMyLanguageTest\testFindTitle(), SpecialPageFactoryTest\testGetAliasListRecursion(), UserTest\testGetCanonicalName(), SpecialPageFactoryTest\testGetNames(), MediaWiki\Auth\AbstractPasswordPrimaryAuthenticationProviderTest\testGetNewPasswordExpiry(), SpecialPageFactoryTest\testGetPage(), SpecialPageFactoryTest\testHookNotCalledTwice(), ApiMainTest\testLacksSameOriginSecurity(), MediaWiki\Session\SessionManagerTest\testLoadSessionInfoFromStore(), MediaWiki\Session\CookieSessionProviderTest\testPersistSession(), MediaWiki\Session\CookieSessionProviderTest\testPersistSessionWithHook(), MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProviderTest\testProviderChangeAuthenticationData(), MediaWiki\Auth\AbstractPrimaryAuthenticationProviderTest\testProviderNormalizeUsername(), LocalisationCacheTest\testRecacheFallbacksWithHooks(), MediaWiki\Session\SessionBackendTest\testRenew(), MediaWiki\Session\SessionBackendTest\testSave(), MediaWiki\Session\PHPSessionHandlerTest\testSessionHandling(), MediaWiki\Auth\ThrottlePreAuthenticationProviderTest\testTestForAccountCreation(), UserTest\testUserGetRightsHooks(), and MediaWiki\Auth\LegacyHookPreAuthenticationProviderTest\unhook().
MediaWikiTestCase::needsDB | ( | ) |
Definition at line 907 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 1516 of file MediaWikiTestCase.php.
References serialize().
Referenced by assertArrayEquals().
|
private |
Definition at line 402 of file MediaWikiTestCase.php.
References class.
Referenced by run().
|
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 778 of file MediaWikiTestCase.php.
References $name, $services, as, MediaWikiServices, and Hooks\run().
Referenced by setService(), InterwikiTest\setWgInterwikiCache(), and MediaWikiTestCaseTest\testOverrideMwServices().
|
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 184 of file MediaWikiTestCase.php.
References $services.
Referenced by PHPUnitMaintClass\execute().
|
private |
Empty all tables so they can be repopulated for tests.
Definition at line 1236 of file MediaWikiTestCase.php.
References addCoreDBData(), as, TestUserRegistry\clear(), Database\delete(), IDatabase\getType(), Database\query(), LinkCache\singleton(), and 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 206 of file MediaWikiTestCase.php.
References $serviceLocator.
|
private |
Restores loggers replaced by setLogger().
Definition at line 872 of file MediaWikiTestCase.php.
References as, and TestingAccessWrapper\newFromObject().
Referenced by tearDown().
MediaWikiTestCase::run | ( | PHPUnit_Framework_TestResult | $result = null | ) |
Definition at line 356 of file MediaWikiTestCase.php.
References addCoreDBData(), addDBData(), addDBDataOnce(), checkDbIsSupported(), DB_MASTER, doLightweightServiceReset(), getCliArg(), needsDB(), oncePerClass(), resetDB(), run, setupAllTestDBs(), and wfGetDB().
MediaWikiTestCase::setCliArg | ( | $offset, | |
$value | |||
) |
string | $offset | |
mixed | $value |
Definition at line 1375 of file MediaWikiTestCase.php.
References PHPUnitMaintClass\$additionalOptions, and $value.
MediaWikiTestCase::setContentLang | ( | $lang | ) |
string | Language | $lang |
Definition at line 823 of file MediaWikiTestCase.php.
References $lang, Language\factory(), and setMwGlobals().
Referenced by MessageCacheTest\configureLanguages(), HtmlTest\setUp(), MediaWikiLangTestCase\setUp(), TitleTest\setUp(), ExtraParserTest\setUp(), CategoryMembershipChangeJobTest\setUp(), MediaWikiTitleCodecTest\setUp(), CategoryMembershipChangeTest\setUp(), InterwikiTest\testConstructor(), TitleTest\testGetPageViewLanguage(), and ArticleTablesTest\testTemplatelinksUsesContentLanguage().
|
protected |
Sets the logger for a specified channel, for the duration of the test.
string | $channel | |
LoggerInterface | $logger |
Definition at line 843 of file MediaWikiTestCase.php.
References TestingAccessWrapper\newFromObject().
Referenced by MediaWikiTestCaseTest\testLoggersAreRestoredOnTearDown().
|
protected |
Definition at line 640 of file MediaWikiTestCase.php.
References $GLOBALS, $value, as, and stashMwGlobals().
Referenced by BackupDumperPageTest\addDBData(), SearchEngineTest\addDBDataOnce(), EditPageTest\assertEdit(), OutputPageTest\assertTransformCssMediaCase(), mergeMwGlobalArrayValue(), SearchEnginePrefixTest\searchProvision(), PrefixSearchTest\searchProvision(), TitleTest\secureAndSplitGlobals(), setContentLang(), ImagePageTest\setUp(), MediaWikiTest\setUp(), MWGrantsTest\setUp(), ResourceLoaderTest\setUp(), PageLangLogFormatterTest\setUp(), MessageTest\setUp(), HtmlTest\setUp(), MWTimestampTest\setUp(), RevisionTest\setUp(), GitInfoTest\setUp(), GlobalTest\setUp(), TestSample\setUp(), TitleTest\setUp(), LinkFilterTest\setUp(), XmlTest\setUp(), BitmapMetadataHandlerTest\setUp(), BitmapScalingTest\setUp(), SvgTest\setUp(), FormatMetadataTest\setUp(), WfThumbIsStandardTest\setUp(), LocalisationCacheTest\setUp(), MWCryptHKDFTest\setUp(), LanguageConverterTest\setUp(), JpegTest\setUp(), LocalFileTest\setUp(), WikiPageTestContentHandlerUseDB\setUp(), RevisionTestContentHandlerUseDB\setUp(), ApiTestCaseUpload\setUp(), ApiQueryTest\setUp(), TemplateParserTest\setUp(), CSSMinTest\setUp(), ContentHandlerTest\setUp(), WikiMapTest\setUp(), ImagePage404Test\setUp(), ApiTestCase\setUp(), TextContentTest\setUp(), UploadBaseTest\setUp(), UploadFromUrlTest\setUp(), CssContentTest\setUp(), ExportTest\setUp(), SpecialPageTest\setUp(), ExifRotationTest\setUp(), ExifTest\setUp(), ActionTest\setUp(), ExifBitmapTest\setUp(), TiffTest\setUp(), SpecialRecentchangesTest\setUp(), EditPageTest\setUp(), ExtraParserTest\setUp(), MediaWiki\Auth\UserDataAuthenticationRequestTest\setUp(), UserTest\setUp(), ApiEditPageTest\setUp(), MWNamespaceTest\setUp(), LinkRendererTest\setUp(), BotPasswordTest\setUp(), SearchEngineTest\setUp(), CategoryMembershipChangeJobTest\setUp(), TitlePermissionTest\setUp(), OldChangesListTest\setUp(), WfParseUrlTest\setUp(), SearchUpdateTest\setUp(), NaiveImportTitleFactoryTest\setUp(), NamespaceImportTitleFactoryTest\setUp(), SubpageImportTitleFactoryTest\setUp(), LinksUpdateTest\setUp(), MediaWikiTitleCodecTest\setUp(), RCCacheEntryFactoryTest\setUp(), MediaWiki\Auth\AuthManagerTest\setUp(), LogFormatterTest\setUp(), PreferencesTest\setUp(), MagicVariableTest\setUp(), PrefixSearchTest\setUp(), SearchEnginePrefixTest\setUp(), MediaWiki\Session\BotPasswordSessionProviderTest\setUp(), ResourceLoaderTestCase\setUp(), DumpTestCase\setUp(), RepoGroupTest\setUpForeignRepo(), setUserLang(), InterwikiTest\setWgInterwikiCache(), FileBackendTest\testAsyncWrites(), MediaWiki\Auth\AuthManagerTest\testAutoAccountCreation(), BotPasswordTest\testBasics(), MediaWiki\Auth\AuthManagerTest\testBeginAccountCreation(), ApiLoginTest\testBotPassword(), UploadStashTest\testBug29408(), SpecialPreferencesTest\testBug41337(), FileTest\testCanAnimateThumbIfAppropriate(), MediaWiki\Auth\AuthManagerTest\testCheckAccountCreatePermissions(), MediaWiki\Auth\AbstractPasswordPrimaryAuthenticationProviderTest\testCheckPasswordValidity(), UserTest\testCheckPasswordValidity(), ExtraParserTest\testCleanSigDisabled(), RevisionTest\testCompressRevisionTextUtf8Gzip(), SpecialPageFactoryTest\testConflictResolution(), MediaWiki\Auth\ThrottlerTest\testConstructor(), ResourceLoaderTest\testConstructRegistrationHook(), MediaWiki\Auth\AuthManagerTest\testContinueAccountCreation(), MediaWiki\Session\CookieSessionProviderTest\testCookieData(), EditPageTest\testCreatePage(), EditPageTest\testCreatePageTrx(), GlobalTest\testDebugFunctionTest(), WebRequestTest\testDetectServer(), ApiDocumentationTest\testDocumentationExists(), DeferredUpdatesTest\testDoUpdatesCLI(), DeferredUpdatesTest\testDoUpdatesWeb(), BadTitleErrorTest\testExceptionSetsStatusCode(), ThrottledErrorTest\testExceptionSetsStatusCode(), ExtensionRegistryTest\testExportExtractedDataGlobals(), ExternalStoreTest\testExternalFetchFromURL(), SideBarTest\testExternalUrlsRequireADescription(), CentralIdLookupTest\testFactory(), SpecialMyLanguageTest\testFindTitle(), RepoGroupTest\testForEachForeignRepoNone(), LinkerTest\testFormatComment(), LinkerTest\testFormatLinksInComment(), FileTest\testGenerateBucketsIfNeeded(), ContentHandlerTest\testGetAutosummary(), ContentHandlerTest\testGetContentText_NonTextContent_fail(), ContentHandlerTest\testGetContentText_NonTextContent_ignore(), ContentHandlerTest\testGetContentText_NonTextContent_serialize(), ContentHandlerTest\testGetContentText_Null(), ContentHandlerTest\testGetContentText_TextContent(), WebRequestTest\testGetIP(), WebRequestTest\testGetIpLackOfRemoteAddrThrowAnException(), ResourceLoaderTest\testGetLoadScript(), SpecialPageFactoryTest\testGetLocalNameFor(), ResourceLoaderStartUpModuleTest\testGetModuleRegistrations(), TitleTest\testGetPageViewLanguage(), HttpTest\testGetProxy(), CssContentTest\testGetRedirectTarget(), JavaScriptContentTest\testGetRedirectTarget(), WikiPageTest\testGetRedirectTarget(), MediaWiki\Session\ImmutableSessionProviderWithCookieTest\testGetSessionIdFromCookie(), FileTest\testGetThumbnailBucket(), SpecialPageFactoryTest\testGetTitleForAlias(), WikiMapTest\testGetWiki(), RepoGroupTest\testHasForeignRepoNegative(), RequestContextTest\testImportScopedSession(), MessageTest\testInContentLanguageOverride(), ImportLogFormatterTest\testInterwikiLogDatabaseRows(), LocalIdLookupTest\testIsAttachedShared(), MWExceptionTest\testisCommandLine(), TextContentTest\testIsCountable(), WikiPageTest\testIsCountable(), RecentChangeTest\testIsInRCLifespan(), MergeHistoryTest\testIsValidMerge(), MovePageTest\testIsValidMove(), TitleTest\testIsValidMoveOperation(), MWExceptionTest\testJsonserializeexceptionBacktracingDisabled(), MWExceptionTest\testJsonserializeexceptionBacktracingEnabled(), MWExceptionTest\testJsonserializeexceptionKeys(), LinkerTest\testLinkBeginHook(), LinkerTest\testLinkEndHook(), MediaWiki\Auth\UserDataAuthenticationRequestTest\testLoadFromSubmission(), BotPasswordTest\testLogin(), ResourceLoaderTest\testMakeLoaderImplementScript(), CssContentHandlerTest\testMakeRedirectContent(), JavaScriptContentHandlerTest\testMakeRedirectContent(), OutputPageTest\testMakeResourceLoaderLink(), UploadBaseTest\testMaxUploadSize(), ExifRotationTest\testMetadataAutoRotate(), ExifRotationTest\testMetadataAutoRotateUnsupported(), ExifRotationTest\testMetadataNoAutoRotate(), BitmapMetadataHandlerTest\testMultilingualCascade(), MailAddressTest\testNewFromUser(), MediaWikiSiteTest\testNormalizePageTitle(), LinksUpdateTest\testOnAddingAndRemovingCategory_recentChangesRowIsAdded(), LinksUpdateTest\testOnAddingAndRemovingCategoryToTemplates_embeddingPagesAreIgnored(), MediaWiki\Session\ImmutableSessionProviderWithCookieTest\testPersistSession(), JpegPixelFormatTest\testPixelFormatRendering(), ResourceLoaderModuleTest\testPlaceholderize(), CdnCacheUpdateTest\testPurgeMergeWeb(), MediaWiki\Auth\CheckBlocksSecondaryAuthenticationProviderTest\testRangeBlock(), ResourceLoaderStartUpModuleTest\testRegistrationsMinified(), ErrorPageErrorTest\testReport(), SpecialPageFactoryTest\testResolveAlias(), SideBarTest\testRespectExternallinktarget(), SideBarTest\testRespectWgnofollowlinks(), ExifRotationTest\testRotationRenderingNoAutoRotate(), MWExceptionTest\testRunHooks(), SpecialSearchTest\testSearchTermIsNotExpanded(), MediaWiki\Session\PHPSessionHandlerTest\testSessionHandling(), MediaWiki\Auth\AuthManagerTest\testSetDefaultUserOptions(), MediaWikiTestCaseTest\testSetGlobalsAreRestoredOnTearDown(), MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProviderTest\testSetPasswordResetFlag(), MediaWiki\Logger\LegacyLoggerTest\testShouldEmit(), ExifBitmapTest\testSwappingICCProfile(), SideBarTest\testTestAttributesAssertionHelper(), ApiQueryTest\testTitlePartToKey(), ApiQueryTest\testTitlesGetNormalized(), MailAddressTest\testToString(), LinksUpdateTest\testUpdate_categorylinks(), LinksUpdateTest\testUpdate_langlinks(), LinksUpdateTest\testUpdate_page_props_without_sortkey(), EditPageTest\testUpdatePage(), EditPageTest\testUpdatePageTrx(), JavaScriptContentTest\testUpdateRedirect(), ApiUploadTest\testUploadChunks(), ApiUploadTest\testUploadStash(), MWExceptionTest\testUseMessageCache(), MWExceptionTest\testUseOutputPage(), TimeAdjustTest\testUserAdjust(), 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 590 of file MediaWikiTestCase.php.
References $name, overrideMwServices(), and use.
Referenced by ApiOpenSearchTest\replaceSearchEngine(), ApiOpenSearchTest\replaceSearchEngineConfig(), TitleTest\secureAndSplitGlobals(), WatchedItemUnitTest\testDuplicateEntries(), WatchedItemUnitTest\testFromUserTitle(), WebRequestTest\testGetIP(), WebRequestTest\testGetIpLackOfRemoteAddrThrowAnException(), WfThumbIsStandardTest\testIsStandard(), 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 1814 of file MediaWikiTestCase.php.
References $handler, and mergeMwGlobalArrayValue().
Referenced by ContentHandlerTest\testDataIndexFields(), and SearchEngineTest\testSearchIndexFields().
|
protected |
Definition at line 463 of file MediaWikiTestCase.php.
References $lbFactory, as, DeferredUpdates\clearPendingUpdates(), ObjectCache\getMainWANInstance(), needsDB(), Maintenance\setLBFactoryTriggers(), and wfRecursiveRemoveDir().
MediaWikiTestCase::setupAllTestDBs | ( | ) |
Set up all test DBs.
Definition at line 1099 of file MediaWikiTestCase.php.
References $wgDBprefix, dbPrefix(), and global.
Referenced by run().
|
static |
Definition at line 122 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.
Definition at line 1081 of file MediaWikiTestCase.php.
References CloneDatabase\changePrefix(), and IDatabase\getType().
|
staticprotected |
Clones the External Store database(s) for testing.
string | $testPrefix | Prefix for test tables |
Definition at line 1166 of file MediaWikiTestCase.php.
References as.
|
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 1135 of file MediaWikiTestCase.php.
References IDatabase\getType(), Database\query(), and Database\tablePrefix().
Referenced by ParserTestTopLevelSuite\setUp().
MediaWikiTestCase::setUserLang | ( | $lang | ) |
string | Language | $lang |
Definition at line 814 of file MediaWikiTestCase.php.
References $lang, RequestContext\getMain(), and setMwGlobals().
Referenced by MessageCacheTest\configureLanguages(), MessageTest\setUp(), HtmlTest\setUp(), MediaWikiLangTestCase\setUp(), TitleTest\setUp(), ExtraParserTest\setUp(), OldChangesListTest\setUp(), MediaWikiTitleCodecTest\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. |
Exception | When trying to stash an unset global |
Definition at line 694 of file MediaWikiTestCase.php.
References $e, $GLOBALS, as, serialize(), and unserialize().
Referenced by GlobalVarConfigTest\maybeStashGlobal(), setMwGlobals(), LocalIdLookupTest\setUp(), MediaWiki\Auth\AuthManagerTest\setUp(), MediaWiki\Auth\AuthManagerTest\testAutoAccountCreation(), MediaWiki\Auth\AuthManagerTest\testCheckAccountCreatePermissions(), MediaWikiTestCaseTest\testExceptionThrownWhenStashingNonExistentGlobals(), MediaWiki\Auth\TemporaryPasswordAuthenticationRequestTest\testNewRandom(), and MediaWikiTestCaseTest\testStashedGlobalsAreRestoredOnTearDown().
|
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 1534 of file MediaWikiTestCase.php.
References as.
|
staticprivate |
array | $matcher | |
string | $actual | |
bool | $isHtml |
Definition at line 1761 of file MediaWikiTestCase.php.
References load.
|
protected |
Definition at line 504 of file MediaWikiTestCase.php.
References $GLOBALS, $status, $value, $wgRequest, $wgSQLMode, as, global, needsDB(), MediaWiki\Session\SessionManager\resetCache(), MediaWiki\Auth\AuthManager\resetCache(), RequestContext\resetMain(), restoreLoggers(), and wfRecursiveRemoveDir().
Referenced by MediaWikiTestCaseTest\testLoggersAreRestoredOnTearDown(), MediaWikiTestCaseTest\testOverrideMwServices(), MediaWikiTestCaseTest\testSetGlobalsAreRestoredOnTearDown(), 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 1050 of file MediaWikiTestCase.php.
References $type, as, CloneDatabase\changePrefix(), global, and JobQueueGroup\singleton().
Referenced by MediaWikiPHPUnitBootstrap\__destruct().
|
final |
Make sure MediaWikiTestCase extending classes have called their parent setUp method.
Definition at line 575 of file MediaWikiTestCase.php.
References class.
|
staticprivate |
Definition at line 1305 of file MediaWikiTestCase.php.
MediaWikiTestCase::usesTemporaryTables | ( | ) |
|
static |
Used as a marker to prevent wfResetOutputBuffers from breaking PHPUnit.
Definition at line 1803 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 34 of file MediaWikiTestCase.php.
Referenced by SpecialPageFactoryTest\testGetAliasListRecursion(), MediaWiki\Session\SessionManagerTest\testLoadSessionInfoFromStore(), DatabaseTest\testTransactionIdle(), DatabaseTest\testTransactionListener(), DatabaseTest\testTransactionResolution(), and HtmlCheckMatrixTest\testValidateCallsUserDefinedValidationCallback().
|
protected |
Primary database.
Definition at line 48 of file MediaWikiTestCase.php.
Referenced by DatabaseSQLTest\assertLastSqlDb(), DatabaseMysqlBaseTest\getMockForViews(), BatchRowUpdateTest\mockDbConsecutiveSelect(), DatabaseMysqlBaseTest\testAddIdentifierQuotes(), ReverseChronologicalPagerTest\testGetDateCond(), DatabaseMysqlBaseTest\testListviews(), LBFactoryTest\testNiceDomains(), DatabaseMysqlBaseTest\testPtHeartbeat(), BatchRowUpdateTest\testReaderBasicIterate(), BatchRowUpdateTest\testReaderSelectConditionsMultiplePrimaryKeys(), BatchRowUpdateTest\testReaderSetFetchColumns(), DatabaseUpdaterTest\testSetAppliedUpdates(), LBFactoryTest\testTrickyDomain(), and BatchRowUpdateTest\testWriterBasicFunctionality().
|
staticprivate |
Definition at line 58 of file MediaWikiTestCase.php.
|
private |
Holds original loggers which have been replaced by setLogger()
Definition at line 88 of file MediaWikiTestCase.php.
|
private |
Holds original values of MediaWiki configuration settings to be restored in tearDown().
See also setMwGlobals().
Definition at line 82 of file MediaWikiTestCase.php.
|
staticprivate |
Definition at line 59 of file MediaWikiTestCase.php.
|
private |
Original value of PHP's error_reporting setting.
Definition at line 66 of file MediaWikiTestCase.php.
|
staticprivate |
Definition at line 57 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 20 of file MediaWikiTestCase.php.
Referenced by resetGlobalServices().
|
protected |
Definition at line 100 of file MediaWikiTestCase.php.
Referenced by checkDbIsSupported().
|
protected |
Definition at line 54 of file MediaWikiTestCase.php.
|
private |
Holds the paths of temporary files/directories created through getNewTempFile, and getNewTempDirectory.
Definition at line 74 of file MediaWikiTestCase.php.
Referenced by FileBackendTest\doTestGetLocalCopy(), and FileBackendTest\doTestGetLocalReference().
|
static |
Definition at line 40 of file MediaWikiTestCase.php.
Referenced by UserTest\testFindUsersByGroup().
|
staticprivate |
Definition at line 56 of file MediaWikiTestCase.php.
const MediaWikiTestCase::DB_PREFIX = 'unittest_' |
Table name prefixes.
Oracle likes it shorter.
Definition at line 93 of file MediaWikiTestCase.php.
Referenced by TestUser\assertNotReal(), ParserTestTopLevelSuite\setUp(), and ParserTestRunner\setupDatabase().
const MediaWikiTestCase::ORA_DB_PREFIX = 'ut_' |
Definition at line 94 of file MediaWikiTestCase.php.
Referenced by TestUser\assertNotReal(), ParserTestTopLevelSuite\setUp(), and ParserTestRunner\setupDatabase().