MediaWiki  1.23.14
MediaWikiParserTest.php
Go to the documentation of this file.
1 <?php
2 require_once __DIR__ . '/NewParserTest.php';
3 
14 
23  const CORE_ONLY = 1;
25  const NO_CORE = 2;
27  const WITH_ALL = 3; # CORE_ONLY | NO_CORE
28 
54  public static function suite( $flags = self::CORE_ONLY ) {
55  if ( is_string( $flags ) ) {
57  }
58  global $wgParserTestFiles, $IP;
59 
60  $mwTestDir = $IP . '/tests/';
61 
62  # Human friendly helpers
63  $wantsCore = ( $flags & self::CORE_ONLY );
64  $wantsRest = ( $flags & self::NO_CORE );
65 
66  # Will hold the .txt parser test files we will include
67  $filesToTest = array();
68 
69  # Filter out .txt files
70  foreach ( $wgParserTestFiles as $parserTestFile ) {
71  $isCore = ( 0 === strpos( $parserTestFile, $mwTestDir ) );
72 
73  if ( $isCore && $wantsCore ) {
74  self::debug( "included core parser tests: $parserTestFile" );
75  $filesToTest[] = $parserTestFile;
76  } elseif ( !$isCore && $wantsRest ) {
77  self::debug( "included non core parser tests: $parserTestFile" );
78  $filesToTest[] = $parserTestFile;
79  } else {
80  self::debug( "skipped parser tests: $parserTestFile" );
81  }
82  }
83  self::debug( 'parser tests files: '
84  . implode( ' ', $filesToTest ) );
85 
86  $suite = new PHPUnit_Framework_TestSuite;
87  foreach ( $filesToTest as $fileName ) {
88  $testsName = basename( $fileName, '.txt' );
89  $escapedFileName = strtr( $fileName, array( "'" => "\\'", '\\' => '\\\\' ) );
90  /* This used to be ucfirst( basename( dirname( $filename ) ) )
91  * and then was ucfirst( basename( $filename, '.txt' )
92  * but that didn't work with names like foo.tests.txt
93  */
94  $parserTestClassName = str_replace( '.', '_', ucfirst( $testsName ) );
95  $parserTestClassDefinition = <<<EOT
102 class $parserTestClassName extends NewParserTest {
103  protected \$file = '$escapedFileName';
104 }
105 EOT;
106 
107  eval( $parserTestClassDefinition );
108  self::debug( "Adding test class $parserTestClassName" );
109  $suite->addTestSuite( $parserTestClassName );
110  }
111  return $suite;
112  }
113 
118  protected static function debug( $msg ) {
119  return wfDebugLog( 'tests-parser', wfGetCaller() . ' ' . $msg );
120  }
121 }
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:25
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:1087
MediaWikiParserTest\debug
static debug( $msg)
Write $msg under log group 'tests-parser'.
Definition: MediaWikiParserTest.php:113
$flags
it s the revision text itself In either if gzip is the revision text is gzipped $flags
Definition: hooks.txt:2124
MediaWikiParserTest\CORE_ONLY
const CORE_ONLY
Include files shipped with MediaWiki core.
Definition: MediaWikiParserTest.php:23
MediaWikiParserTest\WITH_ALL
const WITH_ALL
Include anything set via $wgParserTestFiles.
Definition: MediaWikiParserTest.php:27
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:13
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:54
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:92
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:1988