MediaWiki
REL1_31
|
Public Member Functions | |
testApiTestGroup () | |
@coversNothing More... | |
![]() | |
__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) | |
setGroupPermissions ( $newPerms, $newKey=null, $newValue=null) | |
Alters $wgGroupPermissions for the duration of the test. More... | |
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 | apiExceptionHasCode (ApiUsageException $ex, $code) |
![]() | |
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 (IMaintainableDatabase $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... | |
Protected Member Functions | |
doApiRequest (array $params, array $session=null, $appendModule=false, User $user=null, $tokenType=null) | |
Does the API request and returns the result. More... | |
doApiRequestWithToken (array $params, array $session=null, User $user=null, $tokenType='auto') | |
Convenience function to access the token parameter of doApiRequest() more succinctly. More... | |
doLogin ( $testUser=null) | |
Previously this would do API requests to log in, as well as setting $wgUser and the request context's user. More... | |
editPage ( $pageName, $text, $summary='', $defaultNs=NS_MAIN) | |
Edits or creates a page/revision. More... | |
getTokenList (TestUser $user, $session=null) | |
revisionDelete ( $rev, array $value=[Revision::DELETED_TEXT=> 1], $comment='') | |
Revision-deletes a revision. More... | |
setExpectedApiException ( $msg, $code=null, array $data=null, $httpCode=0) | |
Expect an ApiUsageException to be thrown with the given parameters, which are the same as ApiUsageException::newWithMessage()'s parameters. More... | |
setUp () | |
tearDown () | |
![]() | |
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... | |
assertFileContains ( $fileName, $actualData, $createIfMissing=true, $msg='') | |
Check whether file contains given data. 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, array $options=[], array $join_conds=[]) | |
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... | |
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... | |
getSchemaOverrides (IMaintainableDatabase $db) | |
Stub. 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) | |
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown. More... | |
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... | |
stashMwGlobals ( $globalKeys) | |
Stashes the global, will be restored in tearDown() More... | |
Static Protected Member Functions | |
static | getErrorFormatter () |
![]() | |
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 (IMaintainableDatabase $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 | |
ApiTestContext | $apiContext |
![]() | |
Database | $db |
Primary database. More... | |
array | $supportedDBs |
array | $tablesUsed = [] |
Static Protected Attributes | |
static | $apiUrl |
static | $errorFormatter = null |
Additional Inherited Members | |
![]() | |
const | DB_PREFIX = 'unittest_' |
Table name prefixes. More... | |
const | ORA_DB_PREFIX = 'ut_' |
![]() | |
static TestUser[] | $users |
Definition at line 5 of file ApiTestCase.php.
|
static |
Definition at line 225 of file ApiTestCase.php.
References $code, $e, function, ApiUsageException\getStatusValue(), and use.
Referenced by ApiOptionsTest\testAnon(), ApiContinuationManagerTest\testContinuation(), ApiBaseTest\testDieStatus(), ApiComparePagesTest\testDiff(), ApiOptionsTest\testNoChanges(), ApiParseTest\testNonexistentPage(), and ApiOptionsTest\testNoOptionname().
|
protected |
Does the API request and returns the result.
The returned value is an array containing
array | $params | |
array | null | $session | |
bool | $appendModule | |
User | null | $user | |
string | null | $tokenType | Set to a string like 'csrf' to send an appropriate token |
ApiUsageException |
Reimplemented in UploadFromUrlTest.
Definition at line 100 of file ApiTestCase.php.
References $context, $params, $user, $value, $wgRequest, $wgUser, as, RequestContext\getMain(), ApiQueryTokens\getToken(), ApiQueryTokens\getTokenTypeSalts(), global, and MediaWiki\Auth\AuthManager\resetCache().
Referenced by ApiQueryTestBase\check(), doApiRequestWithToken(), ApiBlockTest\doBlock(), ApiQueryRecentChangesIntegrationTest\doGeneratorRecentChangesRequest(), ApiQueryWatchlistRawIntegrationTest\doGeneratorWatchlistRawRequest(), ApiQueryWatchlistIntegrationTest\doGeneratorWatchlistRequest(), ApiQueryRecentChangesIntegrationTest\doListRecentChangesRequest(), ApiQueryWatchlistRawIntegrationTest\doListWatchlistRawRequest(), ApiQueryWatchlistIntegrationTest\doListWatchlistRequest(), ApiParseTest\doTestLangLinks(), ApiLogoutTest\doUserLogout(), getTokenList(), ApiLogoutTest\getUserCsrfTokenFromApi(), ApiQueryContinueTestBase\query(), ApiLoginTest\testApiLoginBadPass(), ApiLoginTest\testApiLoginGoodPass(), ApiLoginTest\testApiLoginNoName(), ApiMainTest\testAssert(), ApiMainTest\testAssertUser(), ApiBlockTest\testBlockingActionWithNoToken(), ApiLoginTest\testBotPassword(), ApiParseTest\testCategoriesHtml(), ApiCheckTokenTest\testCheckTokenExpired(), ApiCheckTokenTest\testCheckTokenInvalid(), ApiCheckTokenTest\testCheckTokenSuffixWarning(), ApiCheckTokenTest\testCheckTokenValid(), ApiClearHasMsgTest\testClearFlag(), ApiQueryRevisionsTest\testContentComesWithContentModelAndFormat(), ApiDeleteTest\testDeletionWithoutPermission(), ApiComparePagesTest\testDiff(), ApiDisabledTest\testDisabled(), ApiParseTest\testDisableTidy(), ApiParseTest\testEffectiveLangLinks(), ApiParseTest\testExistingSection(), ApiParseTest\testFollowedRedirect(), ApiParseTest\testFollowedRedirectById(), ApiParseTest\testFormatCategories(), ApiWatchTest\testGetRollbackToken(), ApiParseTest\testHeadHtml(), ApiParseTest\testHeadItems(), ApiParseTest\testHeadItemsWithSkin(), ApiRevisionDeleteTest\testHidingRevisions(), ApiParseTest\testIndicators(), ApiParseTest\testIndicatorsWithSkin(), ApiQueryContributionsTest\testInterwikiUser(), ApiParseTest\testInvalidSection(), ApiParseTest\testInvalidTitle(), ApiParseTest\testIwlinks(), ApiParseTest\testLimitReports(), ApiUploadTest\testLogin(), ApiLoginTest\testLoginWithNoSameOriginSecurity(), ApiParseTest\testModules(), ApiParseTest\testModulesWithSkin(), ApiParseTest\testNewSection(), ApiParseTest\testNewSectionWithPage(), ApiParseTest\testNonexistentOldId(), ApiParseTest\testNonexistentPage(), ApiParseTest\testNoPst(), ApiParseTest\testOnlyPst(), ApiParseTest\testParseById(), ApiParseTest\testParseByName(), ApiParseTest\testParseByOldId(), ApiParseTest\testParseTree(), ApiParseTest\testParseTreeNonWikitext(), ApiQueryAllPagesTest\testPrefixNormalizationSearchBug(), ApiParseTest\testPst(), ApiPurgeTest\testPurgeMainPage(), ApiParseTest\testRevDel(), ApiParseTest\testRevDelNoPermission(), ApiParseTest\testRevId(), ApiParseTest\testRevidNoText(), ApiLoginTest\testRunLogin(), ApiParseTest\testSection(), ApiParseTest\testSectionNoContent(), ApiParseTest\testSerializationError(), ApiQueryContributionsTest\testSorting(), ApiParseTest\testSuppressed(), ApiParseTest\testTextNoContentModel(), ApiParseTest\testTitleNoText(), ApiParseTest\testTitleProvided(), ApiQueryTest\testTitlesAreRejectedIfInvalid(), ApiQueryTest\testTitlesGetNormalized(), ApiQueryTest\testTitlesWithWhitespaces(), ApiParseTest\testTitleWithNonexistentRevId(), ApiParseTest\testTitleWithNonMatchingRevId(), ApiParseTest\testUnfollowedRedirect(), ApiRevisionDeleteTest\testUnhidingOutput(), ApiUploadTest\testUploadRequiresToken(), ApiWatchTest\testWatchClear(), ApiWatchTest\testWatchEdit(), ApiWatchTest\testWatchProtect(), ApiWatchTest\testWatchRollback(), ApiUserrightsTest\testWebToken(), and ApiUnblockTest\testWithNoToken().
|
protected |
Convenience function to access the token parameter of doApiRequest() more succinctly.
array | $params | Key-value API params |
array | null | $session | Session array |
User | null | $user | A User object for the context |
string | $tokenType | Which token type to pass |
Definition at line 170 of file ApiTestCase.php.
References $user, and doApiRequest().
Referenced by ApiUserrightsTest\doFailedRightsChange(), ApiUserrightsTest\doSuccessfulRightsChange(), ApiEditPageTest\testAppendInMediaWikiNamespace(), ApiEditPageTest\testAppendInMediaWikiNamespaceWithSerializationError(), ApiEditPageTest\testAppendNewSection(), ApiEditPageTest\testAppendNewSectionWithInvalidContentModel(), ApiEditPageTest\testAppendNewSectionWithSummary(), ApiEditPageTest\testAppendNewSectionWithTitle(), ApiEditPageTest\testAppendNewSectionWithTitleAndSummary(), ApiEditPageTest\testAppendToFirstSection(), ApiEditPageTest\testAppendToNonexistentSection(), ApiEditPageTest\testAppendToSection(), ApiEditPageTest\testAppendWithNonTextContentHandler(), ApiStashEditTest\testBasicEdit(), ApiEditPageTest\testCheckDirectApiEditingDisallowed_forNonTextContent(), ApiEditPageTest\testCorrectContentFormat(), ApiEditPageTest\testCreateImageRedirectAnon(), ApiEditPageTest\testCreateImageRedirectLoggedIn(), ApiEditPageTest\testCreateOnly(), ApiDeleteTest\testDelete(), ApiDeleteTest\testDeleteAbortedByHook(), ApiDeleteTest\testDeleteNonexistent(), ApiDeleteTest\testDeleteUnwatch(), ApiDeleteTest\testDeleteWatch(), ApiDeleteTest\testDeleteWithoutTagPermission(), ApiDeleteTest\testDeleteWithTag(), ApiEditPageTest\testEdit(), ApiEditPageTest\testEdit_redirect(), ApiEditPageTest\testEdit_redirectText(), ApiEditPageTest\testEditAbortedByEditPageHookWithNoResult(), ApiEditPageTest\testEditAbortedByEditPageHookWithResult(), ApiEditPageTest\testEditAbortedByHook(), ApiEditPageTest\testEditAbortedByHookWithCustomOutput(), ApiEditPageTest\testEditAppend(), ApiEditPageTest\testEditConflict(), ApiEditPageTest\testEditConflict_bug41990(), ApiEditPageTest\testEditConflict_newSection(), ApiEditPageTest\testEditMalformedSection(), ApiEditPageTest\testEditMinor(), ApiEditPageTest\testEditNewSection(), ApiEditPageTest\testEditRecreate(), ApiEditPageTest\testEditSection(), ApiEditPageTest\testEditUnwatch(), ApiEditPageTest\testEditWatch(), ApiEditPageTest\testEditWhileBlocked(), ApiEditPageTest\testEditWhileReadOnly(), ApiEditPageTest\testEditWithoutTagPermission(), ApiEditPageTest\testEditWithStartTimestamp(), ApiEditPageTest\testEditWithTag(), ApiMoveTest\testFromWithFromid(), ApiEditPageTest\testIncorrectMd5AppendText(), ApiEditPageTest\testIncorrectMd5PrependText(), ApiEditPageTest\testIncorrectMd5Text(), ApiEditPageTest\testMd5AppendText(), ApiEditPageTest\testMd5PrependAndAppendText(), ApiEditPageTest\testMd5PrependText(), ApiEditPageTest\testMd5Text(), ApiEditPageTest\testMismatchedContentFormat(), ApiMoveTest\testMove(), ApiMoveTest\testMoveById(), ApiMoveTest\testMoveNonexistent(), ApiMoveTest\testMoveNonexistentId(), ApiMoveTest\testMoveNoPermission(), ApiMoveTest\testMoveSubpages(), ApiMoveTest\testMoveSubpagesError(), ApiMoveTest\testMoveTalk(), ApiMoveTest\testMoveTalkFailed(), ApiMoveTest\testMoveToInvalidPageName(), ApiEditPageTest\testNoCreate(), ApiMoveTest\testPingLimiter(), ApiEditPageTest\testProhibitedAnonymousEdit(), ApiEditPageTest\testProhibitedChangeContentModel(), ApiEditPageTest\testReversedUndoAfter(), ApiMoveTest\testSelfMove(), ApiSetNotificationTimestampIntegrationTest\testStuff(), ApiEditPageTest\testSupportsDirectApiEditing_withContentHandlerOverride(), ApiMoveTest\testSuppressRedirect(), ApiMoveTest\testSuppressRedirectNoPermission(), ApiMoveTest\testTagsNoPermission(), ApiEditPageTest\testTooBigEdit(), ApiEditPageTest\testUndoAfterContentModelChange(), ApiEditPageTest\testUndoAfterToHiddenRev(), ApiEditPageTest\testUndoAfterToInvalidRev(), ApiEditPageTest\testUndoAfterToRevFromDifferentPage(), ApiEditPageTest\testUndoToInvalidRev(), ApiEditPageTest\testUndoToRevFromDifferentPage(), ApiEditPageTest\testUndoWithConflicts(), ApiEditPageTest\testUndoWithSwappedRevisions(), ApiEditPageTest\testUnsupportedContentFormat(), ApiUploadTest\testUpload(), ApiUploadTest\testUploadChunks(), ApiUploadTest\testUploadMissingParams(), ApiUploadTest\testUploadSameContent(), ApiUploadTest\testUploadSameFileName(), ApiUploadTest\testUploadStash(), and ApiUploadTest\testUploadZeroLength().
|
protected |
Previously this would do API requests to log in, as well as setting $wgUser and the request context's user.
The API requests are unnecessary, and the global-setting is unwanted, so this method should not be called. Instead, pass appropriate User values directly to functions that need them. For functions that still rely on $wgUser, set that directly. If you just want to log in the test sysop user, don't do anything – that's the default.
TestUser | string | $testUser | Object, or key to self::$users such as 'sysop' or 'uploader' |
Definition at line 186 of file ApiTestCase.php.
References $wgUser, RequestContext\getMain(), and global.
|
protected |
Edits or creates a page/revision.
string | $pageName | Page title |
string | $text | Content of the page |
string | $summary | Optional summary string for the revision |
int | $defaultNs | Optional namespace id |
Definition at line 52 of file ApiTestCase.php.
References $title, WikiPage\factory(), ContentHandler\makeContent(), and Title\newFromText().
Referenced by ApiParseTest\addDBDataOnce(), ApiQueryBasicTest\addDBDataOnce(), ApiQueryContinue2Test\addDBDataOnce(), ApiQueryContinueTest\addDBDataOnce(), ApiMoveTest\createPage(), ApiPageSetTest\createPageSetWithRedirect(), ApiRevisionDeleteTest\setUp(), ApiEditPageTest\testAppendNewSection(), ApiEditPageTest\testAppendNewSectionWithInvalidContentModel(), ApiEditPageTest\testAppendNewSectionWithSummary(), ApiEditPageTest\testAppendNewSectionWithTitle(), ApiEditPageTest\testAppendNewSectionWithTitleAndSummary(), ApiEditPageTest\testAppendToFirstSection(), ApiEditPageTest\testAppendToNonexistentSection(), ApiEditPageTest\testAppendToSection(), ApiParseTest\testCategoriesHtml(), ApiEditPageTest\testCreateOnly(), ApiDeleteTest\testDelete(), ApiDeleteTest\testDeleteAbortedByHook(), ApiDeleteTest\testDeleteUnwatch(), ApiDeleteTest\testDeleteWatch(), ApiDeleteTest\testDeleteWithoutTagPermission(), ApiDeleteTest\testDeleteWithTag(), ApiDeleteTest\testDeletionWithoutPermission(), ApiEditPageTest\testEditMalformedSection(), ApiEditPageTest\testEditMinor(), ApiEditPageTest\testEditRecreate(), ApiEditPageTest\testEditWithStartTimestamp(), ApiParseTest\testFollowedRedirect(), ApiParseTest\testFollowedRedirectById(), ApiParseTest\testFormatCategories(), ApiQueryBasicTest\testGeneratorRedirects(), ApiEditPageTest\testMd5AppendText(), ApiEditPageTest\testMd5PrependAndAppendText(), ApiEditPageTest\testMd5PrependText(), ApiParseTest\testNoPst(), ApiParseTest\testOnlyPst(), ApiParseTest\testPst(), ApiEditPageTest\testReversedUndoAfter(), ApiParseTest\testSection(), ApiParseTest\testSectionNoContent(), ApiPageSetTest\testSpecialRedirects(), ApiEditPageTest\testUndoAfterToHiddenRev(), ApiEditPageTest\testUndoAfterToInvalidRev(), ApiEditPageTest\testUndoAfterToRevFromDifferentPage(), ApiEditPageTest\testUndoToInvalidRev(), ApiEditPageTest\testUndoToRevFromDifferentPage(), ApiEditPageTest\testUndoWithConflicts(), ApiEditPageTest\testUndoWithSwappedRevisions(), and ApiParseTest\testUnfollowedRedirect().
|
staticprotected |
Definition at line 214 of file ApiTestCase.php.
References $errorFormatter, and Language\factory().
|
protected |
Definition at line 201 of file ApiTestCase.php.
References $user, and doApiRequest().
Referenced by ApiBlockTest\getTokens(), ApiWatchTest\getTokens(), and ApiTokensTest\runTokenTest().
|
protected |
Revision-deletes a revision.
Revision | int | $rev | Revision to delete |
array | $value | Keys are Revision::DELETED_* flags. Values are 1 to set the bit, 0 to clear, -1 to leave alone. (All other values also clear the bit.) |
string | $comment | Deletion comment |
Definition at line 67 of file ApiTestCase.php.
References $rev, $value, RevisionDeleter\createList(), RequestContext\getMain(), and Revision\newFromId().
Referenced by ApiParseTest\addDBDataOnce().
|
protected |
Expect an ApiUsageException to be thrown with the given parameters, which are the same as ApiUsageException::newWithMessage()'s parameters.
This allows checking for an exception whose text is given by a message key instead of text, so as not to hard-code the message's text into test code.
Definition at line 254 of file ApiTestCase.php.
References $code, class, and ApiUsageException\newWithMessage().
Referenced by ApiLogoutTest\testUserLogoutBadToken().
|
protected |
Reimplemented from MediaWikiLangTestCase.
Reimplemented in UploadFromUrlTest, ApiQueryTest, ApiUploadTestCase, ApiSetNotificationTimestampIntegrationTest, ApiRevisionDeleteTest, ApiQueryWatchlistRawIntegrationTest, ApiQueryWatchlistIntegrationTest, ApiQueryRecentChangesIntegrationTest, ApiLogoutTest, ApiEditPageTest, ApiComparePagesTest, and ApiBlockTest.
Definition at line 15 of file ApiTestCase.php.
References $wgServer, global, ApiQueryInfo\resetTokenCache(), MediaWikiTestCase\setMwGlobals(), and wfScript().
|
protected |
Reimplemented from MediaWikiTestCase.
Reimplemented in ApiEditPageTest, and ApiBlockTest.
Definition at line 37 of file ApiTestCase.php.
References MediaWiki\Session\SessionManager\getGlobalSession().
ApiTestCase::testApiTestGroup | ( | ) |
|
protected |
Definition at line 13 of file ApiTestCase.php.
|
staticprotected |
Definition at line 6 of file ApiTestCase.php.
|
staticprotected |
Definition at line 8 of file ApiTestCase.php.
Referenced by getErrorFormatter().