MediaWiki  REL1_24
MediaWikiTestCase Class Reference

Inherited by ActionTest, ApiModuleManagerTest, ArrayDiffFormatterTest, ArrayUtilsTest, ArticleTest, AutoLoaderTest, BadTitleErrorTest, BagOStuffTest, BaseDumpTest, BitmapMetadataHandlerTest, BitmapScalingTest, BloomCacheRedisTest, CdbTest, CLDRPluralRuleEvaluatorTest, CleanUpTest, ConfigFactoryTest, ContentHandlerTest, CSSMinTest, DatabaseMysqlBaseTest, DatabaseSqliteTest, DatabaseSQLTest, DatabaseTest, DeferredUpdatesTest, DifferenceEngineTest, DiffHistoryBlobTest, DiffOpTest, DiffTest, DummyExtensionsTest, ErrorPageErrorTest, ExifBitmapTest, ExifTest, ExternalStoreTest, ExtraParserTest, FallbackTest, FauxRequestTest, FauxResponseTest, FetchTextTest, FileBackendTest, FileRepoTest, FormatJsonTest, FormOptionsInitializationTest, FormOptionsTest, GenericArrayObjectTest, GIFMetadataExtractorTest, GitInfoTest, GlobalTest, GlobalVarConfigTest, GlobalWithDBTest, HashConfigTest, HashRingTest, HooksTest, HtmlAutoCompleteSelectFieldTest, HtmlCheckMatrixTest, HtmlFormatterTest, HtmlTest, HttpTest, IEUrlExtensionTest, ImageListPagerTest, InstallDocFormatterTest, IPSetTest, IPTCTest, IPTest, JavaScriptMinifierTest, JobQueueTest, JpegMetadataExtractorTest, LanguageClassesTestCase, LBFactoryTest, LicensesTest, LinksUpdateTest, LocalFileTest, LocalisationCacheTest, MagicVariableTest, MailAddressTest, MaintenanceTest, MediaHandlerTest, MediaWikiLangTestCase, MediaWikiMediaTestCase, MediaWikiPageLinkRendererTest, MediaWikiTestCaseTest, MediaWikiTitleCodecTest, MimeMagicTest, MultiConfigTest, MWCryptHKDFTest, MWDebugTest, MWExceptionHandlerTest, MWExceptionTest, MWFunctionTest, MWMessagePackTest, MWNamespaceTest, NewParserTest, OracleInstallerTest, ORMRowTest, ORMTableTest, OutputPageTest, ParserOutputTest, ParserPreloadTest, PasswordTest, PasswordTestCase, PathRouterTest, PNGMetadataExtractorTest, PoolCounterTest, PreferencesTest, PrefixUniquenessTest, PreprocessorTest, ProcessCacheLRUTest, QueryAllSpecialPagesTest, ReadOnlyErrorTest, RecentChangeTest, RefreshLinksPartitionTest, RepoGroupTest, RequestContextTest, ResourceLoaderTestCase, ResourcesTest, RevisionStorageTest, RevisionTest, RunningStatTest, SanitizerTest, SanitizerValidateEmailTest, SearchUpdateTest, SiteConfigurationTest, SiteListTest, SiteSQLStoreTest, SiteTest, SkinFactoryTest, SkinTemplateTest, SpecialMIMESearchTest, SpecialMyLanguageTest, SpecialPageAliasTest, SpecialPageFactoryTest, SpecialPageTest, SpecialPreferencesTest, SpecialRecentchangesTest, SpecialSearchTest, StoreBatchTest, StringUtilsTest, StructureTest, SVGMetadataExtractorTest, TagHookTest, ThrottledErrorTest, TidyTest, TiffTest, TitleArrayFromResultTest, TitleMethodsTest, TitleTest, TitleValueTest, UIDGeneratorTest, UploadBaseTest, UploadStashTest, UserArrayFromResultTest, UserNotLoggedInTest, UserTest, WebRequestTest, WfAssembleUrlTest, WfBaseConvertTest, WfBaseNameTest, WfBCP47Test, WfExpandUrlTest, WfGetCallerTest, WfParseUrlTest, WfRemoveDotSegmentsTest, WfShellExecTest, WfShorthandToIntegerTest, WfTimestampTest, WfUrlencodeTest, XmlJs, XmlSelectTest, XmlTest, XmlTypeCheckTest, XMPTest, XMPValidateTest, and ZipDirectoryReaderTest.

Collaboration diagram for MediaWikiTestCase:

List of all members.

Public Member Functions

 __call ($func, $args)
 __construct ($name=null, array $data=array(), $dataName= '')
 __destruct ()
 addDBData ()
 Stub.
 dbPrefix ()
 getCliArg ($offset)
 hideDeprecated ($function)
 Don't throw a warning if $function is deprecated and called later.
 needsDB ()
 run (PHPUnit_Framework_TestResult $result=null)
 setCliArg ($offset, $value)
 testMediaWikiTestCaseParentSetupCalled ()
 Make sure MediaWikiTestCase extending classes have called their parent setUp method.
 usesTemporaryTables ()

Static Public Member Functions

static assertTag ($matcher, $actual, $message= '', $isHtml=true)
 Note: we are overriding this method to remove the deprecated error.
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.
static teardownTestDB ()
 Restores MediaWiki to using the table set (table prefix) it was using before setupTestDB() was called.

Public Attributes

const DB_PREFIX = 'unittest_'
 Table name prefixes.
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.
 assertArrayEquals (array $expected, array $actual, $ordered=false, $named=false)
 Assert that two arrays are equal.
 assertException ($code, $expected= 'Exception', $message= '')
 Asserts that an exception of the specified type occurs when running the provided code.
 assertHTMLEquals ($expected, $actual, $msg= '')
 Put each HTML element on its own line and then equals() the results.
 assertSelect ($table, $fields, $condition, array $expectedRows)
 Asserts that the given database query yields the rows given by $expectedRows.
 assertType ($type, $actual, $message= '')
 Asserts the type of the provided value.
 assertTypeOrValue ($type, $actual, $value=false, $message= '')
 Asserts that the provided variable is of the specified internal type or equals the $value argument.
 assertValidHtmlDocument ($html)
 Asserts that the given string is valid HTML document.
 assertValidHtmlSnippet ($html)
 Asserts that the given string is a valid HTML snippet.
 checkDbIsSupported ()
 checkHasDiff3 ()
 Check, if $wgDiff3 is set and ready to merge Will mark the calling test as skipped, if not ready.
 checkHasGzip ()
 Check whether we have the 'gzip' commandline utility, will skip the test whenever "gzip -V" fails.
 checkPHPExtension ($extName)
 Check if $extName is a loaded PHP extension, will skip the test whenever it is not loaded.
 getDefaultWikitextNS ()
 Returns the ID of a namespace that defaults to Wikitext.
 getNewTempDirectory ()
 obtains a new temporary directory
 getNewTempFile ()
 Obtains a new temporary file name.
 isWikitextNS ($ns)
 Returns true if the given namespace defaults to Wikitext according to $wgNamespaceContentModels.
 mergeMwGlobalArrayValue ($name, $values)
 Merges the given values into a MW global array variable.
 objectAssociativeSort (array &$array)
 Does an associative sort that works for objects.
 setMwGlobals ($pairs, $value=null)
 setUp ()
 stashMwGlobals ($globalKeys)
 Stashes the global, will be restored in tearDown()
 tearDown ()

Static Protected Member Functions

static stripStringKeys (&$r)
 Utility function for eliminating all string keys from an array.

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.
 resetDB ()
 Empty all tables so they can be repopulated for tests.

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.
array $mwGlobals = array()
 Holds original values of MediaWiki configuration settings to be restored in tearDown().
int $phpErrorLevel
 Original value of PHP's error_reporting setting.
array $tmpFiles = array()
 Holds the paths of temporary files/directories created through getNewTempFile, and getNewTempDirectory.

Static Private Attributes

static $dbSetup = false
static $oldTablePrefix = false
static $reuseDB = false
static $useTemporaryTables = true

Detailed Description

Since:
1.18

Definition at line 6 of file MediaWikiTestCase.php.


Constructor & Destructor Documentation

Definition at line 85 of file MediaWikiTestCase.php.


Member Function Documentation

MediaWikiTestCase::__call ( func,
args 
)
Since:
1.18
Parameters:
string$func
array$args
Returns:
mixed
Exceptions:
MWException

Reimplemented in MWNamespaceTest.

Definition at line 592 of file MediaWikiTestCase.php.

Definition at line 434 of file MediaWikiTestCase.php.

Stub.

If a test needs to add additional data to the database, it should implement this method and do so

Since:
1.18

Reimplemented in NewParserTest, FetchTextTest, BackupDumperLoggerTest, ApiQueryBasicTest, ApiQueryContinueTest, ApiQueryContinue2Test, MessageCacheTest, TextPassDumperTest, BlockTest, BackupDumperPageTest, ApiBlockTest, GenderCacheTest, and SpecialMyLanguageTest.

Definition at line 431 of file MediaWikiTestCase.php.

MediaWikiTestCase::arrayWrap ( array elements) [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.

Since:
1.20
Parameters:
array$elements
Returns:
array

Definition at line 759 of file MediaWikiTestCase.php.

Referenced by SiteTest\instanceProvider(), GenericArrayObjectTest\instanceProvider(), SiteListTest\siteArrayProvider(), and SiteListTest\siteListProvider().

MediaWikiTestCase::assertArrayEquals ( array expected,
array actual,
ordered = false,
named = false 
) [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.

Since:
1.20
Parameters:
array$expected
array$actual
bool$orderedIf the order of the values should match
bool$namedIf the keys should match

Definition at line 780 of file MediaWikiTestCase.php.

Referenced by SiteListTest\testGetGlobalIdentifiers(), ApiModuleManagerTest\testGetGroups(), DjVuTest\testGetImageSize(), ApiModuleManagerTest\testGetNames(), ApiModuleManagerTest\testGetNamesWithClasses(), DjVuTest\testGetPageDimensions(), TextContentTest\testGetParserOutput(), PoolCounterTest\testHashKeyIntoSlots(), SiteListTest\testSerialization(), GenericArrayObjectTest\testSerialization(), UIDGeneratorTest\testTimestampedUID(), and LinksUpdateTest\testUpdate_pagelinks().

MediaWikiTestCase::assertEmpty2 ( value,
msg 
) [private]

Used as a compatibility method for phpunit < 3.7.32.

Parameters:
string$value
string$msg

Definition at line 610 of file MediaWikiTestCase.php.

References $value.

MediaWikiTestCase::assertException ( code,
expected = 'Exception',
message = '' 
) [protected]

Asserts that an exception of the specified type occurs when running the provided code.

Since:
1.21
Deprecated:
since 1.22 Use setExpectedException
Parameters:
callable$code
string$expected
string$message

Definition at line 1045 of file MediaWikiTestCase.php.

MediaWikiTestCase::assertHTMLEquals ( expected,
actual,
msg = '' 
) [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

Since:
1.20
Parameters:
string$expectedHTML on oneline
string$actualHTML on oneline
string$msgOptional message

Definition at line 811 of file MediaWikiTestCase.php.

MediaWikiTestCase::assertSelect ( table,
fields,
condition,
array expectedRows 
) [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.

Since:
1.20
Parameters:
string | array$tableThe table(s) to query
string | array$fieldsThe columns to include in the result (and to sort by)
string | array$condition"where" condition(s)
array$expectedRowsAn array of arrays giving the expected rows.
Exceptions:
MWExceptionIf 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 719 of file MediaWikiTestCase.php.

Referenced by LinksUpdateTest\assertLinksUpdate().

static MediaWikiTestCase::assertTag ( matcher,
actual,
message = '',
isHtml = true 
) [static]
MediaWikiTestCase::assertType ( type,
actual,
message = '' 
) [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.

Since:
1.20
Parameters:
string$type
mixed$actual
string$message

Definition at line 887 of file MediaWikiTestCase.php.

Referenced by ActionTest\testActionFactory(), UIDGeneratorTest\testNewSequentialID(), UIDGeneratorTest\testNewSequentialIDs(), FormatJsonTest\testParse(), FormatJsonTest\testParseErrors(), FormatJsonTest\testParseTryFixing(), and ApiQueryTestBase\validateRequestExpectedPair().

MediaWikiTestCase::assertTypeOrValue ( type,
actual,
value = false,
message = '' 
) [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.

Since:
1.20
Parameters:
string$type
mixed$actual
mixed$value
string$message

Definition at line 868 of file MediaWikiTestCase.php.

Referenced by SiteTest\testGetGlobalId(), SiteTest\testGetLanguageCode(), and SiteTest\testGetPath().

Asserts that the given string is valid HTML document.

Since:
1.23
Note:
Will mark the test as skipped if the "tidy" module is not installed.
This ignores $wgUseTidy, so we can check for valid HTML even (and especially) when automatic tidying is disabled.
Parameters:
string$htmlA complete HTML document

Definition at line 1091 of file MediaWikiTestCase.php.

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.

Since:
1.23
Note:
Will mark the test as skipped if the "tidy" module is not installed.
This ignores $wgUseTidy, so we can check for valid HTML even (and especially) when automatic tidying is disabled.
Parameters:
string$htmlAn HTML snippet (treated as the contents of the body tag).

Definition at line 1075 of file MediaWikiTestCase.php.

Referenced by HtmlFormatterTest\testTransform().

Exceptions:
MWException
Since:
1.18

Definition at line 662 of file MediaWikiTestCase.php.

Check, if $wgDiff3 is set and ready to merge Will mark the calling test as skipped, if not ready.

Since:
1.21

Definition at line 977 of file MediaWikiTestCase.php.

Referenced by EditPageTest\testAutoMerge(), and GlobalTest\testMerge().

Check whether we have the 'gzip' commandline utility, will skip the test whenever "gzip -V" fails.

Result is cached at the process level.

Returns:
bool
Since:
1.21

Definition at line 1001 of file MediaWikiTestCase.php.

Referenced by TextPassDumperTest\testCheckpointGzip(), BackupDumperPageTest\testCurrentStubGzip(), BackupDumperPageTest\testXmlDumpsBackupUseCase(), and BackupDumperLoggerTest\testXmlDumpsBackupUseCaseLogging().

Returns:
string
Since:
1.18

Definition at line 402 of file MediaWikiTestCase.php.

Referenced by DatabaseTest\prefixAndQuote().

Since:
1.18
Parameters:
string$offset
Returns:
mixed

Definition at line 673 of file MediaWikiTestCase.php.

References PHPUnitMaintClass\$additionalOptions.

Referenced by BagOStuffTest\setUp(), StoreBatchTest\setUp(), JobQueueTest\setUp(), and BagOStuffTest\testMerge().

Returns the ID of a namespace that defaults to Wikitext.

Exceptions:
MWExceptionIf there is none.
Returns:
int The ID of the wikitext Namespace
Since:
1.21

Definition at line 921 of file MediaWikiTestCase.php.

Referenced by TextPassDumperTest\addDBData(), EditPageTest\assertEdit(), RevisionStorageTest\createPage(), DifferenceEngineTest\getTitle(), WikiPageTest\newPage(), EditPageTest\testAutoMerge(), TextContentTest\testDeletionUpdates(), and WikitextContentTest\testGetSecondaryDataUpdates().

obtains a new temporary directory

The obtained directory is enlisted to be removed (recursively with all its contained files) upon tearDown.

Since:
1.20
Returns:
string Absolute name of the temporary directory

Definition at line 180 of file MediaWikiTestCase.php.

Referenced by TextPassDumperTest\checkpointHelper(), and MediaWikiMediaTestCase\setUp().

static MediaWikiTestCase::isNotUnittest ( table) [static, private]

Definition at line 620 of file MediaWikiTestCase.php.

References global.

MediaWikiTestCase::isWikitextNS ( ns) [protected]

Returns true if the given namespace defaults to Wikitext according to $wgNamespaceContentModels.

Parameters:
int$nsThe namespace ID to check
Returns:
bool
Since:
1.21

Definition at line 904 of file MediaWikiTestCase.php.

Referenced by SearchEngineTest\addPages(), and SearchEngineTest\fetchIds().

static MediaWikiTestCase::listTables ( db) [static]
Since:
1.18
Parameters:
DataBaseBase$db
Returns:
array

Definition at line 631 of file MediaWikiTestCase.php.

MediaWikiTestCase::mergeMwGlobalArrayValue ( name,
values 
) [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.

Parameters:
string$nameThe name of the global, as in wgFooBar
array$valuesThe array containing the entries to set in that global
Exceptions:
MWExceptionIf the designated global is not an array.
Since:
1.21

Definition at line 380 of file MediaWikiTestCase.php.

Referenced by RevisionTest\setUp(), TitleMethodsTest\setUp(), ApiRevisionDeleteTest\setUp(), SpecialMyLanguageTest\testFindTitle(), SpecialPageFactoryTest\testGetNames(), and SpecialPageFactoryTest\testGetPage().

Returns:
bool
Since:
1.18

Definition at line 410 of file MediaWikiTestCase.php.

Does an associative sort that works for objects.

Since:
1.20
Parameters:
array$array

Definition at line 825 of file MediaWikiTestCase.php.

Empty all tables so they can be repopulated for tests.

Definition at line 558 of file MediaWikiTestCase.php.

MediaWikiTestCase::setCliArg ( offset,
value 
)
Since:
1.18
Parameters:
string$offset
mixed$value

Definition at line 684 of file MediaWikiTestCase.php.

References PHPUnitMaintClass\$additionalOptions, and $value.

MediaWikiTestCase::setMwGlobals ( pairs,
value = null 
) [protected]

Definition at line 313 of file MediaWikiTestCase.php.

Referenced by BackupDumperPageTest\addDBData(), EditPageTest\assertEdit(), OutputPageTest\assertTransformCssMediaCase(), MessageCacheTest\configureLanguages(), TitleTest\secureAndSplitGlobals(), ImagePageTest\setUp(), AutoLoaderTest\setUp(), MessageTest\setUp(), HtmlTest\setUp(), GitInfoTest\setUp(), ResourceLoaderTest\setUp(), GlobalTest\setUp(), RevisionTest\setUp(), LanguageConverterTest\setUp(), TitleTest\setUp(), MediaWikiLangTestCase\setUp(), SvgTest\setUp(), FormatMetadataTest\setUp(), TestSample\setUp(), LinkFilterTest\setUp(), XmlTest\setUp(), BitmapMetadataHandlerTest\setUp(), BitmapScalingTest\setUp(), JpegTest\setUp(), LocalisationCacheTest\setUp(), ApiTestCase\setUp(), CssContentTest\setUp(), RevisionTestContentHandlerUseDB\setUp(), CSSMinTest\setUp(), WikiPageTestContentHandlerUseDB\setUp(), ExtraParserTest\setUp(), ExifTest\setUp(), TiffTest\setUp(), ApiCreateAccountTest\setUp(), ApiTestCaseUpload\setUp(), ImagePage404Test\setUp(), UploadFromUrlTest\setUp(), LocalFileTest\setUp(), ExifRotationTest\setUp(), ExifBitmapTest\setUp(), TextContentTest\setUp(), XmlSelectTest\setUp(), ContentHandlerTest\setUp(), SpecialPageTest\setUp(), ActionTest\setUp(), UserTest\setUp(), BlockTest\setUp(), ResourceLoaderTestCase\setUp(), MWNamespaceTest\setUp(), ApiEditPageTest\setUp(), JobQueueTest\setUp(), TagHookTest\setUp(), RCCacheEntryFactoryTest\setUp(), SearchUpdateTest\setUp(), OldChangesListTest\setUp(), WfParseUrlTest\setUp(), MediaWikiPageLinkRendererTest\setUp(), MediaWikiTitleCodecTest\setUp(), RepoGroupTest\setUpForeignRepo(), SpecialPreferencesTest\testBug41337(), FileTest\testCanAnimateThumbIfAppropriate(), RevisionTest\testCompressRevisionTextUtf8Gzip(), HtmlTest\testElementBasics(), ExternalStoreTest\testExternalFetchFromURL(), SpecialMyLanguageTest\testFindTitle(), RepoGroupTest\testForEachForeignRepoNone(), LinkerTest\testFormatComment(), FileTest\testGenerateBucketsIfNeeded(), ContentHandlerTest\testGetContentText_NonTextContent_fail(), ContentHandlerTest\testGetContentText_NonTextContent_ignore(), ContentHandlerTest\testGetContentText_NonTextContent_serialize(), ContentHandlerTest\testGetContentText_Null(), ContentHandlerTest\testGetContentText_TextContent(), ConfigFactoryTest\testGetDefaultInstance(), WebRequestTest\testGetIP(), WebRequestTest\testGetIpLackOfRemoteAddrThrowAnException(), ResourceLoaderTest\testGetLoadScript(), SpecialPageFactoryTest\testGetLocalNameFor(), ResourceLoaderStartupModuleTest\testGetModuleRegistrations(), WikiPageTest\testGetRedirectTarget(), FileTest\testGetThumbnailBucket(), SpecialPageFactoryTest\testGetTitleForAlias(), RepoGroupTest\testHasForeignRepoNegative(), RequestContextTest\testImportScopedSession(), MessageTest\testInContentLanguage(), MessageTest\testInContentLanguageOverride(), MWExceptionTest\testisCommandLine(), TextContentTest\testIsCountable(), WikiPageTest\testIsCountable(), TitleTest\testIsValidMoveOperation(), MWExceptionTest\testJsonserializeexceptionBacktracingDisabled(), MWExceptionTest\testJsonserializeexceptionBacktracingEnabled(), MWExceptionTest\testJsonserializeexceptionKeys(), OutputPageTest\testMakeResourceLoaderLink(), ExifRotationTest\testMetadataAutoRotate(), ExifRotationTest\testMetadataAutoRotateUnsupported(), ExifRotationTest\testMetadataNoAutoRotate(), BitmapMetadataHandlerTest\testMultilingualCascade(), MailAddressTest\testNewFromUser(), MediaWikiSiteTest\testNormalizePageTitle(), ResourceLoaderStartupModuleTest\testRegistrationsMinified(), SanitizerTest\testRemovehtmltagsOnHtml5Tags(), SpecialPageFactoryTest\testResolveAlias(), ExifRotationTest\testRotationRenderingNoAutoRotate(), MWExceptionTest\testRunHooks(), SpecialSearchTest\testSearchTermIsNotExpanded(), MediaWikiTestCaseTest\testSetGlobalsAreRestoredOnTearDown(), ArticleTablesTest\testTemplatelinksUsesContentLanguage(), ApiQueryTest\testTitlesGetNormalized(), MailAddressTest\testToString(), LinksUpdateTest\testUpdate_categorylinks(), LinksUpdateTest\testUpdate_langlinks(), LinksUpdateTest\testUpdate_page_props_without_sortkey(), ApiUploadTest\testUploadChunks(), ApiUploadTest\testUploadStash(), MWExceptionTest\testUseMessageCache(), MWExceptionTest\testUseOutputPage(), TimeAdjustTest\testUserAdjust(), LinkerTest\testUserLink(), and WfExpandUrlTest\testWfExpandUrl().

MediaWikiTestCase::setUp ( ) [protected]

Reimplemented in FetchTextTest, MaintenanceTest, TextPassDumperTest, BackupDumperPageTest, DumpTestCase, TestORMRowTest, NewParserTest, LanguageClassesTestCase, FormOptionsInitializationTest, SideBarTest, RevisionStorageTest, WikiPageTest, MagicVariableTest, PreferencesTest, DatabaseSqliteTest, MediaWikiTitleCodecTest, PasswordTestCase, MediaWikiPageLinkRendererTest, FormOptionsTest, FauxResponseTest, WfParseUrlTest, OldChangesListTest, LinksUpdateTest, SearchUpdateTest, RCCacheEntryFactoryTest, TitlePermissionTest, SearchEngineTest, ApiOptionsTest, TagHookTest, DifferenceEngineTest, LogFormatterTest, JobQueueTest, UploadStashTest, ParserPreloadTest, ApiEditPageTest, FileBackendTest, JpegMetadataExtractorTest, MWNamespaceTest, ResourceLoaderTestCase, ApiRevisionDeleteTest, BlockTest, ActionTest, ApiQueryTest, BloomCacheRedisTest, DatabaseTest, PathRouterTest, UserTest, ArticleTest, ContentHandlerTest, DatabaseSQLTest, StoreBatchTest, PreprocessorTest, SpecialPageTest, ApiParseTest, ApiPurgeTest, TextContentTest, DjVuTest, ExifBitmapTest, ExifRotationTest, MediaWikiMediaTestCase, TitleMethodsTest, XmlSelectTest, ApiBlockTest, ApiCreateAccountTest, ApiTestCaseUpload, ApiUnblockTest, CollationTest, WikitextContentHandlerTest, ErrorPageErrorTest, ThrottledErrorTest, ExtraParserTest, ImagePage404Test, LocalFileTest, ExifTest, TiffTest, UploadFromUrlTest, ZipDirectoryReaderTest, ApiQueryAllPagesTest, ApiTestCase, ApiWatchTest, MessageCacheTest, CssContentTest, BadTitleErrorTest, CSSMinTest, GIFHandlerTest, PNGHandlerTest, XCFHandlerTest, BagOStuffTest, RevisionTestContentHandlerUseDB, SpecialMIMESearchTest, UploadBaseTest, CdbTest, WikiPageTestContentHandlerUseDB, GenderCacheTest, LocalisationCacheTest, JpegTest, PNGMetadataExtractorTest, SVGMetadataExtractorTest, XMPTest, SanitizerTest, SiteConfigurationTest, WebRequestTest, LinkFilterTest, BitmapMetadataHandlerTest, BitmapScalingTest, FormatMetadataTest, GIFMetadataExtractorTest, SvgTest, MWTimestampTest, TidyTest, TestSample, XmlTest, GitInfoTest, GlobalTest, LanguageConverterTest, ResourceLoaderTest, RevisionTest, TitleTest, MediaWikiLangTestCase, HtmlTest, MimeMagicTest, MWDebugTest, DiffHistoryBlobTest, HooksTest, MessageTest, ResourceLoaderModuleTest, ImagePageTest, TimeAdjustTest, and AutoLoaderTest.

Definition at line 194 of file MediaWikiTestCase.php.

static MediaWikiTestCase::setupTestDB ( DatabaseBase db,
prefix 
) [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.

Since:
1.21
Note:
the original table prefix is stored in self::$oldTablePrefix. This is used by teardownTestDB() to return the wiki to using the original table set.
this method only works when first called. Subsequent calls have no effect, even if using different parameters.
Parameters:
DatabaseBase$dbThe database connection
string$prefixThe prefix to use for the new table set (aka schema).
Exceptions:
MWExceptionIf the database table prefix is already $prefix

Definition at line 524 of file MediaWikiTestCase.php.

MediaWikiTestCase::stashMwGlobals ( globalKeys) [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).

Parameters:
array | string$globalKeysKey to the global variable, or an array of keys.
Exceptions:
ExceptionWhen trying to stash an unset global
Since:
1.23

Definition at line 340 of file MediaWikiTestCase.php.

Referenced by GlobalVarConfigTest\maybeStashGlobal(), MediaWikiTestCaseTest\testExceptionThrownWhenStashingNonExistentGlobals(), and MediaWikiTestCaseTest\testStashedGlobalsAreRestoredOnTearDown().

static MediaWikiTestCase::stripStringKeys ( &$  r) [static, protected]

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.

Since:
1.20
Parameters:
mixed$rThe array to remove string keys from.

Definition at line 843 of file MediaWikiTestCase.php.

static MediaWikiTestCase::teardownTestDB ( ) [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).

Since:
1.21

Definition at line 492 of file MediaWikiTestCase.php.

Referenced by MediaWikiPHPUnitBootstrap\__destruct().

Make sure MediaWikiTestCase extending classes have called their parent setUp method.

Definition at line 275 of file MediaWikiTestCase.php.

static MediaWikiTestCase::unprefixTable ( tableName) [static, private]

Definition at line 614 of file MediaWikiTestCase.php.

Since:
1.21
Returns:
bool

Definition at line 150 of file MediaWikiTestCase.php.

References $useTemporaryTables.


Member Data Documentation

MediaWikiTestCase::$called = array() [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 19 of file MediaWikiTestCase.php.

Referenced by HtmlCheckMatrixTest\testValidateCallsUserDefinedValidationCallback().

MediaWikiTestCase::$dbSetup = false [static, private]

Definition at line 39 of file MediaWikiTestCase.php.

array MediaWikiTestCase::$mwGlobals = array() [private]

Holds original values of MediaWiki configuration settings to be restored in tearDown().

See also setMwGlobals().

Definition at line 60 of file MediaWikiTestCase.php.

MediaWikiTestCase::$oldTablePrefix = false [static, private]

Definition at line 40 of file MediaWikiTestCase.php.

int MediaWikiTestCase::$phpErrorLevel [private]

Original value of PHP's error_reporting setting.

Definition at line 46 of file MediaWikiTestCase.php.

MediaWikiTestCase::$reuseDB = false [static, private]

Definition at line 38 of file MediaWikiTestCase.php.

array MediaWikiTestCase::$supportedDBs [protected]
Initial value:
 array(
        'mysql',
        'sqlite',
        'postgres',
        'oracle'
    )
Since:
1.18

Definition at line 71 of file MediaWikiTestCase.php.

array MediaWikiTestCase::$tablesUsed = array() [protected]
Since:
1.19

Definition at line 35 of file MediaWikiTestCase.php.

array MediaWikiTestCase::$tmpFiles = array() [private]

Holds the paths of temporary files/directories created through getNewTempFile, and getNewTempDirectory.

Definition at line 53 of file MediaWikiTestCase.php.

MediaWikiTestCase::$users [static]

Reimplemented in UploadStashTest.

Definition at line 25 of file MediaWikiTestCase.php.

MediaWikiTestCase::$useTemporaryTables = true [static, private]

Definition at line 37 of file MediaWikiTestCase.php.

Referenced by usesTemporaryTables().

const MediaWikiTestCase::DB_PREFIX = 'unittest_'

Table name prefixes.

Oracle likes it shorter.

Definition at line 65 of file MediaWikiTestCase.php.

Definition at line 66 of file MediaWikiTestCase.php.


The documentation for this class was generated from the following file: