Ejegg has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/379440 )
Change subject: WIP shouldRectifyOrphan for Ingenico ...................................................................... WIP shouldRectifyOrphan for Ingenico TODO: set up a test with a real contribution_tracking row that has a civi contribution_id in it. Will fail till we implement something like GlobalCollectOrphanAdapter's getContributionTracking Bug: T176376 Change-Id: Icfb5e193f48a0160fb469d7fdd84a5dbbb8646fe --- M ingenico_gateway/ingenico.adapter.php M tests/phpunit/Adapter/Ingenico/IngenicoOrphanAdapterTest.php 2 files changed, 37 insertions(+), 23 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface refs/changes/40/379440/1 diff --git a/ingenico_gateway/ingenico.adapter.php b/ingenico_gateway/ingenico.adapter.php index daa88b7..a13d7b0 100644 --- a/ingenico_gateway/ingenico.adapter.php +++ b/ingenico_gateway/ingenico.adapter.php @@ -243,4 +243,23 @@ $this->getData_Unstaged_Escaped( 'gateway_txn_id' ) ); } + + public function shouldRectifyOrphan() { + if ( $this->getPaymentMethod() !== 'cc' ) { + // Skip other payment methods which shouldn't be in the pending + // queue anyway. See https://phabricator.wikimedia.org/T161160 + $this->logger->info( "Skipping non-credit card pending record." ); + return false; + } + $civiId = $this->getData_Unstaged_Escaped( 'contribution_id' ); + if ( $civiId ) { + $ctId = $this->getData_Unstaged_Escaped( 'contribution_tracking_id' ); + $this->logger->error( + "$ctId: Contribution tracking already has contribution_id $civiId. " . + 'Stop confusing donors!' + ); + return false; + } + return true; + } } diff --git a/tests/phpunit/Adapter/Ingenico/IngenicoOrphanAdapterTest.php b/tests/phpunit/Adapter/Ingenico/IngenicoOrphanAdapterTest.php index 4e7eee5..826e0be 100644 --- a/tests/phpunit/Adapter/Ingenico/IngenicoOrphanAdapterTest.php +++ b/tests/phpunit/Adapter/Ingenico/IngenicoOrphanAdapterTest.php @@ -31,9 +31,16 @@ * @group OrphanSlayer */ class DonationInterface_Adapter_Ingenico_Orphans_IngenicoTest extends DonationInterfaceTestCase { + protected $dummy_utm_data; + public function setUp() { parent::setUp(); - $this->markTestSkipped( 'Orphan adapter not yet implemented' ); + $this->dummy_utm_data = array( + 'utm_source' => 'dummy_source', + 'utm_campaign' => 'dummy_campaign', + 'utm_medium' => 'dummy_medium', + 'date' => time(), + ); TestingContext::get()->providerConfigurationOverride = TestingProviderConfiguration::createForProvider( @@ -43,34 +50,18 @@ $this->setMwGlobals( array( 'wgIngenicoGatewayEnabled' => true, - 'wgDonationInterfaceAllowedHtmlForms' => array( - 'cc-vmad' => array( - 'gateway' => 'ingenico', - 'payment_methods' => array( 'cc' => array( 'visa', 'mc', 'amex', 'discover' ) ), - 'countries' => array( - '+' => array( 'US', ), - ), - ), - ), ) ); } - /** - * @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 - */ - function __construct( $name = null, array $data = array(), $dataName = '' ) { - parent::__construct( $name, $data, $dataName ); - $this->dummy_utm_data = array( - 'utm_source' => 'dummy_source', - 'utm_campaign' => 'dummy_campaign', - 'utm_medium' => 'dummy_medium', - 'date' => time(), - ); + public function testShouldRectifyOrphan() { + $message = $this->createOrphan( array( 'gateway' => 'ingenico' ) ); + $this->gatewayAdapter = $this->getFreshGatewayObject( $message ); + $result = $this->gatewayAdapter->shouldRectifyOrphan(); + $this->assertEquals( $result, true, 'shouldRectifyOrphan returning false.' ); } public function testConstructor() { + $this->markTestSkipped( 'Orphan adapter not yet implemented' ); $class = $this->testAdapterClass; $gateway = $this->getFreshGatewayObject(); @@ -81,6 +72,7 @@ } public function testBatchOrderID_generate() { + $this->markTestSkipped( 'Orphan adapter not yet implemented' ); // no data on construct, generate Order IDs $gateway = $this->getFreshGatewayObject( null, array( 'order_id_meta' => array( 'generate' => true ) ) ); $this->assertTrue( $gateway->getOrderIDMeta( 'generate' ), 'The order_id meta generate setting override is not working properly. Order_id generation may be broken.' ); @@ -101,6 +93,7 @@ } public function testBatchOrderID_no_generate() { + $this->markTestSkipped( 'Orphan adapter not yet implemented' ); // no data on construct, do not generate Order IDs $gateway = $this->getFreshGatewayObject( null, array( 'order_id_meta' => array( 'generate' => false ) ) ); $this->assertFalse( $gateway->getOrderIDMeta( 'generate' ), 'The order_id meta generate setting override is not working properly. Deferred order_id generation may be broken.' ); @@ -126,6 +119,7 @@ * @dataProvider mcNoRetryCodeProvider */ public function testNoMastercardFinesForRepeatOnBadCodes( $code ) { + $this->markTestSkipped( 'Orphan adapter not yet implemented' ); $gateway = $this->getFreshGatewayObject( null, array( 'order_id_meta' => array( 'generate' => false ) ) ); // Toxic card should not retry, even if there's an order id collision @@ -155,6 +149,7 @@ * fraud scores. */ function testGetOrderstatusPostProcessFraud() { + $this->markTestSkipped( 'Orphan adapter not yet implemented' ); $this->markTestSkipped( 'OrderStatus not yet implemented' ); $this->setMwGlobals( array( 'wgDonationInterfaceEnableCustomFilters' => true, -- To view, visit https://gerrit.wikimedia.org/r/379440 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Icfb5e193f48a0160fb469d7fdd84a5dbbb8646fe Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/DonationInterface Gerrit-Branch: master Gerrit-Owner: Ejegg <ej...@ejegg.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits