General cleanup of Parser tests
- Fixes scope - Adds covers tags Change-Id: I6024f2f7cc7a1812a417c6c389b0a15addde0b5e
This commit is contained in:
parent
5bf45af50e
commit
17c1e91238
7 changed files with 59 additions and 24 deletions
|
|
@ -33,22 +33,22 @@
|
|||
*/
|
||||
class ParserTest {
|
||||
/**
|
||||
* boolean $color whereas output should be colorized
|
||||
* @var bool $color whereas output should be colorized
|
||||
*/
|
||||
private $color;
|
||||
|
||||
/**
|
||||
* boolean $showOutput Show test output
|
||||
* @var bool $showOutput Show test output
|
||||
*/
|
||||
private $showOutput;
|
||||
|
||||
/**
|
||||
* boolean $useTemporaryTables Use temporary tables for the temporary database
|
||||
* @var bool $useTemporaryTables Use temporary tables for the temporary database
|
||||
*/
|
||||
private $useTemporaryTables = true;
|
||||
|
||||
/**
|
||||
* boolean $databaseSetupDone True if the database has been set up
|
||||
* @var bool $databaseSetupDone True if the database has been set up
|
||||
*/
|
||||
private $databaseSetupDone = false;
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ class ParserTest {
|
|||
private $dbClone;
|
||||
|
||||
/**
|
||||
* string $oldTablePrefix Original table prefix
|
||||
* @var string $oldTablePrefix Original table prefix
|
||||
*/
|
||||
private $oldTablePrefix;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,12 +4,14 @@
|
|||
* CSSJanus libary:
|
||||
* http://code.google.com/p/cssjanus/source/browse/trunk/cssjanus_test.py
|
||||
* Ported to PHP for ResourceLoader and has been extended since.
|
||||
*
|
||||
* @covers CSSJanus
|
||||
*/
|
||||
class CSSJanusTest extends MediaWikiTestCase {
|
||||
/**
|
||||
* @dataProvider provideTransformCases
|
||||
*/
|
||||
function testTransform( $cssA, $cssB = null ) {
|
||||
public function testTransform( $cssA, $cssB = null ) {
|
||||
|
||||
if ( $cssB ) {
|
||||
$transformedA = CSSJanus::transform( $cssA );
|
||||
|
|
@ -28,7 +30,7 @@ class CSSJanusTest extends MediaWikiTestCase {
|
|||
/**
|
||||
* @dataProvider provideTransformAdvancedCases
|
||||
*/
|
||||
function testTransformAdvanced( $code, $expectedOutput, $options = array() ) {
|
||||
public function testTransformAdvanced( $code, $expectedOutput, $options = array() ) {
|
||||
$swapLtrRtlInURL = isset( $options['swapLtrRtlInURL'] ) ? $options['swapLtrRtlInURL'] : false;
|
||||
$swapLeftRightInURL = isset( $options['swapLeftRightInURL'] ) ? $options['swapLeftRightInURL'] : false;
|
||||
|
||||
|
|
@ -44,7 +46,7 @@ class CSSJanusTest extends MediaWikiTestCase {
|
|||
* @dataProvider provideTransformBrokenCases
|
||||
* @group Broken
|
||||
*/
|
||||
function testTransformBroken( $code, $expectedOutput ) {
|
||||
public function testTransformBroken( $code, $expectedOutput ) {
|
||||
$flipped = CSSJanus::transform( $code );
|
||||
|
||||
$this->assertEquals( $expectedOutput, $flipped, 'Test flipping' );
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
* @group Database
|
||||
* @group Parser
|
||||
* @group Stub
|
||||
*
|
||||
* @todo covers tags
|
||||
*/
|
||||
class NewParserTest extends MediaWikiTestCase {
|
||||
static protected $articles = array(); // Array of test articles defined by the tests
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ class ParserMethodsTest extends MediaWikiLangTestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider providePreSaveTransform
|
||||
* @covers Parser::preSaveTransform
|
||||
*/
|
||||
public function testPreSaveTransform( $text, $expected ) {
|
||||
global $wgParser;
|
||||
|
|
@ -28,6 +29,9 @@ class ParserMethodsTest extends MediaWikiLangTestCase {
|
|||
$this->assertEquals( $expected, $text );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Parser::callParserFunction
|
||||
*/
|
||||
public function testCallParserFunction() {
|
||||
global $wgParser;
|
||||
|
||||
|
|
@ -45,6 +49,10 @@ class ParserMethodsTest extends MediaWikiLangTestCase {
|
|||
), $ret, 'callParserFunction works for {{#tag:pre|foo|style=margin-left: 1.6em}}' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Parser::parse
|
||||
* @covers ParserOutput::getSections
|
||||
*/
|
||||
public function testGetSections() {
|
||||
global $wgParser;
|
||||
|
||||
|
|
@ -83,5 +91,5 @@ class ParserMethodsTest extends MediaWikiLangTestCase {
|
|||
),
|
||||
), $out->getSections(), 'getSections() with proper value when <h2> is used' );
|
||||
}
|
||||
// TODO: Add tests for cleanSig() / cleanSigInSig(), getSection(), replaceSection(), getPreloadText()
|
||||
//@Todo Add tests for cleanSig() / cleanSigInSig(), getSection(), replaceSection(), getPreloadText()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
class ParserOutputTest extends MediaWikiTestCase {
|
||||
|
||||
function dataIsLinkInternal() {
|
||||
public static function provideIsLinkInternal() {
|
||||
return array(
|
||||
// Different domains
|
||||
array( false, 'http://example.org', 'http://mediawiki.org' ),
|
||||
|
|
@ -29,13 +29,17 @@ class ParserOutputTest extends MediaWikiTestCase {
|
|||
|
||||
/**
|
||||
* Test to make sure ParserOutput::isLinkInternal behaves properly
|
||||
* @dataProvider dataIsLinkInternal
|
||||
* @dataProvider provideIsLinkInternal
|
||||
* @covers ParserOutput::isLinkInternal
|
||||
*/
|
||||
function testIsLinkInternal( $shouldMatch, $server, $url ) {
|
||||
|
||||
public function testIsLinkInternal( $shouldMatch, $server, $url ) {
|
||||
$this->assertEquals( $shouldMatch, ParserOutput::isLinkInternal( $server, $url ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ParserOutput::setExtensionData
|
||||
* @covers ParserOutput::getExtensionData
|
||||
*/
|
||||
public function testExtensionData() {
|
||||
$po = new ParserOutput();
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,17 @@
|
|||
* @author Antoine Musso
|
||||
*/
|
||||
class ParserPreloadTest extends MediaWikiTestCase {
|
||||
/**
|
||||
* @var Parser
|
||||
*/
|
||||
private $testParser;
|
||||
/**
|
||||
* @var ParserOptions
|
||||
*/
|
||||
private $testParserOptions;
|
||||
/**
|
||||
* @var Title
|
||||
*/
|
||||
private $title;
|
||||
|
||||
protected function setUp() {
|
||||
|
|
@ -31,14 +40,14 @@ class ParserPreloadTest extends MediaWikiTestCase {
|
|||
/**
|
||||
* @covers Parser::getPreloadText
|
||||
*/
|
||||
function testPreloadSimpleText() {
|
||||
public function testPreloadSimpleText() {
|
||||
$this->assertPreloaded( 'simple', 'simple' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Parser::getPreloadText
|
||||
*/
|
||||
function testPreloadedPreIsUnstripped() {
|
||||
public function testPreloadedPreIsUnstripped() {
|
||||
$this->assertPreloaded(
|
||||
'<pre>monospaced</pre>',
|
||||
'<pre>monospaced</pre>',
|
||||
|
|
@ -49,7 +58,7 @@ class ParserPreloadTest extends MediaWikiTestCase {
|
|||
/**
|
||||
* @covers Parser::getPreloadText
|
||||
*/
|
||||
function testPreloadedNowikiIsUnstripped() {
|
||||
public function testPreloadedNowikiIsUnstripped() {
|
||||
$this->assertPreloaded(
|
||||
'<nowiki>[[Dummy title]]</nowiki>',
|
||||
'<nowiki>[[Dummy title]]</nowiki>',
|
||||
|
|
@ -57,7 +66,7 @@ class ParserPreloadTest extends MediaWikiTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
function assertPreloaded( $expected, $text, $msg = '' ) {
|
||||
protected function assertPreloaded( $expected, $text, $msg = '' ) {
|
||||
$this->assertEquals(
|
||||
$expected,
|
||||
$this->testParser->getPreloadText(
|
||||
|
|
|
|||
|
|
@ -1,9 +1,16 @@
|
|||
<?php
|
||||
|
||||
class PreprocessorTest extends MediaWikiTestCase {
|
||||
var $mTitle = 'Page title';
|
||||
var $mPPNodeCount = 0;
|
||||
var $mOptions;
|
||||
protected $mTitle = 'Page title';
|
||||
protected $mPPNodeCount = 0;
|
||||
/**
|
||||
* @var ParserOptions
|
||||
*/
|
||||
protected $mOptions;
|
||||
/**
|
||||
* @var Preprocessor
|
||||
*/
|
||||
protected $mPreprocessor;
|
||||
|
||||
protected function setUp() {
|
||||
global $wgParserConf, $wgContLang;
|
||||
|
|
@ -115,7 +122,7 @@ class PreprocessorTest extends MediaWikiTestCase {
|
|||
* @param string $wikiText
|
||||
* @return string
|
||||
*/
|
||||
function preprocessToXml( $wikiText ) {
|
||||
protected function preprocessToXml( $wikiText ) {
|
||||
if ( method_exists( $this->mPreprocessor, 'preprocessToXml' ) ) {
|
||||
return $this->normalizeXml( $this->mPreprocessor->preprocessToXml( $wikiText ) );
|
||||
}
|
||||
|
|
@ -134,14 +141,15 @@ class PreprocessorTest extends MediaWikiTestCase {
|
|||
* @param string $xml
|
||||
* @return string
|
||||
*/
|
||||
function normalizeXml( $xml ) {
|
||||
protected function normalizeXml( $xml ) {
|
||||
return preg_replace( '!<([a-z]+)/>!', '<$1></$1>', str_replace( ' />', '/>', $xml ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideCases
|
||||
* @covers Preprocessor_DOM::preprocessToXml
|
||||
*/
|
||||
function testPreprocessorOutput( $wikiText, $expectedXml ) {
|
||||
public function testPreprocessorOutput( $wikiText, $expectedXml ) {
|
||||
$this->assertEquals( $this->normalizeXml( $expectedXml ), $this->preprocessToXml( $wikiText ) );
|
||||
}
|
||||
|
||||
|
|
@ -160,8 +168,9 @@ class PreprocessorTest extends MediaWikiTestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider provideFiles
|
||||
* @covers Preprocessor_DOM::preprocessToXml
|
||||
*/
|
||||
function testPreprocessorOutputFiles( $filename ) {
|
||||
public function testPreprocessorOutputFiles( $filename ) {
|
||||
$folder = __DIR__ . "/../../../parser/preprocess";
|
||||
$wikiText = file_get_contents( "$folder/$filename.txt" );
|
||||
$output = $this->preprocessToXml( $wikiText );
|
||||
|
|
@ -222,6 +231,7 @@ class PreprocessorTest extends MediaWikiTestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider provideHeadings
|
||||
* @covers Preprocessor_DOM::preprocessToXml
|
||||
*/
|
||||
function testHeadings( $wikiText, $expectedXml ) {
|
||||
$this->assertEquals( $this->normalizeXml( $expectedXml ), $this->preprocessToXml( $wikiText ) );
|
||||
|
|
|
|||
Loading…
Reference in a new issue