r79443 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79442‎ | r79443 | r79444 >
Date:22:04, 1 January 2011
Author:platonides
Status:ok (Comments)
Tags:
Comment:
Use an autoloader for the tests, following the ideas from r72858.
The SeleniumTestConstants class was added in r79437
Modified paths:
  • /trunk/phase3/tests/TestsAutoLoader.php (added) (history)
  • /trunk/phase3/tests/phpunit/includes/api/ApiTest.php (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/api/ApiUploadTest.php (modified) (history)
  • /trunk/phase3/tests/phpunit/phpunit.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/api/ApiTest.php
@@ -1,7 +1,5 @@
22 <?php
33
4 -require_once( dirname( __FILE__ ) . '/ApiSetup.php' );
5 -
64 class MockApi extends ApiBase {
75 public function execute() { }
86 public function getVersion() { }
Index: trunk/phase3/tests/phpunit/includes/api/ApiUploadTest.php
@@ -17,9 +17,6 @@
1818 // TODO: refactor into several files
1919 // TODO: port the other Upload tests, and other API tests to this framework
2020
21 -require_once( dirname( __FILE__ ) . '/RandomImageGenerator.php' );
22 -require_once( dirname( __FILE__ ) . '/../../../../includes/User.php' );
23 -
2421 /* Wraps the user object, so we can also retain full access to properties like password if we log in via the API */
2522 class ApiTestUser {
2623 public $username;
@@ -130,7 +127,7 @@
131128 // add edit token to fake session
132129 $session['wsEditToken'] = $session['wsToken'];
133130 // add token to request parameters
134 - $params['token'] = md5( $session['wsToken'] ) . EDIT_TOKEN_SUFFIX;
 131+ $params['token'] = md5( $session['wsToken'] ) . User::EDIT_TOKEN_SUFFIX;
135132 return $this->doApiRequest( $params, $session );
136133 } else {
137134 throw new Exception( "request data not in right format" );
Index: trunk/phase3/tests/phpunit/phpunit.php
@@ -35,7 +35,6 @@
3636 require_once( 'PHPUnit/TextUI/Command.php' );
3737 }
3838
39 -require_once( "$IP/tests/phpunit/MediaWikiPHPUnitCommand.php" );
40 -require_once( "$IP/tests/phpunit/MediaWikiTestCase.php" );
 39+require_once( "$IP/tests/TestsAutoLoader.php" );
4140 MediaWikiPHPUnitCommand::main();
4241
Index: trunk/phase3/tests/TestsAutoLoader.php
@@ -0,0 +1,13 @@
 2+<?php
 3+
 4+global $wgAutoloadClasses;
 5+$testFolder = dirname( __FILE__ );
 6+
 7+$wgAutoloadClasses += array(
 8+ 'MediaWikiTestCase' => "$testFolder/phpunit/MediaWikiTestCase.php",
 9+ 'MediaWikiPHPUnitCommand' => "$testFolder/phpunit/MediaWikiPHPUnitCommand.php",
 10+ 'ApiTestSetup' => "$testFolder/phpunit/includes/api/ApiSetup.php",
 11+ 'RandomImageGenerator' => "$testFolder/phpunit/includes/api/RandomImageGenerator.php",
 12+ 'SeleniumTestConstants' => "$testFolder/selenium/SeleniumTestConstants.php",
 13+);
 14+
Property changes on: trunk/phase3/tests/TestsAutoLoader.php
___________________________________________________________________
Added: svn:eol-style
115 + native

Follow-up revisions

RevisionCommit summaryAuthorDate
r79447Followup r79443: Add some form of organization to the test autoloadersoxred9322:16, 1 January 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r72858Follow up r72566. Per CR r9132#c9132 these files were intended to explicitely...platonides13:42, 12 September 2010
r79437I am fed up of selenium constants which aren't properly defined by all files ...platonides20:56, 1 January 2011

Comments

#Comment by Reedy (talk | contribs)   23:53, 13 January 2011
PHP Fatal error:  Unsupported operand types in /home/ci/cruisecontrol-bin-2.8.3/projects/mw/source/tests/TestsAutoLoader.php on line 22

PHP Stack trace:

PHP   1. {main}() /home/ci/cruisecontrol-bin-2.8.3/projects/mw/source/tests/phpunit/phpunit.php:0

PHP   2. require_once() /home/ci/cruisecontrol-bin-2.8.3/projects/mw/source/tests/phpunit/phpunit.php:38

http://ci.tesla.usability.wikimedia.org/cruisecontrol/buildresults/mw

array_merge instead?

#Comment by Platonides (talk | contribs)   08:20, 14 January 2011

I'm not seeing such error in tesla.

#Comment by Reedy (talk | contribs)   16:05, 14 January 2011

Wonder if it was just a transient problem that is now fixed...

#Comment by Reedy (talk | contribs)   01:23, 15 January 2011

Resetting new, must've just been a hiccup in CI

Status & tagging log