Merge pull request #4627 from colemanw/docblocks
[civicrm-core.git] / tests / phpunit / api / v3 / ContributionPageTest.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
06a1bc01 4 | CiviCRM version 4.5 |
6a488035 5 +--------------------------------------------------------------------+
06a1bc01 6 | Copyright CiviCRM LLC (c) 2004-2014 |
6a488035
TO
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
26*/
27
28require_once 'CiviTest/CiviUnitTestCase.php';
29
30
31/**
32 * Test APIv3 civicrm_contribute_recur* functions
33 *
34 * @package CiviCRM_APIv3
35 * @subpackage API_Contribution
36 */
37
38class api_v3_ContributionPageTest extends CiviUnitTestCase {
39 protected $_apiversion = 3;
40 protected $testAmount = 34567;
41 protected $params;
42 protected $id = 0;
43 protected $contactIds = array();
44 protected $_entity = 'contribution_page';
45 protected $contribution_result = null;
f64a217a 46 protected $_priceSetParams = array();
f8fe0df6 47 /**
48 * Payment processor details
49 * @var array
50 */
51 protected $_paymentProcessor = array();
f64a217a
EM
52
53 /**
54 * @var array
55 * - contribution_page
56 * - price_set
57 * - price_field
58 * - price_field_value
59 */
60 protected $_ids = array();
61
b7c9bc4c 62
6a488035
TO
63 public $DBResetRequired = TRUE;
64 public function setUp() {
65 parent::setUp();
66 $this->contactIds[] = $this->individualCreate();
67 $this->params = array(
6a488035
TO
68 'title' => "Test Contribution Page",
69 'financial_type_id' => 1,
70 'currency' => 'NZD',
71 'goal_amount' => $this->testAmount,
6cdac50b 72 'is_pay_later' => 1,
f64a217a
EM
73 'is_monetary' => TRUE,
74 );
75
76 $this->_priceSetParams = array(
77 'is_quick_config' => 1,
78 'extends' => 'CiviContribute',
79 'financial_type_id' => 'Donation',
80 'title' => 'my Page'
6a488035
TO
81 );
82 }
83
84 function tearDown() {
85 foreach ($this->contactIds as $id) {
fc928539 86 $this->callAPISuccess('contact', 'delete', array('id' => $id));
611c7ece 87 }
f9342903 88 $this->quickCleanUpFinancialEntities();
6a488035
TO
89 }
90
91 public function testCreateContributionPage() {
fc928539 92 $result = $this->callAPIAndDocument($this->_entity, 'create', $this->params, __FUNCTION__, __FILE__);
93 $this->assertEquals(1, $result['count']);
94 $this->assertNotNull($result['values'][$result['id']]['id']);
6a488035
TO
95 $this->getAndCheck($this->params, $result['id'], $this->_entity);
96 }
97
98 public function testGetBasicContributionPage() {
fc928539 99 $createResult = $this->callAPISuccess($this->_entity, 'create', $this->params);
6a488035 100 $this->id = $createResult['id'];
6a488035 101 $getParams = array(
6a488035
TO
102 'currency' => 'NZD',
103 'financial_type_id' => 1,
104 );
fc928539 105 $getResult = $this->callAPIAndDocument($this->_entity, 'get', $getParams, __FUNCTION__, __FILE__);
106 $this->assertEquals(1, $getResult['count']);
6a488035
TO
107 }
108
109 public function testGetContributionPageByAmount() {
fc928539 110 $createResult = $this->callAPISuccess($this->_entity, 'create', $this->params);
6a488035 111 $this->id = $createResult['id'];
6a488035 112 $getParams = array(
6a488035
TO
113 'amount' => ''. $this->testAmount, // 3456
114 'currency' => 'NZD',
115 'financial_type_id' => 1,
116 );
fc928539 117 $getResult = $this->callAPIAndDocument($this->_entity, 'get', $getParams, __FUNCTION__, __FILE__);
118 $this->assertEquals(1, $getResult['count']);
6a488035
TO
119 }
120
121 public function testDeleteContributionPage() {
fc928539 122 $createResult = $this->callAPISuccess($this->_entity, 'create', $this->params);
123 $deleteParams = array('id' => $createResult['id']);
611c7ece 124 $this->callAPIAndDocument($this->_entity, 'delete', $deleteParams, __FUNCTION__, __FILE__);
fc928539 125 $checkDeleted = $this->callAPISuccess($this->_entity, 'get', array());
126 $this->assertEquals(0, $checkDeleted['count']);
6a488035
TO
127 }
128
129 public function testGetFieldsContributionPage() {
fc928539 130 $result = $this->callAPISuccess($this->_entity, 'getfields', array('action' => 'create'));
6a488035
TO
131 $this->assertEquals(12, $result['values']['start_date']['type']);
132 }
133
be26f3e0 134
d58b453e
EM
135 /**
136 * Test form submission with basic price set
137 */
be26f3e0 138 public function testSubmit() {
f64a217a
EM
139 $this->setUpContributionPage();
140 $priceFieldID = reset($this->_ids['price_field']);
141 $priceFieldValueID = reset($this->_ids['price_field_value']);
142 $submitParams = array(
143 'price_' . $priceFieldID => $priceFieldValueID,
144 'id' => (int) $this->_ids['contribution_page'],
145 'amount' => 10
be26f3e0
EM
146 );
147
f64a217a
EM
148 $this->callAPISuccess('contribution_page', 'submit', $submitParams);
149 $this->callAPISuccess('contribution', 'getsingle', array('contribution_page_id' => $this->_ids['contribution_page']));
150 }
f64a217a
EM
151 /**
152 * Test submit with a membership block in place
153 */
f9342903
EM
154 public function testSubmitMembershipBlockNotSeparatePayment() {
155 $this->setUpMembershipContributionPage();
f64a217a 156 $submitParams = array(
3e28c791 157 'price_' . $this->_ids['price_field'][0] => reset($this->_ids['price_field_value']),
f9342903 158 'id' => (int) $this->_ids['contribution_page'],
f64a217a
EM
159 'amount' => 10,
160 'billing_first_name' => 'Billy',
161 'billing_middle_name' => 'Goat',
162 'billing_last_name' => 'Gruff',
163 'selectMembership' => $this->_ids['membership_type'],
164
165 );
166
167 $this->callAPIAndDocument('contribution_page', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page', NULL, 'Submit');
f9342903 168 $contribution = $this->callAPISuccess('contribution', 'getsingle', array('contribution_page_id' => $this->_ids['contribution_page']));
f64a217a 169 $this->callAPISuccess('membership_payment', 'getsingle', array('contribution_id' => $contribution['id']));
f9342903
EM
170 }
171
172 /**
173 * Test submit with a membership block in place
174 */
175 public function testSubmitMembershipBlockIsSeparatePayment() {
176 $this->setUpMembershipContributionPage(TRUE);
177 $submitParams = array(
3e28c791 178 'price_' . $this->_ids['price_field'][0] => reset($this->_ids['price_field_value']),
f9342903
EM
179 'id' => (int) $this->_ids['contribution_page'],
180 'amount' => 10,
181 'billing_first_name' => 'Billy',
182 'billing_middle_name' => 'Goat',
183 'billing_last_name' => 'Gruff',
184 'selectMembership' => $this->_ids['membership_type'],
185 );
186
187 $this->callAPIAndDocument('contribution_page', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page', NULL, 'Submit');
188 $contributions = $this->callAPISuccess('contribution', 'get', array('contribution_page_id' => $this->_ids['contribution_page']));
189 $this->assertCount(2, $contributions['values']);
190 $membershipPayment = $this->callAPISuccess('membership_payment', 'getsingle', array());
191 $this->assertTrue(in_array($membershipPayment['contribution_id'], array_keys($contributions['values'])));
192 $membership = $this->callAPISuccessGetSingle('membership', array('id' => $membershipPayment['membership_id']));
193 $this->assertEquals($membership['contact_id'], $contributions['values'][$membershipPayment['contribution_id']]['contact_id']);
194 }
f64a217a 195
797c4f88
EM
196 /**
197 * Test submit with a membership block in place
198 */
199 public function testSubmitMembershipBlockTwoTypesIsSeparatePayment() {
200 $this->_ids['membership_type'] = array($this->membershipTypeCreate(array('minimum_fee' => 6)));
201 $this->_ids['membership_type'][] = $this->membershipTypeCreate(array('name' => 'Student', 'minimum_fee' => 50));
202 $this->setUpMembershipContributionPage(TRUE);
203 $submitParams = array(
204 'price_' . $this->_ids['price_field'][0] => $this->_ids['price_field_value'][1],
205 'id' => (int) $this->_ids['contribution_page'],
206 'amount' => 10,
207 'billing_first_name' => 'Billy',
208 'billing_middle_name' => 'Goat',
209 'billing_last_name' => 'Gruff',
210 'selectMembership' => $this->_ids['membership_type'][1],
211 );
212
213 $this->callAPIAndDocument('contribution_page', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page', NULL, 'Submit');
214 $contributions = $this->callAPISuccess('contribution', 'get', array('contribution_page_id' => $this->_ids['contribution_page'],));
215 $this->assertCount(2, $contributions['values']);
216 $ids = array_keys($contributions['values']);
217 $this->assertEquals('10.00', $contributions['values'][$ids[0]]['total_amount']);
218 $this->assertEquals('50.00', $contributions['values'][$ids[1]]['total_amount']);
219 $membershipPayment = $this->callAPISuccess('membership_payment', 'getsingle', array());
220 $this->assertArrayHasKey($membershipPayment['contribution_id'], $contributions['values']);
221 $membership = $this->callAPISuccessGetSingle('membership', array('id' => $membershipPayment['membership_id']));
222 $this->assertEquals($membership['contact_id'], $contributions['values'][$membershipPayment['contribution_id']]['contact_id']);
223 }
224
8ca611b7
EM
225 /**
226 * Test submit with a membership block in place
227 */
228 public function testSubmitMembershipBlockIsSeparatePaymentPaymentProcessor() {
229 $this->setUpMembershipContributionPage(TRUE);
230 $submitParams = array(
231 'price_' . $this->_ids['price_field'][0] => reset($this->_ids['price_field_value']),
232 'id' => (int) $this->_ids['contribution_page'],
233 'amount' => 10,
234 'billing_first_name' => 'Billy',
235 'billing_middle_name' => 'Goat',
236 'billing_last_name' => 'Gruff',
237 'selectMembership' => $this->_ids['membership_type'],
238 'payment_processor' => 1,
239 'credit_card_number' => '4111111111111111',
240 'credit_card_type' => 'Visa',
241 'credit_card_exp_date' => array('M' => 9, 'Y' => 2040 ),
242 'cvv2' => 123,
243 );
05990684 244
8ca611b7
EM
245 $this->callAPIAndDocument('contribution_page', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page', NULL, 'Submit');
246 $contributions = $this->callAPISuccess('contribution', 'get', array('contribution_page_id' => $this->_ids['contribution_page'], 'contribution_status_id' => 1));
247 $this->assertCount(2, $contributions['values']);
248 $membershipPayment = $this->callAPISuccess('membership_payment', 'getsingle', array());
249 $this->assertTrue(in_array($membershipPayment['contribution_id'], array_keys($contributions['values'])));
250 $membership = $this->callAPISuccessGetSingle('membership', array('id' => $membershipPayment['membership_id']));
251 $this->assertEquals($membership['contact_id'], $contributions['values'][$membershipPayment['contribution_id']]['contact_id']);
252 }
f8fe0df6 253
254 /**
e6fa4056
EM
255 * Test submit recurring membership with immediate confirmation (IATS style)
256 * - we process 2 membership transactions against with a recurring contribution against a contribution page with an immediate
257 * processor (IASTS style - denoted by returning trxn_id)
258 * - the first creates a new membership, completed contribution, in progress recurring. Check these
259 * - create another - end date should be extended
f8fe0df6 260 */
261 public function testSubmitMembershipPriceSetPaymentPaymentProcessorRecur() {
262 $this->params['is_recur'] = 1;
263 $var = array();
264 $this->params['recur_frequency_unit'] = 'month';
265 $this->setUpMembershipContributionPage();
266 $dummyPP = CRM_Core_Payment::singleton('live', $this->_paymentProcessor);
e6fa4056 267 $dummyPP->setDoDirectPaymentResult(array('contribution_status_id' => 1, 'trxn_id' => 'create_first_success',));
f8fe0df6 268
269 $submitParams = array(
270 'price_' . $this->_ids['price_field'][0] => reset($this->_ids['price_field_value']),
271 'id' => (int) $this->_ids['contribution_page'],
272 'amount' => 10,
273 'billing_first_name' => 'Billy',
274 'billing_middle_name' => 'Goat',
275 'billing_last_name' => 'Gruff',
276 'email' => 'billy@goat.gruff',
277 'selectMembership' => $this->_ids['membership_type'],
278 'payment_processor' => 1,
279 'credit_card_number' => '4111111111111111',
280 'credit_card_type' => 'Visa',
281 'credit_card_exp_date' => array('M' => 9, 'Y' => 2040 ),
282 'cvv2' => 123,
283 'is_recur' => 1,
284 'frequency_interval' => 1,
285 'frequency_unit' => 'month',
286 );
287
288 $this->callAPIAndDocument('contribution_page', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page', NULL, 'Submit');
289 $contribution = $this->callAPISuccess('contribution', 'getsingle', array('contribution_page_id' => $this->_ids['contribution_page'], 'contribution_status_id' => 1));
290 $membershipPayment = $this->callAPISuccess('membership_payment', 'getsingle', array());
291 $this->assertEquals($membershipPayment['contribution_id'], $contribution['id']);
292 $membership = $this->callAPISuccessGetSingle('membership', array('id' => $membershipPayment['membership_id']));
293 $this->assertEquals($membership['contact_id'], $contribution['contact_id']);
294 $this->assertEquals(1, $membership['status_id']);
295 $this->callAPISuccess('contribution_recur', 'getsingle', array('id' => $contribution['contribution_recur_id']));
e6fa4056
EM
296 //@todo - check with Joe about these not existing
297 //$this->callAPISuccess('line_item', 'getsingle', array('contribution_id' => $contribution['id'], 'entity_id' => $membership['id']));
f8fe0df6 298 //renew it with processor setting completed - should extend membership
299 $submitParams['contact_id'] = $contribution['contact_id'];
e6fa4056 300 $dummyPP->setDoDirectPaymentResult(array('contribution_status_id' => 1, 'trxn_id' => 'create_second_success',));
f8fe0df6 301 $this->callAPISuccess('contribution_page', 'submit', $submitParams);
302 $this->callAPISuccess('contribution', 'getsingle', array('id' => array('NOT IN' => array($contribution['id'])), 'contribution_page_id' => $this->_ids['contribution_page'], 'contribution_status_id' => 1));
303 $renewedMembership = $this->callAPISuccessGetSingle('membership', array('id' => $membershipPayment['membership_id']));
304 $this->assertEquals(date('Y-m-d', strtotime('+ 1 year', strtotime($membership['end_date']))), $renewedMembership['end_date']);
305 $recurringContribution = $this->callAPISuccess('contribution_recur', 'getsingle', array('id' => $contribution['contribution_recur_id']));
e6fa4056 306 $this->assertEquals(2, $recurringContribution['contribution_status_id']);
f8fe0df6 307 }
308
309 /**
e6fa4056
EM
310 * Test submit recurring membership with delayed confirmation (Authorize.net style)
311 * - we process 2 membership transactions against with a recurring contribution against a contribution page with a delayed
312 * processor (Authorize.net style - denoted by NOT returning trxn_id)
313 * - the first creates a pending membership, pending contribution, penging recurring. Check these
314 * - complete the transaction
315 * - create another - end date should NOT be extended
f8fe0df6 316 */
317 public function testSubmitMembershipPriceSetPaymentPaymentProcessorRecurDelayed() {
318 $this->params['is_recur'] = 1;
f8fe0df6 319 $this->params['recur_frequency_unit'] = 'month';
320 $this->setUpMembershipContributionPage();
321 $dummyPP = CRM_Core_Payment::singleton('live', $this->_paymentProcessor);
e6fa4056 322 $dummyPP->setDoDirectPaymentResult(array('contribution_status_id' => 2,));
f8fe0df6 323
324 $submitParams = array(
325 'price_' . $this->_ids['price_field'][0] => reset($this->_ids['price_field_value']),
326 'id' => (int) $this->_ids['contribution_page'],
327 'amount' => 10,
328 'billing_first_name' => 'Billy',
329 'billing_middle_name' => 'Goat',
330 'billing_last_name' => 'Gruff',
331 'email' => 'billy@goat.gruff',
332 'selectMembership' => $this->_ids['membership_type'],
333 'payment_processor' => 1,
334 'credit_card_number' => '4111111111111111',
335 'credit_card_type' => 'Visa',
336 'credit_card_exp_date' => array('M' => 9, 'Y' => 2040 ),
337 'cvv2' => 123,
e6fa4056
EM
338 'is_recur' => 1,
339 'frequency_interval' => 1,
340 'frequency_unit' => 'month',
f8fe0df6 341 );
342
343 $this->callAPIAndDocument('contribution_page', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page', NULL, 'Submit');
e6fa4056 344 $contribution = $this->callAPISuccess('contribution', 'getsingle', array('contribution_page_id' => $this->_ids['contribution_page'], 'contribution_status_id' => 2));
f8fe0df6 345 $membershipPayment = $this->callAPISuccess('membership_payment', 'getsingle', array());
346 $this->assertEquals($membershipPayment['contribution_id'], $contribution['id']);
347 $membership = $this->callAPISuccessGetSingle('membership', array('id' => $membershipPayment['membership_id']));
348 $this->assertEquals($membership['contact_id'], $contribution['contact_id']);
e6fa4056
EM
349 $this->assertEquals(5, $membership['status_id']);
350 //@todo - check with Joe about these not existing
351 //$this->callAPISuccess('line_item', 'getsingle', array('contribution_id' => $contribution['id'], 'entity_id' => $membership['id']));
352 $this->callAPISuccess('contribution', 'completetransaction', array('id' => $contribution['id'], 'trxn_id' => 'ipn_called'));
353 $membership = $this->callAPISuccessGetSingle('membership', array('id' => $membershipPayment['membership_id']));
f8fe0df6 354 //renew it with processor setting completed - should extend membership
355 $submitParams = array_merge($submitParams, array(
356 'contact_id' => $contribution['contact_id'],
357 'is_recur' => 1,
358 'frequency_interval' => 1,
359 'frequency_unit' => 'month',)
360 );
361 $dummyPP->setDoDirectPaymentResult(array('contribution_status_id' => 2,));
f8fe0df6 362 $this->callAPISuccess('contribution_page', 'submit', $submitParams);
e6fa4056 363 $newContribution = $this->callAPISuccess('contribution', 'getsingle', array('id' => array(
f8fe0df6 364 'NOT IN' => array($contribution['id'])), 'contribution_page_id' => $this->_ids['contribution_page'], 'contribution_status_id' => 2)
365 );
e6fa4056 366
f8fe0df6 367 $renewedMembership = $this->callAPISuccessGetSingle('membership', array('id' => $membershipPayment['membership_id']));
368 //no renewal as the date hasn't changed
369 $this->assertEquals($membership['end_date'], $renewedMembership['end_date']);
e6fa4056
EM
370 $recurringContribution = $this->callAPISuccess('contribution_recur', 'getsingle', array('id' => $newContribution['contribution_recur_id']));
371 $this->assertEquals(2, $recurringContribution['contribution_status_id']);
f8fe0df6 372 }
373
f9342903
EM
374 /**
375 * set up membership contribution page
376 * @param bool $isSeparatePayment
377 */
378 function setUpMembershipContributionPage($isSeparatePayment = FALSE) {
379 $this->setUpMembershipBlockPriceSet();
f8fe0df6 380 $this->params['payment_processor_id'] = $this->_ids['payment_processor'] = $this->paymentProcessorCreate(array(
381 'payment_processor_type_id' => 'Dummy',
382 'class_name' => 'Payment_Dummy',
383 'billing_mode' => 1,
384 ));
385 $this->_paymentProcessor = $this->callAPISuccess('payment_processor', 'getsingle', array('id' => $this->params['payment_processor_id']));
f9342903
EM
386 $this->setUpContributionPage();
387
388 $this->callAPISuccess('membership_block', 'create', array(
389 'entity_id' => $this->_ids['contribution_page'],
390 'entity_table' => 'civicrm_contribution_page',
391 'is_required' => TRUE,
392 'is_active' => TRUE,
393 'is_separate_payment' => $isSeparatePayment,
394 'membership_type_default' => $this->_ids['membership_type'],
395 ));
f64a217a
EM
396 }
397
f9342903
EM
398 /**
399 * The default data set does not include a complete default membership price set - not quite sure why
400 * This function ensures it exists & populates $this->_ids with it's data
401 */
402 function setUpMembershipBlockPriceSet() {
403 $this->_ids['price_set'][] = $this->callAPISuccess('price_set', 'getvalue', array('name' => 'default_membership_type_amount', 'return' => 'id'));
404 if (empty($this->_ids['membership_type'])) {
3e28c791 405 $this->_ids['membership_type'] = array($this->membershipTypeCreate(array('minimum_fee' => 2)));
f9342903 406 }
3e28c791
EM
407 $priceField = $this->callAPISuccess('price_field', 'create', array(
408 'price_set_id' => reset($this->_ids['price_set']),
409 'name' => 'membership_amount',
410 'label' => 'Membership Amount',
411 'html_type' => 'Radio',
412 'sequential' => 1,
413 ));
414 $this->_ids['price_field'][] = $priceField['id'];
415 foreach ($this->_ids['membership_type'] as $membershipTypeID) {
416 $priceFieldValue = $this->callAPISuccess('price_field_value', 'create', array(
f9342903
EM
417 'name' => 'membership_amount',
418 'label' => 'Membership Amount',
3e28c791
EM
419 'amount' => 1,
420 'financial_type_id' => 1,
421 'format.only_id' => TRUE,
422 'membership_type_id' => $membershipTypeID,
423 'price_field_id' => $priceField['id'],
f9342903 424 ));
3e28c791 425 $this->_ids['price_field_value'][] = $priceFieldValue['id'];
f9342903
EM
426 }
427 }
3e28c791 428
f64a217a
EM
429 /**
430 * help function to set up contribution page with some defaults
431 */
432 function setUpContributionPage() {
433 $contributionPageResult = $this->callAPISuccess($this->_entity, 'create', $this->params);
434 if (empty($this->_ids['price_set'])) {
435 $priceSet = $this->callAPISuccess('price_set', 'create', $this->_priceSetParams);
436 $this->_ids['price_set'][] = $priceSet['id'];
437 }
438 $priceSetID = reset($this->_ids['price_set']);
439 CRM_Price_BAO_PriceSet::addTo('civicrm_contribution_page', $contributionPageResult['id'], $priceSetID );
f9342903
EM
440
441 if (empty($this->_ids['price_field'])) {
442 $priceField = $this->callAPISuccess('price_field', 'create', array(
443 'price_set_id' => $priceSetID,
444 'label' => 'Goat Breed',
445 'html_type' => 'Radio',
446 ));
447 $this->_ids['price_field'] = array($priceField['id']);
448 }
449 if (empty($this->_ids['price_field_value'])) {
450 $this->callAPISuccess('price_field_value', 'create', array(
451 'price_set_id' => $priceSetID,
452 'price_field_id' => $priceField['id'],
453 'label' => 'Long Haired Goat',
454 'amount' => 20,
455 )
456 );
457 $priceFieldValue = $this->callAPISuccess('price_field_value', 'create', array(
458 'price_set_id' => $priceSetID,
459 'price_field_id' => $priceField['id'],
460 'label' => 'Shoe-eating Goat',
461 'amount' => 10,
462 )
463 );
464 $this->_ids['price_field_value'] = array($priceFieldValue['id']);
465 }
f64a217a 466 $this->_ids['contribution_page'] = $contributionPageResult['id'];
be26f3e0
EM
467 }
468
6a488035
TO
469 public static function setUpBeforeClass() {
470 // put stuff here that should happen before all tests in this unit
471 }
472
473 public static function tearDownAfterClass(){
474 $tablesToTruncate = array(
475 'civicrm_contact',
476 'civicrm_financial_type',
477 'civicrm_contribution',
478 'civicrm_contribution_page',
479 );
480 $unitTest = new CiviUnitTestCase();
481 $unitTest->quickCleanup($tablesToTruncate);
482 }
483}
484