* @var DjVuSupport
*/
private $djVuSupport;
+ /**
+ * @var TidySupport
+ */
+ private $tidySupport;
protected $file = false;
parent::setUp();
//Setup CLI arguments
- if ( $this->getCliArg( 'regex=' ) ) {
- $this->regex = $this->getCliArg( 'regex=' );
+ if ( $this->getCliArg( 'regex' ) ) {
+ $this->regex = $this->getCliArg( 'regex' );
} else {
# Matches anything
$this->regex = '';
$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;
# 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;
self::getOptionValue( 'wgLinkHolderBatchSize', $opts, 1000 );
$uploadDir = $this->getUploadDir();
- if ( $this->getCliArg( 'use-filebackend=' ) ) {
+ if ( $this->getCliArg( 'use-filebackend' ) ) {
if ( self::$backendToUse ) {
$backend = self::$backendToUse;
} else {
- $name = $this->getCliArg( 'use-filebackend=' );
+ $name = $this->getCliArg( 'use-filebackend' );
$useConfig = array();
foreach ( $wgFileBackends as $conf ) {
if ( $conf['name'] == $name ) {
$backend = RepoGroup::singleton()->getLocalRepo()->getBackend();
$backend->prepare( array( 'dir' => "$base/local-public/3/3a" ) );
$backend->store( array(
- 'src' => "$IP/tests/phpunit/data/parser/headbg.jpg", 'dst' => "$base/local-public/3/3a/Foobar.jpg"
+ 'src' => "$IP/tests/phpunit/data/parser/headbg.jpg",
+ 'dst' => "$base/local-public/3/3a/Foobar.jpg"
) );
$backend->prepare( array( 'dir' => "$base/local-public/e/ea" ) );
$backend->store( array(
- 'src' => "$IP/tests/phpunit/data/parser/wiki.png", 'dst' => "$base/local-public/e/ea/Thumb.png"
+ 'src' => "$IP/tests/phpunit/data/parser/wiki.png",
+ 'dst' => "$base/local-public/e/ea/Thumb.png"
) );
$backend->prepare( array( 'dir' => "$base/local-public/0/09" ) );
$backend->store( array(
- 'src' => "$IP/tests/phpunit/data/parser/headbg.jpg", 'dst' => "$base/local-public/0/09/Bad.jpg"
+ 'src' => "$IP/tests/phpunit/data/parser/headbg.jpg",
+ 'dst' => "$base/local-public/0/09/Bad.jpg"
) );
$backend->prepare( array( 'dir' => "$base/local-public/5/5f" ) );
$backend->store( array(
- 'src' => "$IP/tests/phpunit/data/parser/LoremIpsum.djvu", 'dst' => "$base/local-public/5/5f/LoremIpsum.djvu"
+ 'src' => "$IP/tests/phpunit/data/parser/LoremIpsum.djvu",
+ 'dst' => "$base/local-public/5/5f/LoremIpsum.djvu"
) );
// No helpful SVG file to copy, so make one ourselves
$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();
$files = $wgParserTestFiles;
- if ( $this->getCliArg( 'file=' ) ) {
- $files = array( $this->getCliArg( 'file=' ) );
+ if ( $this->getCliArg( 'file' ) ) {
+ $files = array( $this->getCliArg( 'file' ) );
}
$dict = $this->getFuzzInput( $files );
/**
* 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;
//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 );