Ejegg has uploaded a new change for review.
https://gerrit.wikimedia.org/r/298304
Change subject: Merge master into deployment
......................................................................
Merge master into deployment
6fa0cde Use 'addModuleStyles' in a couple more places
10cb1cd Put referrer back in session again
4cc8e39 Encapsulated amount validation for better messages
880b22c Disable AmEx payment submethod outside USA
Removed tests
Change-Id: I48bf9f6ead09309e36602b99f319dfda4112923e
---
D tests/Adapter/Amazon/AmazonTest.php
D tests/AmountTest.php
D tests/DataValidatorTest.php
3 files changed, 0 insertions(+), 638 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface
refs/changes/04/298304/1
diff --git a/tests/Adapter/Amazon/AmazonTest.php
b/tests/Adapter/Amazon/AmazonTest.php
deleted file mode 100644
index 7db84e1..0000000
--- a/tests/Adapter/Amazon/AmazonTest.php
+++ /dev/null
@@ -1,285 +0,0 @@
-<<<<<<< HEAD (5671e5 Merge master into deployment)
-=======
-<?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.
- */
-
-/**
- *
- * @group Fundraising
- * @group DonationInterface
- * @group Amazon
- */
-class DonationInterface_Adapter_Amazon_Test extends DonationInterfaceTestCase {
-
- /**
- * @param $name string The name of the test case
- * @param $data array Any parameters read from a dataProvider
- * @param $dataName string|int The name or index of the data set
- */
- public function __construct( $name = null, array $data = array(),
$dataName = '' ) {
- parent::__construct( $name, $data, $dataName );
- $this->testAdapterClass = 'TestingAmazonAdapter';
- }
-
- public function setUp() {
- parent::setUp();
-
- TestingAmazonAdapter::$mockClient = new MockAmazonClient();
-
- $this->setMwGlobals( array(
- 'wgAmazonGatewayEnabled' => true,
- 'wgDonationInterfaceAllowedHtmlForms' => array(
- 'amazon' => array(
- 'gateway' => 'amazon',
- 'payment_methods' => array('amazon' =>
'ALL'),
- 'redirect',
- ),
- 'amazon-recurring' => array(
- 'gateway' => 'amazon',
- 'payment_methods' => array('amazon' =>
'ALL'),
- 'redirect',
- 'recurring',
- ),
- ),
- ) );
- }
-
- public function tearDown() {
- TestingAmazonAdapter::$fakeGlobals = array();
- parent::tearDown();
- }
-
- /**
- * Integration test to verify that the Amazon gateway converts Canadian
- * dollars before redirecting
- *
- * @dataProvider canadaLanguageProvider
- */
- function testCanadianDollarConversion( $language ) {
- $init = $this->getDonorTestData( 'CA' );
- unset( $init['order_id'] );
- $init['payment_method'] = 'amazon';
- $init['ffname'] = 'amazon';
- $init['language'] = $language;
- $rates = CurrencyRates::getCurrencyRates();
- $cadRate = $rates['CAD'];
-
- $expectedAmount = floor( $init['amount'] / $cadRate );
-
- TestingAmazonAdapter::$fakeGlobals = array(
- 'FallbackCurrency' => 'USD',
- 'NotifyOnConvert' => true,
- );
-
- $expectedNotification = wfMessage(
- 'donate_interface-fallback-currency-notice',
- 'USD'
- )->inLanguage( $language )->text();
-
- $locale = $init['language'] . '_' . $init['country'];
- $expectedDisplayAmount = Amount::format( $expectedAmount,
'USD', $locale );
-
- $that = $this; //needed for PHP pre-5.4
- $convertTest = function( $amountString ) use (
$expectedDisplayAmount, $that ) {
- $that->assertEquals( $expectedDisplayAmount, trim(
$amountString ), 'Displaying wrong amount' );
- };
-
- $assertNodes = array(
- 'selected-amount' => array( 'innerhtml' => $convertTest
),
- 'mw-content-text' => array(
- 'innerhtmlmatches' =>
"/.*$expectedNotification.*/"
- )
- );
- $this->verifyFormOutput( 'TestingAmazonGateway', $init,
$assertNodes, false );
- }
-
- /**
- * Integration test to verify that the Amazon gateway shows an error
message when validation fails.
- */
- function testShowFormOnError() {
- $init = $this->getDonorTestData();
- $init['OTT'] = 'SALT123456789';
- $init['amount'] = '-100.00';
- $init['ffname'] = 'amazon';
- $session = array( 'Donor' => $init );
- $errorMessage = wfMessage(
'donate_interface-error-msg-invalid-amount' )->text();
- $assertNodes = array(
- 'mw-content-text' => array(
- 'innerhtmlmatches' => "/.*$errorMessage.*/"
- )
- );
-
- $this->verifyFormOutput( 'AmazonGateway', $init, $assertNodes,
false, $session );
- }
-
- /**
- * Check that the adapter makes the correct calls for successful
donations
- */
- function testDoPaymentSuccess() {
- $init = $this->getDonorTestData( 'US' );
- $init['amount'] = '10.00';
- $init['order_reference_id'] = mt_rand( 0, 10000000 ); //
provided by client-side widget IRL
- // We don't get any profile data up front
- unset( $init['email'] );
- unset( $init['fname'] );
- unset( $init['lname'] );
-
- $gateway = $this->getFreshGatewayObject( $init );
- $result = $gateway->doPayment();
- // FIXME: PaymentResult->isFailed returns null for false
- $this->assertTrue( !( $result->isFailed() ), 'Result should not
be failed when responses are good' );
- $this->assertEquals( 'Testy',
$gateway->getData_Unstaged_Escaped( 'fname' ), 'Did not populate first name
from Amazon data' );
- $this->assertEquals( 'Test',
$gateway->getData_Unstaged_Escaped( 'lname' ), 'Did not populate last name from
Amazon data' );
- $this->assertEquals( '[email protected]',
$gateway->getData_Unstaged_Escaped( 'email' ), 'Did not populate email from
Amazon data' );
- $mockClient = TestingAmazonAdapter::$mockClient;
- $setOrderReferenceDetailsArgs =
$mockClient->calls['setOrderReferenceDetails'][0];
- $oid = $gateway->getData_Unstaged_Escaped( 'order_id' );
- $this->assertEquals( $oid,
$setOrderReferenceDetailsArgs['seller_order_reference_id'], 'Did not set order
id on order reference' );
- $this->assertEquals( $init['amount'],
$setOrderReferenceDetailsArgs['amount'], 'Did not set amount on order
reference' );
- $this->assertEquals( $init['currency_code'],
$setOrderReferenceDetailsArgs['currency_code'], 'Did not set currency code on
order reference' );
- $queued = $gateway->queue_messages;
- $this->assertNotEmpty( $queued['complete'], 'Not sending a
message to the complete queue' );
- $message = $queued['complete'][0];
- $this->assertEquals( 'S01-0391295-0674065-C095112',
$message['gateway_txn_id'], 'Queue message has wrong txn ID' );
- }
-
- /**
- * Check that declined authorization is reflected in the result's errors
- */
- function testDoPaymentDeclined() {
- $init = $this->getDonorTestData( 'US' );
- $init['amount'] = '10.00';
- $init['order_reference_id'] = mt_rand( 0, 10000000 ); //
provided by client-side widget IRL
- // We don't get any profile data up front
- unset( $init['email'] );
- unset( $init['fname'] );
- unset( $init['lname'] );
-
- $mockClient = TestingAmazonAdapter::$mockClient;
- $mockClient->returns['authorize'][] = 'InvalidPaymentMethod';
-
- $gateway = $this->getFreshGatewayObject( $init );
- $result = $gateway->doPayment();
-
- $this->assertTrue( $result->getRefresh(), 'Result should be a
refresh on error' );
- $errors = $result->getErrors();
- $this->assertTrue( isset( $errors['InvalidPaymentMethod'] ),
'InvalidPaymentMethod error should be set' );
- }
-
- /**
- * This apparently indicates a shady enough txn that we should turn
them away
- */
- function testFailOnAmazonRejected() {
- $init = $this->getDonorTestData( 'US' );
- $init['amount'] = '10.00';
- $init['order_reference_id'] = mt_rand( 0, 10000000 ); //
provided by client-side widget IRL
- // We don't get any profile data up front
- unset( $init['email'] );
- unset( $init['fname'] );
- unset( $init['lname'] );
-
- $mockClient = TestingAmazonAdapter::$mockClient;
- $mockClient->returns['authorize'][] = 'AmazonRejected';
-
- $gateway = $this->getFreshGatewayObject( $init );
- $result = $gateway->doPayment();
-
- $this->assertTrue( $result->isFailed(), 'Result should be
failed' );
- // Could assert something about errors after rebasing onto
master
- // $errors = $result->getErrors();
- // $this->assertTrue( isset( $errors['AmazonRejected'] ),
'AmazonRejected error should be set' );
- }
-
- /**
- * When the transaction times out, just gotta fail it till we work out
an
- * asynchronous authorization flow
- */
- function testTransactionTimedOut() {
- $init = $this->getDonorTestData( 'US' );
- $init['amount'] = '10.00';
- $init['order_reference_id'] = mt_rand( 0, 10000000 ); //
provided by client-side widget IRL
- // We don't get any profile data up front
- unset( $init['email'] );
- unset( $init['fname'] );
- unset( $init['lname'] );
-
- $mockClient = TestingAmazonAdapter::$mockClient;
- $mockClient->returns['authorize'][] = 'TransactionTimedOut';
-
- $gateway = $this->getFreshGatewayObject( $init );
- $result = $gateway->doPayment();
-
- $this->assertTrue( $result->isFailed(), 'Result should be
failed' );
- }
-
- /**
- * When the SDK throws an exceptions, we should handle it.
- */
- function testClientException() {
- $init = $this->getDonorTestData( 'US' );
- $init['amount'] = '10.00';
- $init['order_reference_id'] = mt_rand( 0, 10000000 ); //
provided by client-side widget IRL
- // We don't get any profile data up front
- unset( $init['email'] );
- unset( $init['fname'] );
- unset( $init['lname'] );
-
- $mockClient = TestingAmazonAdapter::$mockClient;
- $mockClient->exceptions['authorize'][] = new Exception( 'Test'
);
-
- $gateway = $this->getFreshGatewayObject( $init );
- $result = $gateway->doPayment();
-
- $errors = $result->getErrors();
- $this->assertTrue( isset( $errors[ResponseCodes::NO_RESPONSE]
), 'NO_RESPONSE error should be set' );
- }
-
- /**
- * Check the adapter makes the correct calls for successful monthly
donations
- */
- function testDoRecurringPaymentSuccess() {
- $init = $this->getDonorTestData( 'US' );
- $init['amount'] = '10.00';
- $init['recurring'] = '1';
- $init['subscr_id'] = 'C01-9650293-7351908';
- // We don't get any profile data up front
- unset( $init['email'] );
- unset( $init['fname'] );
- unset( $init['lname'] );
-
- $gateway = $this->getFreshGatewayObject( $init );
- $result = $gateway->doPayment();
- // FIXME: PaymentResult->isFailed returns null for false
- $this->assertTrue( !( $result->isFailed() ), 'Result should not
be failed when responses are good' );
- $this->assertEquals( 'Testy',
$gateway->getData_Unstaged_Escaped( 'fname' ), 'Did not populate first name
from Amazon data' );
- $this->assertEquals( 'Test',
$gateway->getData_Unstaged_Escaped( 'lname' ), 'Did not populate last name from
Amazon data' );
- $this->assertEquals( '[email protected]',
$gateway->getData_Unstaged_Escaped( 'email' ), 'Did not populate email from
Amazon data' );
- $mockClient = TestingAmazonAdapter::$mockClient;
- $setBillingAgreementDetailsArgs =
$mockClient->calls['setBillingAgreementDetails'][0];
- $oid = $gateway->getData_Unstaged_Escaped( 'order_id' );
- $this->assertEquals( $oid,
$setBillingAgreementDetailsArgs['seller_billing_agreement_id'], 'Did not set
order id on billing agreement' );
- $authorizeOnBillingAgreementDetailsArgs =
$mockClient->calls['authorizeOnBillingAgreement'][0];
- $this->assertEquals( $init['amount'],
$authorizeOnBillingAgreementDetailsArgs['authorization_amount'], 'Did not
authorize correct amount' );
- $this->assertEquals( $init['currency_code'],
$authorizeOnBillingAgreementDetailsArgs['currency_code'], 'Did not authorize
correct currency code' );
- $queued = $gateway->queue_messages;
- $this->assertNotEmpty( $queued['complete'], 'Not sending a
message to the complete queue' );
- $message = $queued['complete'][0];
- $this->assertEquals( 'S01-5318994-6362993-C004044',
$message['gateway_txn_id'], 'Queue message has wrong txn ID' );
- $this->assertEquals( $init['subscr_id'], $message['subscr_id'],
'Queue message has wrong subscription ID' );
- }
-}
->>>>>>> BRANCH (3716c2 Merge "Encapsulated amount validation for better
messages")
diff --git a/tests/AmountTest.php b/tests/AmountTest.php
deleted file mode 100644
index 1f365ab..0000000
--- a/tests/AmountTest.php
+++ /dev/null
@@ -1,199 +0,0 @@
-<?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.
- */
-
-/**
- * @group Fundraising
- * @group DonationInterface
- * @group Validation
- */
-class AmountTest extends DonationInterfaceTestCase {
-
- /**
- * @var GatewayType
- */
- protected $adapter;
- /**
- * @var Amount
- */
- protected $validator;
- /**
- * @var array
- */
- protected $errors;
- /**
- * @var array
- */
- protected $normalized;
-
- public function setUp() {
- parent::setUp();
- $this->setMwGlobals( array(
- 'wgDonationInterfacePriceFloor' => 1.50,
- 'wgDonationInterfacePriceCeiling' => 100,
- 'wgLanguageCode' => 'en',
- ) );
-
- $this->setUpRequest( array(
- 'country' => 'US',
- 'uselang' => 'en',
- ) );
-
- $this->normalized = array(
- 'language' => 'en',
- 'country' => 'US',
- 'currency_code' => 'USD',
- );
-
- $this->errors = array();
- $this->adapter = new TestingGenericAdapter();
- $this->validator = new Amount();
- }
-
- protected function validate() {
- $this->validator->validate(
- $this->adapter, $this->normalized, $this->errors
- );
- }
-
- public function testValidUsd() {
- $this->normalized['amount'] = '10.00';
- $this->validate();
- $this->assertEmpty( $this->errors, 'Error shown for valid
amount' );
- }
-
- public function testZeroAmount() {
- $this->normalized['amount'] = '0.00';
- $this->validate();
- $this->assertNotEmpty( $this->errors, 'No error for zero
amount' );
- $expected = DataValidator::getErrorMessage(
- 'amount', 'not_empty', 'en'
- );
- $this->assertEquals(
- $expected,
- $this->errors['amount'],
- 'Wrong error message for zero amount'
- );
- }
-
- public function testWhitespaceAmount() {
- $this->normalized['amount'] = ' ';
- $this->validate();
- $this->assertNotEmpty( $this->errors, 'No error for whitespace
amount' );
- $expected = DataValidator::getErrorMessage(
- 'amount', 'not_empty', 'en'
- );
- $this->assertEquals(
- $expected,
- $this->errors['amount'],
- 'Wrong error message for whitespace amount'
- );
- }
-
- public function testNonNumericAmount() {
- $this->normalized['amount'] = 'XYZ123';
- $this->validate();
- $this->assertNotEmpty( $this->errors, 'No error for non-numeric
amount' );
- $this->assertEquals(
- WmfFramework::formatMessage(
'donate_interface-error-msg-invalid-amount' ),
- $this->errors['amount'],
- 'Wrong error message for non-numeric amount'
- );
- }
-
- public function testNegativeAmount() {
- $this->normalized['amount'] = '-100.00';
- $this->validate();
- $this->assertNotEmpty( $this->errors, 'No error for negative
amount' );
- $this->assertEquals(
- WmfFramework::formatMessage(
'donate_interface-error-msg-invalid-amount' ),
- $this->errors['amount'],
- 'Wrong error message for negative amount'
- );
- }
-
- public function testTooMuchUsd() {
- $this->normalized['amount'] = '101.00';
- $this->validate();
- $this->assertNotEmpty( $this->errors, 'No error for excessive
amount (USD)' );
- $expected = WmfFramework::formatMessage(
- 'donate_interface-bigamount-error',
- 100,
- 'USD',
- $this->adapter->getGlobal( 'MajorGiftsEmail' )
- );
- $this->assertEquals(
- $expected,
- $this->errors['amount'],
- 'Wrong error message for excessive amount (USD)'
- );
- }
-
- public function testTooLittleUsd() {
- $this->normalized['amount'] = '1.49';
- $this->validate();
- $this->assertNotEmpty( $this->errors, 'No error for diminutive
amount (USD)' );
-
- $formattedMin = Amount::format( 1.50, 'USD', 'en_US' );
- $expected = WmfFramework::formatMessage(
- 'donate_interface-smallamount-error',
- $formattedMin
- );
- $this->assertEquals(
- $expected,
- $this->errors['amount'],
- 'Wrong error message for diminutive amount (USD)'
- );
- }
-
- // Conversion tests depend on Barbadian monetary policy
- // BBD is convenient as it's pegged to $0.50
- public function testTooMuchBbd() {
- $this->normalized['currency_code'] = 'BBD';
- $this->normalized['amount'] = '201.00';
- $this->validate();
- $this->assertNotEmpty( $this->errors, 'No error for excessive
amount (BBD)' );
- $expected = WmfFramework::formatMessage(
- 'donate_interface-bigamount-error',
- 200,
- 'BBD',
- $this->adapter->getGlobal( 'MajorGiftsEmail' )
- );
- $this->assertEquals(
- $expected,
- $this->errors['amount'],
- 'Wrong error message for excessive amount (BBD)'
- );
- }
-
- public function testTooLittleBbd() {
- $this->normalized['currency_code'] = 'BBD';
- $this->normalized['amount'] = '2.95';
- $this->validate();
- $this->assertNotEmpty( $this->errors, 'No error for diminutive
amount (BBD)' );
-
- $formattedMin = Amount::format( 3.00, 'BBD', 'en_US' );
- $expected = WmfFramework::formatMessage(
- 'donate_interface-smallamount-error',
- $formattedMin
- );
- $this->assertEquals(
- $expected,
- $this->errors['amount'],
- 'Wrong error message for diminutive amount (BBD)'
- );
- }
-}
diff --git a/tests/DataValidatorTest.php b/tests/DataValidatorTest.php
deleted file mode 100644
index 1a1b6ee..0000000
--- a/tests/DataValidatorTest.php
+++ /dev/null
@@ -1,154 +0,0 @@
-<<<<<<< HEAD (5671e5 Merge master into deployment)
-=======
-<?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.
- */
-
-/**
- * @group Fundraising
- * @group DonationInterface
- * @group Validation
- * @category UnitTesting
- */
-class DataValidatorTest extends PHPUnit_Framework_TestCase {
- /**
- * Test the Luhn check algorithm
- * @dataProvider luhnDataProvider
- */
- public function testLuhnCheck( $number, $expresult, $helpful_message ) {
- $result = DataValidator::cc_number_exists_in_str( $number );
- $this->assertEquals( $expresult, $result, "$number failed
expected luhn check ($helpful_message)" );
- }
-
- public function luhnDataProvider() {
- return array(
- // Mastercard
- array ( '5333331605740535', true, 'Mastercard' ),
- array ( '5143792293131636', true, 'Mastercard' ),
- array ( 'John Doe 5199122553269905 Random', true,
'Mastercard' ),
- array ( '5497-8801-7320-5943', true, 'Mastercard' ),
- array ( '5370 5369 5295 3903', true, 'Mastercard' ),
- array ( '5295975049354398', true, 'Mastercard' ),
- array ( '5122728197617259', true, 'Mastercard' ),
- array ( '5372869474419840', true, 'Mastercard' ),
- array ( '5479089850576103', true, 'Mastercard' ),
- array ( '5375122664558457', true, 'Mastercard' ),
- // VISA array(16), digit
- array ( '4024007145540307', true, 'Visa 16 digit' ),
- array ( '4532676809474030', true, 'Visa 16 digit' ),
- array ( '4024007139174626', true, 'Visa 16 digit' ),
- array ( '4556384391069166', true, 'Visa 16 digit' ),
- array ( '4916423001204113', true, 'Visa 16 digit' ),
- array ( '4716409516522919', true, 'Visa 16 digit' ),
- array ( '4296465885589572', true, 'Visa 16 digit' ),
- array ( '4532969094459737', true, 'Visa 16 digit' ),
- array ( '4485480938896362', true, 'Visa 16 digit' ),
- array ( '4539357366702682', true, 'Visa 16 digit' ),
- // VISA array(13), digit
- array ( '4916199124929', true, 'Visa 13 digit' ),
- array ( '4916237697951', true, 'Visa 13 digit' ),
- array ( '4929247091115', true, 'Visa 13 digit' ),
- array ( '4024007169572', true, 'Visa 13 digit' ),
- array ( '4716716919391', true, 'Visa 13 digit' ),
- // American Express
- array ( '343114236688284', true, 'Amex' ),
- array ( '379274178561225', true, 'Amex' ),
- // Discover
- array ( '6011013905647431', true, 'Discover' ),
- array ( '6011045341391380', true, 'Discover' ),
- array ( '6011324325736120', true, 'Discover' ),
- // Diners Club is not currently working at all
- /**
- array ( '30343484937451', true, 'Diners Club' ),
- array ( '30037415730064', true, 'Diners Club' ),
- array ( '30392872026500', true, 'Diners Club' ),
- */
- // enRoute
- array ( '201454799826249', true, 'enRoute' ),
- array ( '201498205795993', true, 'enRoute' ),
- array ( '214960886496931', true, 'enRoute' ),
- // JCB
- array ( '3582219461343499', true, 'JCB' ),
- array ( '3534022982879267', true, 'JCB' ),
- //not sure what is wrong with the next one, but it's
failing
- //array ( '3519002211673029', true, 'JCB' ),
- // Voyager is also not currently working at all
- /**
- array ( '869952786819898', true, 'Voyager' ),
- array ( '869967184704708', true, 'Voyager' ),
- array ( '869901879171733', true, 'Voyager' ),
- */
- // Not credit cards
- array ( 'John Doe', false, 'Not a valid credit card' ),
- array ( 'Peter 123456', false, 'Not a valid credit
card' ),
- array ( '1234567', false, 'Not a valid credit card' )
- );
- }
-
- /**
- * Oh Shit: It's an actual simple unit test!
- * @covers DataValidator::getZeroPaddedValue()
- */
- public function testGetZeroPaddedValue() {
- //make sure that it works in the two main categories of ways it
should work
- $this->assertEquals( '00123',
DataValidator::getZeroPaddedValue( '123', 5 ), "getZeroPaddedValue does not
properly pad out a value in the simplest case" );
- $this->assertEquals( '00123',
DataValidator::getZeroPaddedValue( '0000123', 5 ), "getZeroPaddedValue does not
properly unpad and re-pad a value when leading zeroes exist in the initial
value" );
-
- //make sure it fails gracefully when asked to do something
silly.
- $this->assertFalse( DataValidator::getZeroPaddedValue(
'123456', 5 ), "getZeroPaddedValue does not return false when the exact desired
value is impossible" );
- }
-
- public function fiscalNumberProvider() {
- return array(
- array( 'BR', '', false ), // empty not OK for BR
- array( 'US', '', true ), // empty OK for US
- array( 'BR', '12345', false ), // too short for BR
- array( 'BR', '00003456789', true ),
- array( 'BR', '000.034.567-89', true ), // strip
punctuation
- array( 'BR', '00.000.000/0001-00', true ), // CPNJ
should pass too
- array( 'BR', '1111222233334444', false ),
- array( 'BR', 'ABC11122233', false ),
- array( 'CL', '12.123.123-K', true ),
- array( 'CL', '12.12.12-4', false ),
- array( 'CO', '123-456', true ),
- array( 'CO', '1234-5678-90', true ),
- array( 'CO', '12A-456-7', false ),
- array( 'CO', '1234-5678-901', false ),
- array( 'AR', 'ABC12312', false ),
- array( 'AR', '12341234', true ),
- array( 'AR', '1112223', true ),
- array( 'AR', '111222', false ),
- array( 'MX', '', true ), // Not required for MX
- );
- }
-
- /**
- * @dataProvider fiscalNumberProvider
- * TODO: Test modular validator integration with DonationData
- */
- public function testValidateFiscalNumber( $country, $value, $valid ) {
- $validator = new FiscalNumber();
- $errors = array();
- $validator->validate(
- new TestingGenericAdapter(),
- array( 'country' => $country, 'fiscal_number' =>
$value, 'language' => 'en' ),
- $errors
- );
- $expectation = $valid ? "should" : "should not";
- $this->assertEquals( $valid, empty( $errors['fiscal_number'] ),
"$value $expectation be a valid fiscal number for $country" );
- }
-}
->>>>>>> BRANCH (3716c2 Merge "Encapsulated amount validation for better
messages")
--
To view, visit https://gerrit.wikimedia.org/r/298304
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I48bf9f6ead09309e36602b99f319dfda4112923e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: deployment
Gerrit-Owner: Ejegg <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits