MediaWiki  REL1_19
NewParserTest Class Reference

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

Inheritance diagram for NewParserTest:
Collaboration diagram for NewParserTest:

List of all members.

Public Member Functions

 addArticle ($name, $text, $line)
 addDBData ()
 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.
 setParserTestFile ($filename)
 Set the file from whose tests will be run by this instance.
 setUp ()
 tearDown ()
 testFuzzTests ()
 Run a fuzz test series Draw input from a set of test files.
 testParserTest ($desc, $input, $result, $opts, $config)
 medium parserTestProvider

Public Attributes

 $functionHooks = array()
 $fuzzSeed = 0
 $hooks = array()
 $keepUploads = false
 $maxFuzzTestLength = 300
 $memoryLimit = 50
 $regex = ''
 $runDisabled = false
 $savedGlobals = array()
 $savedInitialGlobals = array()
 $savedWeirdGlobals = array()
 $showProgress = true

Protected Member Functions

 cleanupOption ($opt)
 getBaseDir ()
 getUploadDir ()
 Get an FS upload directory (only applies to FSFileBackend)
 parseOptions ($instring)
 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.
 teardownGlobals ()
 Restore default values and perform any necessary clean-up after each test runs.
 tidy ($text)
 Run the "tidy" command on text if the $wgUseTidy global is true.

Static Protected Member Functions

static getOptionValue ($key, $opts, $default)
 Use a regex to find out the value of an option.

Protected Attributes

 $file = false

Static Protected Attributes

static $articles = array()
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.

Detailed Description

Although marked as a stub, can work independently.

Database Parser Stub

Definition at line 10 of file NewParserTest.php.


Member Function Documentation

NewParserTest::addArticle ( name,
text,
line 
)

Definition at line 745 of file NewParserTest.php.

Referenced by publishTestArticles().

Here is the caller graph for this function:

Stub.

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

Reimplemented from MediaWikiTestCase.

Definition at line 119 of file NewParserTest.php.

References $user, Language\getLocalisationCache(), Title\makeTitle(), User\newFromId(), LinkCache\singleton(), MessageCache\singleton(), wfBaseConvert(), and wfLocalFile().

Here is the call graph for this function:

NewParserTest::cleanupOption ( opt) [protected]

Definition at line 867 of file NewParserTest.php.

Referenced by parseOptions().

Here is the caller graph for this function:

static NewParserTest::deleteFiles ( files) [static, private]

Delete the specified files, if they exist.

Parameters:
$filesArray: full paths to files to delete.

Definition at line 479 of file NewParserTest.php.

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

Referenced by teardownUploads().

Here is the call graph for this function:

Here is the caller graph for this function:

NewParserTest::getBaseDir ( ) [protected]

Definition at line 494 of file NewParserTest.php.

Referenced by setupUploads(), and teardownUploads().

Here is the caller graph for this function:

NewParserTest::getFuzzInput ( filenames)

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

Definition at line 679 of file NewParserTest.php.

References $matches.

Referenced by testFuzzTests().

Here is the caller graph for this function:

Get a memory usage breakdown.

Definition at line 697 of file NewParserTest.php.

Referenced by testFuzzTests().

Here is the caller graph for this function:

static NewParserTest::getOptionValue ( key,
opts,
default 
) [static, protected]

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

Parameters:
$keyString: name of option val to retrieve
$optsOptions array to look in
$defaultMixed: default value returned if not found

Definition at line 884 of file NewParserTest.php.

Referenced by setupGlobals().

Here is the caller graph for this function:

NewParserTest::getParser ( preprocessor = null)

Get a Parser object.

Definition at line 732 of file NewParserTest.php.

References $wgParserConf, and wfRunHooks().

Referenced by testFuzzTests(), and testParserTest().

Here is the call graph for this function:

Here is the caller graph for this function:

NewParserTest::getUploadDir ( ) [protected]

Get an FS upload directory (only applies to FSFileBackend)

Returns:
String: the directory

Definition at line 393 of file NewParserTest.php.

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

Referenced by setupGlobals().

Here is the call graph for this function:

Here is the caller graph for this function:

NewParserTest::parseOptions ( instring) [protected]

Definition at line 812 of file NewParserTest.php.

References $matches, $regex, and cleanupOption().

Referenced by testParserTest().

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 498 of file NewParserTest.php.

References $wgParserTestFiles.

Definition at line 749 of file NewParserTest.php.

References addArticle().

Referenced by setupGlobals().

Here is the call graph for this function:

Here is the caller graph for this function:

Remove last character if it is a newline.

Definition at line 801 of file NewParserTest.php.

Definition at line 774 of file NewParserTest.php.

References $wgParser.

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:
$nameString
Returns:
Bool true if tag hook is present

Definition at line 768 of file NewParserTest.php.

References $wgParser.

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

Definition at line 509 of file NewParserTest.php.

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.

Definition at line 236 of file NewParserTest.php.

References $backendToUse, $wgFileBackends, $wgHooks, MagicWord\clearCache(), FileBackendGroup\destroySingleton(), RepoGroup\destroySingleton(), Language\factory(), MediaWikiTestCase\getCliArg(), getOptionValue(), getUploadDir(), publishTestArticles(), setupUploads(), and MessageCache\singleton().

Referenced by testFuzzTests(), and testParserTest().

Here is the call graph for this function:

Here is the caller graph for this function:

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 419 of file NewParserTest.php.

References $IP, getBaseDir(), and RepoGroup\singleton().

Referenced by setupGlobals().

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 103 of file NewParserTest.php.

References $wgNamespaceAliases, $wgNamespaceProtection, FileBackendGroup\destroySingleton(), and RepoGroup\destroySingleton().

Here is the call graph for this function:

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

Definition at line 438 of file NewParserTest.php.

References RepoGroup\destroySingleton(), LinkCache\singleton(), and teardownUploads().

Referenced by testFuzzTests(), and testParserTest().

Here is the call graph for this function:

Here is the caller graph for this function:

Remove the dummy uploads directory.

Definition at line 452 of file NewParserTest.php.

References deleteFiles(), and getBaseDir().

Referenced by teardownGlobals().

Here is the call graph for this function:

Here is the caller graph for this function:

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

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

ParserFuzz

Definition at line 603 of file NewParserTest.php.

References $files, $input, $title, $user, $wgParserTestFiles, MediaWikiTestCase\getCliArg(), getFuzzInput(), getMemoryBreakdown(), getParser(), Title\makeTitle(), ParserOptions\newFromUser(), setupGlobals(), and teardownGlobals().

Here is the call graph for this function:

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

medium parserTestProvider

Definition at line 517 of file NewParserTest.php.

References $input, $options, $out, $output, $result, $section, $title, $user, Linker\formatComment(), getParser(), ParserOptions\newFromContext(), Title\newFromText(), parseOptions(), setupGlobals(), teardownGlobals(), tidy(), and wfDebug().

Here is the call graph for this function:

NewParserTest::tidy ( text) [protected]

Run the "tidy" command on text if the $wgUseTidy global is true.

Parameters:
$textString: the text to tidy
Returns:
String

Definition at line 788 of file NewParserTest.php.

References $wgUseTidy.

Referenced by testParserTest().

Here is the caller graph for this function:


Member Data Documentation

NewParserTest::$articles = array() [static, protected]

Definition at line 11 of file NewParserTest.php.

NewParserTest::$backendToUse [static, protected]

Definition at line 15 of file NewParserTest.php.

Referenced by setupGlobals().

NewParserTest::$file = false [protected]

Definition at line 32 of file NewParserTest.php.

Referenced by deleteFiles().

NewParserTest::$functionHooks = array()

Definition at line 25 of file NewParserTest.php.

NewParserTest::$fuzzSeed = 0

Definition at line 29 of file NewParserTest.php.

NewParserTest::$hooks = array()

Definition at line 24 of file NewParserTest.php.

NewParserTest::$keepUploads = false

Definition at line 17 of file NewParserTest.php.

NewParserTest::$maxFuzzTestLength = 300

Definition at line 28 of file NewParserTest.php.

NewParserTest::$memoryLimit = 50

Definition at line 30 of file NewParserTest.php.

NewParserTest::$regex = ''

Reimplemented from MediaWikiTestCase.

Definition at line 19 of file NewParserTest.php.

Referenced by parseOptions().

NewParserTest::$runDisabled = false

Reimplemented from MediaWikiTestCase.

Definition at line 18 of file NewParserTest.php.

NewParserTest::$savedGlobals = array()

Definition at line 23 of file NewParserTest.php.

NewParserTest::$savedInitialGlobals = array()

Definition at line 21 of file NewParserTest.php.

NewParserTest::$savedWeirdGlobals = array()

Definition at line 22 of file NewParserTest.php.

NewParserTest::$showProgress = true

Definition at line 20 of file NewParserTest.php.


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