MediaWiki  REL1_20
MediaWikiTestCase Class Reference

Inherited by ArticleTest, BaseDumpTest, BitmapMetadataHandlerTest, BitmapScalingTest, CdbTest, CLDRPluralRuleEvaluatorTest, CleanUpTest, CSSJanusTest, CSSMinTest, DatabaseSqliteTest, DatabaseSQLTest, DatabaseTest, DeviceDetectionTest, DiffHistoryBlobTest, DummyExtensionsTest, EditPageTest, ExifBitmapTest, ExifRotationTest, ExifTest, ExternalStoreTest, ExtraParserTest, FauxResponseTest, FetchTextTest, FileBackendTest, FileRepoTest, FormatMetadataTest, FormOptionsInitializationTest, FormOptionsTest, GenericArrayObjectTest, GetSlaveServerTest, GIFHandlerTest, GIFMetadataExtractorTest, GlobalTest, GlobalWithDBTest, HooksTest, HtmlTest, HttpTest, IEUrlExtensionTest, InstallDocFormatterTest, IPTCTest, IPTest, JavaScriptMinifierTest, JpegMetadataExtractorTest, JpegTest, JsonTest, LanguageAmTest, LanguageArTest, LanguageBeTaraskTest, LanguageBeTest, LanguageBhTest, LanguageBsTest, LanguageCsTest, LanguageCuTest, LanguageCyTest, LanguageDsbTest, LanguageFrTest, LanguageGaTest, LanguageGdTest, LanguageGvTest, LanguageHeTest, LanguageHiTest, LanguageHrTest, LanguageHsbTest, LanguageHuTest, LanguageHyTest, LanguageKshTest, LanguageLnTest, LanguageLtTest, LanguageLvTest, LanguageMgTest, LanguageMkTest, LanguageMlTest, LanguageMoTest, LanguageMtTest, LanguageNlTest, LanguageNsoTest, LanguagePlTest, LanguageRoTest, LanguageRuTest, LanguageSeTest, LanguageSgsTest, LanguageShTest, LanguageSkTest, LanguageSlTest, LanguageSmaTest, LanguageSrTest, LanguageTest, LanguageTiTest, LanguageTlTest, LanguageTrTest, LanguageUkTest, LanguageUzTest, LanguageWaTest, LicensesTest, LinksUpdateTest, LocalFileTest, LocalisationCacheTest, MagicVariableTest, MaintenanceTest, MediaHandlerTest, MediaWikiLangTestCase, MWDebugTest, MWFunctionTest, MWNamespaceTest, NewParserTest, ORMRowTest, ParserOptionsTest, ParserPreloadTest, PathRouterTest, PNGHandlerTest, PNGMetadataExtractorTest, PreferencesTest, PrefixUniquenessTest, PreprocessorTest, ProcessCacheLRUTest, QueryAllSpecialPagesTest, RecentChangeTest, ResourceLoaderTest, RevisionStorageTest, RevisionTest, SanitizerTest, SanitizerValidateEmailTest, SearchEngineTest, SearchUpdateTest, SeleniumConfigurationTest, ServicesJsonTest, SiteConfigurationTest, SpecialRecentchangesTest, SpecialSearchTest, StoreBatchTest, StructureTest, SVGMetadataExtractorTest, TagHookTest, TiffTest, TimestampTest, TitleMethodsTest, TitleTest, UploadStashTest, UploadTest, UserTest, WebRequestTest, wfAssembleUrl, wfBaseName, wfBCP47, wfExpandUrl, wfGetCaller, wfRemoveDotSegments, wfShorthandToIntegerTest, wfTimestamp, wfUrlencodeTest, XmlJs, XmlSelectTest, XmlTest, 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= '')
 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)

Public Attributes

 $regex = ''
 $runDisabled = false
 $suite
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.
 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.
 checkDbIsSupported ()
 getNewTempDirectory ()
 obtains a new temporary directory
 getNewTempFile ()
 obtains a new temporary file name
 listTables ()
 objectAssociativeSort (array &$array)
 Does an associative sort that works for objects.
 tearDown ()

Static Protected Member Functions

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

Protected Attributes

DatabaseBase $db
 $oldTablePrefix
 $reuseDB = false
 $supportedDBs
 $tablesUsed = array()
 $useTemporaryTables = true

Private Member Functions

 addCoreDBData ()
 assertEmpty2 ($value, $msg)
 initDB ()
 resetDB ()
 Empty all tables so they can be repopulated for tests.

Static Private Member Functions

static isNotUnittest ($table)
static unprefixTable ($tableName)

Private Attributes

array $tmpfiles = array()
 Holds the paths of temporary files/directories created through getNewTempFile, and getNewTempDirectory.

Static Private Attributes

static $dbSetup = false

Detailed Description

Definition at line 3 of file MediaWikiTestCase.php.


Constructor & Destructor Documentation

MediaWikiTestCase::__construct ( name = null,
array $  data = array(),
dataName = '' 
)

Reimplemented in RevisionStorageTest, WikiPageTest, and LinksUpdateTest.

Definition at line 44 of file MediaWikiTestCase.php.


Member Function Documentation

MediaWikiTestCase::__call ( func,
args 
)

Reimplemented in MWNamespaceTest.

Definition at line 268 of file MediaWikiTestCase.php.

Definition at line 165 of file MediaWikiTestCase.php.

Stub.

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

Reimplemented in FetchTextTest, NewParserTest, BackupDumperLoggerTest, SearchEngineTest, TextPassDumperTest, BlockTest, BackupDumperPageTest, ApiBlockTest, and GenderCacheTest.

Definition at line 163 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 409 of file MediaWikiTestCase.php.

Referenced by GenericArrayObjectTest\instanceProvider().

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
boolean$orderedIf the order of the values should match
boolean$namedIf the keys should match

Definition at line 430 of file MediaWikiTestCase.php.

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

Definition at line 286 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 459 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:
$tableString|Array the table(s) to query
$fieldsString|Array the columns to include in the result (and to sort by)
$conditionString|Array "where" condition(s)
$expectedRowsArray - an 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 369 of file MediaWikiTestCase.php.

Referenced by LinksUpdateTest\assertLinksUpdate().

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 536 of file MediaWikiTestCase.php.

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 516 of file MediaWikiTestCase.php.

Definition at line 319 of file MediaWikiTestCase.php.

obtains a new temporary directory

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

Returns:
string: absolute name of the temporary directory

Definition at line 107 of file MediaWikiTestCase.php.

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

Don't throw a warning if $function is deprecated and called later.

Parameters:
$functionString
Returns:
null

Definition at line 345 of file MediaWikiTestCase.php.

Referenced by BlockTest\testBug29116LoadWithEmptyIp(), and RevisionStorageTest\testRevText().

Definition at line 221 of file MediaWikiTestCase.php.

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

Definition at line 295 of file MediaWikiTestCase.php.

Definition at line 299 of file MediaWikiTestCase.php.

Definition at line 144 of file MediaWikiTestCase.php.

MediaWikiTestCase::objectAssociativeSort ( array &$  array) [protected]

Does an associative sort that works for objects.

Since:
1.20
Parameters:
array$array

Definition at line 473 of file MediaWikiTestCase.php.

Empty all tables so they can be repopulated for tests.

Definition at line 247 of file MediaWikiTestCase.php.

MediaWikiTestCase::run ( PHPUnit_Framework_TestResult $  result = NULL)

Definition at line 51 of file MediaWikiTestCase.php.

Referenced by HooksTest\testNewStyleHooks().

MediaWikiTestCase::setCliArg ( offset,
value 
)

Definition at line 333 of file MediaWikiTestCase.php.

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:
$rmixed the array to remove string keys from.

Definition at line 491 of file MediaWikiTestCase.php.

MediaWikiTestCase::tearDown ( ) [protected]

Reimplemented in FileBackendTest, StoreBatchTest, SeleniumConfigurationTest, NewParserTest, UploadStashTest, ApiOptionsTest, TitlePermissionTest, MagicVariableTest, UserTest, HtmlTest, SearchUpdateTest, SideBarTest, WikiPageTest, XmlTest, ExifRotationTest, MediaWikiLangTestCase, MWNamespaceTest, LanguageSrTest, LanguageUzTest, ApiTestCaseUpload, FormatMetadataTest, CSSMinTest, ParserPreloadTest, LanguageConverterTest, UploadTest, RevisionTest, TestSample, MWDebugTest, BaseDumpTest, ArticleTest, LanguageRuTest, LanguageSkTest, LanguageSlTest, LanguageUkTest, ExifBitmapTest, ExifTest, ParserOptionsTest, LanguageAmTest, LanguageBeTest, LanguageBhTest, LanguageBsTest, LanguageCsTest, LanguageCuTest, LanguageCyTest, LanguageDsbTest, LanguageFrTest, LanguageGaTest, LanguageGdTest, LanguageGvTest, LanguageHeTest, LanguageHiTest, LanguageHrTest, LanguageHsbTest, LanguageHuTest, LanguageHyTest, LanguageKshTest, LanguageLnTest, LanguageLtTest, LanguageLvTest, LanguageMgTest, LanguageMkTest, LanguageMlTest, LanguageMoTest, LanguageMtTest, LanguageNlTest, LanguageNsoTest, LanguagePlTest, LanguageRoTest, LanguageSeTest, LanguageSgsTest, LanguageShTest, LanguageSmaTest, LanguageTiTest, LanguageTlTest, LanguageTrTest, LanguageWaTest, DatabaseTest, ExternalStoreTest, SpecialSearchTest, TimeAdjustTest, LanguageArTest, GlobalTest, JpegTest, BitmapScalingTest, TiffTest, LanguageTest, SearchEngineTest, WebRequestTest, XmlSelectTest, and LanguageBeTaraskTest.

Definition at line 120 of file MediaWikiTestCase.php.

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

Definition at line 290 of file MediaWikiTestCase.php.


Member Data Documentation

DatabaseBase MediaWikiTestCase::$db [protected]

Reimplemented in DatabaseSqliteTest, and DatabaseTest.

Definition at line 15 of file MediaWikiTestCase.php.

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

Definition at line 21 of file MediaWikiTestCase.php.

MediaWikiTestCase::$oldTablePrefix [protected]

Definition at line 16 of file MediaWikiTestCase.php.

MediaWikiTestCase::$regex = ''

Reimplemented in NewParserTest.

Definition at line 5 of file MediaWikiTestCase.php.

MediaWikiTestCase::$reuseDB = false [protected]

Definition at line 18 of file MediaWikiTestCase.php.

MediaWikiTestCase::$runDisabled = false

Reimplemented in NewParserTest.

Definition at line 6 of file MediaWikiTestCase.php.

MediaWikiTestCase::$suite

Definition at line 4 of file MediaWikiTestCase.php.

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

Definition at line 37 of file MediaWikiTestCase.php.

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

Definition at line 19 of file MediaWikiTestCase.php.

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

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

Definition at line 28 of file MediaWikiTestCase.php.

MediaWikiTestCase::$users [static]

Reimplemented in UploadStashTest.

Definition at line 11 of file MediaWikiTestCase.php.

MediaWikiTestCase::$useTemporaryTables = true [protected]

Definition at line 17 of file MediaWikiTestCase.php.

const MediaWikiTestCase::DB_PREFIX = 'unittest_'

Table name prefixes.

Oracle likes it shorter.

Definition at line 34 of file MediaWikiTestCase.php.

Definition at line 35 of file MediaWikiTestCase.php.


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