3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
29 require_once 'CiviTest/CiviUnitTestCase.php';
30 require_once 'CiviTest/Contact.php';
31 require_once 'CiviTest/ContributionPage.php';
32 require_once 'CiviTest/Custom.php';
33 require_once 'CiviTest/PaypalPro.php';
34 class CRM_Contribute_BAO_ContributionPageTest
extends CiviUnitTestCase
{
37 'name' => 'Contribution BAOs',
38 'description' => 'Test all Contribute_BAO_ContributionPage methods.',
39 'group' => 'CiviCRM BAO Tests',
45 $this->_financialTypeID
= 1;
52 * create() method (create Contribution Page)
54 function testCreate() {
57 'qfkey' => '9a3ef3c08879ad4c8c109b21c583400e',
58 'title' => 'Test Contribution Page',
59 'financial_type_id' => $this->_financialTypeID
,
61 'footer_text' => 'Thanks',
62 'is_for_organization' => 0,
63 'for_organization' => ' I am contributing on behalf of an organization',
64 'goal_amount' => '400',
66 'honor_block_title' => '',
67 'honor_block_text' => '',
68 'start_date' => '20091022105900',
69 'start_date_time' => '10:59AM',
70 'end_date' => '19700101000000',
71 'end_date_time' => '',
72 'is_credit_card_only' => '',
76 $contributionpage = CRM_Contribute_BAO_ContributionPage
::create($params);
78 $this->assertNotNull($contributionpage->id
);
79 $this->assertType('int', $contributionpage->id
);
80 ContributionPage
::delete($contributionpage->id
);
84 * test setIsActive() method
86 function testsetIsActive() {
89 'title' => 'Test Contribution Page',
90 'financial_type_id' => $this->_financialTypeID
,
94 $contributionpage = CRM_Contribute_BAO_ContributionPage
::create($params);
95 $id = $contributionpage->id
;
97 $pageActive = CRM_Contribute_BAO_ContributionPage
::setIsActive($id, $is_active);
98 $this->assertEquals($pageActive, true, 'Verify financial types record deletion.');
99 ContributionPage
::delete($contributionpage->id
);
103 * test setValues() method
105 function testSetValues() {
108 'title' => 'Test Contribution Page',
109 'financial_type_id' => $this->_financialTypeID
,
113 $contributionpage = CRM_Contribute_BAO_ContributionPage
::create($params);
115 $id = $contributionpage->id
;
117 $setValues = CRM_Contribute_BAO_ContributionPage
::setValues($id, $values);
119 $this->assertEquals($params['title'], $values['title'], 'Verify contribution title.');
120 $this->assertEquals($this->_financialTypeID
, $values['financial_type_id'], 'Verify financial types id.');
121 $this->assertEquals(1, $values['is_active'], 'Verify contribution is_active value.');
122 ContributionPage
::delete($contributionpage->id
);
128 function testcopy() {
130 'qfkey' => '9a3ef3c08879ad4c8c109b21c583400e',
131 'title' => 'Test Contribution Page',
132 'financial_type_id' => $this->_financialTypeID
,
134 'footer_text' => 'Thanks',
135 'is_for_organization' => 0,
136 'for_organization' => ' I am contributing on behalf of an organization',
137 'goal_amount' => '400',
139 'honor_block_title' => '',
140 'honor_block_text' => '',
141 'start_date' => '20091022105900',
142 'start_date_time' => '10:59AM',
143 'end_date' => '19700101000000',
144 'end_date_time' => '',
145 'is_credit_card_only' => '',
149 $contributionpage = CRM_Contribute_BAO_ContributionPage
::create($params);
150 $copycontributionpage = CRM_Contribute_BAO_ContributionPage
::copy($contributionpage->id
);
151 $this->assertEquals($copycontributionpage->financial_type_id
, $this->_financialTypeID
, 'Check for Financial type id.');
152 $this->assertEquals($copycontributionpage->goal_amount
, 400, 'Check for goal amount.');
153 ContributionPage
::delete($contributionpage->id
);
154 ContributionPage
::delete($copycontributionpage->id
);
158 * test checkRecurPaymentProcessor() method
160 function testcheckRecurPaymentProcessor() {
161 //@todo paypalpro create seems to fail silently without causing this class to fail
162 // $this->paymentProcessorCreate may be a better option
163 $paymentProcessor = PaypalPro
::create();
165 'title' => 'Test Contribution Page',
166 'financial_type_id' => $this->_financialTypeID
,
168 'payment_processor_id' => $paymentProcessor,
171 $contributionpage = CRM_Contribute_BAO_ContributionPage
::create($params);
172 $id = $contributionpage->id
;
173 $checkRecurring = CRM_Contribute_BAO_ContributionPage
::checkRecurPaymentProcessor($id);
174 $this->assertEquals($checkRecurring, FALSE, 'Check for false return.');
175 ContributionPage
::delete($contributionpage->id
);