Parsoid
A bidirectional parser between wikitext and HTML5
Loading...
Searching...
No Matches
Wikimedia\Parsoid\ParserTests\Test Class Reference

Represents a parser test. More...

+ Inheritance diagram for Wikimedia\Parsoid\ParserTests\Test:
+ Collaboration diagram for Wikimedia\Parsoid\ParserTests\Test:

Public Member Functions

 __construct (array $testProperties, array $knownFailures=[], ?string $comment=null, ?callable $warnFunc=null)
 
 matchesFilter ( $testFilter)
 
 pageName ()
 
 computeTestModes (array $testRunnerModes)
 Given a test runner that runs in a specific set of test modes ($testRunnerModes) compute the list of valid test modes based on what modes have been enabled on the test itself.
 
 applyManualChanges (Document $doc)
 Apply manually-specified changes, which are provided in a pseudo-jQuery format.
 
 applyChanges (array $dumpOpts, Document $doc, array $changelist)
 Make changes to a DOM in order to run a selser test on it.
 
 isDuplicateChangeTree (array $change)
 For a selser test, check if a change we could make has already been tested in this round.
 
 generateChanges (Document $doc)
 Generate a change object for a document, so we can apply it during a selser test.
 
 testAllModes (array $targetModes, array $runnerOpts, callable $runTest)
 FIXME: clean up this mess!
 
 normalizeHTML ( $actual, ?string $normExpected, bool $standalone=true)
 Normalize expected and actual HTML to suppress irrelevant differences.
 
 normalizeWT (string $actual, string $expected, bool $standalone=true)
 Normalize expected and actual wikitext to suppress irrelevant differences.
 
- Public Member Functions inherited from Wikimedia\Parsoid\ParserTests\Item
 __construct (array $props, ?string $comment=null)
 
 errorMsg (string $desc, ?string $text=null)
 Return a friendly error message related to this item.
 
 error (string $desc, ?string $text=null)
 Throw an error related to this item.
 

Public Attributes

const ALL_TEST_MODES = [ 'wt2html', 'wt2wt', 'html2html', 'html2wt', 'selser' ]
 
 $testName = null
 
 $options = []
 
 $config = []
 
 $sections = []
 
 $knownFailures = []
 
 $wikitext = null
 
 $parsoidHtml = null
 
 $legacyHtml = null
 
 $selserChangeTrees = []
 
 $changetree = null
 
 $duplicateChange = false
 
 $seed = null
 
 $resultWT = null
 
 $wt2wtPassed = null
 
 $wt2wtResult = null
 
 $selser = null
 
 $changedHTMLStr = null
 
 $cachedBODYstr = null
 
 $cachedWTstr = null
 
 $cachedNormalizedHTML = null
 
 $time = []
 
const STATIC_RANDOM_STRING = 'ahseeyooxooZ8Oon0boh'
 
- Public Attributes inherited from Wikimedia\Parsoid\ParserTests\Item
 $type
 
 $filename
 
 $lineNumStart
 
 $lineNumEnd
 
 $comment
 

Detailed Description

Represents a parser test.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\Parsoid\ParserTests\Test::__construct ( array $testProperties,
array $knownFailures = [],
?string $comment = null,
?callable $warnFunc = null )
Parameters
array$testPropertieskey-value mapping of properties
array$knownFailuresKnown failures for this test, indexed by testing mode
?string$commentOptional comment describing the test
?callable$warnFuncOptional callback used to emit deprecation warnings.

Member Function Documentation

◆ applyChanges()

Wikimedia\Parsoid\ParserTests\Test::applyChanges ( array $dumpOpts,
Document $doc,
array $changelist )

Make changes to a DOM in order to run a selser test on it.

Parameters
array$dumpOpts
Document$doc
array$changelist

◆ applyManualChanges()

Wikimedia\Parsoid\ParserTests\Test::applyManualChanges ( Document $doc)

Apply manually-specified changes, which are provided in a pseudo-jQuery format.

Parameters
Document$doc

◆ computeTestModes()

Wikimedia\Parsoid\ParserTests\Test::computeTestModes ( array $testRunnerModes)

Given a test runner that runs in a specific set of test modes ($testRunnerModes) compute the list of valid test modes based on what modes have been enabled on the test itself.

Parameters
array$testRunnerModesWhat test modes is the test runner running with?
Returns
array

◆ generateChanges()

Wikimedia\Parsoid\ParserTests\Test::generateChanges ( Document $doc)

Generate a change object for a document, so we can apply it during a selser test.

Parameters
Document$doc
Returns
array The list of changes.

If no node in the DOM subtree rooted at 'node' is editable in the VE, this function should return false.

Currently true for template and extension content, and for entities.

Even if a DOM subtree might be editable in the VE, certain nodes in the DOM might not be directly editable.

Currently, this restriction is only applied to DOMs generated for images. Possibly, there are other candidates.

◆ isDuplicateChangeTree()

Wikimedia\Parsoid\ParserTests\Test::isDuplicateChangeTree ( array $change)

For a selser test, check if a change we could make has already been tested in this round.

Used for generating unique tests.

Parameters
array$changeCandidate change.
Returns
bool

◆ matchesFilter()

Wikimedia\Parsoid\ParserTests\Test::matchesFilter ( $testFilter)
Parameters
array$testFilterTest Filter as set in TestRunner
Returns
bool if test matches the filter

◆ normalizeHTML()

Wikimedia\Parsoid\ParserTests\Test::normalizeHTML ( $actual,
?string $normExpected,
bool $standalone = true )

Normalize expected and actual HTML to suppress irrelevant differences.

The normalization is determined by the HTML sections present in the test as well as other Parsoid-specific test options.

Parameters
Element | string$actual
?string$normExpected
bool$standalone
Returns
array

◆ normalizeWT()

Wikimedia\Parsoid\ParserTests\Test::normalizeWT ( string $actual,
string $expected,
bool $standalone = true )

Normalize expected and actual wikitext to suppress irrelevant differences.

Because of selser as well as manual edit trees, expected wikitext isn't always found in the same section for all tests ending in WT (unlike normalizeHTML). Hence, (a) this code has a different structure than normalizeHTML (b) we cannot cache normalized wikitext

Parameters
string$actual
string$expected
bool$standalone
Returns
array

◆ testAllModes()

Wikimedia\Parsoid\ParserTests\Test::testAllModes ( array $targetModes,
array $runnerOpts,
callable $runTest )

FIXME: clean up this mess!

  • generate all changes at once (generateChanges should return a tree really) rather than going to all these lengths of interleaving change generation with tests
  • set up the changes in item directly rather than juggling around with indexes etc
  • indicate whether to compare to wt2wt or the original input
  • maybe make a full selser test one method that uses others rather than the current chain of methods that sometimes do something for selser
Parameters
array$targetModes
array$runnerOpts
callable$runTest

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