Index: trunk/extensions/DonationInterface/tests/Adapter/GlobalCollect/BankTransferTestCase.php |
— | — | @@ -33,51 +33,19 @@ |
34 | 34 | */ |
35 | 35 | class DonationInterface_Adapter_GlobalCollect_BankTransferTestCase extends DonationInterfaceTestCase { |
36 | 36 | |
37 | | - /* |
38 | | - Acceptance Criteria |
39 | | - 308.1 *Given that a donor wants to donate via an offline bank transfer |
40 | | - When they submit the following information: |
41 | | - Amount |
42 | | - Country (Required – use ISO 3166 codes) |
43 | | - First Name |
44 | | - Surname |
45 | | - Street Address |
46 | | - Zip |
47 | | - City |
48 | | - State (optional) |
49 | | - Then an XML submission is created and sent to Global Collect with the above information AND: |
50 | | - MERCHANTREFERENCE (contribution tracking id) |
51 | | - curencycode |
52 | | - 308.2 |
53 | | - GIven that a donation order was submitted with the above information |
54 | | - When the submit button is pressed and a response recieved from Global Collect |
55 | | - The response is parased and the following information is displayed to the donor: |
56 | | - PAYMENTREFERENCE |
57 | | - Account Holder |
58 | | - Bank Name |
59 | | - City |
60 | | - Swift Code |
61 | | - SpecialID (if provided) |
62 | | - Bank Account Number |
63 | | - IBAN |
64 | | - CountryDescription |
65 | | - Notes |
66 | | - We do not need to have donor information stored on our side yet as long as it is sent to Global Collect |
67 | | - */ |
68 | | - |
69 | 37 | /** |
70 | | - * testbuildRequestXML |
| 38 | + * testBuildRequestXml |
71 | 39 | * |
72 | 40 | * @todo |
73 | 41 | * - there are many cases to this that need to be developed. |
74 | 42 | * - Do not consider this a complete test! |
75 | 43 | * |
76 | 44 | * @covers GatewayAdapter::__construct |
77 | | - * @covers GatewayAdapter::do_transaction |
| 45 | + * @covers GatewayAdapter::currentTransaction |
78 | 46 | * @covers GatewayAdapter::buildRequestXML |
79 | 47 | * @covers GatewayAdapter::getData |
80 | 48 | */ |
81 | | - public function testbuildRequestXML() { |
| 49 | + public function testBuildRequestXml() { |
82 | 50 | |
83 | 51 | global $wgGlobalCollectGatewayTest; |
84 | 52 | |
— | — | @@ -90,91 +58,69 @@ |
91 | 59 | $_SERVER['SERVER_NAME'] = TESTS_HOSTNAME; |
92 | 60 | $_SERVER['REQUEST_URI'] = '/index.php/Special:GlobalCollectGateway?form_name=TwoStepAmount'; |
93 | 61 | |
94 | | - |
95 | | - $options = array(); |
96 | | - |
97 | | - $options['test'] = true; |
98 | | - $transactionType = 'BANK_TRANSFER'; |
99 | | - |
100 | | - $amount = 350; |
101 | | - |
102 | | - $options['postDefaults'] = array( |
103 | | - 'returnTitle' => true, |
104 | | - 'returnTo' => 'http://' . TESTS_HOSTNAME . '/index.php/Special:GlobalCollectGatewayResult', |
| 62 | + $payment_product_id = 11; |
| 63 | + |
| 64 | + $optionsForTestData = array( |
| 65 | + 'form_name' => 'TwoStepAmount', |
| 66 | + 'payment_method' => 'bt', |
| 67 | + 'payment_submethod' => 'bt', |
105 | 68 | ); |
106 | 69 | |
107 | | - $options['testData'] = array( |
108 | | - 'amount' => $amount, |
109 | | - 'transaction_type' => $transactionType, |
110 | | - 'email' => TESTS_EMAIL, |
111 | | - 'fname' => 'Testy', |
112 | | - 'lname' => 'Testerton', |
113 | | - 'street' => '123 Happy Street', |
114 | | - 'city' => 'Barcelona', |
115 | | - 'state' => 'XX', |
116 | | - 'zip' => '', |
117 | | - 'country' => 'ES', |
118 | | - //'size' => 'small', |
119 | | - 'currency' => 'EUR', |
120 | | - 'payment_method' => '', |
121 | | - //'order_id' => '5038287830', |
122 | | - //'i_order_id' => '1234567890', |
123 | | - 'numAttempt' => 0, |
124 | | - 'referrer' => 'http://' . TESTS_HOSTNAME . '/index.php/Special:GlobalCollectGateway?form_name=TwoStepAmount', |
125 | | - 'utm_source' => '..gc_bt', |
126 | | - 'utm_medium' => null, |
127 | | - 'utm_campaign' => null, |
128 | | - 'language' => 'en', |
129 | | - 'comment-option' => '', |
130 | | - 'comment' => '', |
131 | | - 'email-opt' => 1, |
132 | | - 'test_string' => '', |
133 | | - 'token' => '', |
134 | | - 'contribution_tracking_id' => '', |
135 | | - 'data_hash' => '', |
136 | | - 'action' => '', |
137 | | - 'gateway' => 'globalcollect', |
138 | | - 'owa_session' => '', |
139 | | - 'owa_ref' => 'http://localhost/defaultTestData', |
140 | | - 'transaction_type' => '', // Used by GlobalCollect for payment types |
141 | | - ); |
142 | | - |
| 70 | + $options = $this->getGatewayAdapterTestDataFromSpain( $optionsForTestData ); |
| 71 | + |
143 | 72 | $gateway = new GlobalCollectAdapter( $options ); |
144 | 73 | |
145 | | - $result = $gateway->do_transaction( $transactionType ); |
| 74 | + $gateway->currentTransaction('INSERT_ORDERWITHPAYMENT'); |
146 | 75 | |
147 | 76 | $request = trim( $gateway->buildRequestXML() ); |
148 | 77 | |
149 | 78 | $orderId = $gateway->getData( 'order_id' ); |
150 | 79 | |
151 | 80 | $expected = '<?xml version="1.0"?>' . "\n"; |
152 | | - $expected .= '<XML><REQUEST><ACTION>INSERT_ORDERWITHPAYMENT</ACTION><META><MERCHANTID>6570</MERCHANTID><VERSION>1.0</VERSION></META><PARAMS><ORDER><ORDERID>' . $orderId . '</ORDERID><AMOUNT>' . $amount * 100 . '</AMOUNT><CURRENCYCODE>EUR</CURRENCYCODE><LANGUAGECODE>en</LANGUAGECODE><COUNTRYCODE>ES</COUNTRYCODE><MERCHANTREFERENCE>' . $orderId . '</MERCHANTREFERENCE></ORDER><PAYMENT><PAYMENTPRODUCTID>11</PAYMENTPRODUCTID><AMOUNT>35000</AMOUNT><CURRENCYCODE>EUR</CURRENCYCODE><LANGUAGECODE>en</LANGUAGECODE><COUNTRYCODE>ES</COUNTRYCODE><HOSTEDINDICATOR>1</HOSTEDINDICATOR><RETURNURL>http://wikimedia-fundraising-1.17.localhost.wikimedia.org/index.php/Special:GlobalCollectGatewayResult?order_id=' . $orderId . '</RETURNURL><FIRSTNAME>Testy</FIRSTNAME><SURNAME>Testerton</SURNAME><STREET>123 Happy Street</STREET><CITY>Barcelona</CITY><STATE>XX</STATE><EMAIL>jpostlethwaite@wikimedia.org</EMAIL></PAYMENT></PARAMS></REQUEST></XML>'; |
153 | | - //$expected .= '<XML><REQUEST><ACTION>Donate</ACTION><ACCOUNT><MERCHANTID>128</MERCHANTID><PASSWORD>k4ftw</PASSWORD><VERSION>3.2</VERSION><RETURNURL>http://' . TESTS_HOSTNAME . '/index.php/Donate-thanks/en</RETURNURL></ACCOUNT><DONATION><DONOR>Tester Testington</DONOR><AMOUNT>35000</AMOUNT><CURRENCYCODE>USD</CURRENCYCODE><LANGUAGECODE>en</LANGUAGECODE><COUNTRYCODE>US</COUNTRYCODE></DONATION></REQUEST></XML>' . "\n"; |
154 | | - $this->assertEquals($request, $expected, 'The constructed XML for transaction type [' . $transactionType . '] does not match our expected.'); |
| 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.'); |
155 | 114 | } |
156 | 115 | |
157 | 116 | /** |
158 | | - * testRequestHasRequiredFields |
159 | | - */ |
160 | | - public function testRequestHasRequiredFields() { |
161 | | - |
162 | | - $this->markTestIncomplete( TESTS_MESSAGE_NOT_IMPLEMENTED ); |
163 | | - |
164 | | - } |
165 | | - |
166 | | - /** |
167 | | - * testReturnDonorResponse |
168 | | - */ |
169 | | - public function testReturnDonorResponse() { |
170 | | - |
171 | | - $this->markTestIncomplete( TESTS_MESSAGE_NOT_IMPLEMENTED ); |
172 | | - |
173 | | - } |
174 | | - |
175 | | - /** |
176 | 117 | * testSendToGlobalCollect |
177 | 118 | * |
178 | 119 | * Adding |
| 120 | + * @covers GatewayAdapter::__construct |
| 121 | + * @covers GatewayAdapter::currentTransaction |
| 122 | + * @covers GatewayAdapter::do_transaction |
| 123 | + * @covers GatewayAdapter::buildRequestXML |
| 124 | + * @covers GatewayAdapter::getData |
179 | 125 | */ |
180 | 126 | public function testSendToGlobalCollect() { |
181 | 127 | $this->markTestIncomplete( TESTS_MESSAGE_NOT_IMPLEMENTED ); |
— | — | @@ -190,57 +136,20 @@ |
191 | 137 | $_SERVER['SERVER_NAME'] = TESTS_HOSTNAME; |
192 | 138 | $_SERVER['REQUEST_URI'] = '/index.php/Special:GlobalCollectGateway?form_name=TwoStepAmount'; |
193 | 139 | |
194 | | - $options = array(); |
195 | | - |
196 | | - $options['test'] = true; |
197 | | - $transactionType = 'BANK_TRANSFER'; |
198 | | - |
199 | | - $options['postDefaults'] = array( |
200 | | - 'returnTitle' => true, |
201 | | - 'returnTo' => 'http://' . TESTS_HOSTNAME . '/index.php/Special:GlobalCollectGatewayResult', |
| 140 | + $payment_product_id = 11; |
| 141 | + |
| 142 | + $optionsForTestData = array( |
| 143 | + 'form_name' => 'TwoStepAmount', |
| 144 | + 'payment_method' => 'bt', |
| 145 | + 'payment_submethod' => 'bt', |
202 | 146 | ); |
203 | 147 | |
204 | | - $amount = 350; |
| 148 | + $options = $this->getGatewayAdapterTestDataFromSpain( $optionsForTestData ); |
205 | 149 | |
206 | | - $options['testData'] = array( |
207 | | - 'amount' => $amount, |
208 | | - 'transaction_type' => $transactionType, |
209 | | - 'email' => TESTS_EMAIL, |
210 | | - 'fname' => 'Testy', |
211 | | - 'lname' => 'Testerton', |
212 | | - 'street' => '123 Happy Street', |
213 | | - 'city' => 'Barcelona', |
214 | | - 'state' => 'XX', |
215 | | - 'zip' => '', |
216 | | - 'country' => 'ES', |
217 | | - //'size' => 'small', |
218 | | - 'currency' => 'EUR', |
219 | | - 'payment_method' => '', |
220 | | - //'order_id' => '5038287830', |
221 | | - //'i_order_id' => '1234567890', |
222 | | - 'numAttempt' => 0, |
223 | | - 'referrer' => 'http://' . TESTS_HOSTNAME . '/index.php/Special:GlobalCollectGateway?form_name=TwoStepAmount', |
224 | | - 'utm_source' => '..gc_bt', |
225 | | - 'utm_medium' => null, |
226 | | - 'utm_campaign' => null, |
227 | | - 'language' => 'en', |
228 | | - 'comment-option' => '', |
229 | | - 'comment' => '', |
230 | | - 'email-opt' => 1, |
231 | | - 'test_string' => '', |
232 | | - 'token' => '', |
233 | | - 'contribution_tracking_id' => '', |
234 | | - 'data_hash' => '', |
235 | | - 'action' => '', |
236 | | - 'gateway' => 'globalcollect', |
237 | | - 'owa_session' => '', |
238 | | - 'owa_ref' => 'http://localhost/defaultTestData', |
239 | | - 'transaction_type' => '', // Used by GlobalCollect for payment types |
240 | | - ); |
241 | | - |
242 | 150 | $gateway = new GlobalCollectAdapter( $options ); |
243 | 151 | $result = $gateway->do_transaction( $transactionType ); |
244 | 152 | |
| 153 | + // This will never assert to true. Another type of assertion will be necessary. |
245 | 154 | $this->assertTrue( $result ); |
246 | 155 | } |
247 | 156 | } |