Index: branches/fundraising/extensions/DonationInterface/tests/DonationDataTest.php |
— | — | @@ -1,275 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/** |
5 | | - * @group Fundraising |
6 | | - * @group Splunge |
7 | | - * @group Gateways |
8 | | - * @author Katie Horn <khorn@wikimedia.org> |
9 | | - */ |
10 | | -$dir = dirname( __FILE__ ) . '/'; |
11 | | -require_once( $dir . '../gateway_common/DonationData.php' ); |
12 | | -class DonationDataTest extends MediaWikiTestCase { |
13 | | - |
14 | | - function __construct(){ |
15 | | - parent::__construct(); |
16 | | - $this->testData = array( |
17 | | - 'amount' => '128', |
18 | | - 'email' => 'unittest@example.com', |
19 | | - 'fname' => 'Testocres', |
20 | | - 'mname' => 'S.', |
21 | | - 'lname' => 'McTestingyou', |
22 | | - 'street' => '123 Fake Street', |
23 | | - 'city' => 'Springfield', |
24 | | - 'state' => 'US', |
25 | | - 'zip' => '99999', |
26 | | - 'country' => 'US', |
27 | | - 'fname2' => 'Testor', |
28 | | - 'lname2' => 'Testeyton', |
29 | | - 'street2' => '123 W. Grand Ave.', |
30 | | - 'city2' => 'Oakland', |
31 | | - 'state2' => 'CA', |
32 | | - 'zip2' => '94607', |
33 | | - 'country2' => 'US', |
34 | | - 'size' => 'Big mcLargeHuge', |
35 | | - 'premium_language' => 'fr', |
36 | | - 'card_num' => '42', |
37 | | - 'card_type' => 'visa', |
38 | | - 'expiration' => '1138', |
39 | | - 'cvv' => '665', |
40 | | - 'currency' => 'USD', |
41 | | - 'payment_method' => '', |
42 | | - 'i_order_id' => '1234567890', |
43 | | - 'numAttempt' => '5', |
44 | | - 'referrer' => 'http://www.testing.com/', |
45 | | - 'utm_source' => '..dd', |
46 | | - 'utm_medium' => 'large', |
47 | | - 'utm_campaign' => 'yes', |
48 | | - 'comment-option' => '', |
49 | | - 'comment' => 'My hovercraft is full of eels', |
50 | | - 'email-opt' => '', |
51 | | - 'test_string' => '', |
52 | | - 'token' => '113811', |
53 | | - 'contribution_tracking_id' => '', |
54 | | - 'data_hash' => '', |
55 | | - 'action' => '', |
56 | | - 'gateway' => 'chainlink', |
57 | | - 'owa_session' => '', |
58 | | - 'owa_ref' => 'http://localhost/importedTestData', |
59 | | - ); |
60 | | - |
61 | | - } |
62 | | - |
63 | | - |
64 | | - function testConstruct(){ |
65 | | - $ddObj = new DonationData(''); //as if we were posted. |
66 | | - $returned = $ddObj->getData(); |
67 | | - $expected = array( 'posted' => '', |
68 | | - 'amount' => '0.00', |
69 | | - 'email' => '', |
70 | | - 'fname' => '', |
71 | | - 'mname' => '', |
72 | | - 'lname' => '', |
73 | | - 'street' => '', |
74 | | - 'city' => '', |
75 | | - 'state' => '', |
76 | | - 'zip' => '', |
77 | | - 'country' => '', |
78 | | - 'fname2' => '', |
79 | | - 'lname2' => '', |
80 | | - 'street2' => '', |
81 | | - 'city2' => '', |
82 | | - 'state2' => '', |
83 | | - 'zip2' => '', |
84 | | - 'country2' => '', |
85 | | - 'size' => '', |
86 | | - 'premium_language' => 'en', |
87 | | - 'card_num' => '', |
88 | | - 'card_type' => '', |
89 | | - 'expiration' => '', |
90 | | - 'cvv' => '', |
91 | | - 'currency' => '', |
92 | | - 'payment_method' => '', |
93 | | - 'numAttempt' => '0', |
94 | | - 'referrer' => '', |
95 | | - 'utm_source' => '..cc', |
96 | | - 'utm_medium' => '', |
97 | | - 'utm_campaign' => '', |
98 | | - 'language' => '', |
99 | | - 'comment-option' => '', |
100 | | - 'comment' => '', |
101 | | - 'email-opt' => '', |
102 | | - 'test_string' => '', |
103 | | - '_cache_' => '', |
104 | | - 'token' => '', |
105 | | - 'contribution_tracking_id' => '', |
106 | | - 'data_hash' => '', |
107 | | - 'action' => '', |
108 | | - 'gateway' => '', |
109 | | - 'owa_session' => '', |
110 | | - 'owa_ref' => '', |
111 | | - ); |
112 | | - unset($returned['order_id']); |
113 | | - unset($returned['i_order_id']); |
114 | | - $this->assertEquals($returned, $expected, "Staged post data does not match expected (largely empty)."); |
115 | | - } |
116 | | - |
117 | | - function testConstructAsTest(){ |
118 | | - $ddObj = new DonationData('', true); //test mode from the start, no data |
119 | | - $returned = $ddObj->getData(); |
120 | | - $expected = array( |
121 | | - 'amount' => '35', |
122 | | - 'email' => 'test@example.com', |
123 | | - 'fname' => 'Tester', |
124 | | - 'mname' => 'T.', |
125 | | - 'lname' => 'Testington', |
126 | | - 'street' => '548 Market St.', |
127 | | - 'city' => 'San Francisco', |
128 | | - 'state' => 'CA', |
129 | | - 'zip' => '94104', |
130 | | - 'country' => 'US', |
131 | | - 'fname2' => 'Testy', |
132 | | - 'lname2' => 'Testerson', |
133 | | - 'street2' => '123 Telegraph Ave.', |
134 | | - 'city2' => 'Berkeley', |
135 | | - 'state2' => 'CA', |
136 | | - 'zip2' => '94703', |
137 | | - 'country2' => 'US', |
138 | | - 'size' => 'small', |
139 | | - 'premium_language' => 'es', |
140 | | - 'card_num' => '378282246310005', |
141 | | - 'card_type' => 'american', |
142 | | - 'expiration' => '1012', |
143 | | - 'cvv' => '001', |
144 | | - 'currency' => 'USD', |
145 | | - 'payment_method' => '', |
146 | | - 'i_order_id' => '1234567890', |
147 | | - 'numAttempt' => '0', |
148 | | - 'referrer' => 'http://www.baz.test.com/index.php?action=foo&action=bar', |
149 | | - 'utm_source' => '..cc', |
150 | | - 'utm_medium' => '', |
151 | | - 'utm_campaign' => '', |
152 | | - 'language' => 'en', |
153 | | - 'comment-option' => '', |
154 | | - 'comment' => '', |
155 | | - 'email-opt' => '', |
156 | | - 'test_string' => '', |
157 | | - 'token' => '', |
158 | | - 'contribution_tracking_id' => '', |
159 | | - 'data_hash' => '', |
160 | | - 'action' => '', |
161 | | - 'gateway' => 'payflowpro', |
162 | | - 'owa_session' => '', |
163 | | - 'owa_ref' => 'http://localhost/defaultTestData', |
164 | | - ); |
165 | | - unset($returned['order_id']); |
166 | | - |
167 | | - $this->assertEquals($expected, $returned, "Staged default test data does not match expected."); |
168 | | - } |
169 | | - |
170 | | - function testRepopulate(){ |
171 | | - $expected = $this->testData; |
172 | | - //just unset a handfull... doesn't matter what, really. |
173 | | - unset($expected['comment-option']); |
174 | | - unset($expected['email-opt']); |
175 | | - unset($expected['test_string']); |
176 | | - |
177 | | - $ddObj = new DonationData(''); |
178 | | - $ddObj->populateData(true, $expected); //change to test mode with explicit test data |
179 | | - $returned = $ddObj->getData(); |
180 | | - //unset these, because they're always new |
181 | | - unset($returned['order_id']); |
182 | | - unset($expected['order_id']); |
183 | | - $this->assertEquals($returned, $expected, "The forced test data did not populate as expected."); |
184 | | - } |
185 | | - |
186 | | - function testIsSomething(){ |
187 | | - $data = $this->testData; |
188 | | - unset($data['zip']); |
189 | | - $ddObj = new DonationData('', true, $data); |
190 | | - $this->assertEquals($ddObj->isSomething('zip'), false, "Zip should currently be nothing."); |
191 | | - $this->assertEquals($ddObj->isSomething('lname'), true, "Lname should currently be something."); |
192 | | - } |
193 | | - |
194 | | - function testGetVal(){ |
195 | | - $data = $this->testData; |
196 | | - unset($data['zip']); |
197 | | - $ddObj = new DonationData('', true, $data); |
198 | | - $this->assertEquals($ddObj->getVal('zip'), null, "Zip should currently be nothing."); |
199 | | - $this->assertEquals($ddObj->getVal('lname'), 'McTestingyou', "Lname should currently be 'McTestingyou'."); |
200 | | - } |
201 | | - |
202 | | - function testSetNormalizedAmount_amtGiven() { |
203 | | - $data = $this->testData; |
204 | | - $data['amount'] = 'this is not a number'; |
205 | | - $data['amountGiven'] = 42.50; |
206 | | - //unset($data['zip']); |
207 | | - $ddObj = new DonationData('', true, $data); |
208 | | - $returned = $ddObj->getData(); |
209 | | - $this->assertEquals($returned['amount'], '42.50', "Amount was not properly reset"); |
210 | | - $this->assertTrue(!(array_key_exists('amountGiven', $returned)), "amountGiven should have been removed from the data"); |
211 | | - } |
212 | | - |
213 | | - function testSetNormalizedAmount_amount() { |
214 | | - $data = $this->testData; |
215 | | - $data['amount'] = 88.15; |
216 | | - $data['amountGiven'] = 42.50; |
217 | | - //unset($data['zip']); |
218 | | - $ddObj = new DonationData('', true, $data); |
219 | | - $returned = $ddObj->getData(); |
220 | | - $this->assertEquals($returned['amount'], 88.15, "Amount was not properly reset"); |
221 | | - $this->assertTrue(!(array_key_exists('amountGiven', $returned)), "amountGiven should have been removed from the data"); |
222 | | - } |
223 | | - |
224 | | - function testSetNormalizedAmount_neagtiveAmount() { |
225 | | - $data = $this->testData; |
226 | | - $data['amount'] = -1; |
227 | | - $data['amountOther'] = 3.25; |
228 | | - //unset($data['zip']); |
229 | | - $ddObj = new DonationData('', true, $data); |
230 | | - $returned = $ddObj->getData(); |
231 | | - $this->assertEquals($returned['amount'], 3.25, "Amount was not properly reset"); |
232 | | - $this->assertTrue(!(array_key_exists('amountOther', $returned)), "amountOther should have been removed from the data"); |
233 | | - } |
234 | | - |
235 | | - function testSetNormalizedAmount_noGoodAmount() { |
236 | | - $data = $this->testData; |
237 | | - $data['amount'] = 'splunge'; |
238 | | - $data['amountGiven'] = 'wombat'; |
239 | | - $data['amountOther'] = 'macedonia'; |
240 | | - //unset($data['zip']); |
241 | | - $ddObj = new DonationData('', true, $data); |
242 | | - $returned = $ddObj->getData(); |
243 | | - $this->assertEquals($returned['amount'], 0.00, "Amount was not properly reset"); |
244 | | - $this->assertTrue(!(array_key_exists('amountOther', $returned)), "amountOther should have been removed from the data"); |
245 | | - $this->assertTrue(!(array_key_exists('amountGiven', $returned)), "amountGiven should have been removed from the data"); |
246 | | - } |
247 | | - |
248 | | - /* |
249 | | - * TODO: Make sure ALL these functions in DonationData are tested, either directly or through a calling function. |
250 | | - * I know that's more regression-ish, but I stand by it. :p |
251 | | - function isCache(){ |
252 | | - function setOwaRefId(){ |
253 | | - function setNormalizedOrderIDs(){ |
254 | | - function generateOrderId() { |
255 | | - public function sanitizeInput( &$value, $key, $flags=ENT_COMPAT, $double_encode=false ) { |
256 | | - function setGateway(){ |
257 | | - function doCacheStuff(){ |
258 | | - function getAnnoyingOrderIDLogLinePrefix(){ |
259 | | - public function getEditToken( $salt = '' ) { |
260 | | - public static function generateToken( $salt = '' ) { |
261 | | - function matchEditToken( $val, $salt = '' ) { |
262 | | - function unsetEditToken() { |
263 | | - public static function ensureSession() { |
264 | | - public function checkTokens() { |
265 | | - function wasPosted(){ |
266 | | - public static function getUtmSource( $utm_source = null, $utm_source_id = null ) { |
267 | | - public function getOptOuts() { |
268 | | - public function getCleanTrackingData( $clean_optouts = false ) { |
269 | | - function saveContributionTracking() { |
270 | | - public static function insertContributionTracking( $tracking_data ) { |
271 | | - public function updateContributionTracking( $force = false ) { |
272 | | - |
273 | | - */ |
274 | | -} |
275 | | - |
276 | | -?> |
Index: branches/fundraising/extensions/DonationInterface/tests/AllTests.php |
— | — | @@ -22,6 +22,7 @@ |
23 | 23 | * @see DonationInterface_Adapter_AllTests |
24 | 24 | */ |
25 | 25 | require_once 'Adapter/AllTests.php'; |
| 26 | +require_once 'DonationDataTestCase.php'; |
26 | 27 | |
27 | 28 | /** |
28 | 29 | * AllTests |
— | — | @@ -50,6 +51,7 @@ |
51 | 52 | $suite = new PHPUnit_Framework_TestSuite( 'Donation Interface Suite' ); |
52 | 53 | |
53 | 54 | $suite->addTestSuite( 'DonationInterface_Adapter_AllTests' ); |
| 55 | + $suite->addTestSuite( 'DonationInterface_DonationDataTestCase' ); |
54 | 56 | //$suite->addTest(DonationInterface_Adapter_AllTests::suite()); |
55 | 57 | |
56 | 58 | return $suite; |
Index: branches/fundraising/extensions/DonationInterface/tests/DonationDataTestCase.php |
— | — | @@ -0,0 +1,326 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Wikimedia Foundation |
| 5 | + * |
| 6 | + * LICENSE |
| 7 | + * |
| 8 | + * This program is free software; you can redistribute it and/or modify |
| 9 | + * it under the terms of the GNU General Public License as published by |
| 10 | + * the Free Software Foundation; either version 2 of the License, or |
| 11 | + * (at your option) any later version. |
| 12 | + * |
| 13 | + * This program is distributed in the hope that it will be useful, |
| 14 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | + * GNU General Public License for more details. |
| 17 | + * |
| 18 | + * @since r98249 |
| 19 | + * @author Katie Horn <khorn@wikimedia.org> |
| 20 | + */ |
| 21 | + |
| 22 | +/** |
| 23 | + * @see DonationInterfaceTestCase |
| 24 | + */ |
| 25 | +require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'DonationInterfaceTestCase.php'; |
| 26 | + |
| 27 | +/** |
| 28 | + * @group Fundraising |
| 29 | + * @group Splunge |
| 30 | + * @group Gateways |
| 31 | + * @author Katie Horn <khorn@wikimedia.org> |
| 32 | + */ |
| 33 | +class DonationInterface_DonationDataTestCase extends DonationInterfaceTestCase { |
| 34 | + |
| 35 | + /** |
| 36 | + * |
| 37 | + */ |
| 38 | + public function __construct(){ |
| 39 | + parent::__construct(); |
| 40 | + $this->testData = array( |
| 41 | + 'amount' => '128', |
| 42 | + 'email' => 'unittest@example.com', |
| 43 | + 'fname' => 'Testocres', |
| 44 | + 'mname' => 'S.', |
| 45 | + 'lname' => 'McTestingyou', |
| 46 | + 'street' => '123 Fake Street', |
| 47 | + 'city' => 'Springfield', |
| 48 | + 'state' => 'US', |
| 49 | + 'zip' => '99999', |
| 50 | + 'country' => 'US', |
| 51 | + 'fname2' => 'Testor', |
| 52 | + 'lname2' => 'Testeyton', |
| 53 | + 'street2' => '123 W. Grand Ave.', |
| 54 | + 'city2' => 'Oakland', |
| 55 | + 'state2' => 'CA', |
| 56 | + 'zip2' => '94607', |
| 57 | + 'country2' => 'US', |
| 58 | + 'size' => 'Big mcLargeHuge', |
| 59 | + 'premium_language' => 'fr', |
| 60 | + 'card_num' => '42', |
| 61 | + 'card_type' => 'visa', |
| 62 | + 'expiration' => '1138', |
| 63 | + 'cvv' => '665', |
| 64 | + 'currency' => 'USD', |
| 65 | + 'payment_method' => '', |
| 66 | + 'i_order_id' => '1234567890', |
| 67 | + 'numAttempt' => '5', |
| 68 | + 'referrer' => 'http://www.testing.com/', |
| 69 | + 'utm_source' => '..dd', |
| 70 | + 'utm_medium' => 'large', |
| 71 | + 'utm_campaign' => 'yes', |
| 72 | + 'comment-option' => '', |
| 73 | + 'comment' => 'My hovercraft is full of eels', |
| 74 | + 'email-opt' => '', |
| 75 | + 'test_string' => '', |
| 76 | + 'token' => '113811', |
| 77 | + 'contribution_tracking_id' => '', |
| 78 | + 'data_hash' => '', |
| 79 | + 'action' => '', |
| 80 | + 'gateway' => 'chainlink', |
| 81 | + 'owa_session' => '', |
| 82 | + 'owa_ref' => 'http://localhost/importedTestData', |
| 83 | + ); |
| 84 | + |
| 85 | + } |
| 86 | + |
| 87 | + |
| 88 | + /** |
| 89 | + * |
| 90 | + */ |
| 91 | + public function testConstruct(){ |
| 92 | + $ddObj = new DonationData(''); //as if we were posted. |
| 93 | + $returned = $ddObj->getData(); |
| 94 | + $expected = array( 'posted' => '', |
| 95 | + 'amount' => '0.00', |
| 96 | + 'email' => '', |
| 97 | + 'fname' => '', |
| 98 | + 'mname' => '', |
| 99 | + 'lname' => '', |
| 100 | + 'street' => '', |
| 101 | + 'city' => '', |
| 102 | + 'state' => '', |
| 103 | + 'zip' => '', |
| 104 | + 'country' => '', |
| 105 | + 'fname2' => '', |
| 106 | + 'lname2' => '', |
| 107 | + 'street2' => '', |
| 108 | + 'city2' => '', |
| 109 | + 'state2' => '', |
| 110 | + 'zip2' => '', |
| 111 | + 'country2' => '', |
| 112 | + 'size' => '', |
| 113 | + 'premium_language' => 'en', |
| 114 | + 'card_num' => '', |
| 115 | + 'card_type' => '', |
| 116 | + 'expiration' => '', |
| 117 | + 'cvv' => '', |
| 118 | + 'currency' => '', |
| 119 | + 'payment_method' => '', |
| 120 | + 'numAttempt' => '0', |
| 121 | + 'referrer' => '', |
| 122 | + 'utm_source' => '..cc', |
| 123 | + 'utm_medium' => '', |
| 124 | + 'utm_campaign' => '', |
| 125 | + 'language' => '', |
| 126 | + 'comment-option' => '', |
| 127 | + 'comment' => '', |
| 128 | + 'email-opt' => '', |
| 129 | + 'test_string' => '', |
| 130 | + '_cache_' => '', |
| 131 | + 'token' => '', |
| 132 | + 'contribution_tracking_id' => '', |
| 133 | + 'data_hash' => '', |
| 134 | + 'action' => '', |
| 135 | + 'gateway' => '', |
| 136 | + 'owa_session' => '', |
| 137 | + 'owa_ref' => '', |
| 138 | + ); |
| 139 | + unset($returned['order_id']); |
| 140 | + unset($returned['i_order_id']); |
| 141 | + $this->assertEquals($returned, $expected, "Staged post data does not match expected (largely empty)."); |
| 142 | + } |
| 143 | + |
| 144 | + /** |
| 145 | + * |
| 146 | + */ |
| 147 | + public function testConstructAsTest(){ |
| 148 | + $ddObj = new DonationData('', true); //test mode from the start, no data |
| 149 | + $returned = $ddObj->getData(); |
| 150 | + $expected = array( |
| 151 | + 'amount' => '35', |
| 152 | + 'email' => 'test@example.com', |
| 153 | + 'fname' => 'Tester', |
| 154 | + 'mname' => 'T.', |
| 155 | + 'lname' => 'Testington', |
| 156 | + 'street' => '548 Market St.', |
| 157 | + 'city' => 'San Francisco', |
| 158 | + 'state' => 'CA', |
| 159 | + 'zip' => '94104', |
| 160 | + 'country' => 'US', |
| 161 | + 'fname2' => 'Testy', |
| 162 | + 'lname2' => 'Testerson', |
| 163 | + 'street2' => '123 Telegraph Ave.', |
| 164 | + 'city2' => 'Berkeley', |
| 165 | + 'state2' => 'CA', |
| 166 | + 'zip2' => '94703', |
| 167 | + 'country2' => 'US', |
| 168 | + 'size' => 'small', |
| 169 | + 'premium_language' => 'es', |
| 170 | + 'card_num' => '378282246310005', |
| 171 | + 'card_type' => 'american', |
| 172 | + 'expiration' => '1012', |
| 173 | + 'cvv' => '001', |
| 174 | + 'currency' => 'USD', |
| 175 | + 'payment_method' => '', |
| 176 | + 'i_order_id' => '1234567890', |
| 177 | + 'numAttempt' => '0', |
| 178 | + 'referrer' => 'http://www.baz.test.com/index.php?action=foo&action=bar', |
| 179 | + 'utm_source' => '..cc', |
| 180 | + 'utm_medium' => '', |
| 181 | + 'utm_campaign' => '', |
| 182 | + 'language' => 'en', |
| 183 | + 'comment-option' => '', |
| 184 | + 'comment' => '', |
| 185 | + 'email-opt' => '', |
| 186 | + 'test_string' => '', |
| 187 | + 'token' => '', |
| 188 | + 'contribution_tracking_id' => '', |
| 189 | + 'data_hash' => '', |
| 190 | + 'action' => '', |
| 191 | + 'gateway' => 'payflowpro', |
| 192 | + 'owa_session' => '', |
| 193 | + 'owa_ref' => 'http://localhost/defaultTestData', |
| 194 | + ); |
| 195 | + unset($returned['order_id']); |
| 196 | + |
| 197 | + $this->assertEquals($expected, $returned, "Staged default test data does not match expected."); |
| 198 | + } |
| 199 | + |
| 200 | + /** |
| 201 | + * |
| 202 | + */ |
| 203 | + public function testRepopulate(){ |
| 204 | + $expected = $this->testData; |
| 205 | + //just unset a handfull... doesn't matter what, really. |
| 206 | + unset($expected['comment-option']); |
| 207 | + unset($expected['email-opt']); |
| 208 | + unset($expected['test_string']); |
| 209 | + |
| 210 | + $ddObj = new DonationData(''); |
| 211 | + $ddObj->populateData(true, $expected); //change to test mode with explicit test data |
| 212 | + $returned = $ddObj->getData(); |
| 213 | + //unset these, because they're always new |
| 214 | + unset($returned['order_id']); |
| 215 | + unset($expected['order_id']); |
| 216 | + $this->assertEquals($returned, $expected, "The forced test data did not populate as expected."); |
| 217 | + } |
| 218 | + |
| 219 | + /** |
| 220 | + * |
| 221 | + */ |
| 222 | + public function testIsSomething(){ |
| 223 | + $data = $this->testData; |
| 224 | + unset($data['zip']); |
| 225 | + $ddObj = new DonationData('', true, $data); |
| 226 | + $this->assertEquals($ddObj->isSomething('zip'), false, "Zip should currently be nothing."); |
| 227 | + $this->assertEquals($ddObj->isSomething('lname'), true, "Lname should currently be something."); |
| 228 | + } |
| 229 | + |
| 230 | + /** |
| 231 | + * |
| 232 | + */ |
| 233 | + public function testGetVal(){ |
| 234 | + $data = $this->testData; |
| 235 | + unset($data['zip']); |
| 236 | + $ddObj = new DonationData('', true, $data); |
| 237 | + $this->assertEquals($ddObj->getVal('zip'), null, "Zip should currently be nothing."); |
| 238 | + $this->assertEquals($ddObj->getVal('lname'), 'McTestingyou', "Lname should currently be 'McTestingyou'."); |
| 239 | + } |
| 240 | + |
| 241 | + /** |
| 242 | + * |
| 243 | + */ |
| 244 | + public function testSetNormalizedAmount_amtGiven() { |
| 245 | + $data = $this->testData; |
| 246 | + $data['amount'] = 'this is not a number'; |
| 247 | + $data['amountGiven'] = 42.50; |
| 248 | + //unset($data['zip']); |
| 249 | + $ddObj = new DonationData('', true, $data); |
| 250 | + $returned = $ddObj->getData(); |
| 251 | + $this->assertEquals($returned['amount'], '42.50', "Amount was not properly reset"); |
| 252 | + $this->assertTrue(!(array_key_exists('amountGiven', $returned)), "amountGiven should have been removed from the data"); |
| 253 | + } |
| 254 | + |
| 255 | + /** |
| 256 | + * |
| 257 | + */ |
| 258 | + public function testSetNormalizedAmount_amount() { |
| 259 | + $data = $this->testData; |
| 260 | + $data['amount'] = 88.15; |
| 261 | + $data['amountGiven'] = 42.50; |
| 262 | + //unset($data['zip']); |
| 263 | + $ddObj = new DonationData('', true, $data); |
| 264 | + $returned = $ddObj->getData(); |
| 265 | + $this->assertEquals($returned['amount'], 88.15, "Amount was not properly reset"); |
| 266 | + $this->assertTrue(!(array_key_exists('amountGiven', $returned)), "amountGiven should have been removed from the data"); |
| 267 | + } |
| 268 | + |
| 269 | + /** |
| 270 | + * |
| 271 | + */ |
| 272 | + public function testSetNormalizedAmount_neagtiveAmount() { |
| 273 | + $data = $this->testData; |
| 274 | + $data['amount'] = -1; |
| 275 | + $data['amountOther'] = 3.25; |
| 276 | + //unset($data['zip']); |
| 277 | + $ddObj = new DonationData('', true, $data); |
| 278 | + $returned = $ddObj->getData(); |
| 279 | + $this->assertEquals($returned['amount'], 3.25, "Amount was not properly reset"); |
| 280 | + $this->assertTrue(!(array_key_exists('amountOther', $returned)), "amountOther should have been removed from the data"); |
| 281 | + } |
| 282 | + |
| 283 | + /** |
| 284 | + * |
| 285 | + */ |
| 286 | + public function testSetNormalizedAmount_noGoodAmount() { |
| 287 | + $data = $this->testData; |
| 288 | + $data['amount'] = 'splunge'; |
| 289 | + $data['amountGiven'] = 'wombat'; |
| 290 | + $data['amountOther'] = 'macedonia'; |
| 291 | + //unset($data['zip']); |
| 292 | + $ddObj = new DonationData('', true, $data); |
| 293 | + $returned = $ddObj->getData(); |
| 294 | + $this->assertEquals($returned['amount'], 0.00, "Amount was not properly reset"); |
| 295 | + $this->assertTrue(!(array_key_exists('amountOther', $returned)), "amountOther should have been removed from the data"); |
| 296 | + $this->assertTrue(!(array_key_exists('amountGiven', $returned)), "amountGiven should have been removed from the data"); |
| 297 | + } |
| 298 | + |
| 299 | + /* |
| 300 | + * TODO: Make sure ALL these functions in DonationData are tested, either directly or through a calling function. |
| 301 | + * I know that's more regression-ish, but I stand by it. :p |
| 302 | + function isCache(){ |
| 303 | + function setOwaRefId(){ |
| 304 | + function setNormalizedOrderIDs(){ |
| 305 | + function generateOrderId() { |
| 306 | + public function sanitizeInput( &$value, $key, $flags=ENT_COMPAT, $double_encode=false ) { |
| 307 | + function setGateway(){ |
| 308 | + function doCacheStuff(){ |
| 309 | + function getAnnoyingOrderIDLogLinePrefix(){ |
| 310 | + public function getEditToken( $salt = '' ) { |
| 311 | + public static function generateToken( $salt = '' ) { |
| 312 | + function matchEditToken( $val, $salt = '' ) { |
| 313 | + function unsetEditToken() { |
| 314 | + public static function ensureSession() { |
| 315 | + public function checkTokens() { |
| 316 | + function wasPosted(){ |
| 317 | + public static function getUtmSource( $utm_source = null, $utm_source_id = null ) { |
| 318 | + public function getOptOuts() { |
| 319 | + public function getCleanTrackingData( $clean_optouts = false ) { |
| 320 | + function saveContributionTracking() { |
| 321 | + public static function insertContributionTracking( $tracking_data ) { |
| 322 | + public function updateContributionTracking( $force = false ) { |
| 323 | + |
| 324 | + */ |
| 325 | +} |
| 326 | + |
| 327 | + |
Property changes on: branches/fundraising/extensions/DonationInterface/tests/DonationDataTestCase.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 328 | + native |