Adamw has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/86771


Change subject: Test setup is more robust
......................................................................

Test setup is more robust

Change-Id: Ifd0dcc45728c6d2f4b4f4e2f1a42a5008780e37a
---
M tests/Adapter/GatewayAdapterTestCase.php
M tests/TestHelper.php
2 files changed, 26 insertions(+), 31 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface 
refs/changes/71/86771/1

diff --git a/tests/Adapter/GatewayAdapterTestCase.php 
b/tests/Adapter/GatewayAdapterTestCase.php
index 07f69fc..b406dc9 100644
--- a/tests/Adapter/GatewayAdapterTestCase.php
+++ b/tests/Adapter/GatewayAdapterTestCase.php
@@ -14,7 +14,6 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  *
- * @since              r98249
  * @author Katie Horn <[email protected]>
  */
 
diff --git a/tests/TestHelper.php b/tests/TestHelper.php
index 458a37f..e928f37 100644
--- a/tests/TestHelper.php
+++ b/tests/TestHelper.php
@@ -28,62 +28,58 @@
 error_reporting( E_ALL | E_STRICT );
 
 if ( !defined( 'MEDIAWIKI' ) ) {
-       define( 'MEDIAWIKI', 1 );
+       define( 'MEDIAWIKI', true );
 }
 
-/**
- * TESTS_WEB_ROOT
- *
- * This is similar to $IP, the installation path in Mediawiki.
- */
-define( 'TESTS_WEB_ROOT', dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) 
);
-
-$IP = TESTS_WEB_ROOT;
+global $IP;
+$IP = strval( getenv( 'MW_INSTALL_PATH' ) ) !== ''
+       ? getenv( 'MW_INSTALL_PATH' )
+       : realpath( __DIR__ . '/../../..' );
 
 /*
  * Required files for unit testing. 
  */
-require_once( TESTS_WEB_ROOT . '/includes/Defines.php' );
-require_once( TESTS_WEB_ROOT . '/includes/DefaultSettings.php' );
-require_once( TESTS_WEB_ROOT . '/LocalSettings.php' );
-require_once( TESTS_WEB_ROOT . '/includes/SpecialPage.php' );
-require_once( TESTS_WEB_ROOT . '/includes/Title.php' );
-require_once( TESTS_WEB_ROOT . '/includes/Exception.php' );
+require_once( "$IP/includes/AutoLoader.php" );
+require_once( "$IP/includes/Defines.php" );
+require_once( "$IP/includes/DefaultSettings.php" );
+require_once( "$IP/LocalSettings.php" );
+
+$DI_ROOT = __DIR__ . '/..';
 
 /**
  * @see DonationData
  */
-require_once dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 
'gateway_common/DonationData.php';
+require_once "$DI_ROOT/gateway_common/DonationData.php";
 
 /**
  * @see GatewayAdapter
  */
-require_once dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 
'gateway_common/gateway.adapter.php';
+require_once "$DI_ROOT/gateway_common/gateway.adapter.php";
 
 /**
  * @see GatewayForm
  */
-require_once dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 
'gateway_common/GatewayForm.php';
+require_once "$DI_ROOT/gateway_common/GatewayForm.php";
 
 /**
  * @see extras/extras.body.php
  */
-require_once dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 
'extras/extras.body.php';
+require_once "$DI_ROOT/extras/extras.body.php";
 
 /**
  * @see GlobalCollectAdapter
  */
-require_once dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 
'globalcollect_gateway/globalcollect.adapter.php';
+require_once "$DI_ROOT/globalcollect_gateway/globalcollect.adapter.php";
 
 /**
  * @see GlobalCollectTestAdapter
  */
-require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 
'Adapter/GlobalCollect/GlobalCollectTestAdapter.php';
+require_once __DIR__ . '/Adapter/GlobalCollect/GlobalCollectTestAdapter.php';
 
 /**
  * @see ContributionTrackingProcessor
  */
-require_once dirname( dirname( dirname( __FILE__ ) ) ) . DIRECTORY_SEPARATOR . 
'ContributionTracking/ContributionTracking.processor.php';
+require_once 
"$IP/extensions/ContributionTracking/ContributionTracking.processor.php";
 
 
 /*
@@ -117,13 +113,13 @@
  *
  * These files need to be required after the above code. Do not move.
  */
-require_once( TESTS_WEB_ROOT . '/includes/WebRequest.php' );
-require_once( TESTS_WEB_ROOT . '/includes/GlobalFunctions.php' );
-require_once( TESTS_WEB_ROOT . '/includes/HttpFunctions.php' );
-require_once( TESTS_WEB_ROOT . '/includes/db/Database.php' );
-require_once( TESTS_WEB_ROOT . '/includes/db/DatabaseMysql.php' );
-require_once( TESTS_WEB_ROOT . '/includes/profiler/Profiler.php' );
-require_once( TESTS_WEB_ROOT . '/includes/Sanitizer.php' );
+require_once( "$IP/includes/WebRequest.php" );
+require_once( "$IP/includes/GlobalFunctions.php" );
+require_once( "$IP/includes/HttpFunctions.php" );
+require_once( "$IP/includes/db/Database.php" );
+require_once( "$IP/includes/db/DatabaseMysql.php" );
+require_once( "$IP/includes/profiler/Profiler.php" );
+require_once( "$IP/includes/Sanitizer.php" );
 $request = $_SERVER;
 $wgRequest = new FauxRequest( $request );
 
@@ -142,6 +138,6 @@
  */
 $_SERVER['HTTP_HOST'] = TESTS_HOSTNAME;
 $_SERVER['SERVER_NAME'] = TESTS_HOSTNAME;
-$_SERVER['SERVER_NAME'] = TESTS_WEB_ROOT;
+$_SERVER['DOCUMENT_ROOT'] = $IP;
 $_SERVER['SERVER_ADMIN'] = TESTS_EMAIL;
 

-- 
To view, visit https://gerrit.wikimedia.org/r/86771
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifd0dcc45728c6d2f4b4f4e2f1a42a5008780e37a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Adamw <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to