this fixes most of contribution webtests
[civicrm-core.git] / tests / phpunit / CiviTest / ContributionPage.php
CommitLineData
6a488035
TO
1<?php
2class ContributionPage extends PHPUnit_Framework_Testcase {
3 /**
4 * Helper function to create
5 * a Contribution Page
6 *
7 * @return $contributionPage id of created Contribution Page
8 */
9 static function create($id = NULL) {
10 require_once "CRM/Contribute/BAO/ContributionPage.php";
11 $params = array(
12 'title' => 'Help Test CiviCRM!',
13 'intro_text' => 'Created for Test Coverage Online Contribution Page',
14 'financial_type_id' => 1,
15 'payment_processor_id' => $id,
16 'is_monetary' => 1,
17 'is_allow_other_amount' => 1,
18 'min_amount' => 10,
19 'max_amount' => 10000,
20 'goal_amount' => 100000,
21 'thankyou_title' => 'Thanks for Your Support!',
22 'thankyou_text' => 'Thank you for your support.',
23 'is_email_receipt' => 1,
24 'receipt_from_name' => 'From TEST',
25 'receipt_from_email' => 'donations@civicrm.org',
26 'cc_receipt' => 'receipt@example.com',
27 'bcc_receipt' => 'bcc@example.com',
28 'is_active' => 1,
29 );
30
31 $contributionPage = CRM_Contribute_BAO_ContributionPage::create($params);
32 return $contributionPage->id;
33 }
34
35 /**
36 * Helper function to delete a Contribution Page
37 *
38 * @param int $contributionPageId - id of the Contribution Page
39 * to be deleted
40 * @return boolean true if Contribution Page deleted, false otherwise
41 */
42 static function delete($contributionPageId) {
43 require_once "CRM/Contribute/DAO/ContributionPage.php";
44 $cp = new CRM_Contribute_DAO_ContributionPage();
45 $cp->id = $contributionPageId;
46 if ($cp->find(TRUE)) {
47 $result = $cp->delete();
48 }
49 return $result;
50 }
51}