Index: trunk/extensions/DonationInterface/tests/Adapter/GlobalCollect/BankTransferTestCase.php |
— | — | @@ -36,121 +36,23 @@ |
37 | 37 | /** |
38 | 38 | * testBuildRequestXml |
39 | 39 | * |
40 | | - * @todo |
41 | | - * - there are many cases to this that need to be developed. |
42 | | - * - Do not consider this a complete test! |
43 | | - * |
44 | 40 | * @covers GatewayAdapter::__construct |
45 | 41 | * @covers GatewayAdapter::currentTransaction |
46 | 42 | * @covers GatewayAdapter::buildRequestXML |
47 | 43 | * @covers GatewayAdapter::getData |
48 | 44 | */ |
49 | 45 | 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; |
63 | 46 | |
64 | 47 | $optionsForTestData = array( |
65 | 48 | 'form_name' => 'TwoStepAmount', |
66 | 49 | 'payment_method' => 'bt', |
67 | 50 | 'payment_submethod' => 'bt', |
| 51 | + 'payment_product_id' => 11, |
68 | 52 | ); |
69 | 53 | |
70 | 54 | $options = $this->getGatewayAdapterTestDataFromSpain( $optionsForTestData ); |
71 | | - |
72 | | - $gateway = new GlobalCollectAdapter( $options ); |
73 | 55 | |
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 ); |
114 | 57 | } |
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 | | - } |
156 | 58 | } |
157 | 59 | |