Awight has uploaded a new change for review.
https://gerrit.wikimedia.org/r/213003
Change subject: WIP Make configuration testable
......................................................................
WIP Make configuration testable
Get rid of conditional initialization, this made it impossible to test multiple
configurations.
* Disable all components by default.
* Wrapped all testing global assignments in setMwGlobals to eliminate some
interaction between tests.
== Deployment notes ==
You must rename and and new variables in LocalSettings.php to use this patch.
Enabling gateways looks like this now:
$wgGlobalCollectGatewayEnabled = true;
Please add a line for each gateway you would like enabled.
All "optional parts" are disabled by default now. Add lines for any custom
filters and features you desire. Adding the following lines before your local
settings will give the same behavior as defaults as they were before this
patch, not including gateways:
$wgDonationInterfaceEnableFormChooser = true;
$wgDonationInterfaceEnableFunctionsFilter = true;
$wgDonationInterfaceEnableMinfraud = true;
$wgDonationInterfaceEnableReferrerFilter = true;
$wgDonationInterfaceEnableSourceFilter = true;
TODO:
* We should use getGlobal everywhere, for example when testing the EnableStomp
configuration, so all features can be toggled per gateway.
* It's creepy to allow GatewayFormChooser to return results for disabled
gateways, but the idea is that we've removing forms from
$wgDonationInterfaceAllowedHtmlForms, so we return an empty array anyway.
This was not consistent in previous code, some forms were gated on
configuration,
most were not.
* Something should work out of the box. Enable a dummy gateway by default?
Bug: T94477
Change-Id: I02bfbf7d46ef9946aae97ead562fc87cc29b5a4e
---
M DonationInterface.php
M DonationInterfaceFormSettings.php
M activemq_stomp/activemq_stomp.php
M extras/custom_filters/custom_filters.body.php
M gateway_common/DataValidator.php
M gateway_common/DonationData.php
M gateway_common/GatewayPage.php
M gateway_common/gateway.adapter.php
M special/GatewayFormChooser.php
M special/SystemStatus.php
M tests/Adapter/Adyen/AdyenTest.php
M tests/Adapter/Amazon/AmazonTest.php
M tests/Adapter/Astropay/AstropayTest.php
M tests/Adapter/GlobalCollect/BankTransferTest.php
M tests/Adapter/GlobalCollect/DirectDebitTest.php
M tests/Adapter/GlobalCollect/GlobalCollectFormLoadTest.php
M tests/Adapter/GlobalCollect/GlobalCollectOrphanAdapterTest.php
M tests/Adapter/GlobalCollect/GlobalCollectTest.php
M tests/Adapter/GlobalCollect/RealTimeBankTransferEnetsTest.php
M tests/Adapter/GlobalCollect/RealTimeBankTransferEpsTest.php
M tests/Adapter/GlobalCollect/RealTimeBankTransferIdealTest.php
M tests/Adapter/GlobalCollect/RealTimeBankTransferNordeaSwedenTest.php
M tests/Adapter/GlobalCollect/RealTimeBankTransferSofortuberweisungTest.php
M tests/Adapter/GlobalCollect/RecurringTest.php
M tests/Adapter/GlobalCollect/YandexTest.php
M tests/Adapter/PayPal/PayPalResultSwitcherTest.php
M tests/Adapter/PayPal/PayPalTest.php
M tests/Adapter/WorldPay/WorldPayTest.php
M tests/FormChooserTest.php
M tests/GatewayValidationTest.php
M tests/IntegrationTest.php
M tests/includes/test_gateway/TestingGenericAdapter.php
32 files changed, 385 insertions(+), 266 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface
refs/changes/03/213003/1
diff --git a/DonationInterface.php b/DonationInterface.php
index 1a89816..19f306b 100644
--- a/DonationInterface.php
+++ b/DonationInterface.php
@@ -716,185 +716,83 @@
*/
$wgDonationInterfaceUtmSourceMap = array();
-// Perform initialization that depends on user configuration.
-$wgExtensionFunctions[] = function() {
- global $wgDonationInterfaceEnabledGateways,
- $wgDonationInterfaceEnableCustomFilters,
- $wgSpecialPages,
- $wgHooks,
- $wgDonationInterfaceFormDirs,
- $wgDonationInterfaceHtmlFormDir,
- $wgAdyenGatewayHtmlFormDir,
- $wgAmazonGatewayHtmlFormDir,
- $wgGlobalCollectGatewayHtmlFormDir,
- $wgPaypalGatewayHtmlFormDir,
- $wgWorldPayGatewayHtmlFormDir;
+$wgDonationInterfaceEnableStomp = false;
+$wgDonationInterfaceEnableQueue = false;
+$wgDonationInterfaceEnableConversionLog = false; //this is definitely an Extra
+$wgDonationInterfaceEnableMinfraud = false; //this is definitely an Extra
- /**
- * Figure out what we've got enabled.
- */
- $optionalParts = array( //define as fail closed.
- 'CustomFilters' => false, //Gets set if at least one filter is
enabled.
- 'Stomp' => false,
- 'Queue' => false,
- 'ConversionLog' => false, //this is definitely an Extra
- 'Minfraud' => true, //this is definitely an Extra
- 'GlobalCollect' => true,
- 'Amazon' => true,
- 'Adyen' => true,
- 'Astropay' => true,
- 'Paypal' => true,
- 'WorldPay' => true,
- 'FormChooser' => true,
- 'ReferrerFilter' => true, //extra
- 'SourceFilter' => true, //extra
- 'FunctionsFilter' => true, //extra
- 'IPVelocityFilter' => false, //extra
- 'SessionVelocityFilter' => false, //extra
- 'SystemStatus' => false, //extra
- );
+$wgGlobalCollectGatewayEnabled = false;
+$wgAmazonGatewayEnabled = false;
+$wgAdyenGatewayEnabled = false;
+$wgAstropayGatewayEnabled = false;
+$wgPaypalGatewayEnabled = false;
+$wgWorldPayGatewayEnabled = false;
- // FIXME: Crude plugin type mechanism.
- $customFilters = array(
- 'ReferrerFilter',
- 'SourceFilter',
- 'Minfraud',
- 'IPVelocityFilter',
- 'SessionVelocityFilter',
- );
+$wgDonationInterfaceEnableFormChooser = false;
+$wgDonationInterfaceEnableReferrerFilter = false; //extra
+$wgDonationInterfaceEnableSourceFilter = false; //extra
+$wgDonationInterfaceEnableFunctionsFilter = false; //extra
+$wgDonationInterfaceEnableIPVelocityFilter = false; //extra
+$wgDonationInterfaceEnableSessionVelocityFilter = false; //extra
+$wgDonationInterfaceEnableSystemStatus = false; //extra
- foreach ($optionalParts as $subextension => $enabled){
- $globalname = 'wgDonationInterfaceEnable' . $subextension;
- global $$globalname;
- if ( isset( $$globalname ) ) {
- $optionalParts[$subextension] = $$globalname;
- }
+$wgSpecialPages['GatewayFormChooser'] = 'GatewayFormChooser';
+$wgSpecialPages['SystemStatus'] = 'SystemStatus';
- if ( $optionalParts[$subextension] === true ) {
- //this is still annoying.
- if ( in_array( $subextension, $customFilters ) ) {
- $optionalParts['CustomFilters'] = true;
- $wgDonationInterfaceEnableCustomFilters = true;
//override this for specific gateways to disable
- }
- }
- }
+$wgSpecialPages['GlobalCollectGateway'] = 'GlobalCollectGateway';
+$wgSpecialPages['GlobalCollectGatewayResult'] = 'GlobalCollectGatewayResult';
+$wgDonationInterfaceGatewayAdapters[] = 'GlobalCollectAdapter';
- /**
- * SPECIAL PAGES
- */
- if ( $optionalParts['FormChooser'] === true ){
- $wgSpecialPages['GatewayFormChooser'] = 'GatewayFormChooser';
- }
- if ( $optionalParts['SystemStatus'] === true ){
- $wgSpecialPages['SystemStatus'] = 'SystemStatus';
- }
+$wgSpecialPages['AmazonGateway'] = 'AmazonGateway';
+$wgDonationInterfaceGatewayAdapters[] = 'AmazonAdapter';
- //GlobalCollect gateway special pages
- if ( $optionalParts['GlobalCollect'] === true ){
- $wgSpecialPages['GlobalCollectGateway'] =
'GlobalCollectGateway';
- $wgSpecialPages['GlobalCollectGatewayResult'] =
'GlobalCollectGatewayResult';
- $wgDonationInterfaceEnabledGateways[] = 'globalcollect';
- }
- //Amazon Simple Payment gateway special pages
- if ( $optionalParts['Amazon'] === true ){
- $wgSpecialPages['AmazonGateway'] = 'AmazonGateway';
- $wgDonationInterfaceEnabledGateways[] = 'amazon';
- }
- //Adyen gateway special pages
- if ( $optionalParts['Adyen'] === true ){
- $wgSpecialPages['AdyenGateway'] = 'AdyenGateway';
- $wgSpecialPages['AdyenGatewayResult'] = 'AdyenGatewayResult';
- $wgDonationInterfaceEnabledGateways[] = 'adyen';
- }
- //Astropay gateway special pages
- if ( $optionalParts['Astropay'] === true ){
- $wgSpecialPages['AstropayGateway'] = 'AstropayGateway';
- $wgSpecialPages['AstropayGatewayResult'] =
'AstropayGatewayResult';
- $wgDonationInterfaceEnabledGateways[] = 'astropay';
- }
- //PayPal
- if ( $optionalParts['Paypal'] === true ){
- $wgSpecialPages['PaypalGateway'] = 'PaypalGateway';
- $wgSpecialPages['PaypalGatewayResult'] = 'PaypalGatewayResult';
- $wgDonationInterfaceEnabledGateways[] = 'paypal';
- }
- //WorldPay
- if ( $optionalParts['WorldPay'] === true ){
- $wgSpecialPages['WorldPayGateway'] = 'WorldPayGateway';
- $wgDonationInterfaceEnabledGateways[] = 'worldpay';
- }
+$wgSpecialPages['AdyenGateway'] = 'AdyenGateway';
+$wgSpecialPages['AdyenGatewayResult'] = 'AdyenGatewayResult';
+$wgDonationInterfaceGatewayAdapters[] = 'AdyenAdapter';
- //Stomp hooks
- if ( $optionalParts['Stomp'] === true ) {
- $wgHooks['ParserFirstCallInit'][] = 'efStompSetup';
- $wgHooks['gwStomp'][] = 'sendSTOMP';
- $wgHooks['gwPendingStomp'][] = 'sendPendingSTOMP';
- $wgHooks['gwFreeformStomp'][] = 'sendFreeformSTOMP';
- }
+$wgSpecialPages['AstropayGateway'] = 'AstropayGateway';
+$wgSpecialPages['AstropayGatewayResult'] = 'AstropayGatewayResult';
+$wgDonationInterfaceGatewayAdapters[] = 'AstropayAdapter';
- //Custom Filters hooks
- if ( $optionalParts['CustomFilters'] === true ) {
- $wgHooks["GatewayValidate"][] = array(
'Gateway_Extras_CustomFilters::onValidate' );
- }
+$wgSpecialPages['PaypalGateway'] = 'PaypalGateway';
+$wgSpecialPages['PaypalGatewayResult'] = 'PaypalGatewayResult';
+$wgDonationInterfaceGatewayAdapters[] = 'PaypalAdapter';
- //Referrer Filter hooks
- if ( $optionalParts['ReferrerFilter'] === true ){
- $wgHooks["GatewayCustomFilter"][] = array(
'Gateway_Extras_CustomFilters_Referrer::onFilter' );
- }
+$wgSpecialPages['WorldPayGateway'] = 'WorldPayGateway';
+$wgDonationInterfaceGatewayAdapters[] = 'WorldPayAdapter';
- //Source Filter hooks
- if ( $optionalParts['SourceFilter'] === true ){
- $wgHooks["GatewayCustomFilter"][] = array(
'Gateway_Extras_CustomFilters_Source::onFilter' );
- }
+//Stomp hooks
+// FIXME: There's no point in using hooks any more, since we're switching
+// behavior inside the callbacks and not via conditional hooking.
+$wgHooks['ParserFirstCallInit'][] = 'efStompSetup';
+$wgHooks['gwStomp'][] = 'sendSTOMP';
+$wgHooks['gwPendingStomp'][] = 'sendPendingSTOMP';
+$wgHooks['gwFreeformStomp'][] = 'sendFreeformSTOMP';
- //Functions Filter hooks
- if ( $optionalParts['FunctionsFilter'] === true ){
- $wgHooks["GatewayCustomFilter"][] = array(
'Gateway_Extras_CustomFilters_Functions::onFilter' );
- }
+//Custom Filters hooks
+$wgHooks["GatewayValidate"][] = array(
'Gateway_Extras_CustomFilters::onValidate' );
- //Minfraud as Filter globals
- if ( $optionalParts['Minfraud'] === true ){
- $wgHooks["GatewayCustomFilter"][] = array(
'Gateway_Extras_CustomFilters_MinFraud::onFilter' );
- }
+//Referrer Filter hooks
+$wgHooks["GatewayCustomFilter"][] = array(
'Gateway_Extras_CustomFilters_Referrer::onFilter' );
- //Conversion Log hooks
- if ($optionalParts['ConversionLog'] === true){
- // Sets the 'conversion log' as logger for post-processing
- $wgHooks["GatewayPostProcess"][] = array(
"Gateway_Extras_ConversionLog::onPostProcess" );
- }
+//Source Filter hooks
+$wgHooks["GatewayCustomFilter"][] = array(
'Gateway_Extras_CustomFilters_Source::onFilter' );
- //Functions Filter hooks
- if ( $optionalParts['IPVelocityFilter'] === true ){
- $wgHooks["GatewayCustomFilter"][] = array(
'Gateway_Extras_CustomFilters_IP_Velocity::onFilter' );
- $wgHooks["GatewayPostProcess"][] = array(
'Gateway_Extras_CustomFilters_IP_Velocity::onPostProcess' );
- }
+//Functions Filter hooks
+$wgHooks["GatewayCustomFilter"][] = array(
'Gateway_Extras_CustomFilters_Functions::onFilter' );
- if ( $optionalParts['SessionVelocityFilter'] === true ) {
- $wgHooks['DonationInterfaceCurlInit'][] = array(
'Gateway_Extras_SessionVelocityFilter::onCurlInit' );
- }
+//Minfraud as Filter globals
+$wgHooks["GatewayCustomFilter"][] = array(
'Gateway_Extras_CustomFilters_MinFraud::onFilter' );
- // Set up form template directories.
- $form_dirs = array(
- 'default' => $wgDonationInterfaceHtmlFormDir,
- 'gc' => $wgGlobalCollectGatewayHtmlFormDir,
- 'paypal' => $wgPaypalGatewayHtmlFormDir,
- 'amazon' => $wgAmazonGatewayHtmlFormDir,
- );
+//Conversion Log hooks
+// Sets the 'conversion log' as logger for post-processing
+$wgHooks["GatewayPostProcess"][] = array(
"Gateway_Extras_ConversionLog::onPostProcess" );
- if ( $wgDonationInterfaceEnableAdyen === true ) {
- $form_dirs['adyen'] = $wgAdyenGatewayHtmlFormDir;
- }
- if ( $wgDonationInterfaceEnableWorldPay === true ) {
- $form_dirs['worldpay'] = $wgWorldPayGatewayHtmlFormDir;
- }
- $wgDonationInterfaceFormDirs = array_merge(
- $form_dirs,
- $wgDonationInterfaceFormDirs
- );
+//Functions Filter hooks
+$wgHooks["GatewayCustomFilter"][] = array(
'Gateway_Extras_CustomFilters_IP_Velocity::onFilter' );
+$wgHooks["GatewayPostProcess"][] = array(
'Gateway_Extras_CustomFilters_IP_Velocity::onPostProcess' );
- // Load the default form settings
- require_once __DIR__ . '/DonationInterfaceFormSettings.php';
-};
+$wgHooks['DonationInterfaceCurlInit'][] = array(
'Gateway_Extras_SessionVelocityFilter::onCurlInit' );
//Unit tests
$wgHooks['UnitTestsList'][] = 'efDonationInterfaceUnitTests';
@@ -1070,7 +968,17 @@
/**
* Base directories for each gateway's form templates.
*/
-$wgDonationInterfaceFormDirs = array();
+$wgDonationInterfaceFormDirs = array(
+ 'adyen' => $wgAdyenGatewayHtmlFormDir,
+ 'amazon' => $wgAmazonGatewayHtmlFormDir,
+ 'default' => $wgDonationInterfaceHtmlFormDir,
+ 'gc' => $wgGlobalCollectGatewayHtmlFormDir,
+ 'paypal' => $wgPaypalGatewayHtmlFormDir,
+ 'worldpay' => $wgWorldPayGatewayHtmlFormDir,
+);
+
+// Load the default form settings.
+require_once __DIR__ . '/DonationInterfaceFormSettings.php';
/**
* FUNCTIONS
diff --git a/DonationInterfaceFormSettings.php
b/DonationInterfaceFormSettings.php
index 43ea871..bd26c8e 100644
--- a/DonationInterfaceFormSettings.php
+++ b/DonationInterfaceFormSettings.php
@@ -1,17 +1,5 @@
<?php
-// Explicitly declare globals so we can load this file from within a function.
-global $wgDonationInterfaceHtmlFormDir,
- $wgAdyenGatewayHtmlFormDir,
- $wgAmazonGatewayHtmlFormDir,
- $wgGlobalCollectGatewayHtmlFormDir,
- $wgPaypalGatewayHtmlFormDir,
- $wgWorldPayGatewayHtmlFormDir,
- $wgDonationInterfaceAllowedHtmlForms,
- $wgDonationInterfaceEnableAdyen,
- $wgDonationInterfaceEnableWorldPay,
- $wgDonationInterfaceFormDirs;
-
/**
* Some setup vars to make our lives a little easier.
* These are unset at the end of the file.
@@ -451,67 +439,63 @@
* Adyen *
**********/
// This is at the bottom so that we prefer GC over adyen
-if ( $wgDonationInterfaceEnableAdyen === true ) {
- $forms_whitelist['adyen'] = array(
- 'file' => $form_dirs['adyen'] . '/adyen.html',
- 'gateway' => 'adyen',
- 'countries' => array( '+' => 'US',),
- 'currencies' => array( '+' => 'USD',),
- 'payment_methods' => array('cc' => array( 'visa', 'mc', 'amex',
'discover' )),
- 'selection_weight' => 0
- );
- $forms_whitelist['adyen-cs'] = array(
- 'file' => $form_dirs['adyen'] . '/adyen-cs.html',
- 'gateway' => 'adyen',
- 'countries' => array( '+' => 'US',),
- 'currencies' => array( '+' => 'USD',),
- 'payment_methods' => array('cc' => array( 'visa', 'mc', 'amex',
'discover' )),
- 'selection_weight' => 0
- );
-}
+$forms_whitelist['adyen'] = array(
+ 'file' => $form_dirs['adyen'] . '/adyen.html',
+ 'gateway' => 'adyen',
+ 'countries' => array( '+' => 'US',),
+ 'currencies' => array( '+' => 'USD',),
+ 'payment_methods' => array('cc' => array( 'visa', 'mc', 'amex',
'discover' )),
+ 'selection_weight' => 0
+);
+$forms_whitelist['adyen-cs'] = array(
+ 'file' => $form_dirs['adyen'] . '/adyen-cs.html',
+ 'gateway' => 'adyen',
+ 'countries' => array( '+' => 'US',),
+ 'currencies' => array( '+' => 'USD',),
+ 'payment_methods' => array('cc' => array( 'visa', 'mc', 'amex',
'discover' )),
+ 'selection_weight' => 0
+);
/**********
* WorldPay *
**********/
// This is at the bottom so that we prefer GC over WorldPay
-if ( $wgDonationInterfaceEnableWorldPay === true ) {
- $forms_whitelist['worldpay'] = array(
- 'file' => $form_dirs['worldpay'] . '/worldpay.html',
- 'gateway' => 'worldpay',
- 'countries' => array( '+' => array( 'AU', 'BE', 'CA', 'FR',
'GB', 'IL', 'NZ', 'US' ) ),
- 'currencies' => array( '+' => 'ALL' ),
- 'payment_methods' => array( 'cc' => 'ALL' ),
- 'selection_weight' => 10
- );
+$forms_whitelist['worldpay'] = array(
+ 'file' => $form_dirs['worldpay'] . '/worldpay.html',
+ 'gateway' => 'worldpay',
+ 'countries' => array( '+' => array( 'AU', 'BE', 'CA', 'FR', 'GB', 'IL',
'NZ', 'US' ) ),
+ 'currencies' => array( '+' => 'ALL' ),
+ 'payment_methods' => array( 'cc' => 'ALL' ),
+ 'selection_weight' => 10
+);
- /*************************
- * WorldPay Form Tests *
- *************************/
+/*************************
+ * WorldPay Form Tests *
+ *************************/
- $worldpay_test_spec = array(
- 'file' => $form_dirs['worldpay'] . '/worldpay-test.html',
- 'selection_weight' => 0,
- ) + $forms_whitelist['worldpay'];
+$worldpay_test_spec = array(
+ 'file' => $form_dirs['worldpay'] . '/worldpay-test.html',
+ 'selection_weight' => 0,
+) + $forms_whitelist['worldpay'];
- //until we are ready for US testing with the other test forms, we have
to limit to the old list.
- $worldpay_test_spec['countries'] = array( '+' => array( 'BE', 'FR',
'US' ) );
+//until we are ready for US testing with the other test forms, we have to
limit to the old list.
+$worldpay_test_spec['countries'] = array( '+' => array( 'BE', 'FR', 'US' ) );
- $forms_whitelist['wp-sn'] = $worldpay_test_spec;
- $forms_whitelist['wp-sw'] = $worldpay_test_spec;
- $forms_whitelist['wp-fud'] = $worldpay_test_spec;
- $forms_whitelist['wp-btnb'] = $worldpay_test_spec;
- $forms_whitelist['wp-btng'] = $worldpay_test_spec;
+$forms_whitelist['wp-sn'] = $worldpay_test_spec;
+$forms_whitelist['wp-sw'] = $worldpay_test_spec;
+$forms_whitelist['wp-fud'] = $worldpay_test_spec;
+$forms_whitelist['wp-btnb'] = $worldpay_test_spec;
+$forms_whitelist['wp-btng'] = $worldpay_test_spec;
- $forms_whitelist['wp-ddcc'] = array(
- 'file' => $form_dirs['worldpay'] . '/worldpay-dd-test.html',
- 'gateway' => 'worldpay',
- 'countries' => array( '+' => array( 'BE', 'FR', 'US' ) ),
- 'currencies' => array( '+' => 'ALL' ),
- 'payment_methods' => array( 'cc' => 'ALL' ),
- 'selection_weight' => 0
- );
-}
+$forms_whitelist['wp-ddcc'] = array(
+ 'file' => $form_dirs['worldpay'] . '/worldpay-dd-test.html',
+ 'gateway' => 'worldpay',
+ 'countries' => array( '+' => array( 'BE', 'FR', 'US' ) ),
+ 'currencies' => array( '+' => 'ALL' ),
+ 'payment_methods' => array( 'cc' => 'ALL' ),
+ 'selection_weight' => 0
+);
/* * ***********
* Error Pages *
@@ -536,11 +520,7 @@
'special_type' => 'error',
);
-// Merge with values set in LocalSettings.php taking precedence.
-$wgDonationInterfaceAllowedHtmlForms = array_merge(
- $forms_whitelist,
- $wgDonationInterfaceAllowedHtmlForms
-);
+$wgDonationInterfaceAllowedHtmlForms = $forms_whitelist;
unset( $forms_whitelist );
unset( $form_dirs );
diff --git a/activemq_stomp/activemq_stomp.php
b/activemq_stomp/activemq_stomp.php
index 311b855..4bfd4ad 100644
--- a/activemq_stomp/activemq_stomp.php
+++ b/activemq_stomp/activemq_stomp.php
@@ -5,6 +5,12 @@
*/
function efStompSetup( &$parser ) {
+ global $wgDonationInterfaceEnableStomp;
+
+ if ( $wgDonationInterfaceEnableStomp !== true ) {
+ return true;
+ }
+
// redundant and causes Fatal Error
// $parser->disableCache();
@@ -38,7 +44,12 @@
* @throws RuntimeException
*/
function sendSTOMP( $transaction, $queue = 'default' ) {
- global $IP, $wgStompServer, $wgStompQueueNames;
+ global $IP, $wgStompServer, $wgStompQueueNames,
+ $wgDonationInterfaceEnableStomp;
+
+ if ( $wgDonationInterfaceEnableStomp !== true ) {
+ return true;
+ }
// Find the queue name
if ( array_key_exists( $transaction['payment_method'] . "-$queue",
$wgStompQueueNames ) ) {
@@ -122,6 +133,12 @@
* nothing exploded big enough to kill the whole thing.
*/
function sendPendingSTOMP( $transaction ) {
+ global $wgDonationInterfaceEnableStomp;
+
+ if ( $wgDonationInterfaceEnableStomp !== true ) {
+ return true;
+ }
+
return sendSTOMP( $transaction, 'pending' );
}
@@ -146,6 +163,12 @@
* nothing exploded big enough to kill the whole thing.
*/
function sendFreeformSTOMP( $transaction, $queue ) {
+ global $wgDonationInterfaceEnableStomp;
+
+ if ( $wgDonationInterfaceEnableStomp !== true ) {
+ return true;
+ }
+
$transaction['freeform'] = true;
return sendSTOMP( $transaction, $queue );
}
diff --git a/extras/custom_filters/custom_filters.body.php
b/extras/custom_filters/custom_filters.body.php
index e6089af..5d1b0d1 100644
--- a/extras/custom_filters/custom_filters.body.php
+++ b/extras/custom_filters/custom_filters.body.php
@@ -154,9 +154,6 @@
}
static function onValidate( &$gateway_adapter ) {
- if ( !$gateway_adapter->getGlobal( 'EnableCustomFilters' ) ){
- return true;
- }
$gateway_adapter->debugarray[] = 'custom filters onValidate
hook!';
return self::singleton( $gateway_adapter )->validate();
}
diff --git a/gateway_common/DataValidator.php b/gateway_common/DataValidator.php
index 3ae71d9..eac51c7 100644
--- a/gateway_common/DataValidator.php
+++ b/gateway_common/DataValidator.php
@@ -238,8 +238,8 @@
'country' => 'validate_country_allowed',
'email' => 'validate_email',
'street' => 'validate_address',
- 'currency_code' => 'validate_currency_code',
'gateway' => 'validate_gateway',
+ 'currency_code' => 'validate_currency_code',
'fname' => 'validate_name',
'lname' => 'validate_name',
'name' => 'validate_name',
@@ -469,8 +469,7 @@
}
return false;
}
-
-
+
/**
* validate_gateway
* Checks to make sure the gateway is populated with a valid and
enabled
@@ -479,9 +478,14 @@
* @return boolean True if $value is a valid gateway, otherwise false
*/
protected static function validate_gateway( $value ){
- global $wgDonationInterfaceEnabledGateways;
+ global $wgDonationInterfaceGatewayAdapters;
- return in_array( $value, $wgDonationInterfaceEnabledGateways,
true );
+ foreach ( $wgDonationInterfaceGatewayAdapters as $adapterClass
) {
+ if ( $adapterClass::getIdentifier() === $value ) {
+ return true;
+ }
+ }
+ return false;
}
/**
diff --git a/gateway_common/DonationData.php b/gateway_common/DonationData.php
index dbad4ea..669f08c 100644
--- a/gateway_common/DonationData.php
+++ b/gateway_common/DonationData.php
@@ -16,6 +16,7 @@
class DonationData implements LogPrefixProvider {
protected $normalized = array( );
protected $gateway;
+ protected $gatewayID;
protected $validationErrors = null;
/**
* @var \Psr\Log\LoggerInterface
diff --git a/gateway_common/GatewayPage.php b/gateway_common/GatewayPage.php
index 0de24e5..0c7e7d0 100644
--- a/gateway_common/GatewayPage.php
+++ b/gateway_common/GatewayPage.php
@@ -62,6 +62,7 @@
public function execute( $par ) {
global $wgContributionTrackingFundraiserMaintenance,
$wgContributionTrackingFundraiserMaintenanceUnsched;
+ // FIXME: Deprecate "language" param.
$language = $this->getRequest()->getVal( 'language' );
if ( $language ) {
RequestContext::getMain()->setLanguage( $language );
@@ -69,6 +70,10 @@
$wgLang = RequestContext::getMain()->getLanguage();
}
+ if ( $this->adapter->getGlobal( 'Enabled' ) !== true ) {
+ throw new BadTitleError();
+ }
+
if( $wgContributionTrackingFundraiserMaintenance
|| $wgContributionTrackingFundraiserMaintenanceUnsched
){
$this->getOutput()->redirect(
Title::newFromText('Special:FundraiserMaintenance')->getFullURL(), '302' );
diff --git a/gateway_common/gateway.adapter.php
b/gateway_common/gateway.adapter.php
index c6c575f..0b38941 100644
--- a/gateway_common/gateway.adapter.php
+++ b/gateway_common/gateway.adapter.php
@@ -3145,7 +3145,7 @@
* $wgDonationInterfaceAllowedHtmlForms
*/
public function session_pushRapidHTMLForm( $form_key ) {
- if ( strlen( $form_key ) === 0 ) {
+ if ( !$form_key ) {
return;
}
diff --git a/special/GatewayFormChooser.php b/special/GatewayFormChooser.php
index 1915610..6a3aadd 100644
--- a/special/GatewayFormChooser.php
+++ b/special/GatewayFormChooser.php
@@ -22,7 +22,14 @@
}
function execute( $par ) {
- global $wgContributionTrackingFundraiserMaintenance,
$wgContributionTrackingFundraiserMaintenanceUnsched;
+ global $wgContributionTrackingFundraiserMaintenance,
+ $wgContributionTrackingFundraiserMaintenanceUnsched,
+ $wgDonationInterfaceEnableFormChooser;
+
+ if ( !$wgDonationInterfaceEnableFormChooser ) {
+ throw new BadTitleError();
+ }
+
if( $wgContributionTrackingFundraiserMaintenance
|| $wgContributionTrackingFundraiserMaintenanceUnsched
){
@@ -38,7 +45,7 @@
$recurring = $this->getRequest()->getVal( 'recurring', false );
$gateway = $coerceNull( $this->getRequest()->getVal( 'gateway',
null ) );
- //This is clearly going to go away before we deploy this
bizniss.
+ // FIXME: This is clearly going to go away before we deploy
this bizniss.
$testNewGetAll = $this->getRequest()->getVal( 'testGetAll',
false );
if ( $testNewGetAll ){
$forms = self::getAllValidForms( $country, $currency,
$paymentMethod, $paymentSubMethod, $recurring, $gateway );
@@ -175,17 +182,6 @@
}
}
- // First get all the valid and enabled gateways capable of
processing shtuff
- $valid_gateways = self::getAllEnabledGateways();
- if ( $gateway !== null ) {
- if ( in_array( $gateway, $valid_gateways ) ) {
- $valid_gateways = array( $gateway );
- } else {
- // Aaah; the requested gateway is not valid :'(
Nothing to do but return nothing
- return array();
- }
- }
-
// then remove the forms that we don't want.
foreach ( $forms as $name => &$meta ) {
// Prefilter for sillyness
@@ -205,12 +201,6 @@
if ( !array_key_exists( $paramName, $meta ) ) {
$meta[$paramName] = 'ALL';
}
- }
-
- // filter on enabled gateways
- if ( !DataValidator::value_appears_in(
$meta['gateway'], $valid_gateways ) ) {
- unset( $forms[$name] );
- continue;
}
//filter on country
diff --git a/special/SystemStatus.php b/special/SystemStatus.php
index 7bf3efc..d03e112 100644
--- a/special/SystemStatus.php
+++ b/special/SystemStatus.php
@@ -12,6 +12,12 @@
}
function execute( $par ) {
+ global $wgDonationInterfaceEnableSystemStatus;
+
+ if ( !$wgDonationInterfaceEnableSystemStatus ) {
+ throw new BadTitleError();
+ }
+
// Right now we just need something that doesn't end up creating
// contribution_ids for testing.
echo "<pre>OK</pre>";
diff --git a/tests/Adapter/Adyen/AdyenTest.php
b/tests/Adapter/Adyen/AdyenTest.php
index 1b11362..fd0b1b3 100644
--- a/tests/Adapter/Adyen/AdyenTest.php
+++ b/tests/Adapter/Adyen/AdyenTest.php
@@ -33,6 +33,14 @@
$this->testAdapterClass = 'TestingAdyenAdapter';
}
+ public function setUp() {
+ parent::setUp();
+
+ $this->setMwGlobals( array(
+ 'wgAdyenGatewayEnabled' => true,
+ ) );
+ }
+
/**
* Integration test to verify that the donate transaction works as
expected when all necessary data is present.
*/
diff --git a/tests/Adapter/Amazon/AmazonTest.php
b/tests/Adapter/Amazon/AmazonTest.php
index 92c38f3..ad31f78 100644
--- a/tests/Adapter/Amazon/AmazonTest.php
+++ b/tests/Adapter/Amazon/AmazonTest.php
@@ -33,6 +33,14 @@
$this->testAdapterClass = 'TestingAmazonAdapter';
}
+ public function setUp() {
+ parent::setUp();
+
+ $this->setMwGlobals( array(
+ 'wgAmazonGatewayEnabled' => true,
+ ) );
+ }
+
public function tearDown() {
TestingAmazonAdapter::$fakeGlobals = array();
parent::tearDown();
diff --git a/tests/Adapter/Astropay/AstropayTest.php
b/tests/Adapter/Astropay/AstropayTest.php
index bbdd9b0..59babb8 100644
--- a/tests/Adapter/Astropay/AstropayTest.php
+++ b/tests/Adapter/Astropay/AstropayTest.php
@@ -33,6 +33,10 @@
function __construct( $name = null, array $data = array(), $dataName =
'' ) {
parent::__construct( $name, $data, $dataName );
$this->testAdapterClass = 'TestingAstropayAdapter';
+
+ $this->setMwGlobals( array(
+ 'wgAstropayGatewayEnabled' => true,
+ ) );
}
function tearDown() {
diff --git a/tests/Adapter/GlobalCollect/BankTransferTest.php
b/tests/Adapter/GlobalCollect/BankTransferTest.php
index 01548d6..c2ee03d 100644
--- a/tests/Adapter/GlobalCollect/BankTransferTest.php
+++ b/tests/Adapter/GlobalCollect/BankTransferTest.php
@@ -26,6 +26,13 @@
* @group BankTransfer
*/
class DonationInterface_Adapter_GlobalCollect_BankTransferTest extends
DonationInterfaceTestCase {
+ public function setUp() {
+ parent::setUp();
+
+ $this->setMwGlobals( array(
+ 'wgGlobalCollectGatewayEnabled' => true,
+ ) );
+ }
/**
* testBuildRequestXml
diff --git a/tests/Adapter/GlobalCollect/DirectDebitTest.php
b/tests/Adapter/GlobalCollect/DirectDebitTest.php
index f16cafc..54fd76b 100644
--- a/tests/Adapter/GlobalCollect/DirectDebitTest.php
+++ b/tests/Adapter/GlobalCollect/DirectDebitTest.php
@@ -24,6 +24,13 @@
* @group RealTimeBankTransfer
*/
class DonationInterface_Adapter_GlobalCollect_DirectDebitTest extends
DonationInterfaceTestCase {
+ public function setUp() {
+ parent::setUp();
+
+ $this->setMwGlobals( array(
+ 'wgGlobalCollectGatewayEnabled' => true,
+ ) );
+ }
/**
* testBuildRequestXml
diff --git a/tests/Adapter/GlobalCollect/GlobalCollectFormLoadTest.php
b/tests/Adapter/GlobalCollect/GlobalCollectFormLoadTest.php
index b39c9e0..15bab27 100644
--- a/tests/Adapter/GlobalCollect/GlobalCollectFormLoadTest.php
+++ b/tests/Adapter/GlobalCollect/GlobalCollectFormLoadTest.php
@@ -23,6 +23,13 @@
* @group GlobalCollect
*/
class GlobalCollectFormLoadTest extends DonationInterfaceTestCase {
+ public function setUp() {
+ parent::setUp();
+
+ $this->setMwGlobals( array(
+ 'wgGlobalCollectGatewayEnabled' => true,
+ ) );
+ }
public function testGCFormLoad() {
$init = $this->getDonorTestData( 'US' );
diff --git a/tests/Adapter/GlobalCollect/GlobalCollectOrphanAdapterTest.php
b/tests/Adapter/GlobalCollect/GlobalCollectOrphanAdapterTest.php
index 92c2e83..e5aee9f 100644
--- a/tests/Adapter/GlobalCollect/GlobalCollectOrphanAdapterTest.php
+++ b/tests/Adapter/GlobalCollect/GlobalCollectOrphanAdapterTest.php
@@ -26,6 +26,13 @@
* @group OrphanSlayer
*/
class DonationInterface_Adapter_GlobalCollect_Orphans_GlobalCollectTest
extends DonationInterfaceTestCase {
+ public function setUp() {
+ parent::setUp();
+
+ $this->setMwGlobals( array(
+ 'wgGlobalCollectGatewayEnabled' => true,
+ ) );
+ }
/**
* @param $name string The name of the test case
diff --git a/tests/Adapter/GlobalCollect/GlobalCollectTest.php
b/tests/Adapter/GlobalCollect/GlobalCollectTest.php
index 127fb0a..0915677 100644
--- a/tests/Adapter/GlobalCollect/GlobalCollectTest.php
+++ b/tests/Adapter/GlobalCollect/GlobalCollectTest.php
@@ -24,6 +24,13 @@
* @group GlobalCollect
*/
class DonationInterface_Adapter_GlobalCollect_GlobalCollectTest extends
DonationInterfaceTestCase {
+ public function setUp() {
+ parent::setUp();
+
+ $this->setMwGlobals( array(
+ 'wgGlobalCollectGatewayEnabled' => true,
+ ) );
+ }
/**
* @param $name string The name of the test case
diff --git a/tests/Adapter/GlobalCollect/RealTimeBankTransferEnetsTest.php
b/tests/Adapter/GlobalCollect/RealTimeBankTransferEnetsTest.php
index 74dd24f..e82fd51 100644
--- a/tests/Adapter/GlobalCollect/RealTimeBankTransferEnetsTest.php
+++ b/tests/Adapter/GlobalCollect/RealTimeBankTransferEnetsTest.php
@@ -24,6 +24,13 @@
* @group RealTimeBankTransfer
*/
class DonationInterface_Adapter_GlobalCollect_RealTimeBankTransferEnetsTest
extends DonationInterfaceTestCase {
+ public function setUp() {
+ parent::setUp();
+
+ $this->setMwGlobals( array(
+ 'wgGlobalCollectGatewayEnabled' => true,
+ ) );
+ }
/**
* testBuildRequestXml
diff --git a/tests/Adapter/GlobalCollect/RealTimeBankTransferEpsTest.php
b/tests/Adapter/GlobalCollect/RealTimeBankTransferEpsTest.php
index a5bae91..51ad355 100644
--- a/tests/Adapter/GlobalCollect/RealTimeBankTransferEpsTest.php
+++ b/tests/Adapter/GlobalCollect/RealTimeBankTransferEpsTest.php
@@ -26,6 +26,13 @@
* @group RealTimeBankTransfer
*/
class DonationInterface_Adapter_GlobalCollect_RealTimeBankTransferEpsTest
extends DonationInterfaceTestCase {
+ public function setUp() {
+ parent::setUp();
+
+ $this->setMwGlobals( array(
+ 'wgGlobalCollectGatewayEnabled' => true,
+ ) );
+ }
/**
* testBuildRequestXmlWithIssuerId820
diff --git a/tests/Adapter/GlobalCollect/RealTimeBankTransferIdealTest.php
b/tests/Adapter/GlobalCollect/RealTimeBankTransferIdealTest.php
index 4cc830e..c55c4a7 100644
--- a/tests/Adapter/GlobalCollect/RealTimeBankTransferIdealTest.php
+++ b/tests/Adapter/GlobalCollect/RealTimeBankTransferIdealTest.php
@@ -24,6 +24,13 @@
* @group RealTimeBankTransfer
*/
class DonationInterface_Adapter_GlobalCollect_RealTimeBankTransferIdealTest
extends DonationInterfaceTestCase {
+ public function setUp() {
+ parent::setUp();
+
+ $this->setMwGlobals( array(
+ 'wgGlobalCollectGatewayEnabled' => true,
+ ) );
+ }
/**
* Test for ideal form loading
diff --git
a/tests/Adapter/GlobalCollect/RealTimeBankTransferNordeaSwedenTest.php
b/tests/Adapter/GlobalCollect/RealTimeBankTransferNordeaSwedenTest.php
index ac5766c..9497d25 100644
--- a/tests/Adapter/GlobalCollect/RealTimeBankTransferNordeaSwedenTest.php
+++ b/tests/Adapter/GlobalCollect/RealTimeBankTransferNordeaSwedenTest.php
@@ -26,6 +26,13 @@
* @group RealTimeBankTransfer
*/
class
DonationInterface_Adapter_GlobalCollect_RealTimeBankTransferNordeaSwedenTest
extends DonationInterfaceTestCase {
+ public function setUp() {
+ parent::setUp();
+
+ $this->setMwGlobals( array(
+ 'wgGlobalCollectGatewayEnabled' => true,
+ ) );
+ }
/**
* testBuildRequestXml
diff --git
a/tests/Adapter/GlobalCollect/RealTimeBankTransferSofortuberweisungTest.php
b/tests/Adapter/GlobalCollect/RealTimeBankTransferSofortuberweisungTest.php
index be7390e..01d4667 100644
--- a/tests/Adapter/GlobalCollect/RealTimeBankTransferSofortuberweisungTest.php
+++ b/tests/Adapter/GlobalCollect/RealTimeBankTransferSofortuberweisungTest.php
@@ -26,6 +26,13 @@
* @group RealTimeBankTransfer
*/
class
DonationInterface_Adapter_GlobalCollect_RealTimeBankTransferSofortuberweisungTest
extends DonationInterfaceTestCase {
+ public function setUp() {
+ parent::setUp();
+
+ $this->setMwGlobals( array(
+ 'wgGlobalCollectGatewayEnabled' => true,
+ ) );
+ }
/**
* testBuildRequestXml
diff --git a/tests/Adapter/GlobalCollect/RecurringTest.php
b/tests/Adapter/GlobalCollect/RecurringTest.php
index 84c4ad9..b756cbf 100644
--- a/tests/Adapter/GlobalCollect/RecurringTest.php
+++ b/tests/Adapter/GlobalCollect/RecurringTest.php
@@ -34,6 +34,14 @@
$this->testAdapterClass = 'TestingGlobalCollectAdapter';
}
+ public function setUp() {
+ parent::setUp();
+
+ $this->setMwGlobals( array(
+ 'wgGlobalCollectGatewayEnabled' => true,
+ ) );
+ }
+
function tearDown() {
TestingGlobalCollectAdapter::clearGlobalsCache();
parent::tearDown();
diff --git a/tests/Adapter/GlobalCollect/YandexTest.php
b/tests/Adapter/GlobalCollect/YandexTest.php
index c6ab991..2998ff4 100644
--- a/tests/Adapter/GlobalCollect/YandexTest.php
+++ b/tests/Adapter/GlobalCollect/YandexTest.php
@@ -24,6 +24,13 @@
* @group Yandex
*/
class DonationInterface_Adapter_GlobalCollect_YandexTest extends
DonationInterfaceTestCase {
+ public function setUp() {
+ parent::setUp();
+
+ $this->setMwGlobals( array(
+ 'wgGlobalCollectGatewayEnabled' => true,
+ ) );
+ }
/**
* testBuildRequestXml
diff --git a/tests/Adapter/PayPal/PayPalResultSwitcherTest.php
b/tests/Adapter/PayPal/PayPalResultSwitcherTest.php
index 4eab6ea..4908c05 100644
--- a/tests/Adapter/PayPal/PayPalResultSwitcherTest.php
+++ b/tests/Adapter/PayPal/PayPalResultSwitcherTest.php
@@ -21,6 +21,13 @@
* @group PayPal
*/
class PayPalResultSwitcherTest extends DonationInterfaceTestCase {
+ public function setUp() {
+ parent::setUp();
+
+ $this->setMwGlobals( array(
+ 'wgPaypalGatewayEnabled' => true,
+ ) );
+ }
function testSuccessfulRedirect() {
$init = $this->getDonorTestData( 'FR' );
diff --git a/tests/Adapter/PayPal/PayPalTest.php
b/tests/Adapter/PayPal/PayPalTest.php
index 9a95484..f847a05 100644
--- a/tests/Adapter/PayPal/PayPalTest.php
+++ b/tests/Adapter/PayPal/PayPalTest.php
@@ -33,6 +33,14 @@
$this->testAdapterClass = 'TestingPaypalAdapter';
}
+ public function setUp() {
+ parent::setUp();
+
+ $this->setMwGlobals( array(
+ 'wgPaypalGatewayEnabled' => true,
+ ) );
+ }
+
public function tearDown() {
TestingPaypalAdapter::$fakeGlobals = array();
diff --git a/tests/Adapter/WorldPay/WorldPayTest.php
b/tests/Adapter/WorldPay/WorldPayTest.php
index 9c4dde8..cb9d2ae 100644
--- a/tests/Adapter/WorldPay/WorldPayTest.php
+++ b/tests/Adapter/WorldPay/WorldPayTest.php
@@ -35,6 +35,14 @@
$this->testAdapterClass = 'TestingWorldPayAdapter';
}
+ public function setUp() {
+ parent::setUp();
+
+ $this->setMwGlobals( array(
+ 'wgWorldPayGatewayEnabled' => true,
+ ) );
+ }
+
/**
* Just making sure we can instantiate the thing without blowing up
completely
*/
diff --git a/tests/FormChooserTest.php b/tests/FormChooserTest.php
index 7076959..3e5c574 100644
--- a/tests/FormChooserTest.php
+++ b/tests/FormChooserTest.php
@@ -33,10 +33,19 @@
$this->testAdapterClass = $adapterclass;
parent::__construct( $name, $data, $dataName );
- self::setupMoreForms();
}
- public static function setupMoreForms() {
+ public function setUp() {
+ parent::setUp();
+
+ $this->setMwGlobals( array(
+ 'wgDonationInterfaceEnableFormChooser' => true,
+ ) );
+
+ $this->setupMoreForms();
+ }
+
+ public function setupMoreForms() {
global $wgDonationInterfaceAllowedHtmlForms,
$wgDonationInterfaceHtmlFormDir,
$wgGlobalCollectGatewayHtmlFormDir, $wgPaypalGatewayHtmlFormDir,
$wgAmazonGatewayHtmlFormDir, $wgWorldPayGatewayHtmlFormDir,
@@ -133,8 +142,13 @@
'payment_methods' => array ( 'cc' => 'ALL' ),
);
- $wgDonationInterfaceAllowedHtmlForms = array_merge(
$wgDonationInterfaceAllowedHtmlForms, $moreForms );
- $wgDonationInterfaceFormDirs = $form_dirs;
+ $this->setMwGlobals( array(
+ 'wgDonationInterfaceAllowedHtmlForms' => array_merge(
+ $wgDonationInterfaceAllowedHtmlForms,
+ $moreForms
+ ),
+ 'wgDonationInterfaceFormDirs' => $form_dirs,
+ ) );
}
function testGetOneValidForm_CC_SpecificCountry() {
@@ -161,7 +175,10 @@
function testMaintenanceMode_Redirect() {
global $wgContributionTrackingFundraiserMaintenance;
- $wgContributionTrackingFundraiserMaintenance = true;
+
+ $this->setMwGlobals( array(
+ 'wgContributionTrackingFundraiserMaintenance' => true,
+ ) );
$expectedLocation =
Title::newFromText('Special:FundraiserMaintenance')->getFullURL();
$assertNodes = array(
diff --git a/tests/GatewayValidationTest.php b/tests/GatewayValidationTest.php
index 7b22ba1..5933576 100644
--- a/tests/GatewayValidationTest.php
+++ b/tests/GatewayValidationTest.php
@@ -30,12 +30,16 @@
parent::setUp();
$this->setMwGlobals( array(
- 'wgDonationInterfaceEnabledGateways' => array(
'donation' ), // base class. awkward.
+ // FIXME: base class sketchiness.
+ 'wgDonationInterfaceGatewayAdapters' => array(
+ 'GatewayAdapter',
+ ),
'wgDonationInterfacePriceFloor' => 2.00,
'wgDonationInterfacePriceCeiling' => 100.00,
) );
TestingGenericAdapter::$acceptedCurrencies[] = 'USD';
+ TestingGenericAdapter::$fakeIdentifier = null;
$this->page = new TestingGatewayPage();
$this->adapter = new TestingGenericAdapter();
@@ -164,4 +168,26 @@
$errors = $this->adapter->getValidationErrors();
$this->assertArrayHasKey( 'currency_code', $errors );
}
+
+ /**
+ * @covers DataValidator::validate_gateway
+ */
+ public function testBadGatewayError() {
+ $badGateway = uniqid();
+
+ // The gateway is calculated from adapter class, so this
validation
+ // doesn't happen in practice and we can't fake a bad gateway
using
+ // GatewayAdapter::addRequestData().
+
+ TestingGenericAdapter::$fakeIdentifier = $badGateway;
+ $this->adapter = new TestingGenericAdapter();
+ $this->page->adapter = $this->adapter;
+
+ $this->page->validateForm();
+
+ $this->assertFalse( $this->adapter->validatedOK() );
+
+ $errors = $this->adapter->getValidationErrors();
+ $this->assertArrayHasKey( 'general', $errors );
+ }
}
diff --git a/tests/IntegrationTest.php b/tests/IntegrationTest.php
index 0473de8..8cf79e8 100644
--- a/tests/IntegrationTest.php
+++ b/tests/IntegrationTest.php
@@ -34,12 +34,37 @@
$this->testAdapterClass = $adapterclass;
parent::__construct( $name, $data, $dataName );
-// self::setupMoreForms();
+ }
+
+ public function setUp() {
+ global $wgGlobalCollectGatewayHtmlFormDir,
$wgPaypalGatewayHtmlFormDir;
+
+ parent::setUp();
+
+ $this->setMwGlobals( array(
+ 'wgGlobalCollectGatewayEnabled' => true,
+ 'wgPaypalGatewayEnabled' => true,
+ 'wgDonationInterfaceAllowedHtmlForms' => array(
+ 'cc-vmad' => array(
+ 'file' =>
$wgGlobalCollectGatewayHtmlFormDir . '/cc/cc-vmad.html',
+ 'gateway' => 'globalcollect',
+ 'payment_methods' => array ( 'cc' =>
array ( 'visa', 'mc', 'amex', 'discover' ) ),
+ 'countries' => array (
+ '+' => array ( 'US', ),
+ ),
+ ),
+ 'paypal' => array(
+ 'file' => $wgPaypalGatewayHtmlFormDir .
'/paypal.html',
+ 'gateway' => 'paypal',
+ 'payment_methods' => array ( 'paypal'
=> 'ALL' ),
+ ),
+ ),
+ ) );
}
//this is meant to simulate a user choosing paypal, then going back and
choosing GC.
public function testBackClickPayPalToGC() {
- $this->testAdapterClass = 'TestingPayPalAdapter';
+ $this->testAdapterClass = 'TestingPaypalAdapter';
$options = $this->getDonorTestData( 'US' );
// unset( $options['ffname'] );
diff --git a/tests/includes/test_gateway/TestingGenericAdapter.php
b/tests/includes/test_gateway/TestingGenericAdapter.php
index df40e4b..10ecb14 100644
--- a/tests/includes/test_gateway/TestingGenericAdapter.php
+++ b/tests/includes/test_gateway/TestingGenericAdapter.php
@@ -29,6 +29,8 @@
public $revalidateCount = 0;
public static $fakeGlobals = array();
+ public static $fakeIdentifier;
+
public static $acceptedCurrencies = array();
public function getCommunicationType() {
@@ -58,6 +60,13 @@
return parent::getGlobal( $name );
}
+ public static function getIdentifier() {
+ if ( self::$fakeIdentifier ) {
+ return self::$fakeIdentifier;
+ }
+ return GatewayAdapter::getIdentifier();
+ }
+
public function defineAccountInfo() {
}
--
To view, visit https://gerrit.wikimedia.org/r/213003
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I02bfbf7d46ef9946aae97ead562fc87cc29b5a4e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Awight <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits