r98269 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98268‎ | r98269 | r98270 >
Date:21:51, 27 September 2011
Author:jpostlethwaite
Status:ok
Tags:fundraising 
Comment:
Added public declaration to methods.
Modified paths:
  • /branches/fundraising/extensions/DonationInterface/tests/Adapter/GatewayAdapterTestCase.php (modified) (history)

Diff [purge]

Index: branches/fundraising/extensions/DonationInterface/tests/Adapter/GatewayAdapterTestCase.php
@@ -39,7 +39,10 @@
4040 */
4141 class DonationInterface_Adapter_GatewayAdapterTestCase extends DonationInterfaceTestCase {
4242
43 - function testbuildRequestXML() {
 43+ /**
 44+ *
 45+ */
 46+ public function testbuildRequestXML() {
4447 $gateway = new TestAdapter();
4548 $gateway->publicCurrentTransaction( 'Test1' );
4649 $built = $gateway->buildRequestXML();
@@ -49,13 +52,19 @@
5053
5154 }
5255
53 - function testParseResponseStatusXML() {
 56+ /**
 57+ *
 58+ */
 59+ public function testParseResponseStatusXML() {
5460
5561 $returned = $this->getTestGatewayTransactionTest2Results();
5662 $this->assertEquals($returned['status'], true, "Status should be true at this point.");
5763 }
5864
59 - function testParseResponseErrorsXML() {
 65+ /**
 66+ *
 67+ */
 68+ public function testParseResponseErrorsXML() {
6069
6170 $returned = $this->getTestGatewayTransactionTest2Results();
6271 $expected_errors = array(
@@ -66,7 +75,10 @@
6776
6877 }
6978
70 - function testParseResponseDataXML() {
 79+ /**
 80+ *
 81+ */
 82+ public function testParseResponseDataXML() {
7183
7284 $returned = $this->getTestGatewayTransactionTest2Results();
7385 $expected_data = array(
@@ -77,14 +89,20 @@
7890
7991 }
8092
81 - function testResponseMessage() {
 93+ /**
 94+ *
 95+ */
 96+ public function testResponseMessage() {
8297
8398 $returned = $this->getTestGatewayTransactionTest2Results();
8499 $this->assertEquals($returned['message'], "Test2 Transaction Successful!", "Expected message was not returned.");
85100
86101 }
87102
88 - function testGetGlobal(){
 103+ /**
 104+ *
 105+ */
 106+ public function testGetGlobal(){
89107 $gateway = new TestAdapter();
90108 $found = $gateway::getGlobal("TestVar");
91109 $expected = "Hi there!";
@@ -92,13 +110,19 @@
93111 }
94112
95113
96 - function getTestGatewayTransactionTest2Results(){
 114+ /**
 115+ *
 116+ */
 117+ public function getTestGatewayTransactionTest2Results(){
97118 $gateway = new TestAdapter();
98119 return $gateway->do_transaction( 'Test2' );
99120 }
100121
101122 }
102123
 124+/**
 125+ * Test Adapter
 126+ */
103127 class TestAdapter extends GatewayAdapter {
104128
105129 const GATEWAY_NAME = 'Test Gateway';
@@ -106,12 +130,18 @@
107131 const COMMUNICATION_TYPE = 'xml';
108132 const GLOBAL_PREFIX = 'wgTestAdapterGateway';
109133
110 - function stageData( $type = 'request' ){
 134+ /**
 135+ *
 136+ */
 137+ public function stageData( $type = 'request' ){
111138 $this->postdata['amount'] = $this->postdata['amount'] * 1000;
112139 $this->postdata['name'] = $this->postdata['fname'] . " " . $this->postdata['lname'];
113140 }
114141
115 - function __construct( ) {
 142+ /**
 143+ *
 144+ */
 145+ public function __construct( ) {
116146 global $wgTestAdapterGatewayTestVar, $wgTestAdapterGatewayUseSyslog, $wgTestAdapterGatewayTest;
117147 $wgTestAdapterGatewayTest = true;
118148 $wgTestAdapterGatewayTestVar = "Hi there!";
@@ -120,7 +150,10 @@
121151
122152 }
123153
124 - function defineAccountInfo(){
 154+ /**
 155+ *
 156+ */
 157+ public function defineAccountInfo(){
125158 $this->accountInfo = array(
126159 'MERCHANTID' => '128',
127160 'PASSWORD' => 'k4ftw',
@@ -129,10 +162,16 @@
130163 );
131164 }
132165
133 - function defineStagedVars(){
 166+ /**
 167+ *
 168+ */
 169+ public function defineStagedVars(){
134170 }
135171
136 - function defineVarMap(){
 172+ /**
 173+ *
 174+ */
 175+ public function defineVarMap(){
137176 $this->var_map = array(
138177 'DONOR' => 'name',
139178 'AMOUNT' => 'amount',
@@ -144,14 +183,20 @@
145184 );
146185 }
147186
148 - function defineReturnValueMap(){
 187+ /**
 188+ *
 189+ */
 190+ public function defineReturnValueMap(){
149191 $this->return_value_map = array(
150192 'AOK' => true,
151193 'WRONG' => false,
152194 );
153195 }
154196
155 - function defineTransactions(){
 197+ /**
 198+ *
 199+ */
 200+ public function defineTransactions(){
156201 $this->transactions = array();
157202
158203 $this->transactions['Test1'] = array(
@@ -196,7 +241,7 @@
197242 * For instance: If it's XML, we only want correctly-formatted XML. Headers must be killed off.
198243 * return a string.
199244 */
200 - function getFormattedResponse( $rawResponse ){
 245+ public function getFormattedResponse( $rawResponse ){
201246 $xmlString = $this->stripXMLResponseHeaders($rawResponse);
202247 $displayXML = $this->formatXmlString( $xmlString );
203248 $realXML = new DomDocument( '1.0' );
@@ -208,7 +253,7 @@
209254 /**
210255 * Parse the response to get the status. Not sure if this should return a bool, or something more... telling.
211256 */
212 - function getResponseStatus( $response ){
 257+ public function getResponseStatus( $response ){
213258
214259 $aok = true;
215260
@@ -225,7 +270,7 @@
226271 * Parse the response to get the errors in a format we can log and otherwise deal with.
227272 * return a key/value array of codes (if they exist) and messages.
228273 */
229 - function getResponseErrors( $response ){
 274+ public function getResponseErrors( $response ){
230275 $errors = array();
231276 foreach ( $response->getElementsByTagName( 'warning' ) as $node ) {
232277 $code = '';
@@ -247,7 +292,7 @@
248293 * Harvest the data we need back from the gateway.
249294 * return a key/value array
250295 */
251 - function getResponseData( $response ){
 296+ public function getResponseData( $response ){
252297 $data = array();
253298 foreach ( $response->getElementsByTagName( 'ImportantData' ) as $node ) {
254299 foreach ( $node->childNodes as $childnode ) {
@@ -260,19 +305,18 @@
261306 return $data;
262307 }
263308
264 - function processResponse( $response ) {
 309+ public function processResponse( $response ) {
265310 //TODO: Stuff.
266311 }
267312
268 - function publicCurrentTransaction( $transaction = '' ){
 313+ public function publicCurrentTransaction( $transaction = '' ){
269314 $this->currentTransaction( $transaction );
270315 }
271316
272 - function curl_transaction($data) {
 317+ public function curl_transaction($data) {
273318 $data = "";
274319 $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>';
275320 return $data;
276321 }
277322 }
278323
279 -?>

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r98255Expanding unit tests for DonationInterfacejpostlethwaite21:13, 27 September 2011

Status & tagging log