Index: trunk/extensions/DonationInterface/tests/DonationInterfaceTestCase.php |
— | — | @@ -41,6 +41,35 @@ |
42 | 42 | * @var GatewayAdapter $gatewayAdapter |
43 | 43 | */ |
44 | 44 | 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 | + } |
45 | 74 | |
46 | 75 | /** |
47 | 76 | * This fetches test data to be used for gateway adapters. |
— | — | @@ -211,7 +240,6 @@ |
212 | 241 | return $return; |
213 | 242 | } |
214 | 243 | |
215 | | - |
216 | 244 | /** |
217 | 245 | * This fetches test data to be used for gateway adapters. |
218 | 246 | * |
— | — | @@ -265,12 +293,6 @@ |
266 | 294 | $expected .= '</ORDER>'; |
267 | 295 | $expected .= '<PAYMENT>'; |
268 | 296 | $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 | | - |
275 | 297 | $expected .= '<AMOUNT>' . $options['testData']['amount'] * 100 . '</AMOUNT>'; |
276 | 298 | $expected .= '<CURRENCYCODE>' . $options['testData']['currency'] . '</CURRENCYCODE>'; |
277 | 299 | $expected .= '<LANGUAGECODE>' . $options['testData']['language'] . '</LANGUAGECODE>'; |
— | — | @@ -283,6 +305,12 @@ |
284 | 306 | $expected .= '<CITY>' . $options['testData']['city'] . '</CITY>'; |
285 | 307 | $expected .= '<STATE>' . $options['testData']['state'] . '</STATE>'; |
286 | 308 | $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 | + |
287 | 315 | $expected .= '</PAYMENT>'; |
288 | 316 | $expected .= '</PARAMS>'; |
289 | 317 | $expected .= '</REQUEST>'; |