| 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 int $id |
| 12 | * |
| 13 | * @return int |
| 14 | * id of created Contribution Page |
| 15 | */ |
| 16 | public static function create($id = NULL) { |
| 17 | require_once "CRM/Contribute/BAO/ContributionPage.php"; |
| 18 | $params = array( |
| 19 | 'title' => 'Help Test CiviCRM!', |
| 20 | 'intro_text' => 'Created for Test Coverage Online Contribution Page', |
| 21 | 'financial_type_id' => 1, |
| 22 | 'payment_processor_id' => $id, |
| 23 | 'is_monetary' => 1, |
| 24 | 'is_allow_other_amount' => 1, |
| 25 | 'min_amount' => 10, |
| 26 | 'max_amount' => 10000, |
| 27 | 'goal_amount' => 100000, |
| 28 | 'thankyou_title' => 'Thank you for your support!', |
| 29 | 'thankyou_text' => 'Thank you for your support.', |
| 30 | 'is_email_receipt' => 1, |
| 31 | 'receipt_from_name' => 'From TEST', |
| 32 | 'receipt_from_email' => 'donations@civicrm.org', |
| 33 | 'cc_receipt' => 'receipt@example.com', |
| 34 | 'bcc_receipt' => 'bcc@example.com', |
| 35 | 'is_active' => 1, |
| 36 | ); |
| 37 | |
| 38 | $contributionPage = CRM_Contribute_BAO_ContributionPage::create($params); |
| 39 | return $contributionPage->id; |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Helper function to delete a Contribution Page. |
| 44 | * |
| 45 | * @param int $contributionPageId |
| 46 | * Id of the Contribution Page. |
| 47 | * to be deleted |
| 48 | * @return bool |
| 49 | * true if Contribution Page deleted, false otherwise |
| 50 | */ |
| 51 | public static function delete($contributionPageId) { |
| 52 | require_once "CRM/Contribute/DAO/ContributionPage.php"; |
| 53 | $cp = new CRM_Contribute_DAO_ContributionPage(); |
| 54 | $cp->id = $contributionPageId; |
| 55 | if ($cp->find(TRUE)) { |
| 56 | $result = $cp->delete(); |
| 57 | } |
| 58 | return $result; |
| 59 | } |
| 60 | |
| 61 | } |