MediaWiki REL1_27
NewParserTest Class Reference

Although marked as a stub, can work independently. More...

Inheritance diagram for NewParserTest:
Collaboration diagram for NewParserTest:

Public Member Functions

 addArticle ( $name, $text, $line)
 
 addDBDataOnce ()
 Stub.
 
 getFuzzInput ( $filenames)
 Get an input dictionary from a set of parser test files.
 
 getMemoryBreakdown ()
 Get a memory usage breakdown.
 
 getParser ( $preprocessor=null)
 Get a Parser object.
 
 parserTestProvider ()
 
 publishTestArticles ()
 
 removeEndingNewline ( $s)
 Remove last character if it is a newline.
 
 requireFunctionHook ( $name)
 
 requireHook ( $name)
 Steal a callback function from the primary parser, save it for application to our scary parser.
 
 requireTransparentHook ( $name)
 
 setParserTestFile ( $filename)
 Set the file from whose tests will be run by this instance.
 
 testFuzzTests ()
 Run a fuzz test series Draw input from a set of test files.
 
 testParserTest ( $desc, $input, $result, $opts, $config)
 medium ParserTests parserTestProvider
 
- Public Member Functions inherited from MediaWikiTestCase
 __call ( $func, $args)
 
 __construct ( $name=null, array $data=[], $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)
 
 setContentLang ( $lang)
 
 setupAllTestDBs ()
 Set up all test DBs.
 
 setUserLang ( $lang)
 
 testMediaWikiTestCaseParentSetupCalled ()
 Make sure MediaWikiTestCase extending classes have called their parent setUp method.
 
 usesTemporaryTables ()
 

Static Public Member Functions

static setUpBeforeClass ()
 
static tearDownAfterClass ()
 
- Static Public Member Functions inherited from MediaWikiTestCase
static assertNotTag ( $matcher, $actual, $message='', $isHtml=true)
 
static assertTag ( $matcher, $actual, $message='', $isHtml=true)
 Note: we are overriding this method to remove the deprecated error.
 
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.
 
static wfResetOutputBuffersBarrier ( $buffer)
 Used as a marker to prevent wfResetOutputBuffers from breaking PHPUnit.
 

Public Attributes

 $functionHooks = []
 
 $fuzzSeed = 0
 
 $hooks = []
 
 $keepUploads = false
 
 $maxFuzzTestLength = 300
 
 $memoryLimit = 50
 
 $regex = ''
 
 $runDisabled = false
 
 $runParsoid = false
 
 $savedGlobals = []
 
 $savedWeirdGlobals = []
 
 $showProgress = true
 
 $transparentHooks = []
 
- Public Attributes inherited from MediaWikiTestCase
const DB_PREFIX = 'unittest_'
 Table name prefixes.
 
const ORA_DB_PREFIX = 'ut_'
 

Protected Member Functions

 cleanupOption ( $opt)
 
 getBaseDir ()
 
 getUploadDir ()
 Get an FS upload directory (only applies to FSFileBackend)
 
 parseOptions ( $instring)
 
 setUp ()
 
 setupGlobals ( $opts=[], $config='')
 Set up the global variables for a consistent environment for each test.
 
 setupUploads ()
 Create a dummy uploads directory which will contain a couple of files in order to pass existence tests.
 
 tearDown ()
 
 teardownGlobals ()
 Restore default values and perform any necessary clean-up after each test runs.
 
- Protected Member Functions inherited from MediaWikiTestCase
 addTmpFiles ( $files)
 
 arrayWrap (array $elements)
 Utility method taking an array of elements and wrapping each element in its 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.
 
 assertValidHtmlDocument ( $html)
 Asserts that the given string is valid HTML document.
 
 assertValidHtmlSnippet ( $html)
 Asserts that the given string is a valid HTML snippet.
 
 checkDbIsSupported ()
 
 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.
 
 insertPage ( $pageName, $text='Sample page for unit test.')
 Insert a new page.
 
 isWikitextNS ( $ns)
 Returns true if the given namespace defaults to Wikitext according to $wgNamespaceContentModels.
 
 markTestSkippedIfNoDiff3 ()
 Check, if $wgDiff3 is set and ready to merge Will mark the calling test as skipped, if not ready.
 
 mergeMwGlobalArrayValue ( $name, $values)
 Merges the given values into a MW global array variable.
 
 objectAssociativeSort (array &$array)
 Does an associative sort that works for objects.
 
 setLogger ( $channel, LoggerInterface $logger)
 Sets the logger for a specified channel, for the duration of the test.
 
 setMwGlobals ( $pairs, $value=null)
 
 stashMwGlobals ( $globalKeys)
 Stashes the global, will be restored in tearDown()
 

Static Protected Member Functions

static getOptionValue ( $key, $opts, $default)
 Use a regex to find out the value of an option.
 
- Static Protected Member Functions inherited from MediaWikiTestCase
static getExternalStoreDatabaseConnections ()
 Gets master database connections for all of the ExternalStoreDB stores configured in $wgDefaultExternalStore.
 
static isUsingExternalStoreDB ()
 Check whether ExternalStoreDB is being used.
 
static setupDatabaseWithTestPrefix (DatabaseBase $db, $prefix)
 Setups a database with the given prefix.
 
static setupExternalStoreTestDBs ( $testPrefix)
 Clones the External Store database(s) for testing.
 
static stripStringKeys (&$r)
 Utility function for eliminating all string keys from an array.
 

Protected Attributes

 $file = false
 
- Protected Attributes inherited from MediaWikiTestCase
DatabaseBase $db
 Primary database.
 
array $supportedDBs
 
array $tablesUsed = []
 

Static Protected Attributes

static $articles = []
 
static $backendToUse
 

Private Member Functions

 teardownUploads ()
 Remove the dummy uploads directory.
 

Static Private Member Functions

static deleteFiles ( $files)
 Delete the specified files, if they exist.
 

Private Attributes

DjVuSupport $djVuSupport
 
TidySupport $tidySupport
 

Additional Inherited Members

- Static Public Attributes inherited from MediaWikiTestCase
static TestUser[] $users
 

Detailed Description

Although marked as a stub, can work independently.

Database Parser Stub

Todo:
covers tags

Definition at line 12 of file NewParserTest.php.

Member Function Documentation

◆ addArticle()

NewParserTest::addArticle (   $name,
  $text,
  $line 
)

Definition at line 981 of file NewParserTest.php.

References $line, and $name.

◆ addDBDataOnce()

NewParserTest::addDBDataOnce ( )

Stub.

If a test suite needs to add additional data to the database, it should implement this method and do so. This method is called once per test suite (i.e. once per class).

Note data added by this method may be removed by resetDB() depending on the contents of $tablesUsed.

To add additional data between test function runs, override prepareDB().

See also
addDBData()
resetDB()
Since
1.27

Reimplemented from MediaWikiTestCase.

Definition at line 212 of file NewParserTest.php.

References $image, $user, Title\makeTitle(), MEDIATYPE_BITMAP, MEDIATYPE_DRAWING, MEDIATYPE_VIDEO, NS_FILE, serialize(), LinkCache\singleton(), the, and wfLocalFile().

◆ cleanupOption()

NewParserTest::cleanupOption (   $opt)
protected

Definition at line 1095 of file NewParserTest.php.

◆ deleteFiles()

static NewParserTest::deleteFiles (   $files)
staticprivate

Delete the specified files, if they exist.

Parameters
array$filesFull paths to files to delete.

Definition at line 655 of file NewParserTest.php.

References $files, as, FileBackend\parentStoragePath(), and RepoGroup\singleton().

◆ getBaseDir()

NewParserTest::getBaseDir ( )
protected

Definition at line 671 of file NewParserTest.php.

◆ getFuzzInput()

NewParserTest::getFuzzInput (   $filenames)

Get an input dictionary from a set of parser test files.

Parameters
array$filenames
Returns
string

Definition at line 912 of file NewParserTest.php.

References $matches, and as.

◆ getMemoryBreakdown()

NewParserTest::getMemoryBreakdown ( )

Get a memory usage breakdown.

Returns
array

Definition at line 931 of file NewParserTest.php.

References $GLOBALS, $name, $value, as, and serialize().

◆ getOptionValue()

static NewParserTest::getOptionValue (   $key,
  $opts,
  $default 
)
staticprotected

Use a regex to find out the value of an option.

Parameters
string$keyName of option val to retrieve
array$optsOptions array to look in
mixed$defaultDefault value returned if not found
Returns
mixed

Definition at line 1114 of file NewParserTest.php.

◆ getParser()

NewParserTest::getParser (   $preprocessor = null)

Get a Parser object.

Parameters
Preprocessor$preprocessor
Returns
Parser

Definition at line 968 of file NewParserTest.php.

References $parser, $wgParserConf, and global.

◆ getUploadDir()

NewParserTest::getUploadDir ( )
protected

Get an FS upload directory (only applies to FSFileBackend)

Returns
string The directory

Definition at line 499 of file NewParserTest.php.

References $dir, wfDebug(), and wfTempDir().

◆ parseOptions()

NewParserTest::parseOptions (   $instring)
protected

Definition at line 1039 of file NewParserTest.php.

References $matches, and as.

◆ parserTestProvider()

NewParserTest::parserTestProvider ( )

Definition at line 675 of file NewParserTest.php.

References $wgParserTestFiles, file, and global.

◆ publishTestArticles()

NewParserTest::publishTestArticles ( )

Definition at line 985 of file NewParserTest.php.

References $line, $name, ParserTest\addArticle(), as, and list.

◆ removeEndingNewline()

NewParserTest::removeEndingNewline (   $s)

Remove last character if it is a newline.

Parameters
string$s
Returns
string

Definition at line 1029 of file NewParserTest.php.

References $s.

◆ requireFunctionHook()

NewParserTest::requireFunctionHook (   $name)

Definition at line 1010 of file NewParserTest.php.

References $name, $wgParser, and global.

◆ requireHook()

NewParserTest::requireHook (   $name)

Steal a callback function from the primary parser, save it for application to our scary parser.

If the hook is not installed, abort processing of this file.

Parameters
string$name
Returns
bool True if tag hook is present

Definition at line 1004 of file NewParserTest.php.

References $name, $wgParser, and global.

◆ requireTransparentHook()

NewParserTest::requireTransparentHook (   $name)

Definition at line 1016 of file NewParserTest.php.

References $name, $wgParser, and global.

◆ setParserTestFile()

NewParserTest::setParserTestFile (   $filename)

Set the file from whose tests will be run by this instance.

Parameters
string$filename

Definition at line 688 of file NewParserTest.php.

References file.

◆ setUp()

◆ setUpBeforeClass()

static NewParserTest::setUpBeforeClass ( )
static

Definition at line 46 of file NewParserTest.php.

References ParserTest\setupInterwikis().

◆ setupGlobals()

NewParserTest::setupGlobals (   $opts = [],
  $config = '' 
)
protected

Set up the global variables for a consistent environment for each test.

Ideally this should replace the global configuration entirely.

Parameters
array$opts
string$config
Returns
RequestContext

Definition at line 376 of file NewParserTest.php.

References $context, $GLOBALS, $lang, $line, $name, $value, $wgFileBackends, as, MagicWord\clearCache(), MessageCache\destroyInstance(), FileBackendGroup\destroySingleton(), RepoGroup\destroySingleton(), MWTidy\destroySingleton(), global, list, NS_MAIN, and wfWikiID().

◆ setupUploads()

NewParserTest::setupUploads ( )
protected

Create a dummy uploads directory which will contain a couple of files in order to pass existence tests.

Returns
string The directory

Definition at line 526 of file NewParserTest.php.

References $base, $IP, global, and RepoGroup\singleton().

◆ tearDown()

◆ tearDownAfterClass()

static NewParserTest::tearDownAfterClass ( )
static

Definition at line 207 of file NewParserTest.php.

References ParserTest\tearDownInterwikis().

◆ teardownGlobals()

NewParserTest::teardownGlobals ( )
protected

Restore default values and perform any necessary clean-up after each test runs.

Definition at line 567 of file NewParserTest.php.

References $GLOBALS, and as.

◆ teardownUploads()

NewParserTest::teardownUploads ( )
private

Remove the dummy uploads directory.

Definition at line 578 of file NewParserTest.php.

References $base, and RepoGroup\singleton().

◆ testFuzzTests()

NewParserTest::testFuzzTests ( )

Run a fuzz test series Draw input from a set of test files.

Todo:
fixme Needs some work to not eat memory until the world explodes

ParserFuzz

Definition at line 833 of file NewParserTest.php.

References $files, $name, $parser, $ret, $title, $user, $wgParserTestFiles, as, global, Title\makeTitle(), ParserOptions\newFromUser(), and NS_MAIN.

◆ testParserTest()

NewParserTest::testParserTest (   $desc,
  $input,
  $result,
  $opts,
  $config 
)

Member Data Documentation

◆ $articles

NewParserTest::$articles = []
staticprotected

Definition at line 13 of file NewParserTest.php.

◆ $backendToUse

NewParserTest::$backendToUse
staticprotected

Definition at line 17 of file NewParserTest.php.

◆ $djVuSupport

DjVuSupport NewParserTest::$djVuSupport
private

Definition at line 38 of file NewParserTest.php.

◆ $file

NewParserTest::$file = false
protected

Definition at line 44 of file NewParserTest.php.

◆ $functionHooks

NewParserTest::$functionHooks = []

Definition at line 27 of file NewParserTest.php.

◆ $fuzzSeed

NewParserTest::$fuzzSeed = 0

Definition at line 32 of file NewParserTest.php.

◆ $hooks

NewParserTest::$hooks = []

Definition at line 26 of file NewParserTest.php.

◆ $keepUploads

NewParserTest::$keepUploads = false

Definition at line 19 of file NewParserTest.php.

◆ $maxFuzzTestLength

NewParserTest::$maxFuzzTestLength = 300

Definition at line 31 of file NewParserTest.php.

◆ $memoryLimit

NewParserTest::$memoryLimit = 50

Definition at line 33 of file NewParserTest.php.

◆ $regex

NewParserTest::$regex = ''

Definition at line 22 of file NewParserTest.php.

◆ $runDisabled

NewParserTest::$runDisabled = false

Definition at line 20 of file NewParserTest.php.

◆ $runParsoid

NewParserTest::$runParsoid = false

Definition at line 21 of file NewParserTest.php.

◆ $savedGlobals

NewParserTest::$savedGlobals = []

Definition at line 25 of file NewParserTest.php.

◆ $savedWeirdGlobals

NewParserTest::$savedWeirdGlobals = []

Definition at line 24 of file NewParserTest.php.

◆ $showProgress

NewParserTest::$showProgress = true

Definition at line 23 of file NewParserTest.php.

◆ $tidySupport

TidySupport NewParserTest::$tidySupport
private

Definition at line 42 of file NewParserTest.php.

◆ $transparentHooks

NewParserTest::$transparentHooks = []

Definition at line 28 of file NewParserTest.php.


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