r100819 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100818‎ | r100819 | r100820 >
Date:16:15, 26 October 2011
Author:jpostlethwaite
Status:deferred
Tags:fundraising 
Comment:
Setup unit test for Bank Transfer.
Modified paths:
  • /trunk/extensions/DonationInterface/tests/Adapter/GlobalCollect/BankTransferTestCase.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/tests/Adapter/GlobalCollect/BankTransferTestCase.php
@@ -36,121 +36,23 @@
3737 /**
3838 * testBuildRequestXml
3939 *
40 - * @todo
41 - * - there are many cases to this that need to be developed.
42 - * - Do not consider this a complete test!
43 - *
4440 * @covers GatewayAdapter::__construct
4541 * @covers GatewayAdapter::currentTransaction
4642 * @covers GatewayAdapter::buildRequestXML
4743 * @covers GatewayAdapter::getData
4844 */
4945 public function testBuildRequestXml() {
50 -
51 - global $wgGlobalCollectGatewayTest;
52 -
53 - $wgGlobalCollectGatewayTest = true;
54 -
55 - $_SERVER = array();
56 -
57 - $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
58 - $_SERVER['HTTP_HOST'] = TESTS_HOSTNAME;
59 - $_SERVER['SERVER_NAME'] = TESTS_HOSTNAME;
60 - $_SERVER['REQUEST_URI'] = '/index.php/Special:GlobalCollectGateway?form_name=TwoStepAmount';
61 -
62 - $payment_product_id = 11;
6346
6447 $optionsForTestData = array(
6548 'form_name' => 'TwoStepAmount',
6649 'payment_method' => 'bt',
6750 'payment_submethod' => 'bt',
 51+ 'payment_product_id' => 11,
6852 );
6953
7054 $options = $this->getGatewayAdapterTestDataFromSpain( $optionsForTestData );
71 -
72 - $gateway = new GlobalCollectAdapter( $options );
7355
74 - $gateway->currentTransaction('INSERT_ORDERWITHPAYMENT');
75 -
76 - $request = trim( $gateway->buildRequestXML() );
77 -
78 - $orderId = $gateway->getData( 'order_id' );
79 -
80 - $expected = '<?xml version="1.0"?>' . "\n";
81 - $expected .= '<XML>';
82 - $expected .= '<REQUEST>';
83 - $expected .= '<ACTION>INSERT_ORDERWITHPAYMENT</ACTION>';
84 - $expected .= '<META><MERCHANTID>' . $gateway->getGatewayMerchantId() . '</MERCHANTID><VERSION>1.0</VERSION></META>';
85 - $expected .= '<PARAMS>';
86 - $expected .= '<ORDER>';
87 - $expected .= '<ORDERID>' . $orderId . '</ORDERID>';
88 - $expected .= '<AMOUNT>' . $options['testData']['amount'] * 100 . '</AMOUNT>';
89 - $expected .= '<CURRENCYCODE>' . $options['testData']['currency'] . '</CURRENCYCODE>';
90 - $expected .= '<LANGUAGECODE>' . $options['testData']['language'] . '</LANGUAGECODE>';
91 - $expected .= '<COUNTRYCODE>' . $options['testData']['country'] . '</COUNTRYCODE>';
92 - $expected .= '<MERCHANTREFERENCE>' . $orderId . '</MERCHANTREFERENCE>';
93 - $expected .= '</ORDER>';
94 - $expected .= '<PAYMENT>';
95 - $expected .= '<PAYMENTPRODUCTID>' . $payment_product_id . '</PAYMENTPRODUCTID>';
96 - $expected .= '<AMOUNT>' . $options['testData']['amount'] * 100 . '</AMOUNT>';
97 - $expected .= '<CURRENCYCODE>' . $options['testData']['currency'] . '</CURRENCYCODE>';
98 - $expected .= '<LANGUAGECODE>' . $options['testData']['language'] . '</LANGUAGECODE>';
99 - $expected .= '<COUNTRYCODE>' . $options['testData']['country'] . '</COUNTRYCODE>';
100 - $expected .= '<HOSTEDINDICATOR>1</HOSTEDINDICATOR>';
101 - $expected .= '<RETURNURL>http://' . TESTS_HOSTNAME . '/index.php/Special:GlobalCollectGatewayResult?order_id=' . $orderId . '</RETURNURL>';
102 - $expected .= '<FIRSTNAME>' . $options['testData']['fname'] . '</FIRSTNAME>';
103 - $expected .= '<SURNAME>' . $options['testData']['lname'] . '</SURNAME>';
104 - $expected .= '<STREET>' . $options['testData']['street'] . '</STREET>';
105 - $expected .= '<CITY>' . $options['testData']['city'] . '</CITY>';
106 - $expected .= '<STATE>' . $options['testData']['state'] . '</STATE>';
107 - $expected .= '<EMAIL>' . TESTS_EMAIL . '</EMAIL>';
108 - $expected .= '</PAYMENT>';
109 - $expected .= '</PARAMS>';
110 - $expected .= '</REQUEST>';
111 - $expected .= '</XML>';
112 -
113 - $this->assertEquals($expected, $request, 'The constructed XML for paymentmethod [' . $optionsForTestData['payment_method'] . '] does not match our expected.');
 56+ $this->buildRequestXmlForGlobalCollect( $optionsForTestData, $options );
11457 }
115 -
116 - /**
117 - * testSendToGlobalCollect
118 - *
119 - * Adding
120 - * @covers GatewayAdapter::__construct
121 - * @covers GatewayAdapter::currentTransaction
122 - * @covers GatewayAdapter::do_transaction
123 - * @covers GatewayAdapter::buildRequestXML
124 - * @covers GatewayAdapter::getData
125 - */
126 - public function testSendToGlobalCollect() {
127 - $this->markTestIncomplete( TESTS_MESSAGE_NOT_IMPLEMENTED );
128 -
129 - global $wgGlobalCollectGatewayTest;
130 -
131 - $wgGlobalCollectGatewayTest = true;
132 -
133 - $_SERVER = array();
134 -
135 - $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
136 - $_SERVER['HTTP_HOST'] = TESTS_HOSTNAME;
137 - $_SERVER['SERVER_NAME'] = TESTS_HOSTNAME;
138 - $_SERVER['REQUEST_URI'] = '/index.php/Special:GlobalCollectGateway?form_name=TwoStepAmount';
139 -
140 - $payment_product_id = 11;
141 -
142 - $optionsForTestData = array(
143 - 'form_name' => 'TwoStepAmount',
144 - 'payment_method' => 'bt',
145 - 'payment_submethod' => 'bt',
146 - );
147 -
148 - $options = $this->getGatewayAdapterTestDataFromSpain( $optionsForTestData );
149 -
150 - $gateway = new GlobalCollectAdapter( $options );
151 - $result = $gateway->do_transaction( $transactionType );
152 -
153 - // This will never assert to true. Another type of assertion will be necessary.
154 - $this->assertTrue( $result );
155 - }
15658 }
15759

Follow-up revisions

RevisionCommit summaryAuthorDate
r100820Setup unit test for Real Time Bank Transfer: epsjpostlethwaite16:17, 26 October 2011
r100821Setup unit test for Real Time Bank Transfer: eNETSjpostlethwaite16:19, 26 October 2011
r100822Setup unit test for Real Time Bank Transfer: Idealjpostlethwaite16:20, 26 October 2011
r100823Setup unit test for Real Time Bank Transfer: NordeaSweedenjpostlethwaite16:21, 26 October 2011
r100824Setup unit test for Real Time Bank Transfer: Sofortuberweisungjpostlethwaite16:23, 26 October 2011
r100825Updating unit test AllTests for GlobalCollect Adapter. Updated @since tags, r...jpostlethwaite16:29, 26 October 2011

Status & tagging log