r74553 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74552‎ | r74553 | r74554 >
Date:18:15, 9 October 2010
Author:platonides
Status:ok (Comments)
Tags:
Comment:
Readd after r72566 a phpunit.php so that globals are kept global.
Modified paths:
  • /trunk/phase3/maintenance/tests/phpunit/Makefile (modified) (history)
  • /trunk/phase3/maintenance/tests/phpunit/bootstrap.php (modified) (history)
  • /trunk/phase3/maintenance/tests/phpunit/phpunit.php (added) (history)

Diff [purge]

Index: trunk/phase3/maintenance/tests/phpunit/bootstrap.php
@@ -1,32 +1,19 @@
2 -<?php
 2+<?php
33 /**
44 * Bootstrapping for MediaWiki PHPUnit tests
5 - *
 5+ * This file is included by phpunit and is NOT in the global scope.
 6+ *
67 * @file
78 */
89
9 -/* Configuration */
 10+if ( !defined( 'MW_PHPUNIT_TEST' ) ) {
 11+ echo <<<EOF
 12+You are running these tests directly from phpunit. You may not have all globals correctly set.
 13+Running phpunit.php instead is recommended.
 14+EOF;
 15+ require_once ( dirname( __FILE__ ) . "/phpunit.php" );
 16+}
1017
11 -// This file is not included in the global scope, but rather within a function, so we must global anything we need to
12 -// have access to in the global scope explicitly
13 -global $wgCommandLineMode, $IP, $optionsWithArgs, $wgProfiler, $wgAutoloadClasses;
14 -
15 -// Evaluate the include path relative to this file
16 -$IP = dirname( dirname( dirname( dirname( __FILE__ ) ) ) );
17 -
18 -// Set a flag which can be used to detect when other scripts have been entered through this entry point or not
19 -define( 'MW_PHPUNIT_TEST', true );
20 -
21 -// Start up MediaWiki in command-line mode
22 -require_once( "$IP/maintenance/commandLine.inc" );
23 -
24 -// Assume UTC for testing purposes
25 -$wgLocaltimezone = 'UTC';
26 -
27 -// To prevent tests from failing with SQLite, we need to turn database caching off
28 -global $wgCaches;
29 -$wgCaches[CACHE_DB] = false;
30 -
3118 // Output a notice when running with older versions of PHPUnit
3219 if ( !version_compare( PHPUnit_Runner_Version::id(), "3.4.1", ">" ) ) {
3320 echo <<<EOF
@@ -74,3 +61,4 @@
7562 }
7663 }
7764 }
 65+
Index: trunk/phase3/maintenance/tests/phpunit/Makefile
@@ -3,7 +3,7 @@
44 SHELL = /bin/sh
55 CONFIG_FILE = $(shell pwd)/suite.xml
66 FLAGS =
7 -PU = phpunit --configuration ${CONFIG_FILE}
 7+PU = php phpunit.php --configuration ${CONFIG_FILE}
88
99 all test: warning
1010
Index: trunk/phase3/maintenance/tests/phpunit/phpunit.php
@@ -0,0 +1,27 @@
 2+#!/usr/bin/env php
 3+<?php
 4+/**
 5+ * Bootstrapping for MediaWiki PHPUnit tests
 6+ *
 7+ * @file
 8+ */
 9+
 10+/* Configuration */
 11+
 12+// Evaluate the include path relative to this file
 13+$IP = dirname( dirname( dirname( dirname( __FILE__ ) ) ) );
 14+
 15+// Set a flag which can be used to detect when other scripts have been entered through this entry point or not
 16+define( 'MW_PHPUNIT_TEST', true );
 17+
 18+// Start up MediaWiki in command-line mode
 19+require_once( "$IP/maintenance/commandLine.inc" );
 20+
 21+// Assume UTC for testing purposes
 22+$wgLocaltimezone = 'UTC';
 23+
 24+// To prevent tests from failing with SQLite, we need to turn database caching off
 25+$wgCaches[CACHE_DB] = false;
 26+
 27+require_once "/usr/bin/phpunit";
 28+
Property changes on: trunk/phase3/maintenance/tests/phpunit/phpunit.php
___________________________________________________________________
Added: svn:eol-style
129 + native
Added: svn:executable
230 + *

Follow-up revisions

RevisionCommit summaryAuthorDate
r74554Look for PHPUnit folder in the PATH and add support for Windows....platonides18:32, 9 October 2010
r74556Follow-up r74553, r74554 and r74555: don't guess, just include stuff properlymaxsem19:00, 9 October 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r72566Merged reorganization work for PHPUnit from branches/phpunit-restructure/tparscal23:02, 7 September 2010

Comments

#Comment by Hashar (talk | contribs)   22:07, 14 October 2010

After upgrading to phpunit 3.5.0, the command "php phpunit.php" is broken.

$ php phpunit.php 
Fatal error: Class 'PHPUnit_Util_Getopt' not found in /opt/local/PEAR/PHPUnit/TextUI/Command.php on line 238
Call Stack:
    0.0004      56096   1. {main}() /mediawiki-trunk/maintenance/tests/phpunit/phpunit.php:0
    0.0590    3483056   2. PHPUnit_TextUI_Command::main() /mediawiki-trunk/maintenance/tests/phpunit/phpunit.php:27
    0.0590    3483680   3. PHPUnit_TextUI_Command->run() /opt/local/PEAR/PHPUnit/TextUI/Command.php:129
    0.0590    3485776   4. PHPUnit_TextUI_Command->handleArguments() /opt/local/PEAR/PHPUnit/TextUI/Command.php:138
$

Looks like a problem with PHPUnit autoloader :-p

Marking 'fixme' since this revision changed the Makefile: -PU = phpunit --configuration ${CONFIG_FILE} +PU = php phpunit.php --configuration ${CONFIG_FILE}

#Comment by Hashar (talk | contribs)   22:08, 14 October 2010

(where is the [Edit] button ?)

Makefile:

-PU = phpunit --configuration ${CONFIG_FILE}
+PU = php phpunit.php --configuration ${CONFIG_FILE}
#Comment by Platonides (talk | contribs)   22:17, 14 October 2010

I think the fixme should be in r74556 which is what used the autoloader. Note that I just called the phpunit entry point.

#Comment by Hashar (talk | contribs)   10:43, 16 October 2010

Marking this revision OK.

I fixed r74556 issue with r74831.

Status & tagging log