Ejegg has uploaded a new change for review. https://gerrit.wikimedia.org/r/323979
Change subject: Merge branch 'master' into deployment ...................................................................... Merge branch 'master' into deployment 74a64bd Make sure tests fail on missing response file dadf7fa Localisation updates from https://translatewiki.net. 9065049 Localisation updates from https://translatewiki.net. 83bd54e Localisation updates from https://translatewiki.net. c9dca52 Localisation updates from https://translatewiki.net. 4a6c546 Allow weighting Minfraud response 197edce Make minfraud weighting more readable Change-Id: I4d253dab27ca94ccacf7bbe12691355c3454412b --- D tests/phpunit/includes/test_gateway/TestingAdyenAdapter.php D tests/phpunit/includes/test_gateway/TestingAstroPayAdapter.php D tests/phpunit/includes/test_gateway/TestingGlobalCollectAdapter.php D tests/phpunit/includes/test_gateway/TestingGlobalCollectOrphanAdapter.php D tests/phpunit/includes/test_gateway/TestingPaypalLegacyAdapter.php 5 files changed, 0 insertions(+), 453 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface refs/changes/79/323979/1 diff --git a/tests/phpunit/includes/test_gateway/TestingAdyenAdapter.php b/tests/phpunit/includes/test_gateway/TestingAdyenAdapter.php deleted file mode 100644 index 98647e8..0000000 --- a/tests/phpunit/includes/test_gateway/TestingAdyenAdapter.php +++ /dev/null @@ -1,73 +0,0 @@ -<<<<<<< HEAD (44e4a8 Merge branch 'master' into deployment) -======= -<?php - -/** - * TestingAdyenAdapter - */ -class TestingAdyenAdapter extends AdyenAdapter { - - //@TODO: That minfraud jerk needs its own isolated tests. - function runAntifraudFilters() { - //now screw around with the batch settings to trick the fraud filters into triggering - $is_batch = $this->isBatchProcessor(); - $this->batch = true; - - parent::runAntifraudFilters(); - - $this->batch = $is_batch; - } - - /** - * Set the error code you want the dummy response to return - */ - public function setDummyGatewayResponseCode( $code ) { - $this->dummyGatewayResponseCode = $code; - } - - /** - * Set the error code you want the dummy response to return - */ - public function setDummyCurlResponseCode( $code ) { - $this->dummyCurlResponseCode = $code; - } - - /** - * Load in some dummy response XML so we can test proper response processing - */ - protected function curl_exec( $ch ) { - $code = ''; - if ( property_exists( $this, 'dummyGatewayResponseCode' ) ) { - $code = '_' . $this->dummyGatewayResponseCode; - } - - //could start stashing these in a further-down subdir if payment type starts getting in the way, - //but frankly I don't want to write tests that test our dummy responses. - $file_path = __DIR__ . '/../'; - $file_path .= 'Responses' . '/' . self::getIdentifier() . '/'; - $file_path .= $this->getCurrentTransaction() . $code . '.testresponse'; - - //these are all going to be short, so... - if ( file_exists( $file_path ) ) { - return file_get_contents( $file_path ); - } - throw new RuntimeException( "File $file_path does not exist." ); - } - - /** - * Load in some dummy curl response info so we can test proper response processing - */ - protected function curl_getinfo( $ch, $opt = null ) { - $code = 200; //response OK - if ( property_exists( $this, 'dummyCurlResponseCode' ) ) { - $code = ( int ) $this->dummyCurlResponseCode; - } - - //put more here if it ever turns out that we care about it. - return array ( - 'http_code' => $code, - ); - } - -} ->>>>>>> BRANCH (197edc Make minfraud weighting more readable) diff --git a/tests/phpunit/includes/test_gateway/TestingAstroPayAdapter.php b/tests/phpunit/includes/test_gateway/TestingAstroPayAdapter.php deleted file mode 100644 index 19859bd..0000000 --- a/tests/phpunit/includes/test_gateway/TestingAstroPayAdapter.php +++ /dev/null @@ -1,79 +0,0 @@ -<<<<<<< HEAD (44e4a8 Merge branch 'master' into deployment) -======= -<?php - -/** - * TestingAstroPayAdapter - * - * TODO: Add dependency injection to the base class so we don't have to repeat - * code (or this comment) here. - */ -class TestingAstroPayAdapter extends AstroPayAdapter { - - public $curled = array(); - - /** - * Set the error code you want the dummy response to return - */ - public function setDummyGatewayResponseCode( $code ) { - $this->dummyGatewayResponseCode = $code; - } - - /** - * Set the error code you want the dummy response to return - */ - public function setDummyCurlResponseCode( $code ) { - $this->dummyCurlResponseCode = $code; - } - - protected function curl_transaction( $data ) { - $this->curled[] = $data; - return parent::curl_transaction( $data ); - } - - /** - * Load in some dummy response JSON so we can test proper response processing - * @throws RuntimeException - */ - protected function curl_exec( $ch ) { - $code = ''; - if ( property_exists( $this, 'dummyGatewayResponseCode' ) ) { - $code = '_' . $this->dummyGatewayResponseCode; - if ( $this->dummyGatewayResponseCode === 'Exception' ) { - throw new RuntimeException( 'blah!' ); - } - } - - //could start stashing these in a further-down subdir if payment type starts getting in the way, - //but frankly I don't want to write tests that test our dummy responses. - $file_path = __DIR__ - . '/../Responses/' - . self::getIdentifier() - . '/' - . $this->getCurrentTransaction() - . $code - . '.testresponse'; - - //these are all going to be short, so... - if ( file_exists( $file_path ) ) { - return file_get_contents( $file_path ); - } - throw new RuntimeException( "File $file_path does not exist." ); - } - - /** - * Load in some dummy curl response info so we can test proper response processing - */ - protected function curl_getinfo( $ch, $opt = null ) { - $code = 200; //response OK - if ( property_exists( $this, 'dummyCurlResponseCode' ) ) { - $code = ( int ) $this->dummyCurlResponseCode; - } - - //put more here if it ever turns out that we care about it. - return array ( - 'http_code' => $code, - ); - } -} ->>>>>>> BRANCH (197edc Make minfraud weighting more readable) diff --git a/tests/phpunit/includes/test_gateway/TestingGlobalCollectAdapter.php b/tests/phpunit/includes/test_gateway/TestingGlobalCollectAdapter.php deleted file mode 100644 index 9ef1482..0000000 --- a/tests/phpunit/includes/test_gateway/TestingGlobalCollectAdapter.php +++ /dev/null @@ -1,127 +0,0 @@ -<<<<<<< HEAD (44e4a8 Merge branch 'master' into deployment) -======= -<?php - -/** - * TestingGlobalCollectAdapter - * - * TODO: Add dependency injection to the base class so we don't have to repeat code here. - */ -class TestingGlobalCollectAdapter extends GlobalCollectAdapter { - - public $curled = array ( ); - - public $pending_messages = array(); - - public $dummyGatewayResponseCode; - - /** - * Also set a useful MerchantID. - */ - public function __construct( $options = array ( ) ) { - if ( is_null( $options ) ) { - $options = array ( ); - } - - //I hate myself for this part, and so do you. - //Deliberately not fixing the actual problem for this patchset. - //@TODO: Change the way the constructor works in all adapter - //objects, such that the mess I am about to make is no longer - //necessary. A patchset may already be near-ready for this... - if ( array_key_exists( 'order_id_meta', $options ) ) { - $this->order_id_meta = $options['order_id_meta']; - unset( $options['order_id_meta'] ); - } - - $this->options = $options; - - parent::__construct( $this->options ); - } - - /** - * @TODO: Get rid of this and the override mechanism as soon as you - * refactor the constructor into something reasonable. - */ - public function defineOrderIDMeta() { - if ( isset( $this->order_id_meta ) ) { - return; - } - parent::defineOrderIDMeta(); - } - - // TODO: Store and test the actual messages. - public function sendPendingMessage() { - $this->pending_messages[] = false; - } - - /** - * Set the error code you want the dummy response to return - */ - public function setDummyGatewayResponseCode( $code ) { - $this->dummyGatewayResponseCode = $code; - } - - /** - * Set the error code you want the dummy response to return - */ - public function setDummyCurlResponseCode( $code ) { - $this->dummyCurlResponseCode = $code; - } - - protected function curl_transaction( $data ) { - $this->curled[] = $data; - return parent::curl_transaction( $data ); - } - - /** - * Load in some dummy response XML so we can test proper response processing - * @throws RuntimeException - */ - protected function curl_exec( $ch ) { - $code = ''; - if ( $this->dummyGatewayResponseCode ) { - if ( is_array( $this->dummyGatewayResponseCode ) ) { - $code = array_shift( $this->dummyGatewayResponseCode ); - } elseif ( is_callable( $this->dummyGatewayResponseCode ) ) { - $code = call_user_func( $this->dummyGatewayResponseCode, $this ); - } else { - $code = $this->dummyGatewayResponseCode; - } - } - if ( $code ) { - if ( $code === 'Exception' ) { - throw new RuntimeException('blah!'); - } - $code = '_' . $code; - } - - //could start stashing these in a further-down subdir if payment type starts getting in the way, - //but frankly I don't want to write tests that test our dummy responses. - $file_path = __DIR__ . '/../'; - $file_path .= 'Responses' . '/' . self::getIdentifier() . '/'; - $file_path .= $this->getCurrentTransaction() . $code . '.testresponse'; - - //these are all going to be short, so... - if ( file_exists( $file_path ) ) { - return file_get_contents( $file_path ); - } - throw new RuntimeException( "File $file_path does not exist." ); - } - - /** - * Load in some dummy curl response info so we can test proper response processing - */ - protected function curl_getinfo( $ch, $opt = null ) { - $code = 200; //response OK - if ( property_exists( $this, 'dummyCurlResponseCode' ) ) { - $code = ( int ) $this->dummyCurlResponseCode; - } - - //put more here if it ever turns out that we care about it. - return array ( - 'http_code' => $code, - ); - } - -} ->>>>>>> BRANCH (197edc Make minfraud weighting more readable) diff --git a/tests/phpunit/includes/test_gateway/TestingGlobalCollectOrphanAdapter.php b/tests/phpunit/includes/test_gateway/TestingGlobalCollectOrphanAdapter.php deleted file mode 100644 index 4a81f6b..0000000 --- a/tests/phpunit/includes/test_gateway/TestingGlobalCollectOrphanAdapter.php +++ /dev/null @@ -1,105 +0,0 @@ -<<<<<<< HEAD (44e4a8 Merge branch 'master' into deployment) -======= -<?php - -/** - * Test wrapper for the orphan adapter - * - * TODO: This is beyond silly. Use traits or whatever it takes. - */ -class TestingGlobalCollectOrphanAdapter extends GlobalCollectOrphanAdapter { - - public $curled = array ( ); - - /** - * Also set a useful MerchantID. - */ - public function __construct( $options = array ( ) ) { - if ( is_null( $options ) ) { - $options = array ( ); - } - - //I hate myself for this part, and so do you. - //Deliberately not fixing the actual problem for this patchset. - //@TODO: Change the way the constructor works in all adapter - //objects, such that the mess I am about to make is no longer - //necessary. A patchset may already be near-ready for this... - if ( array_key_exists( 'order_id_meta', $options ) ) { - $this->order_id_meta = $options['order_id_meta']; - unset( $options['order_id_meta'] ); - } - - $this->options = $options; - - parent::__construct( $this->options ); - } - - /** - * @TODO: Get rid of this and the override mechanism as soon as you - * refactor the constructor into something reasonable. - */ - public function defineOrderIDMeta() { - if ( isset( $this->order_id_meta ) ) { - return; - } - parent::defineOrderIDMeta(); - } - - /** - * Set the error code you want the dummy response to return - */ - public function setDummyGatewayResponseCode( $code ) { - $this->dummyGatewayResponseCode = $code; - } - - /** - * Set the error code you want the dummy response to return - */ - public function setDummyCurlResponseCode( $code ) { - $this->dummyCurlResponseCode = $code; - } - - protected function curl_transaction( $data ) { - $this->curled[] = $data; - return parent::curl_transaction( $data ); - } - - /** - * Load in some dummy response XML so we can test proper response processing - */ - protected function curl_exec( $ch ) { - $code = ''; - if ( property_exists( $this, 'dummyGatewayResponseCode' ) ) { - $code = '_' . $this->dummyGatewayResponseCode; - } - - //could start stashing these in a further-down subdir if payment type starts getting in the way, - //but frankly I don't want to write tests that test our dummy responses. - $file_path = __DIR__ . '/../'; - $file_path .= 'Responses' . '/' . self::getIdentifier() . '/'; - $file_path .= $this->getCurrentTransaction() . $code . '.testresponse'; - - //these are all going to be short, so... - if ( file_exists( $file_path ) ) { - return file_get_contents( $file_path ); - } - throw new RuntimeException( "File $file_path does not exist." ); - } - - /** - * Load in some dummy curl response info so we can test proper response processing - */ - protected function curl_getinfo( $ch, $opt = null ) { - $code = 200; //response OK - if ( property_exists( $this, 'dummyCurlResponseCode' ) ) { - $code = ( int ) $this->dummyCurlResponseCode; - } - - //put more here if it ever turns out that we care about it. - return array ( - 'http_code' => $code, - ); - } - -} ->>>>>>> BRANCH (197edc Make minfraud weighting more readable) diff --git a/tests/phpunit/includes/test_gateway/TestingPaypalLegacyAdapter.php b/tests/phpunit/includes/test_gateway/TestingPaypalLegacyAdapter.php deleted file mode 100644 index 77f8159..0000000 --- a/tests/phpunit/includes/test_gateway/TestingPaypalLegacyAdapter.php +++ /dev/null @@ -1,69 +0,0 @@ -<<<<<<< HEAD (44e4a8 Merge branch 'master' into deployment) -======= -<?php - -/** - * @TODO: Extend/damage things here. I'm sure we'll need it eventually... - */ -class TestingPaypalLegacyAdapter extends PaypalLegacyAdapter { - public static $fakeGlobals = array(); - - /** - * Set the error code you want the dummy response to return - */ - public function setDummyGatewayResponseCode( $code ) { - $this->dummyGatewayResponseCode = $code; - } - - /** - * Set the error code you want the dummy response to return - */ - public function setDummyCurlResponseCode( $code ) { - $this->dummyCurlResponseCode = $code; - } - - /** - * Load in some dummy response XML so we can test proper response processing - */ - protected function curl_exec( $ch ) { - $code = ''; - if ( property_exists( $this, 'dummyGatewayResponseCode' ) ) { - $code = '_' . $this->dummyGatewayResponseCode; - } - - //could start stashing these in a further-down subdir if payment type starts getting in the way, - //but frankly I don't want to write tests that test our dummy responses. - $file_path = __DIR__ . '/../'; - $file_path .= 'Responses' . '/' . self::getIdentifier() . '/'; - $file_path .= $this->getCurrentTransaction() . $code . '.testresponse'; - - //these are all going to be short, so... - if ( file_exists( $file_path ) ) { - return file_get_contents( $file_path ); - } - throw new RuntimeException( "File $file_path does not exist." ); - } - - /** - * Load in some dummy curl response info so we can test proper response processing - */ - protected function curl_getinfo( $ch, $opt = null ) { - $code = 200; //response OK - if ( property_exists( $this, 'dummyCurlResponseCode' ) ) { - $code = ( int ) $this->dummyCurlResponseCode; - } - - //put more here if it ever turns out that we care about it. - return array ( - 'http_code' => $code, - ); - } - - public static function getGlobal( $name ) { - if ( array_key_exists( $name, self::$fakeGlobals ) ) { - return self::$fakeGlobals[$name]; - } - return parent::getGlobal( $name ); - } -} ->>>>>>> BRANCH (197edc Make minfraud weighting more readable) -- To view, visit https://gerrit.wikimedia.org/r/323979 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4d253dab27ca94ccacf7bbe12691355c3454412b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/DonationInterface Gerrit-Branch: deployment Gerrit-Owner: Ejegg <eeggles...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits