MediaWiki  1.23.15
MediaWikiPHPUnitCommand.php
Go to the documentation of this file.
1 <?php
2 
3 class MediaWikiPHPUnitCommand extends PHPUnit_TextUI_Command {
4 
5  public static $additionalOptions = array(
6  'regex=' => false,
7  'file=' => false,
8  'use-filebackend=' => false,
9  'use-bagostuff=' => false,
10  'use-jobqueue=' => false,
11  'keep-uploads' => false,
12  'use-normal-tables' => false,
13  'reuse-db' => false,
14  'wiki=' => false,
15  'debug-tests' => false,
16  );
17 
18  public function __construct() {
19  foreach ( self::$additionalOptions as $option => $default ) {
20  $this->longOptions[$option] = $option . 'Handler';
21  }
22  }
23 
24  protected function handleArguments( array $argv ) {
25  parent::handleArguments( $argv );
26 
27  if ( !isset( $this->arguments['listeners'] ) ) {
28  $this->arguments['listeners'] = array();
29  }
30 
31  foreach ( $this->options[0] as $option ) {
32  switch ( $option[0] ) {
33  case '--debug-tests':
34  $this->arguments['listeners'][] = new MediaWikiPHPUnitTestListener( 'PHPUnitCommand' );
35  break;
36  }
37  }
38  }
39 
40  public static function main( $exit = true ) {
41  $command = new self;
42 
43  if ( wfIsWindows() ) {
44  # Windows does not come anymore with ANSI.SYS loaded by default
45  # PHPUnit uses the suite.xml parameters to enable/disable colors
46  # which can be then forced to be enabled with --colors.
47  # The below code inject a parameter just like if the user called
48  # phpunit with a --no-color option (which does not exist). It
49  # overrides the suite.xml setting.
50  # Probably fix bug 29226
51  $command->arguments['colors'] = false;
52  }
53 
54  # Makes MediaWiki PHPUnit directory includable so the PHPUnit will
55  # be able to resolve relative files inclusion such as suites/*
56  # PHPUnit uses stream_resolve_include_path() internally
57  # See bug 32022
58  set_include_path(
59  __DIR__
60  . PATH_SEPARATOR
61  . get_include_path()
62  );
63 
64  $command->run( $_SERVER['argv'], $exit );
65  }
66 
67  public function __call( $func, $args ) {
68 
69  if ( substr( $func, -7 ) == 'Handler' ) {
70  if ( is_null( $args[0] ) ) {
71  $args[0] = true;
72  } //Booleans
73  self::$additionalOptions[substr( $func, 0, -7 )] = $args[0];
74  }
75  }
76 
77  public function run( array $argv, $exit = true ) {
78  wfProfileIn( __METHOD__ );
79 
80  $ret = parent::run( $argv, false );
81 
82  wfProfileOut( __METHOD__ );
83 
84  // Return to real wiki db, so profiling data is preserved
85  MediaWikiTestCase::teardownTestDB();
86 
87  // Log profiling data, e.g. in the database or UDP
88  wfLogProfilingData();
89 
90  if ( $exit ) {
91  exit( $ret );
92  } else {
93  return $ret;
94  }
95  }
96 
97  public function showHelp() {
98  parent::showHelp();
99 
100  print <<<EOT
101 
102 ParserTest-specific options:
103  --regex="<regex>" Only run parser tests that match the given regex
104  --file="<filename>" File describing parser tests
105  --keep-uploads Re-use the same upload directory for each test, don't delete it
106 
107 Database options:
108  --use-normal-tables Use normal DB tables.
109  --reuse-db Init DB only if tables are missing and keep after finish.
110 
111 Debugging options:
112  --debug-tests Log testing activity to the PHPUnitCommand log channel.
113 
114 EOT;
115  }
116 }
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
MediaWikiPHPUnitCommand\main
static main( $exit=true)
Definition: MediaWikiPHPUnitCommand.php:40
MediaWikiPHPUnitTestListener
Definition: MediaWikiPHPUnitTestListener.php:2
MediaWikiPHPUnitCommand\$additionalOptions
static $additionalOptions
Definition: MediaWikiPHPUnitCommand.php:5
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
$command
$command
Definition: cdb.php:63
MediaWikiPHPUnitCommand\handleArguments
handleArguments(array $argv)
Definition: MediaWikiPHPUnitCommand.php:24
options
We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going and make changes or fix bugs In we can take all the code that deals with the little used title reversing options(say) and put it in one place. Instead of having little title-reversing if-blocks spread all over the codebase in showAnArticle
wfIsWindows
wfIsWindows()
Check if the operating system is Windows.
Definition: GlobalFunctions.php:2571
MediaWikiPHPUnitCommand
Definition: MediaWikiPHPUnitCommand.php:3
MediaWikiPHPUnitCommand\__construct
__construct()
Definition: MediaWikiPHPUnitCommand.php:18
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