Ejegg has uploaded a new change for review.
https://gerrit.wikimedia.org/r/151673
Change subject: WIP: Test cases for Belgium
......................................................................
WIP: Test cases for Belgium
Change-Id: Ib5e0a11706307b7e5f0368aa5a082111f483176d
---
M tests/Adapter/PayPal/PayPalTestCase.php
M tests/Adapter/WorldPay/WorldPayTestCase.php
M tests/DonationInterfaceTestCase.php
3 files changed, 120 insertions(+), 4 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface
refs/changes/73/151673/1
diff --git a/tests/Adapter/PayPal/PayPalTestCase.php
b/tests/Adapter/PayPal/PayPalTestCase.php
index c230618..2bed263 100644
--- a/tests/Adapter/PayPal/PayPalTestCase.php
+++ b/tests/Adapter/PayPal/PayPalTestCase.php
@@ -148,4 +148,47 @@
$this->verifyFormOutput( 'PaypalGateway', $init, $assertNodes,
false );
}
+ /**
+ * Integration test to verify that the Donate transaction works as
expected in Belgium for fr, de, and nl.
+ *
+ * @dataProvider belgiumLanguageProvider
+ */
+ function testDoTransactionDonate_BE( $language ) {
+ $init = $this->getDonorTestData( 'BE' );
+ $init['language'] = $language;
+ $this->setLanguage( $language );
+ $gateway = $this->getFreshGatewayObject( $init );
+ $donateText = wfMessage(
'donate_interface-donation-description' )->inLanguage( $language )->text();
+ $ret = $gateway->do_transaction( 'Donate' );
+ parse_str( parse_url( $ret['redirect'], PHP_URL_QUERY ), $res );
+
+ $expected = array (
+ 'amount' => $init['amount'],
+ 'currency_code' => $init['currency_code'],
+ 'country' => 'BE',
+ 'business' => '[email protected]',
+ 'cmd' => '_donations',
+ 'item_name' => $donateText,
+ 'item_number' => 'DONATE',
+ 'no_note' => '0',
+ 'custom' => $gateway->getData_Unstaged_Escaped(
'contribution_tracking_id' ),
+ 'lc' => $init['country'], //this works because it's a
US donor...
+ 'cancel_return' => $gateway->getGlobal( 'ReturnURL' ),
+ 'return' => $gateway->getGlobal( 'ReturnURL' ),
+ );
+
+ $this->assertEquals( $expected, $res, 'Paypal "Donate"
transaction not constructing the expected redirect URL' );
+ $this->assertNull( $gateway->getData_Unstaged_Escaped(
'order_id' ), "Paypal order_id is not null, and we shouldn't be generating one"
);
+ }
+
+ /**
+ * Supported languages for Belgium
+ */
+ public function belgiumLanguageProvider() {
+ return array(
+ array( 'nl' ),
+ array( 'de' ),
+ array( 'fr' ),
+ );
+ }
}
diff --git a/tests/Adapter/WorldPay/WorldPayTestCase.php
b/tests/Adapter/WorldPay/WorldPayTestCase.php
index 389cd3c..109483c 100644
--- a/tests/Adapter/WorldPay/WorldPayTestCase.php
+++ b/tests/Adapter/WorldPay/WorldPayTestCase.php
@@ -197,6 +197,55 @@
}
/**
+ * Make sure Belgian form load in all of that country's supported
languages
+ * @dataProvider belgiumLanguageProvider
+ */
+ public function testWorldPayFormLoad_BE( $language ) {
+ $init = $this->getDonorTestData( 'BE' );
+ unset( $init['order_id'] );
+ $init['payment_method'] = 'cc';
+ $init['payment_submethod'] = 'visa';
+ $init['ffname'] = 'worldpay';
+ $init['language'] = $language;
+
+ $assertNodes = array (
+ 'selected-amount' => array (
+ 'nodename' => 'span',
+ 'innerhtml' => '€1.55',
+ ),
+ 'fname-label' => array (
+ 'nodename' => 'label',
+ 'innerhtml' => wfMessage(
'donate_interface-donor-fname' )->inLanguage( $language )->text(),
+ ),
+ 'lname-label' => array (
+ 'nodename' => 'label',
+ 'innerhtml' => wfMessage(
'donate_interface-donor-lname' )->inLanguage( $language )->text(),
+ ),
+ 'emailAdd-label' => array (
+ 'nodename' => 'label',
+ 'innerhtml' => wfMessage(
'donate_interface-donor-email' )->inLanguage( $language )->text(),
+ ),
+ 'informationsharing' => array (
+ 'nodename' => 'p',
+ 'innerhtml' => wfMessage(
'donate_interface-informationsharing', '.*' )->inLanguage( $language )->text(),
+ ),
+ );
+
+ $this->verifyFormOutput( 'TestingWorldPayGateway', $init,
$assertNodes, true );
+ }
+
+ /**
+ * Supported languages for Belgium
+ */
+ public function belgiumLanguageProvider() {
+ return array(
+ array( 'nl' ),
+ array( 'de' ),
+ array( 'fr' ),
+ );
+ }
+
+ /**
* Testing that we can retrieve the cvv_match value and run antifraud
on it correctly
*/
function testAntifraudCVVMatch() {
diff --git a/tests/DonationInterfaceTestCase.php
b/tests/DonationInterfaceTestCase.php
index 73825fa..802441d 100644
--- a/tests/DonationInterfaceTestCase.php
+++ b/tests/DonationInterfaceTestCase.php
@@ -170,6 +170,17 @@
'amount' => '1.55',
'language' => 'nl',
),
+ 'BE' => array (
+ 'city' => 'Antwerp',
+ 'state' => 'XX',
+ 'zip' => '0',
+ 'currency_code' => 'EUR',
+ 'street' => '123 nep straat',
+ 'fname' => 'Voornaam',
+ 'lname' => 'Achternaam',
+ 'amount' => '1.55',
+ 'language' => 'nl',
+ ),
);
//default to US
if ( $country === '' ) {
@@ -342,18 +353,16 @@
$newRequest = new TestingRequest( $initial_vars, false );
$mainContext->setRequest( $newRequest );
$mainContext->setOutput( $newOutput );
- $newLang = new TestingLanguage();
- //this should be more robust, but... might have to work for now.
- $newLang->forceLang( $initial_vars['language'] );
$globals = array (
'wgRequest' => $newRequest,
'wgTitle' => Title::newFromText( 'nonsense is
apparently fine' ),
'wgOut' => $newOutput,
- 'wgLang' => $newLang,
);
$this->setMwGlobals( $globals );
+
+ $this->setLanguage( $initial_vars['language'] );
ob_start();
$formpage = new $special_page_class();
@@ -488,6 +497,21 @@
return $return;
}
+ /**
+ * Set global language for the duration of the test
+ *
+ * @param string $language language code to force
+ */
+ protected function setLanguage( $language ) {
+ $newLang = new TestingLanguage();
+ //this should be more robust, but... might have to work for now.
+ $newLang->forceLang( $language );
+
+ $this->setMwGlobals( array (
+ 'wgLang' => $newLang,
+ ) );
+ }
+
static function getInnerHTML( $node ) {
$innerHTML = '';
$children = $node->childNodes;
--
To view, visit https://gerrit.wikimedia.org/r/151673
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib5e0a11706307b7e5f0368aa5a082111f483176d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Ejegg <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits