* Remove $wg*Selenium* globals as they are only used for testing.
[lhc/web/wiklou.git] / maintenance / tests / phpunit
1 #!/usr/bin/env php
2 <?php
3
4 require( dirname( __FILE__ ) . '/../commandLine.inc' );
5 // XXX: This can go away if everyone switches to PHPUnit 3.5
6 if ( @file_get_contents( 'PHPUnit/Autoload.php', true ) !== false ) {
7 // Works for PHPUnit >= 3.5
8 require_once 'PHPUnit/Autoload.php';
9 } else {
10 // Works for PHPUnit < 3.5
11 require_once 'PHPUnit/TextUI/Command.php';
12 }
13 define( 'MW_PHPUNIT_TEST', 1 );
14
15 $wgLocaltimezone = 'UTC';
16
17 /* Tests were failing with sqlite */
18 global $wgCaches;
19 $wgCaches[CACHE_DB] = false;
20
21 if ( !version_compare( PHPUnit_Runner_Version::id(), "3.4.1", ">" ) ) {
22 echo <<<EOF
23 ************************************************************
24
25 These tests run best with version PHPUnit 3.4.2 or later.
26 Earlier versions may show failures because earlier versions
27 of PHPUnit do not properly implement dependencies.
28
29 ************************************************************
30
31 EOF;
32 }
33
34 class MWPHPUnitCommand extends PHPUnit_TextUI_Command {
35 protected function handleCustomTestSuite() {
36 $suite = new PHPUnit_Framework_TestSuite;
37 if ( !empty( $this->options[1] ) ) {
38 $files = $this->options[1];
39 } else {
40 require( dirname( __FILE__ ) . '/TestFileList.php' );
41 $files = $testFiles;
42 wfRunHooks( 'UnitTestsList', array( &$files ) );
43 }
44 foreach ( $files as $file ) {
45 $suite->addTestFile( $file );
46 }
47 $suite->setName( 'MediaWiki test suite' );
48 $this->arguments['test'] = $suite;
49 }
50 }
51
52 $command = new MWPHPUnitCommand;
53 $command->run( $argv );
54