jenkins-bot has submitted this change and it was merged.
Change subject: Add PayPal tests
......................................................................
Add PayPal tests
Change-Id: I350095e5f51b391caa45a75674d5dfb0bd97b720
---
M paypal_gateway/paypal_resultswitcher.body.php
M tests/Adapter/PayPal/AllTests.php
A tests/Adapter/PayPal/PayPalResultSwitcherTestCase.php
M tests/Adapter/PayPal/PayPalTestCase.php
4 files changed, 65 insertions(+), 1 deletion(-)
Approvals:
Mwalker: Looks good to me, approved
jenkins-bot: Verified
diff --git a/paypal_gateway/paypal_resultswitcher.body.php
b/paypal_gateway/paypal_resultswitcher.body.php
index f5e99a6..1d6e745 100644
--- a/paypal_gateway/paypal_resultswitcher.body.php
+++ b/paypal_gateway/paypal_resultswitcher.body.php
@@ -43,7 +43,7 @@
}
if ( $forbidden ){
- wfHttpError( 403, 'Forbidden', wfMsg(
'donate_interface-error-http-403' ) );
+ wfHttpError( 403, 'Forbidden', wfMessage(
'donate_interface-error-http-403' )->text() );
}
$oid = $this->adapter->getData_Unstaged_Escaped( 'order_id' );
diff --git a/tests/Adapter/PayPal/AllTests.php
b/tests/Adapter/PayPal/AllTests.php
index 167f82a..1fb1254 100644
--- a/tests/Adapter/PayPal/AllTests.php
+++ b/tests/Adapter/PayPal/AllTests.php
@@ -19,6 +19,7 @@
* @see DonationInterface_Adapter_GlobalCollect_GlobalCollectTestCase
*/
require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'PayPalTestCase.php';
+require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR .
'PayPalResultSwitcherTestCase.php';
/**
* AllTests
@@ -49,6 +50,7 @@
// general PayPal tests
$suite->addTestSuite(
'DonationInterface_Adapter_PayPal_TestCase' );
+ $suite->addTestSuite( 'PayPalResultSwitcherTestCase' );
return $suite;
}
diff --git a/tests/Adapter/PayPal/PayPalResultSwitcherTestCase.php
b/tests/Adapter/PayPal/PayPalResultSwitcherTestCase.php
new file mode 100644
index 0000000..b7a5dbd
--- /dev/null
+++ b/tests/Adapter/PayPal/PayPalResultSwitcherTestCase.php
@@ -0,0 +1,44 @@
+<?php
+/**
+ * Wikimedia Foundation
+ *
+ * LICENSE
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+/**
+ * @see DonationInterfaceTestCase
+ */
+require_once dirname( dirname( dirname( __FILE__ ) ) ) . DIRECTORY_SEPARATOR .
'DonationInterfaceTestCase.php';
+
+/**
+ * @group Fundraising
+ * @group DonationInterface
+ * @group PayPal
+ */
+class PayPalResultSwitcherTestCase extends DonationInterfaceTestCase {
+
+ function testSuccessfulRedirect() {
+ $init = $this->getDonorTestData( 'FR' );
+ $init['OTT'] = 'SALT123456789';
+ $_SESSION['Donor'] = $init;
+
+ $assertNodes = array(
+ 'headers' => array(
+ 'Location' =>
'https://wikimediafoundation.org/wiki/Thank_You/fr',
+ ),
+ );
+
+ $this->verifyFormOutput( 'PaypalGatewayResult', $init,
$assertNodes, false );
+ }
+
+}
diff --git a/tests/Adapter/PayPal/PayPalTestCase.php
b/tests/Adapter/PayPal/PayPalTestCase.php
index 7218e7e..6bf23b9 100644
--- a/tests/Adapter/PayPal/PayPalTestCase.php
+++ b/tests/Adapter/PayPal/PayPalTestCase.php
@@ -125,4 +125,22 @@
$this->assertEquals( $expected, $res, 'Paypal "DonateXclick"
transaction not constructing the expected redirect URL' );
}
+ /**
+ * Integration test to verify that the Paypal gateway shows an error
message when validation fails.
+ */
+ function testShowFormOnError() {
+ $init = $this->getDonorTestData();
+ $init['OTT'] = 'SALT123456789';
+ $init['amount'] = '-100.00';
+ $_SESSION['Donor'] = $init;
+ $errorMessage =
wfMessage('donate_interface-error-msg-field-correction',
wfMessage('donate_interface-error-msg-amount')->text())->text();
+ $assertNodes = array(
+ 'mw-content-text' => array(
+ 'innerhtmlmatches' => "/.*$errorMessage.*/"
+ )
+ );
+
+ $this->verifyFormOutput( 'PaypalGateway', $init, $assertNodes,
false );
+ }
+
}
--
To view, visit https://gerrit.wikimedia.org/r/146361
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I350095e5f51b391caa45a75674d5dfb0bd97b720
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Ejegg <[email protected]>
Gerrit-Reviewer: Awight <[email protected]>
Gerrit-Reviewer: Katie Horn <[email protected]>
Gerrit-Reviewer: Mwalker <[email protected]>
Gerrit-Reviewer: Ssmith <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits