Index: branches/fundraising/extensions/DonationInterface/tests/Adapter/GatewayAdapterTestCase.php |
— | — | @@ -39,7 +39,10 @@ |
40 | 40 | */ |
41 | 41 | class DonationInterface_Adapter_GatewayAdapterTestCase extends DonationInterfaceTestCase { |
42 | 42 | |
43 | | - function testbuildRequestXML() { |
| 43 | + /** |
| 44 | + * |
| 45 | + */ |
| 46 | + public function testbuildRequestXML() { |
44 | 47 | $gateway = new TestAdapter(); |
45 | 48 | $gateway->publicCurrentTransaction( 'Test1' ); |
46 | 49 | $built = $gateway->buildRequestXML(); |
— | — | @@ -49,13 +52,19 @@ |
50 | 53 | |
51 | 54 | } |
52 | 55 | |
53 | | - function testParseResponseStatusXML() { |
| 56 | + /** |
| 57 | + * |
| 58 | + */ |
| 59 | + public function testParseResponseStatusXML() { |
54 | 60 | |
55 | 61 | $returned = $this->getTestGatewayTransactionTest2Results(); |
56 | 62 | $this->assertEquals($returned['status'], true, "Status should be true at this point."); |
57 | 63 | } |
58 | 64 | |
59 | | - function testParseResponseErrorsXML() { |
| 65 | + /** |
| 66 | + * |
| 67 | + */ |
| 68 | + public function testParseResponseErrorsXML() { |
60 | 69 | |
61 | 70 | $returned = $this->getTestGatewayTransactionTest2Results(); |
62 | 71 | $expected_errors = array( |
— | — | @@ -66,7 +75,10 @@ |
67 | 76 | |
68 | 77 | } |
69 | 78 | |
70 | | - function testParseResponseDataXML() { |
| 79 | + /** |
| 80 | + * |
| 81 | + */ |
| 82 | + public function testParseResponseDataXML() { |
71 | 83 | |
72 | 84 | $returned = $this->getTestGatewayTransactionTest2Results(); |
73 | 85 | $expected_data = array( |
— | — | @@ -77,14 +89,20 @@ |
78 | 90 | |
79 | 91 | } |
80 | 92 | |
81 | | - function testResponseMessage() { |
| 93 | + /** |
| 94 | + * |
| 95 | + */ |
| 96 | + public function testResponseMessage() { |
82 | 97 | |
83 | 98 | $returned = $this->getTestGatewayTransactionTest2Results(); |
84 | 99 | $this->assertEquals($returned['message'], "Test2 Transaction Successful!", "Expected message was not returned."); |
85 | 100 | |
86 | 101 | } |
87 | 102 | |
88 | | - function testGetGlobal(){ |
| 103 | + /** |
| 104 | + * |
| 105 | + */ |
| 106 | + public function testGetGlobal(){ |
89 | 107 | $gateway = new TestAdapter(); |
90 | 108 | $found = $gateway::getGlobal("TestVar"); |
91 | 109 | $expected = "Hi there!"; |
— | — | @@ -92,13 +110,19 @@ |
93 | 111 | } |
94 | 112 | |
95 | 113 | |
96 | | - function getTestGatewayTransactionTest2Results(){ |
| 114 | + /** |
| 115 | + * |
| 116 | + */ |
| 117 | + public function getTestGatewayTransactionTest2Results(){ |
97 | 118 | $gateway = new TestAdapter(); |
98 | 119 | return $gateway->do_transaction( 'Test2' ); |
99 | 120 | } |
100 | 121 | |
101 | 122 | } |
102 | 123 | |
| 124 | +/** |
| 125 | + * Test Adapter |
| 126 | + */ |
103 | 127 | class TestAdapter extends GatewayAdapter { |
104 | 128 | |
105 | 129 | const GATEWAY_NAME = 'Test Gateway'; |
— | — | @@ -106,12 +130,18 @@ |
107 | 131 | const COMMUNICATION_TYPE = 'xml'; |
108 | 132 | const GLOBAL_PREFIX = 'wgTestAdapterGateway'; |
109 | 133 | |
110 | | - function stageData( $type = 'request' ){ |
| 134 | + /** |
| 135 | + * |
| 136 | + */ |
| 137 | + public function stageData( $type = 'request' ){ |
111 | 138 | $this->postdata['amount'] = $this->postdata['amount'] * 1000; |
112 | 139 | $this->postdata['name'] = $this->postdata['fname'] . " " . $this->postdata['lname']; |
113 | 140 | } |
114 | 141 | |
115 | | - function __construct( ) { |
| 142 | + /** |
| 143 | + * |
| 144 | + */ |
| 145 | + public function __construct( ) { |
116 | 146 | global $wgTestAdapterGatewayTestVar, $wgTestAdapterGatewayUseSyslog, $wgTestAdapterGatewayTest; |
117 | 147 | $wgTestAdapterGatewayTest = true; |
118 | 148 | $wgTestAdapterGatewayTestVar = "Hi there!"; |
— | — | @@ -120,7 +150,10 @@ |
121 | 151 | |
122 | 152 | } |
123 | 153 | |
124 | | - function defineAccountInfo(){ |
| 154 | + /** |
| 155 | + * |
| 156 | + */ |
| 157 | + public function defineAccountInfo(){ |
125 | 158 | $this->accountInfo = array( |
126 | 159 | 'MERCHANTID' => '128', |
127 | 160 | 'PASSWORD' => 'k4ftw', |
— | — | @@ -129,10 +162,16 @@ |
130 | 163 | ); |
131 | 164 | } |
132 | 165 | |
133 | | - function defineStagedVars(){ |
| 166 | + /** |
| 167 | + * |
| 168 | + */ |
| 169 | + public function defineStagedVars(){ |
134 | 170 | } |
135 | 171 | |
136 | | - function defineVarMap(){ |
| 172 | + /** |
| 173 | + * |
| 174 | + */ |
| 175 | + public function defineVarMap(){ |
137 | 176 | $this->var_map = array( |
138 | 177 | 'DONOR' => 'name', |
139 | 178 | 'AMOUNT' => 'amount', |
— | — | @@ -144,14 +183,20 @@ |
145 | 184 | ); |
146 | 185 | } |
147 | 186 | |
148 | | - function defineReturnValueMap(){ |
| 187 | + /** |
| 188 | + * |
| 189 | + */ |
| 190 | + public function defineReturnValueMap(){ |
149 | 191 | $this->return_value_map = array( |
150 | 192 | 'AOK' => true, |
151 | 193 | 'WRONG' => false, |
152 | 194 | ); |
153 | 195 | } |
154 | 196 | |
155 | | - function defineTransactions(){ |
| 197 | + /** |
| 198 | + * |
| 199 | + */ |
| 200 | + public function defineTransactions(){ |
156 | 201 | $this->transactions = array(); |
157 | 202 | |
158 | 203 | $this->transactions['Test1'] = array( |
— | — | @@ -196,7 +241,7 @@ |
197 | 242 | * For instance: If it's XML, we only want correctly-formatted XML. Headers must be killed off. |
198 | 243 | * return a string. |
199 | 244 | */ |
200 | | - function getFormattedResponse( $rawResponse ){ |
| 245 | + public function getFormattedResponse( $rawResponse ){ |
201 | 246 | $xmlString = $this->stripXMLResponseHeaders($rawResponse); |
202 | 247 | $displayXML = $this->formatXmlString( $xmlString ); |
203 | 248 | $realXML = new DomDocument( '1.0' ); |
— | — | @@ -208,7 +253,7 @@ |
209 | 254 | /** |
210 | 255 | * Parse the response to get the status. Not sure if this should return a bool, or something more... telling. |
211 | 256 | */ |
212 | | - function getResponseStatus( $response ){ |
| 257 | + public function getResponseStatus( $response ){ |
213 | 258 | |
214 | 259 | $aok = true; |
215 | 260 | |
— | — | @@ -225,7 +270,7 @@ |
226 | 271 | * Parse the response to get the errors in a format we can log and otherwise deal with. |
227 | 272 | * return a key/value array of codes (if they exist) and messages. |
228 | 273 | */ |
229 | | - function getResponseErrors( $response ){ |
| 274 | + public function getResponseErrors( $response ){ |
230 | 275 | $errors = array(); |
231 | 276 | foreach ( $response->getElementsByTagName( 'warning' ) as $node ) { |
232 | 277 | $code = ''; |
— | — | @@ -247,7 +292,7 @@ |
248 | 293 | * Harvest the data we need back from the gateway. |
249 | 294 | * return a key/value array |
250 | 295 | */ |
251 | | - function getResponseData( $response ){ |
| 296 | + public function getResponseData( $response ){ |
252 | 297 | $data = array(); |
253 | 298 | foreach ( $response->getElementsByTagName( 'ImportantData' ) as $node ) { |
254 | 299 | foreach ( $node->childNodes as $childnode ) { |
— | — | @@ -260,19 +305,18 @@ |
261 | 306 | return $data; |
262 | 307 | } |
263 | 308 | |
264 | | - function processResponse( $response ) { |
| 309 | + public function processResponse( $response ) { |
265 | 310 | //TODO: Stuff. |
266 | 311 | } |
267 | 312 | |
268 | | - function publicCurrentTransaction( $transaction = '' ){ |
| 313 | + public function publicCurrentTransaction( $transaction = '' ){ |
269 | 314 | $this->currentTransaction( $transaction ); |
270 | 315 | } |
271 | 316 | |
272 | | - function curl_transaction($data) { |
| 317 | + public function curl_transaction($data) { |
273 | 318 | $data = ""; |
274 | 319 | $data['result'] = 'BLAH BLAH BLAH BLAH whatever something blah blah<?xml version="1.0"?>' . "\n" . '<XML><Response><Status>AOK</Status><ImportantData><thing>stuff</thing><otherthing>12</otherthing></ImportantData><errorswarnings><warning><code>128</code><message>Your shoe\'s untied...</message></warning><warning><code>45</code><message>Low clearance!</message></warning></errorswarnings></Response></XML>'; |
275 | 320 | return $data; |
276 | 321 | } |
277 | 322 | } |
278 | 323 | |
279 | | -?> |