r100818 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100817‎ | r100818 | r100819 >
Date:16:13, 26 October 2011
Author:jpostlethwaite
Status:deferred
Tags:fundraising 
Comment:
Added helper method buildRequestXmlForGlobalCollect() for unit testing. Reordered expected XML parameterrs for unit test.
Modified paths:
  • /trunk/extensions/DonationInterface/tests/DonationInterfaceTestCase.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/tests/DonationInterfaceTestCase.php
@@ -41,6 +41,35 @@
4242 * @var GatewayAdapter $gatewayAdapter
4343 */
4444 protected $gatewayAdapter;
 45+
 46+ /**
 47+ * buildRequestXmlForGlobalCollect
 48+ *
 49+ * @todo
 50+ * - there are many cases to this that need to be developed.
 51+ * - Do not consider this a complete test!
 52+ *
 53+ * @covers GatewayAdapter::__construct
 54+ * @covers GatewayAdapter::currentTransaction
 55+ * @covers GatewayAdapter::buildRequestXML
 56+ * @covers GatewayAdapter::getData
 57+ */
 58+ public function buildRequestXmlForGlobalCollect( $optionsForTestData, $options ) {
 59+
 60+ global $wgGlobalCollectGatewayTest;
 61+
 62+ $wgGlobalCollectGatewayTest = true;
 63+
 64+ $this->gatewayAdapter = new GlobalCollectAdapter( $options );
 65+
 66+ $this->gatewayAdapter->currentTransaction('INSERT_ORDERWITHPAYMENT');
 67+
 68+ $request = trim( $this->gatewayAdapter->buildRequestXML() );
 69+
 70+ $expected = $this->getExpectedXmlRequestForGlobalCollect( $optionsForTestData, $options );
 71+
 72+ $this->assertEquals($expected, $request, 'The constructed XML for payment_method [' . $optionsForTestData['payment_method'] . '] and payment_submethod [' . $optionsForTestData['payment_submethod'] . '] does not match our expected request.');
 73+ }
4574
4675 /**
4776 * This fetches test data to be used for gateway adapters.
@@ -211,7 +240,6 @@
212241 return $return;
213242 }
214243
215 -
216244 /**
217245 * This fetches test data to be used for gateway adapters.
218246 *
@@ -265,12 +293,6 @@
266294 $expected .= '</ORDER>';
267295 $expected .= '<PAYMENT>';
268296 $expected .= '<PAYMENTPRODUCTID>' . $optionsForTestData['payment_product_id'] . '</PAYMENTPRODUCTID>';
269 -
270 - // Set the issuer id if it is passed.
271 - if ( isset( $optionsForTestData['issuer_id'] ) ) {
272 - $expected .= '<ISSUERID>' . $optionsForTestData['issuer_id'] . '</ISSUERID>';
273 - }
274 -
275297 $expected .= '<AMOUNT>' . $options['testData']['amount'] * 100 . '</AMOUNT>';
276298 $expected .= '<CURRENCYCODE>' . $options['testData']['currency'] . '</CURRENCYCODE>';
277299 $expected .= '<LANGUAGECODE>' . $options['testData']['language'] . '</LANGUAGECODE>';
@@ -283,6 +305,12 @@
284306 $expected .= '<CITY>' . $options['testData']['city'] . '</CITY>';
285307 $expected .= '<STATE>' . $options['testData']['state'] . '</STATE>';
286308 $expected .= '<EMAIL>' . TESTS_EMAIL . '</EMAIL>';
 309+
 310+ // Set the issuer id if it is passed.
 311+ if ( isset( $optionsForTestData['issuer_id'] ) ) {
 312+ $expected .= '<ISSUERID>' . $optionsForTestData['issuer_id'] . '</ISSUERID>';
 313+ }
 314+
287315 $expected .= '</PAYMENT>';
288316 $expected .= '</PARAMS>';
289317 $expected .= '</REQUEST>';

Status & tagging log