Ejegg has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/366013 )
Change subject: Merge branch 'master' into deployment ...................................................................... Merge branch 'master' into deployment 9305f7662 Localisation updates from https://translatewiki.net. b6eb7d3c6 Localisation updates from https://translatewiki.net. 153e676ff PayPal EC: use ajax to get redirect URL a4534c043 Localisation updates from https://translatewiki.net. c3d44f0d9 Common setup for donation API tests, add one for PayPal EC 0755c651e Localisation updates from https://translatewiki.net. 7f179918c Leave form disabled while redirecting to PayPal EC Change-Id: Iaa6e901006f65ad1f5b0aa8d02a89e0552a7d0fc --- D tests/phpunit/Adapter/Amazon/AmazonApiTest.php D tests/phpunit/Adapter/GlobalCollect/GlobalCollectApiTest.php D tests/phpunit/Adapter/PayPal/PayPalApiTest.php D tests/phpunit/DonationInterfaceApiTestCase.php D tests/phpunit/includes/test_gateway/TestingGlobalCollectAdapter.php 5 files changed, 0 insertions(+), 314 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface refs/changes/13/366013/1 diff --git a/tests/phpunit/Adapter/Amazon/AmazonApiTest.php b/tests/phpunit/Adapter/Amazon/AmazonApiTest.php deleted file mode 100644 index 2717faa..0000000 --- a/tests/phpunit/Adapter/Amazon/AmazonApiTest.php +++ /dev/null @@ -1,59 +0,0 @@ -<<<<<<< HEAD (9bcbec Merge branch 'master' into deployment) -======= -<?php -use SmashPig\Tests\TestingContext; -use SmashPig\Tests\TestingGlobalConfiguration; - -/** - * @group Amazon - * @group DonationInterface - * @group DonationInterfaceApi - * @group Fundraising - * @group medium - */ -class AmazonApiTest extends DonationInterfaceApiTestCase { - public function setUp() { - parent::setUp(); - TestingAmazonAdapter::$mockClient = new MockAmazonClient(); - } - - public function tearDown() { - TestingAmazonAdapter::$mockClient = null; - parent::tearDown(); - } - - public function testDoPaymentSuccess() { - $params = array( - 'amount' => '1.55', - 'currency' => 'USD', - 'recurring' => '0', - 'wmf_token' => 'e601502632e5e51dc2a17a0045162272+\\', - 'orderReferenceId' => mt_rand( 0, 10000000 ), - 'action' => 'di_amazon_bill', - ); - $session = array( - 'Donor' => array( - 'amount' => '1.55', - 'currency' => 'USD', - 'recurring' => '0', - 'contribution_tracking_id' => mt_rand( 0, 10000000 ), - 'country' => 'US', - ), - 'amazonEditToken' => 'kjaskdjahsdkjsad', - ); - $apiResult = $this->doApiRequest( $params, $session ); - $redirect = $apiResult[0]['redirect']; - $this->assertEquals( 'https://wikimediafoundation.org/wiki/Thank_You/en?country=US', $redirect ); - $mockClient = TestingAmazonAdapter::$mockClient; - $setOrderReferenceDetailsArgs = $mockClient->calls['setOrderReferenceDetails'][0]; - $oid = $session['Donor']['contribution_tracking_id'] . '-0'; - $this->assertEquals( $oid, $setOrderReferenceDetailsArgs['seller_order_id'], 'Did not set order id on order reference' ); - $this->assertEquals( $params['amount'], $setOrderReferenceDetailsArgs['amount'], 'Did not set amount on order reference' ); - - $this->assertEquals( $params['currency'], $setOrderReferenceDetailsArgs['currency_code'], 'Did not set currency code on order reference' ); - $message = DonationQueue::instance()->pop( 'donations' ); - $this->assertNotNull( $message, 'Not sending a message to the donations queue' ); - $this->assertEquals( 'S01-0391295-0674065-C095112', $message['gateway_txn_id'], 'Queue message has wrong txn ID' ); - } -} ->>>>>>> BRANCH (7f1799 Leave form disabled while redirecting to PayPal EC) diff --git a/tests/phpunit/Adapter/GlobalCollect/GlobalCollectApiTest.php b/tests/phpunit/Adapter/GlobalCollect/GlobalCollectApiTest.php deleted file mode 100644 index 84a18a1..0000000 --- a/tests/phpunit/Adapter/GlobalCollect/GlobalCollectApiTest.php +++ /dev/null @@ -1,62 +0,0 @@ -<<<<<<< HEAD (9bcbec Merge branch 'master' into deployment) -======= -<?php -use SmashPig\CrmLink\Messages\SourceFields; - -/** - * @group Fundraising - * @group DonationInterface - * @group GlobalCollect - * @group GlobalCollectApi - * @group DonationInterfaceApi - * @group medium - */ -class GlobalCollectApiTest extends DonationInterfaceApiTestCase { - - public function testGoodSubmit() { - $init = DonationInterfaceTestCase::getDonorTestData(); - $init['email'] = 'g...@innocent.com'; - $init['payment_method'] = 'cc'; - $init['gateway'] = 'globalcollect'; - $init['action'] = 'donate'; - - $apiResult = $this->doApiRequest( $init ); - $result = $apiResult[0]['result']; - $orderId = $result['orderid']; - - $this->assertEquals( 'url_placeholder', $result['formaction'], 'GC API not setting formaction' ); - $this->assertTrue( is_numeric( $orderId ), 'GC API not setting numeric order ID' ); - $this->assertTrue( $result['status'], 'GC API result status should be true' ); - preg_match( "/Special:GlobalCollectGatewayResult\?order_id={$orderId}\$/", $result['returnurl'], $match ); - $this->assertNotEmpty( $match, 'GC API not setting proper return url' ); - $message = DonationQueue::instance()->pop( 'pending' ); - $this->assertNotNull( $message, 'Not sending a message to the pending queue' ); - SourceFields::removeFromMessage( $message ); - $expected = array( - 'gateway_txn_id' => '626113410', - 'response' => 'Response Status: 20', - 'gateway_account' => 'test', - 'fee' => 0, - 'utm_source' => '..cc', - 'language' => 'en', - 'email' => 'g...@innocent.com', - 'first_name' => 'Firstname', - 'last_name' => 'Surname', - 'country' => 'US', - 'gateway' => 'globalcollect', - 'order_id' => '626113410', - 'recurring' => '', - 'payment_method' => 'cc', - 'payment_submethod' => '', - 'currency' => 'USD', - 'gross' => '1.55', - 'user_ip' => '127.0.0.1', - 'street_address' => '123 Fake Street', - 'city' => 'San Francisco', - 'state_province' => 'CA', - 'postal_code' => '94105' - ); - $this->assertArraySubset( $expected, $message ); - } -} ->>>>>>> BRANCH (7f1799 Leave form disabled while redirecting to PayPal EC) diff --git a/tests/phpunit/Adapter/PayPal/PayPalApiTest.php b/tests/phpunit/Adapter/PayPal/PayPalApiTest.php deleted file mode 100644 index 86d76ed..0000000 --- a/tests/phpunit/Adapter/PayPal/PayPalApiTest.php +++ /dev/null @@ -1,47 +0,0 @@ -<?php -use SmashPig\PaymentProviders\PayPal\Tests\PayPalTestConfiguration; -use SmashPig\Tests\TestingContext; - -/** - * @group Fundraising - * @group DonationInterface - * @group PayPal - * @group DonationInterfaceApi - * @group medium - */ -class PayPalApiTest extends DonationInterfaceApiTestCase { - - public function setUp() { - parent::setUp(); - $ctx = TestingContext::get(); - $ctx->providerConfigurationOverride = PayPalTestConfiguration::get( - $ctx->getGlobalConfiguration() - ); - $this->setMwGlobals( array( - 'wgDonationInterfaceCancelPage' => 'https://example.com/tryAgain.php', - 'wgPaypalExpressGatewayEnabled' => true, - 'wgDonationInterfaceThankYouPage' => 'https://example.org/wiki/Thank_You', - ) ); - } - - public function testGoodSubmit() { - $init = array( - 'amount' => 1.55, - 'currency' => 'USD', - 'payment_method' => 'paypal', - 'utm_source' => 'CD1234_FR', - 'utm_medium' => 'sitenotice', - 'country' => 'US', - 'contribution_tracking_id' => strval( mt_rand() ), - 'language' => 'fr', - ); - $init['gateway'] = 'paypal_ec'; - $init['action'] = 'donate'; - - $apiResult = $this->doApiRequest( $init ); - $result = $apiResult[0]['result']; - $expectedUrl = 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-8US12345X1234567U'; - $this->assertEquals( $expectedUrl, $result['formaction'], 'PayPal Express API not setting formaction' ); - $this->assertTrue( $result['status'], 'PayPal Express result status should be true' ); - } -} diff --git a/tests/phpunit/DonationInterfaceApiTestCase.php b/tests/phpunit/DonationInterfaceApiTestCase.php deleted file mode 100644 index d50ec00..0000000 --- a/tests/phpunit/DonationInterfaceApiTestCase.php +++ /dev/null @@ -1,26 +0,0 @@ -<?php - -use SmashPig\Core\Context; -use SmashPig\Tests\TestingContext; -use SmashPig\Tests\TestingGlobalConfiguration; - -class DonationInterfaceApiTestCase extends ApiTestCase { - - public function setUp() { - parent::setUp(); - $config = TestingGlobalConfiguration::create(); - TestingContext::init( $config ); - $this->setMwGlobals( array( - 'wgDonationInterfaceEnableQueue' => true, - 'wgDonationInterfaceDefaultQueueServer' => array( - 'type' => 'TestingQueue', - ), - ) ); - } - - public function tearDown() { - parent::tearDown(); - Context::set( null ); - TestingQueue::clearAll(); - } -} diff --git a/tests/phpunit/includes/test_gateway/TestingGlobalCollectAdapter.php b/tests/phpunit/includes/test_gateway/TestingGlobalCollectAdapter.php deleted file mode 100644 index c9079b6..0000000 --- a/tests/phpunit/includes/test_gateway/TestingGlobalCollectAdapter.php +++ /dev/null @@ -1,120 +0,0 @@ -<<<<<<< HEAD (9bcbec 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 $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(); - } - - /** - * 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 (7f1799 Leave form disabled while redirecting to PayPal EC) -- To view, visit https://gerrit.wikimedia.org/r/366013 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iaa6e901006f65ad1f5b0aa8d02a89e0552a7d0fc Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/DonationInterface Gerrit-Branch: deployment Gerrit-Owner: Ejegg <ej...@ejegg.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits