MediaWiki  1.23.2
MediaWikiParserTest.php
Go to the documentation of this file.
1 <?php
2 require_once __DIR__ . '/NewParserTest.php';
3 
13 
22  const CORE_ONLY = 1;
24  const NO_CORE = 2;
26  const WITH_ALL = 3; # CORE_ONLY | NO_CORE
27 
53  public static function suite( $flags = self::CORE_ONLY ) {
54  if ( is_string( $flags ) ) {
56  }
57  global $wgParserTestFiles, $IP;
58 
59  $mwTestDir = $IP . '/tests/';
60 
61  # Human friendly helpers
62  $wantsCore = ( $flags & self::CORE_ONLY );
63  $wantsRest = ( $flags & self::NO_CORE );
64 
65  # Will hold the .txt parser test files we will include
66  $filesToTest = array();
67 
68  # Filter out .txt files
69  foreach ( $wgParserTestFiles as $parserTestFile ) {
70  $isCore = ( 0 === strpos( $parserTestFile, $mwTestDir ) );
71 
72  if ( $isCore && $wantsCore ) {
73  self::debug( "included core parser tests: $parserTestFile" );
74  $filesToTest[] = $parserTestFile;
75  } elseif ( !$isCore && $wantsRest ) {
76  self::debug( "included non core parser tests: $parserTestFile" );
77  $filesToTest[] = $parserTestFile;
78  } else {
79  self::debug( "skipped parser tests: $parserTestFile" );
80  }
81  }
82  self::debug( 'parser tests files: '
83  . implode( ' ', $filesToTest ) );
84 
85  $suite = new PHPUnit_Framework_TestSuite;
86  foreach ( $filesToTest as $fileName ) {
87  $testsName = basename( $fileName, '.txt' );
88  $escapedFileName = strtr( $fileName, array( "'" => "\\'", '\\' => '\\\\' ) );
89  /* This used to be ucfirst( basename( dirname( $filename ) ) )
90  * and then was ucfirst( basename( $filename, '.txt' )
91  * but that didn't work with names like foo.tests.txt
92  */
93  $parserTestClassName = str_replace( '.', '_', ucfirst( $testsName ) );
94  $parserTestClassDefinition = <<<EOT
101 class $parserTestClassName extends NewParserTest {
102  protected \$file = '$escapedFileName';
103 }
104 EOT;
105 
106  eval( $parserTestClassDefinition );
107  self::debug( "Adding test class $parserTestClassName" );
108  $suite->addTestSuite( $parserTestClassName );
109  }
110  return $suite;
111  }
112 
117  protected static function debug( $msg ) {
118  return wfDebugLog( 'tests-parser', wfGetCaller() . ' ' . $msg );
119  }
120 }
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
MediaWikiParserTest\NO_CORE
const NO_CORE
Include non core files as set in $wgParserTestFiles.
Definition: MediaWikiParserTest.php:24
wfDebugLog
wfDebugLog( $logGroup, $text, $dest='all')
Send a line to a supplementary debug log file, if configured, or main debug log if not.
Definition: GlobalFunctions.php:1040
MediaWikiParserTest\debug
static debug( $msg)
Write $msg under log group 'tests-parser'.
Definition: MediaWikiParserTest.php:112
$flags
it s the revision text itself In either if gzip is the revision text is gzipped $flags
Definition: hooks.txt:2113
MediaWikiParserTest\CORE_ONLY
const CORE_ONLY
Include files shipped with MediaWiki core.
Definition: MediaWikiParserTest.php:22
MediaWikiParserTest\WITH_ALL
const WITH_ALL
Include anything set via $wgParserTestFiles.
Definition: MediaWikiParserTest.php:26
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
MediaWikiParserTest
The UnitTest must be either a class that inherits from MediaWikiTestCase or a class that provides a p...
Definition: MediaWikiParserTest.php:12
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
MediaWikiParserTest\suite
static suite( $flags=self::CORE_ONLY)
Get a PHPUnit test suite of parser tests.
Definition: MediaWikiParserTest.php:53
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
$IP
$IP
Definition: WebStart.php:88
wfGetCaller
wfGetCaller( $level=2)
Get the name of the function which called this function wfGetCaller( 1 ) is the function with the wfG...
Definition: GlobalFunctions.php:1941