Ejegg has uploaded a new change for review. https://gerrit.wikimedia.org/r/286945
Change subject: Merge master into deployment ...................................................................... Merge master into deployment 8329b0e Encapsulate validation along with transformations 4acd8a9 Localisation updates from https://translatewiki.net. ab396ae Revert "Localisation updates from https://translatewiki.net." dc348a4 Allow single-parameter WmfFramework::messageExists a00b1e8 Localize subdivisions 6ef4248 Fix spurious and non-specific fiscal number error 0f70f35 Localisation updates from https://translatewiki.net. 7e72463 Localisation updates from https://translatewiki.net. d8ac7a5 Initial reorganization of js for new forms e675c6f DRY donation form title 585d71a Persist state/province selection, localize prompt 07b8aa4 Get adapter class in a more adaptable way 7f07a4b Guard against undefined variable and index errors 3bad948 Align amount and currency inputs b195db8 Support query_string response parsing f42cb2f Defaults and comments 573112a Helper function to unstage the keys of an array 16eaadb Restore check_not_empty Removed tests Change-Id: I52f557a23250091631052c823e33cc236525c034 --- D tests/DataValidatorTest.php 1 file changed, 0 insertions(+), 149 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface refs/changes/45/286945/1 diff --git a/tests/DataValidatorTest.php b/tests/DataValidatorTest.php deleted file mode 100644 index 5cfee02..0000000 --- a/tests/DataValidatorTest.php +++ /dev/null @@ -1,149 +0,0 @@ -<<<<<<< HEAD (7dd1f9 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( '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( - 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 (16eaad Restore check_not_empty) -- To view, visit https://gerrit.wikimedia.org/r/286945 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I52f557a23250091631052c823e33cc236525c034 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
