* @var DjVuSupport
*/
private $djVuSupport;
+ /**
+ * @var TidySupport
+ */
+ private $tidySupport;
protected $file = false;
$tmpGlobals['wgExtensionAssetsPath'] = '/extensions';
$tmpGlobals['wgStylePath'] = '/skins';
$tmpGlobals['wgEnableUploads'] = true;
+ $tmpGlobals['wgUploadNavigationUrl'] = false;
$tmpGlobals['wgThumbnailScriptPath'] = false;
$tmpGlobals['wgLocalFileRepo'] = array(
'class' => 'LocalRepo',
$tmpGlobals['wgUseImageResize'] = true;
$tmpGlobals['wgAllowExternalImages'] = true;
$tmpGlobals['wgRawHtml'] = false;
- $tmpGlobals['wgUseTidy'] = false;
- $tmpGlobals['wgAlwaysUseTidy'] = false;
$tmpGlobals['wgWellFormedXml'] = true;
$tmpGlobals['wgAllowMicrodataAttributes'] = true;
$tmpGlobals['wgExperimentalHtmlIds'] = false;
$tmpGlobals['wgFileExtensions'][] = 'svg';
$tmpGlobals['wgSVGConverter'] = 'rsvg';
$tmpGlobals['wgSVGConverters']['rsvg'] =
- '$path/rsvg-convert -w $width -h $height $input -o $output';
+ '$path/rsvg-convert -w $width -h $height -o $output $input';
if ( $GLOBALS['wgStyleDirectory'] === false ) {
$tmpGlobals['wgStyleDirectory'] = "$IP/skins";
# see https://gerrit.wikimedia.org/r/111390
$tmpGlobals['wgExtraInterlanguageLinkPrefixes'] = array( 'mul' );
- //DjVu support
+ // DjVu support
$this->djVuSupport = new DjVuSupport();
+ // Tidy support
+ $this->tidySupport = new TidySupport();
+ // We always set 'wgUseTidy' to false when parsing, but certain
+ // test-running modes still use tidy if available, so ensure
+ // that the tidy-related options are all set to their defaults.
+ $tmpGlobals['wgUseTidy'] = false;
+ $tmpGlobals['wgAlwaysUseTidy'] = false;
+ $tmpGlobals['wgDebugTidy'] = false;
+ $tmpGlobals['wgTidyConf'] = $IP . '/includes/tidy.conf';
+ $tmpGlobals['wgTidyOpts'] = '';
+ $tmpGlobals['wgTidyInternal'] = $this->tidySupport->isInternal();
$this->setMwGlobals( $tmpGlobals );
/**
* Set up the global variables for a consistent environment for each test.
* Ideally this should replace the global configuration entirely.
+ * @param array $opts
+ * @param string $config
+ * @return RequestContext
*/
protected function setupGlobals( $opts = array(), $config = '' ) {
global $wgFileBackends;
$this->savedGlobals = array();
/** @since 1.20 */
- wfRunHooks( 'ParserTestGlobals', array( &$settings ) );
+ Hooks::run( 'ParserTestGlobals', array( &$settings ) );
$langObj = Language::factory( $lang );
$settings['wgContLang'] = $langObj;
$output = $parser->parse( $input, $title, $options, true, true, 1337 );
$output->setTOCEnabled( !isset( $opts['notoc'] ) );
$out = $output->getText();
+ if ( isset( $opts['tidy'] ) ) {
+ if ( !$this->tidySupport->isEnabled() ) {
+ $this->markTestSkipped( "SKIPPED: tidy extension is not installed.\n" );
+ } else {
+ $out = MWTidy::tidy( $out );
+ $out = preg_replace( '/\s+$/', '', $out );
+ }
+ }
if ( isset( $opts['showtitle'] ) ) {
if ( $output->getTitleText() ) {
}
if ( isset( $opts['ill'] ) ) {
- $out = $this->tidy( implode( ' ', $output->getLanguageLinks() ) );
+ $out = implode( ' ', $output->getLanguageLinks() );
} elseif ( isset( $opts['cat'] ) ) {
$outputPage = $context->getOutput();
$outputPage->addCategoryLinks( $output->getCategories() );
$cats = $outputPage->getCategoryLinks();
if ( isset( $cats['normal'] ) ) {
- $out = $this->tidy( implode( ' ', $cats['normal'] ) );
+ $out = implode( ' ', $cats['normal'] );
} else {
$out = '';
}
}
$parser->mPreprocessor = null;
-
- $result = $this->tidy( $result );
}
$this->teardownGlobals();
/**
* Get an input dictionary from a set of parser test files
* @param array $filenames
+ * @return string
*/
function getFuzzInput( $filenames ) {
$dict = '';
/**
* Get a memory usage breakdown
+ * @return array
*/
function getMemoryBreakdown() {
$memStats = array();
/**
* Get a Parser object
* @param Preprocessor $preprocessor
+ * @return Parser
*/
function getParser( $preprocessor = null ) {
global $wgParserConf;
$class = $wgParserConf['class'];
$parser = new $class( array( 'preprocessorClass' => $preprocessor ) + $wgParserConf );
- wfRunHooks( 'ParserTestParser', array( &$parser ) );
+ Hooks::run( 'ParserTestParser', array( &$parser ) );
return $parser;
}
//Various "cleanup" functions
- /**
- * Run the "tidy" command on text if the $wgUseTidy
- * global is true
- *
- * @param string $text The text to tidy
- * @return string
- */
- protected function tidy( $text ) {
- global $wgUseTidy;
-
- if ( $wgUseTidy ) {
- $text = MWTidy::tidy( $text );
- }
-
- return $text;
- }
-
/**
* Remove last character if it is a newline
* @param string $s
+ * @return string
*/
public function removeEndingNewline( $s ) {
if ( substr( $s, -1 ) === "\n" ) {
* @param string $key Name of option val to retrieve
* @param array $opts Options array to look in
* @param mixed $default Default value returned if not found
+ * @return mixed
*/
protected static function getOptionValue( $key, $opts, $default ) {
$key = strtolower( $key );