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

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. More...
 
const ORA_DB_PREFIX = 'ut_'
 

Protected Member Functions

 cleanupOption ($opt)
 
 getBaseDir ()
 
 getUploadDir ()
 Get an FS upload directory (only applies to FSFileBackend) More...
 
 parseOptions ($instring)
 
 setUp ()
 
 setupGlobals ($opts=[], $config= '')
 Set up the global variables for a consistent environment for each test. More...
 
 setupUploads ()
 Create a dummy uploads directory which will contain a couple of files in order to pass existence tests. More...
 
 tearDown ()
 
 teardownGlobals ()
 Restore default values and perform any necessary clean-up after each test runs. More...
 
- 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. More...
 
 assertArrayEquals (array $expected, array $actual, $ordered=false, $named=false)
 Assert that two arrays are equal. 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 ()
 
 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...
 
 insertPage ($pageName, $text= 'Sample page for unit test.')
 Insert a new page. More...
 
 isWikitextNS ($ns)
 Returns true if the given namespace defaults to Wikitext according to $wgNamespaceContentModels. More...
 
 markTestSkippedIfNoDiff3 ()
 Check, if $wgDiff3 is set and ready to merge Will mark the calling test as skipped, if not ready. 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...
 
 setLogger ($channel, LoggerInterface $logger)
 Sets the logger for a specified channel, for the duration of the test. More...
 
 setMwGlobals ($pairs, $value=null)
 
 setUp ()
 
 stashMwGlobals ($globalKeys)
 Stashes the global, will be restored in tearDown() More...
 
 tearDown ()
 

Static Protected Member Functions

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

Protected Attributes

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

Static Protected Attributes

static $articles = []
 
static $backendToUse
 

Private Member Functions

 teardownUploads ()
 Remove the dummy uploads directory. More...
 

Static Private Member Functions

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

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

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

Definition at line 981 of file NewParserTest.php.

References $line, and $name.

NewParserTest::cleanupOption (   $opt)
protected

Definition at line 1095 of file NewParserTest.php.

Referenced by parseOptions().

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 $file, $files, as, FileBackend\parentStoragePath(), and RepoGroup\singleton().

NewParserTest::getBaseDir ( )
protected

Definition at line 671 of file NewParserTest.php.

Referenced by setupUploads(), and teardownUploads().

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.

Referenced by testFuzzTests().

NewParserTest::getMemoryBreakdown ( )

Get a memory usage breakdown.

Returns
array

Definition at line 931 of file NewParserTest.php.

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

Referenced by testFuzzTests().

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.

References $key.

NewParserTest::getParser (   $preprocessor = null)

Get a Parser object.

Parameters
Preprocessor$preprocessor
Returns
Parser

Definition at line 968 of file NewParserTest.php.

References $parser, global, and Hooks\run().

Referenced by testFuzzTests(), and testParserTest().

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, MediaWikiTestCase\getNewTempDirectory(), wfDebug(), and wfTempDir().

Referenced by setupGlobals().

NewParserTest::parseOptions (   $instring)
protected

Definition at line 1039 of file NewParserTest.php.

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

Referenced by testParserTest().

NewParserTest::parserTestProvider ( )

Definition at line 675 of file NewParserTest.php.

References file, and global.

NewParserTest::publishTestArticles ( )

Definition at line 985 of file NewParserTest.php.

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

Referenced by setupGlobals().

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.

NewParserTest::requireFunctionHook (   $name)

Definition at line 1010 of file NewParserTest.php.

References $name, $wgParser, and global.

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.

NewParserTest::requireTransparentHook (   $name)

Definition at line 1016 of file NewParserTest.php.

References $name, $wgParser, and global.

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.

static NewParserTest::setUpBeforeClass ( )
static

Definition at line 46 of file NewParserTest.php.

References ParserTest\setupInterwikis().

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(), Language\factory(), MediaWikiTestCase\getCliArg(), getUploadDir(), global, list, NS_MAIN, publishTestArticles(), Hooks\run(), setupUploads(), and wfWikiID().

Referenced by testFuzzTests(), and testParserTest().

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, getBaseDir(), global, and RepoGroup\singleton().

Referenced by setupGlobals().

static NewParserTest::tearDownAfterClass ( )
static

Definition at line 207 of file NewParserTest.php.

References ParserTest\tearDownInterwikis().

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, as, and teardownUploads().

Referenced by testFuzzTests(), and testParserTest().

NewParserTest::teardownUploads ( )
private

Remove the dummy uploads directory.

Definition at line 578 of file NewParserTest.php.

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

Referenced by teardownGlobals().

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, as, MediaWikiTestCase\getCliArg(), getFuzzInput(), getMemoryBreakdown(), getParser(), global, Title\makeTitle(), ParserOptions\newFromUser(), NS_MAIN, setupGlobals(), teardownGlobals(), and User.

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

Member Data Documentation

NewParserTest::$articles = []
staticprotected

Definition at line 13 of file NewParserTest.php.

NewParserTest::$backendToUse
staticprotected

Definition at line 17 of file NewParserTest.php.

DjVuSupport NewParserTest::$djVuSupport
private

Definition at line 38 of file NewParserTest.php.

NewParserTest::$file = false
protected

Definition at line 44 of file NewParserTest.php.

Referenced by deleteFiles().

NewParserTest::$functionHooks = []

Definition at line 27 of file NewParserTest.php.

NewParserTest::$fuzzSeed = 0

Definition at line 32 of file NewParserTest.php.

NewParserTest::$hooks = []

Definition at line 26 of file NewParserTest.php.

NewParserTest::$keepUploads = false

Definition at line 19 of file NewParserTest.php.

NewParserTest::$maxFuzzTestLength = 300

Definition at line 31 of file NewParserTest.php.

NewParserTest::$memoryLimit = 50

Definition at line 33 of file NewParserTest.php.

NewParserTest::$regex = ''

Definition at line 22 of file NewParserTest.php.

Referenced by parseOptions().

NewParserTest::$runDisabled = false

Definition at line 20 of file NewParserTest.php.

NewParserTest::$runParsoid = false

Definition at line 21 of file NewParserTest.php.

NewParserTest::$savedGlobals = []

Definition at line 25 of file NewParserTest.php.

NewParserTest::$savedWeirdGlobals = []

Definition at line 24 of file NewParserTest.php.

NewParserTest::$showProgress = true

Definition at line 23 of file NewParserTest.php.

TidySupport NewParserTest::$tidySupport
private

Definition at line 42 of file NewParserTest.php.

NewParserTest::$transparentHooks = []

Definition at line 28 of file NewParserTest.php.


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