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