jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/362313 )
Change subject: Move fraud filter config to TestConfiguration ...................................................................... Move fraud filter config to TestConfiguration Once upon a time I thought it was OK to do stuff in test case constructors. That was totally wrong, as all of the constructors are called before any of the tests are run. These maps don't need to be set dynamically - they can just live in the test config. Change-Id: I33c1260a8d7394ca1722d70eff0bf2c8ddae7a9f --- M tests/phpunit/Adapter/AstroPay/AstroPayTest.php M tests/phpunit/FraudFiltersTest.php M tests/phpunit/TestConfiguration.php 3 files changed, 64 insertions(+), 73 deletions(-) Approvals: Mepps: Looks good to me, approved jenkins-bot: Verified diff --git a/tests/phpunit/Adapter/AstroPay/AstroPayTest.php b/tests/phpunit/Adapter/AstroPay/AstroPayTest.php index 5b6643a..95a7c34 100644 --- a/tests/phpunit/Adapter/AstroPay/AstroPayTest.php +++ b/tests/phpunit/Adapter/AstroPay/AstroPayTest.php @@ -446,7 +446,6 @@ * Test that we run the AntiFraud filters before redirecting */ function testAntiFraudFilters() { - DonationInterface_FraudFiltersTest::setupFraudMaps( $this ); $init = $this->getDonorTestData( 'BR' ); $init['payment_method'] = 'cc'; $init['bank_code'] = 'VD'; diff --git a/tests/phpunit/FraudFiltersTest.php b/tests/phpunit/FraudFiltersTest.php index b8726c7..96245bc 100644 --- a/tests/phpunit/FraudFiltersTest.php +++ b/tests/phpunit/FraudFiltersTest.php @@ -25,77 +25,6 @@ */ class DonationInterface_FraudFiltersTest 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 = '' ) { - $adapterclass = TESTS_ADAPTER_DEFAULT; - $this->testAdapterClass = $adapterclass; - - parent::__construct( $name, $data, $dataName ); - self::setupFraudMaps( $this ); - } - - public static function setupFraudMaps( $testContext ) { - // Declare so setMwGlobals can override. - global $wgGlobalCollectGatewayCustomFiltersFunctions; - $wgGlobalCollectGatewayCustomFiltersFunctions = null; - - - // Declare here cos reused. - $customFilters = array( - 'getScoreCountryMap' => 50, - 'getScoreUtmCampaignMap' => 50, - 'getScoreUtmSourceMap' => 15, - 'getScoreUtmMediumMap' => 15, - 'getScoreEmailDomainMap' => 75, - ); - - $testContext->setMwGlobals( array( - 'wgDonationInterfaceCustomFiltersActionRanges' => array ( - 'process' => array ( 0, 25 ), - 'review' => array ( 25, 50 ), - 'challenge' => array ( 50, 75 ), - 'reject' => array ( 75, 100 ), - ), - - 'wgDonationInterfaceCustomFiltersRefRules' => array ( - '/donate-error/i' => 5, - ), - - 'wgDonationInterfaceCustomFiltersSrcRules' => array ( '/wikimedia\.org/i' => 80 ), - - 'wgDonationInterfaceCustomFiltersFunctions' => $customFilters, - - 'wgGlobalCollectGatewayCustomFiltersFunctions' => array( - 'getCVVResult' => 20, - 'getAVSResult' => 25, - ) + $customFilters, - - 'wgDonationInterfaceCountryMap' => array ( - 'US' => 40, - 'CA' => 15, - 'RU' => -4, - ), - - 'wgDonationInterfaceUtmCampaignMap' => array ( - '/^(C14_)/' => 14, - '/^(spontaneous)/' => 5 - ), - 'wgDonationInterfaceUtmSourceMap' => array ( - '/somethingmedia/' => 70 - ), - 'wgDonationInterfaceUtmMediumMap' => array ( - '/somethingmedia/' => 80 - ), - 'wgDonationInterfaceEmailDomainMap' => array ( - 'wikimedia.org' => 42, - 'wikipedia.org' => 50, - ), - ) ); - } function testGCFraudFilters() { $this->setMwGlobals( array( diff --git a/tests/phpunit/TestConfiguration.php b/tests/phpunit/TestConfiguration.php index 88695f6..30d6cb4 100644 --- a/tests/phpunit/TestConfiguration.php +++ b/tests/phpunit/TestConfiguration.php @@ -78,7 +78,17 @@ $wgDonationInterfaceEnableMinfraud, $wgDonationInterfaceEnableFunctionsFilter, $wgDonationInterfaceEnableReferrerFilter, - $wgDonationInterfaceEnableSourceFilter; + $wgDonationInterfaceEnableSourceFilter, + $wgDonationInterfaceCustomFiltersActionRanges, + $wgDonationInterfaceCustomFiltersRefRules, + $wgDonationInterfaceCustomFiltersSrcRules, + $wgDonationInterfaceCustomFiltersFunctions, + $wgGlobalCollectGatewayCustomFiltersFunctions, + $wgDonationInterfaceCountryMap, + $wgDonationInterfaceUtmCampaignMap, + $wgDonationInterfaceUtmSourceMap, + $wgDonationInterfaceUtmMediumMap, + $wgDonationInterfaceEmailDomainMap; $wgDonationInterfaceGatewayAdapters = array( 'globalcollect'=> 'TestingGlobalCollectAdapter', @@ -179,3 +189,56 @@ $wgDonationInterfaceEnableFunctionsFilter = true; $wgDonationInterfaceEnableReferrerFilter = true; $wgDonationInterfaceEnableSourceFilter = true; + +$customFilters = array( + 'getScoreCountryMap' => 50, + 'getScoreUtmCampaignMap' => 50, + 'getScoreUtmSourceMap' => 15, + 'getScoreUtmMediumMap' => 15, + 'getScoreEmailDomainMap' => 75, +); + + +$wgDonationInterfaceCustomFiltersActionRanges = array ( + 'process' => array ( 0, 25 ), + 'review' => array ( 25, 50 ), + 'challenge' => array ( 50, 75 ), + 'reject' => array ( 75, 100 ), +); + +$wgDonationInterfaceCustomFiltersRefRules = array ( + '/donate-error/i' => 5, +); + +$wgDonationInterfaceCustomFiltersSrcRules = array ( '/wikimedia\.org/i' => 80 ); + +$wgDonationInterfaceCustomFiltersFunctions = $customFilters; + +$wgGlobalCollectGatewayCustomFiltersFunctions = array( + 'getCVVResult' => 20, + 'getAVSResult' => 25, +) + $customFilters; + +$wgDonationInterfaceCountryMap = array ( + 'US' => 40, + 'CA' => 15, + 'RU' => -4, +); + +$wgDonationInterfaceUtmCampaignMap = array ( + '/^(C14_)/' => 14, + '/^(spontaneous)/' => 5 +); + +$wgDonationInterfaceUtmSourceMap = array ( + '/somethingmedia/' => 70 +); + +$wgDonationInterfaceUtmMediumMap = array ( + '/somethingmedia/' => 80 +); + +$wgDonationInterfaceEmailDomainMap = array ( + 'wikimedia.org' => 42, + 'wikipedia.org' => 50, +); -- To view, visit https://gerrit.wikimedia.org/r/362313 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I33c1260a8d7394ca1722d70eff0bf2c8ddae7a9f Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/DonationInterface Gerrit-Branch: master Gerrit-Owner: Ejegg <ej...@ejegg.com> Gerrit-Reviewer: Mepps <me...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits