MediaWiki
1.23.2
|
Inherits PHPUnit_Framework_TestCase.
Inherited by ArrayDiffFormatterTest, ArrayUtilsTest, ArticleTest, AutoLoaderTest, BadTitleErrorTest, BagOStuffTest, BaseDumpTest, BitmapMetadataHandlerTest, BitmapScalingTest, CdbTest, CLDRPluralRuleEvaluatorTest, CleanUpTest, ConfigFactoryTest, ContentHandlerTest, CssContentTest, CSSJanusTest, CSSMinTest, DatabaseMysqlBaseTest, DatabaseSqliteTest, DatabaseSQLTest, DatabaseTest, DifferenceEngineTest, DiffHistoryBlobTest, DiffOpTest, DiffTest, DjVuTest, DummyExtensionsTest, ErrorPageErrorTest, ExifBitmapTest, ExifRotationTest, ExifTest, ExternalStoreTest, ExtraParserTest, FallbackTest, FauxRequestTest, FauxResponseTest, FetchTextTest, FileBackendTest, FileRepoTest, FormatJsonTest, FormatMetadataTest, FormOptionsInitializationTest, FormOptionsTest, GenericArrayObjectTest, GetSlaveServerTest, GIFHandlerTest, GlobalTest, GlobalVarConfigTest, GlobalWithDBTest, HashRingTest, HooksTest, HtmlCheckMatrixTest, HtmlFormatterTest, HttpTest, IEUrlExtensionTest, InstallDocFormatterTest, IPTCTest, IPTest, JavaScriptMinifierTest, JobQueueTest, JpegMetadataExtractorTest, JpegTest, LanguageClassesTestCase, LBFactoryTest, LessFileCompilationTest, LicensesTest, LinksUpdateTest, LocalFileTest, LocalisationCacheTest, MagicVariableTest, MaintenanceTest, MediaHandlerTest, MediaWikiLangTestCase, MediaWikiTestCaseTest, MediaWikiTitleCodecTest, MWDebugTest, MWExceptionHandlerTest, MWExceptionTest, MWFunctionTest, MWMessagePackTest, MWNamespaceTest, OracleInstallerTest, ORMRowTest, ORMTableTest, OutputPageTest, ParserOutputTest, ParserPreloadTest, PathRouterTest, PNGHandlerTest, PNGMetadataExtractorTest, PreferencesTest, PrefixUniquenessTest, PreprocessorTest, ProcessCacheLRUTest, QueryAllSpecialPagesTest, ReadOnlyErrorTest, RecentChangeTest, RefreshLinksPartitionTest, RequestContextTest, ResourceLoaderLESSTest, ResourceLoaderTestCase, ResourcesTest, RevisionStorageTest, RevisionTest, RunningStatTest, SanitizerTest, SanitizerValidateEmailTest, SearchUpdateTest, SiteConfigurationTest, SiteListTest, SiteSQLStoreTest, SiteTest, SkinTemplateTest, SpecialListFilesTest, SpecialPageAliasTest, SpecialPageTest, SpecialPreferencesTest, SpecialRecentchangesTest, SpecialSearchTest, StoreBatchTest, StringUtilsTest, StructureTest, SVGMetadataExtractorTest, SvgTest, TagHookTest, ThrottledErrorTest, TidyTest, TiffTest, TitleArrayFromResultTest, TitleMethodsTest, TitleTest, TitleValueTest, UIDGeneratorTest, UploadBaseTest, UploadStashTest, UserArrayFromResultTest, UserNotLoggedInTest, UserTest, WebRequestTest, WfAssembleUrlTest, WfBaseConvertTest, WfBaseNameTest, WfBCP47Test, WfExpandUrlTest, WfGetCallerTest, WfParseUrlTest, WfRemoveDotSegmentsTest, WfShorthandToIntegerTest, WfTimestampTest, WfUrlencodeTest, XmlJs, XmlSelectTest, XmlTest, XmlTypeCheckTest, XMPTest, XMPValidateTest, and ZipDirectoryReaderTest.
Public Member Functions | |
__call ( $func, $args) | |
__construct ( $name=null, array $data=array(), $dataName='') | |
addDBData () | |
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) | |
testMediaWikiTestCaseParentSetupCalled () | |
Make sure MediaWikiTestCase extending classes have called their parent setUp method. More... | |
usesTemporaryTables () | |
Static Public Member Functions | |
static | listTables ( $db) |
static | setupTestDB (DatabaseBase $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... | |
Public Attributes | |
const | DB_PREFIX = 'unittest_' |
Table name prefixes. More... | |
const | ORA_DB_PREFIX = 'ut_' |
Static Public Attributes | |
static | $users |
Protected Member Functions | |
arrayWrap (array $elements) | |
Utility method taking an array of elements and wrapping each element in it's own array. More... | |
assertArrayEquals (array $expected, array $actual, $ordered=false, $named=false) | |
Assert that two arrays are equal. More... | |
assertException ( $code, $expected='Exception', $message='') | |
Asserts that an exception of the specified type occurs when running the provided code. 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 () | |
checkHasDiff3 () | |
Check, if $wgDiff3 is set and ready to merge Will mark the calling test as skipped, if not ready. More... | |
checkHasGzip () | |
Check whether we have the 'gzip' commandline utility, will skip the test whenever "gzip -V" fails. More... | |
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... | |
isWikitextNS ( $ns) | |
Returns true if the given namespace defaults to Wikitext according to $wgNamespaceContentModels. 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... | |
setMwGlobals ( $pairs, $value=null) | |
setUp () | |
stashMwGlobals ( $globalKeys) | |
Stashes the global, will be restored in tearDown() More... | |
tearDown () | |
Static Protected Member Functions | |
static | stripStringKeys (&$r) |
Utility function for eliminating all string keys from an array. More... | |
Protected Attributes | |
DatabaseBase | $db |
array | $supportedDBs |
array | $tablesUsed = array() |
Private Member Functions | |
addCoreDBData () | |
assertEmpty2 ( $value, $msg) | |
Used as a compatibility method for phpunit < 3.7.32. More... | |
resetDB () | |
Empty all tables so they can be repopulated for tests. More... | |
Static Private Member Functions | |
static | isNotUnittest ( $table) |
static | unprefixTable ( $tableName) |
Private Attributes | |
$called = array() | |
$called tracks whether the setUp and tearDown method has been called. More... | |
array | $mwGlobals = array() |
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 = array() |
Holds the paths of temporary files/directories created through getNewTempFile, and getNewTempDirectory. More... | |
Static Private Attributes | |
static | $dbSetup = false |
static | $oldTablePrefix = false |
static | $reuseDB = false |
static | $useTemporaryTables = true |
Definition at line 6 of file MediaWikiTestCase.php.
Reimplemented in RevisionStorageTest, WikiPageTest, JobQueueTest, RefreshLinksPartitionTest, and LinksUpdateTest.
Definition at line 79 of file MediaWikiTestCase.php.
References $name.
MediaWikiTestCase::__call | ( | $func, | |
$args | |||
) |
string | $func | |
array | $args |
MWException |
Reimplemented in MWNamespaceTest.
Definition at line 581 of file MediaWikiTestCase.php.
|
private |
Definition at line 423 of file MediaWikiTestCase.php.
References $user, array(), EDIT_NEW, WikiPage\factory(), User\newFromName(), Title\newFromText(), and User\resetIdByNameCache().
Referenced by run().
MediaWikiTestCase::addDBData | ( | ) |
Stub.
If a test needs to add additional data to the database, it should implement this method and do so
Reimplemented in FetchTextTest, BackupDumperLoggerTest, ApiQueryBasicTest, ApiQueryContinueTest, ApiQueryContinue2Test, MessageCacheTest, TextPassDumperTest, BlockTest, BackupDumperPageTest, ApiBlockTest, and GenderCacheTest.
Definition at line 420 of file MediaWikiTestCase.php.
Referenced by run().
|
protected |
Utility method taking an array of elements and wrapping each element in it's own array.
Useful for data providers that only return a single argument.
array | $elements |
Definition at line 743 of file MediaWikiTestCase.php.
References array().
Referenced by SiteTest\instanceProvider(), GenericArrayObjectTest\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 764 of file MediaWikiTestCase.php.
References array(), and objectAssociativeSort().
Referenced by SiteListTest\testGetGlobalIdentifiers(), DjVuTest\testGetImageSize(), DjVuTest\testGetPageDimensions(), TextContentTest\testGetParserOutput(), SiteListTest\testSerialization(), GenericArrayObjectTest\testSerialization(), UIDGeneratorTest\testTimestampedUID(), and LinksUpdateTest\testUpdate_pagelinks().
|
private |
Used as a compatibility method for phpunit < 3.7.32.
Definition at line 597 of file MediaWikiTestCase.php.
References $value.
|
protected |
Asserts that an exception of the specified type occurs when running the provided code.
callable | $code | |
string | $expected | |
string | $message |
Definition at line 1025 of file MediaWikiTestCase.php.
|
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 793 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 "@group Database" to enable database test support, or list the tables under testing in $this->tablesUsed, or override the needsDB() method. |
Definition at line 703 of file MediaWikiTestCase.php.
References $db, $res, array(), as, DB_SLAVE, DatabaseType\lastError(), needsDB(), DatabaseBase\select(), stripStringKeys(), wfGetCaller(), and wfGetDB().
Referenced by LinksUpdateTest\assertLinksUpdate().
|
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 869 of file MediaWikiTestCase.php.
References $type.
Referenced by assertTypeOrValue(), FileBackendTest\doTestLockCalls(), UIDGeneratorTest\testNewSequentialID(), UIDGeneratorTest\testNewSequentialIDs(), and ApiQueryTestBase\validateRequestExpectedPair().
|
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 850 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 1071 of file MediaWikiTestCase.php.
References $GLOBALS, $html, and MWTidy\checkErrors().
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 1055 of file MediaWikiTestCase.php.
References $html, and assertValidHtmlDocument().
Referenced by HtmlFormatterTest\testTransform().
|
protected |
MWException |
Definition at line 649 of file MediaWikiTestCase.php.
References $supportedDBs.
Referenced by run().
|
protected |
Check, if $wgDiff3 is set and ready to merge Will mark the calling test as skipped, if not ready.
Definition at line 959 of file MediaWikiTestCase.php.
References global, wfRestoreWarnings(), and wfSuppressWarnings().
Referenced by EditPageTest\testAutoMerge(), GlobalTest\testMerge(), and WikitextContentHandlerTest\testMerge3().
|
protected |
Check whether we have the 'gzip' commandline utility, will skip the test whenever "gzip -V" fails.
Result is cached at the process level.
Definition at line 983 of file MediaWikiTestCase.php.
References $retval, and wfShellExec().
Referenced by TextPassDumperTest\testCheckpointGzip(), BackupDumperPageTest\testCurrentStubGzip(), BackupDumperPageTest\testXmlDumpsBackupUseCase(), and BackupDumperLoggerTest\testXmlDumpsBackupUseCaseLogging().
|
protected |
Check if $extName is a loaded PHP extension, will skip the test whenever it is not loaded.
Definition at line 1005 of file MediaWikiTestCase.php.
Referenced by DiffHistoryBlobTest\setUp(), TiffTest\setUp(), XMPTest\setUp(), FormatMetadataTest\setUp(), JpegTest\setUp(), ExifBitmapTest\setUp(), ExifTest\setUp(), CollationTest\setUp(), ExifRotationTest\setUp(), RevisionTest\testCompressRevisionTextUtf8Gzip(), RevisionTest\testGetRevisionTextGzip(), RevisionTest\testGetRevisionTextUtf8LegacyGzip(), RevisionTest\testGetRevisionTextUtf8NativeGzip(), BitmapMetadataHandlerTest\testMultilingualCascade(), and PNGMetadataExtractorTest\testPngNativetZtxt().
MediaWikiTestCase::dbPrefix | ( | ) |
Definition at line 391 of file MediaWikiTestCase.php.
References DB_PREFIX, and ORA_DB_PREFIX.
Referenced by DatabaseTest\prefixAndQuote(), and run().
MediaWikiTestCase::getCliArg | ( | $offset | ) |
Definition at line 658 of file MediaWikiTestCase.php.
References MediaWikiPHPUnitCommand\$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 903 of file MediaWikiTestCase.php.
References $namespaces, array(), 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 BackupDumperPageTest\addDBData(), TextPassDumperTest\addDBData(), FetchTextTest\addDBData(), EditPageTest\assertEdit(), RevisionStorageTest\createPage(), DifferenceEngineTest\getTitle(), WikiPageTest\newPage(), EditPageTest\testAutoMerge(), TextContentTest\testDeletionUpdates(), WikitextContentTest\testGetSecondaryDataUpdates(), and RevisionStorageTest\testUserWasLastToEdit().
|
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 173 of file MediaWikiTestCase.php.
References getNewTempFile(), and wfMkdirParents().
Referenced by TextPassDumperTest\checkpointHelper(), and ExifRotationTest\setUp().
|
protected |
Obtains a new temporary file name.
The obtained filename is enlisted to be removed upon tearDown
Definition at line 156 of file MediaWikiTestCase.php.
References wfTempDir().
Referenced by TextPassDumperTest\checkpointHelper(), getNewTempDirectory(), BaseDumpTest\setUpPrefetch(), TextPassDumperTest\setUpStub(), CdbTest\testCdb(), BackupDumperPageTest\testCurrentStubGzip(), BackupDumperPageTest\testCurrentStubPlain(), BackupDumperPageTest\testFullStubPlain(), BackupDumperPageTest\testFullTextPlain(), TextPassDumperTest\testPlain(), BackupDumperLoggerTest\testPlain(), TextPassDumperTest\testPrefetchPlain(), GlobalTest\testWfMkdirParents(), BackupDumperPageTest\testXmlDumpsBackupUseCase(), and BackupDumperLoggerTest\testXmlDumpsBackupUseCaseLogging().
MediaWikiTestCase::hideDeprecated | ( | $function | ) |
Don't throw a warning if $function is deprecated and called later.
string | $function |
Definition at line 679 of file MediaWikiTestCase.php.
References wfDeprecated(), wfRestoreWarnings(), and wfSuppressWarnings().
Referenced by RevisionTest\testConstructWithContent(), RevisionTest\testConstructWithText(), WikiPageTest\testDoEdit(), WikiPageTest\testDoQuickEdit(), LBFactoryTest\testGetLBFactoryClass(), RevisionStorageTest\testGetRawText(), RevisionTest\testGetRawText(), WikiPageTest\testGetRawText(), RevisionStorageTest\testGetText(), RevisionTest\testGetText(), WikiPageTest\testGetText(), and ArticleTest\testStaticFunctions().
|
staticprivate |
Definition at line 607 of file MediaWikiTestCase.php.
|
protected |
Returns true if the given namespace defaults to Wikitext according to $wgNamespaceContentModels.
int | $ns | The namespace ID to check |
Definition at line 886 of file MediaWikiTestCase.php.
References CONTENT_MODEL_WIKITEXT, and global.
Referenced by SearchEngineTest\addPages(), SearchEngineTest\fetchIds(), and TitlePermissionTest\testQuickPermissions().
|
static |
DataBaseBase | $db |
Definition at line 618 of file MediaWikiTestCase.php.
References $db, $tables, array(), DatabaseType\getType(), global, DatabaseBase\listTables(), and DatabaseBase\listViews().
Referenced by setupTestDB().
|
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 369 of file MediaWikiTestCase.php.
References $GLOBALS, $name, as, and setMwGlobals().
Referenced by RevisionTest\setUp(), and TitleMethodsTest\setUp().
MediaWikiTestCase::needsDB | ( | ) |
Definition at line 399 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 807 of file MediaWikiTestCase.php.
Referenced by assertArrayEquals().
|
private |
MediaWikiTestCase::run | ( | PHPUnit_Framework_TestResult | $result = null | ) |
Definition at line 86 of file MediaWikiTestCase.php.
References ObjectCache\$instances, $useTemporaryTables, addCoreDBData(), addDBData(), CACHE_DB, checkDbIsSupported(), DB_MASTER, dbPrefix(), getCliArg(), needsDB(), resetDB(), setupTestDB(), wfGetDB(), wfProfileIn(), and wfProfileOut().
MediaWikiTestCase::setCliArg | ( | $offset, | |
$value | |||
) |
Definition at line 667 of file MediaWikiTestCase.php.
References MediaWikiPHPUnitCommand\$additionalOptions, and $value.
|
protected |
Definition at line 302 of file MediaWikiTestCase.php.
References $GLOBALS, $value, array(), as, and stashMwGlobals().
Referenced by BackupDumperPageTest\addDBData(), EditPageTest\assertEdit(), MessageCacheTest\configureLanguages(), mergeMwGlobalArrayValue(), BitmapMetadataHandlerTest\setUp(), GlobalTest\setUp(), AutoLoaderTest\setUp(), BitmapScalingTest\setUp(), SvgTest\setUp(), MessageTest\setUp(), LanguageConverterTest\setUp(), RevisionTest\setUp(), TiffTest\setUp(), ResourceLoaderTest\setUp(), TestSample\setUp(), LinkFilterTest\setUp(), XmlTest\setUp(), MediaWikiLangTestCase\setUp(), FormatMetadataTest\setUp(), ExifBitmapTest\setUp(), JpegTest\setUp(), CssContentTest\setUp(), TitleTest\setUp(), CSSMinTest\setUp(), ApiTestCase\setUp(), WikiPageTest_ContentHandlerUseDB\setUp(), ExifTest\setUp(), RevisionTest_ContentHandlerUseDB\setUp(), ApiTestCaseUpload\setUp(), TextContentTest\setUp(), UploadFromUrlTest\setUp(), LocalFileTest\setUp(), ExifRotationTest\setUp(), ApiCreateAccountTest\setUp(), ExtraParserTest\setUp(), RCCacheEntryFactoryTest\setUp(), XmlSelectTest\setUp(), SpecialPageTest\setUp(), ContentHandlerTest\setUp(), UserTest\setUp(), BlockTest\setUp(), TagHookTest\setUp(), ApiEditPageTest\setUp(), MWNamespaceTest\setUp(), ResourceLoaderTestCase\setUp(), JobQueueTest\setUp(), LogFormatterTest\setUp(), SearchEngineTest\setUp(), TitlePermissionTest\setUp(), SearchUpdateTest\setUp(), WfParseUrlTest\setUp(), MediaWikiTitleCodecTest\setUp(), MagicVariableTest\setUp(), PreferencesTest\setUp(), DumpTestCase\setUp(), ArticleTablesTest\testbug14404(), UploadStashTest\testBug29408(), SpecialPreferencesTest\testBug41337(), UserTest\testCheckPasswordValidity(), ExtraParserTest\testCleanSigDisabled(), RevisionTest\testCompressRevisionTextUtf8Gzip(), ExternalStoreTest\testExternalFetchFromURL(), SideBarTest\testExternalUrlsRequireADescription(), ContentHandlerTest\testGetContentText_NonTextContent_fail(), ContentHandlerTest\testGetContentText_NonTextContent_ignore(), ContentHandlerTest\testGetContentText_NonTextContent_serialize(), ContentHandlerTest\testGetContentText_Null(), ContentHandlerTest\testGetContentText_TextContent(), WebRequestTest\testGetIP(), WebRequestTest\testGetIpLackOfRemoteAddrThrowAnException(), ResourceLoaderStartupModuleTest\testGetModuleRegistrations(), MessageTest\testInContentLanguageDisabled(), MessageTest\testInContentLanguageEnabled(), MWExceptionTest\testisCommandLine(), TextContentTest\testIsCountable(), WikiPageTest\testIsCountable(), MWExceptionTest\testJsonserializeexceptionBacktracingDisabled(), MWExceptionTest\testJsonserializeexceptionBacktracingEnabled(), MWExceptionTest\testJsonserializeexceptionKeys(), ExifRotationTest\testMetadataNoAutoRotate(), BitmapMetadataHandlerTest\testMultilingualCascade(), SanitizerTest\testRemovehtmltagsOnHtml5Tags(), SideBarTest\testRespectExternallinktarget(), SideBarTest\testRespectWgnofollowlinks(), ExifRotationTest\testRotationRenderingNoAutoRotate(), MWExceptionTest\testRunHooks(), TitleTest\testSecureAndSplit(), MediaWikiTestCaseTest\testSetGlobalsAreRestoredOnTearDown(), SideBarTest\testTestAttributesAssertionHelper(), LinksUpdateTest\testUpdate_categorylinks(), ApiUploadTest\testUploadChunks(), ApiUploadTest\testUploadStash(), MWExceptionTest\testUseMessageCache(), MWExceptionTest\testUseOutputPage(), TimeAdjustTest\testUserAdjust(), LinkerTest\testUserLink(), and WfExpandUrlTest\testWfExpandUrl().
|
protected |
Reimplemented in FetchTextTest, MaintenanceTest, TextPassDumperTest, BackupDumperPageTest, DumpTestCase, TestORMRowTest, LanguageClassesTestCase, FormOptionsInitializationTest, SideBarTest, RevisionStorageTest, DatabaseSqliteTest, WikiPageTest, MagicVariableTest, PreferencesTest, MediaWikiTitleCodecTest, FormOptionsTest, FauxResponseTest, WfParseUrlTest, LinksUpdateTest, SearchUpdateTest, TitlePermissionTest, SearchEngineTest, ApiOptionsTest, DifferenceEngineTest, LogFormatterTest, DjVuTest, JobQueueTest, UploadStashTest, ResourceLoaderTestCase, ParserPreloadTest, ApiEditPageTest, FileBackendTest, MWNamespaceTest, BlockTest, JpegMetadataExtractorTest, TagHookTest, ApiQueryTest, PathRouterTest, UserTest, ArticleTest, ContentHandlerTest, DatabaseSQLTest, DatabaseTest, StoreBatchTest, PreprocessorTest, SpecialPageTest, ApiParseTest, ApiPurgeTest, RCCacheEntryFactoryTest, WikitextContentHandlerTest, TitleMethodsTest, XmlSelectTest, ApiBlockTest, ApiCreateAccountTest, ApiTestCaseUpload, ApiUnblockTest, CollationTest, TextContentTest, ErrorPageErrorTest, ThrottledErrorTest, ExtraParserTest, LocalFileTest, ExifRotationTest, UploadFromUrlTest, ZipDirectoryReaderTest, ApiQueryAllPagesTest, ApiTestCase, ApiWatchTest, MessageCacheTest, CssContentTest, BadTitleErrorTest, CSSMinTest, ExifTest, BagOStuffTest, RevisionTest_ContentHandlerUseDB, TitleTest, UploadBaseTest, CdbTest, WikiPageTest_ContentHandlerUseDB, GenderCacheTest, ExifBitmapTest, GIFHandlerTest, JpegTest, PNGHandlerTest, SanitizerTest, SiteConfigurationTest, WebRequestTest, LinkFilterTest, FormatMetadataTest, PNGMetadataExtractorTest, SVGMetadataExtractorTest, XMPTest, MWTimestampTest, TidyTest, TestSample, XmlTest, MediaWikiLangTestCase, LanguageConverterTest, TiffTest, ResourceLoaderTest, RevisionTest, MWDebugTest, DiffHistoryBlobTest, HooksTest, BitmapScalingTest, SvgTest, MessageTest, GlobalTest, BitmapMetadataHandlerTest, TimeAdjustTest, and AutoLoaderTest.
Definition at line 187 of file MediaWikiTestCase.php.
References as, needsDB(), wfProfileIn(), wfProfileOut(), and wfRecursiveRemoveDir().
|
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.
DatabaseBase | $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 513 of file MediaWikiTestCase.php.
References $db, $useTemporaryTables, CloneDatabase\changePrefix(), DatabaseType\getType(), global, listTables(), and DatabaseBase\query().
Referenced by run().
|
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 329 of file MediaWikiTestCase.php.
References $e, $GLOBALS, array(), and as.
Referenced by setMwGlobals(), MediaWikiTestCaseTest\testExceptionThrownWhenStashingNonExistentGlobals(), 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 825 of file MediaWikiTestCase.php.
References as.
Referenced by assertSelect().
|
protected |
Reimplemented in MaintenanceTest, TestORMRowTest, LanguageClassesTestCase, ApiOptionsTest, RevisionStorageTest, JobQueueTest, StoreBatchTest, RevisionTest, SearchEngineTest, LogFormatterTest, WikiPageTest, ContentHandlerTest, UploadStashTest, ApiEditPageTest, TitleMethodsTest, ApiQueryTest, ParserPreloadTest, LanguageConverterTest, BagOStuffTest, TestSample, ApiTestCaseUpload, GlobalTest, UploadBaseTest, ArticleTest, XmlSelectTest, BaseDumpTest, DatabaseTest, MWDebugTest, ErrorPageErrorTest, ThrottledErrorTest, BadTitleErrorTest, WebRequestTest, and UIDGeneratorTest.
Definition at line 216 of file MediaWikiTestCase.php.
References $GLOBALS, $phpErrorLevel, $value, array(), as, fail, needsDB(), wfProfileIn(), wfProfileOut(), and wfRecursiveRemoveDir().
Referenced by MediaWikiTestCaseTest\testSetGlobalsAreRestoredOnTearDown(), 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 481 of file MediaWikiTestCase.php.
References CloneDatabase\changePrefix().
|
final |
Make sure MediaWikiTestCase extending classes have called their parent setUp method.
Definition at line 264 of file MediaWikiTestCase.php.
|
staticprivate |
Definition at line 601 of file MediaWikiTestCase.php.
References global.
MediaWikiTestCase::usesTemporaryTables | ( | ) |
Definition at line 143 of file MediaWikiTestCase.php.
References $useTemporaryTables.
|
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 20 of file MediaWikiTestCase.php.
Referenced by HtmlCheckMatrixTest\testValidateCallsUserDefinedValidationCallback().
|
protected |
Definition at line 31 of file MediaWikiTestCase.php.
Referenced by assertSelect(), DatabaseMysqlBaseTest\getMockForViews(), listTables(), setupTestDB(), DatabaseMysqlBaseTest\testAddIdentifierQuotes(), ORMTableTest\testIgnoreErrorsOverride(), DatabaseMysqlBaseTest\testIsView(), and DatabaseMysqlBaseTest\testListviews().
|
staticprivate |
Definition at line 40 of file MediaWikiTestCase.php.
Holds original values of MediaWiki configuration settings to be restored in tearDown().
See also setMwGlobals().
Definition at line 61 of file MediaWikiTestCase.php.
|
staticprivate |
Definition at line 41 of file MediaWikiTestCase.php.
|
private |
Original value of PHP's error_reporting setting.
Definition at line 47 of file MediaWikiTestCase.php.
Referenced by tearDown().
|
staticprivate |
Definition at line 39 of file MediaWikiTestCase.php.
|
protected |
Definition at line 72 of file MediaWikiTestCase.php.
Referenced by checkDbIsSupported().
Definition at line 36 of file MediaWikiTestCase.php.
Holds the paths of temporary files/directories created through getNewTempFile, and getNewTempDirectory.
Definition at line 54 of file MediaWikiTestCase.php.
Referenced by FileBackendTest\doTestGetLocalCopy(), and FileBackendTest\doTestGetLocalReference().
|
static |
Definition at line 26 of file MediaWikiTestCase.php.
|
staticprivate |
Definition at line 38 of file MediaWikiTestCase.php.
Referenced by run(), setupTestDB(), and usesTemporaryTables().
const MediaWikiTestCase::DB_PREFIX = 'unittest_' |
Table name prefixes.
Oracle likes it shorter.
Definition at line 66 of file MediaWikiTestCase.php.
Referenced by dbPrefix().
const MediaWikiTestCase::ORA_DB_PREFIX = 'ut_' |
Definition at line 67 of file MediaWikiTestCase.php.
Referenced by dbPrefix().