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';
36 * Class CRM_Contribute_BAO_ContributionPageTest
38 class CRM_Contribute_BAO_ContributionPageTest
extends CiviUnitTestCase
{
44 'name' => 'Contribution BAOs',
45 'description' => 'Test all Contribute_BAO_ContributionPage methods.',
46 'group' => 'CiviCRM BAO Tests',
52 $this->_financialTypeID
= 1;
59 * create() method (create Contribution Page)
61 function testCreate() {
64 'qfkey' => '9a3ef3c08879ad4c8c109b21c583400e',
65 'title' => 'Test Contribution Page',
66 'financial_type_id' => $this->_financialTypeID
,
68 'footer_text' => 'Thanks',
69 'is_for_organization' => 0,
70 'for_organization' => ' I am contributing on behalf of an organization',
71 'goal_amount' => '400',
73 'honor_block_title' => '',
74 'honor_block_text' => '',
75 'start_date' => '20091022105900',
76 'start_date_time' => '10:59AM',
77 'end_date' => '19700101000000',
78 'end_date_time' => '',
79 'is_credit_card_only' => '',
83 $contributionpage = CRM_Contribute_BAO_ContributionPage
::create($params);
85 $this->assertNotNull($contributionpage->id
);
86 $this->assertType('int', $contributionpage->id
);
87 ContributionPage
::delete($contributionpage->id
);
91 * test setIsActive() method
93 function testsetIsActive() {
96 'title' => 'Test Contribution Page',
97 'financial_type_id' => $this->_financialTypeID
,
101 $contributionpage = CRM_Contribute_BAO_ContributionPage
::create($params);
102 $id = $contributionpage->id
;
104 $pageActive = CRM_Contribute_BAO_ContributionPage
::setIsActive($id, $is_active);
105 $this->assertEquals($pageActive, true, 'Verify financial types record deletion.');
106 ContributionPage
::delete($contributionpage->id
);
110 * test setValues() method
112 function testSetValues() {
115 'title' => 'Test Contribution Page',
116 'financial_type_id' => $this->_financialTypeID
,
120 $contributionpage = CRM_Contribute_BAO_ContributionPage
::create($params);
122 $id = $contributionpage->id
;
124 $setValues = CRM_Contribute_BAO_ContributionPage
::setValues($id, $values);
126 $this->assertEquals($params['title'], $values['title'], 'Verify contribution title.');
127 $this->assertEquals($this->_financialTypeID
, $values['financial_type_id'], 'Verify financial types id.');
128 $this->assertEquals(1, $values['is_active'], 'Verify contribution is_active value.');
129 ContributionPage
::delete($contributionpage->id
);
135 function testcopy() {
137 'qfkey' => '9a3ef3c08879ad4c8c109b21c583400e',
138 'title' => 'Test Contribution Page',
139 'financial_type_id' => $this->_financialTypeID
,
141 'footer_text' => 'Thanks',
142 'is_for_organization' => 0,
143 'for_organization' => ' I am contributing on behalf of an organization',
144 'goal_amount' => '400',
146 'honor_block_title' => '',
147 'honor_block_text' => '',
148 'start_date' => '20091022105900',
149 'start_date_time' => '10:59AM',
150 'end_date' => '19700101000000',
151 'end_date_time' => '',
152 'is_credit_card_only' => '',
156 $contributionpage = CRM_Contribute_BAO_ContributionPage
::create($params);
157 $copycontributionpage = CRM_Contribute_BAO_ContributionPage
::copy($contributionpage->id
);
158 $this->assertEquals($copycontributionpage->financial_type_id
, $this->_financialTypeID
, 'Check for Financial type id.');
159 $this->assertEquals($copycontributionpage->goal_amount
, 400, 'Check for goal amount.');
160 ContributionPage
::delete($contributionpage->id
);
161 ContributionPage
::delete($copycontributionpage->id
);
165 * test checkRecurPaymentProcessor() method
167 function testcheckRecurPaymentProcessor() {
168 //@todo paypalpro create seems to fail silently without causing this class to fail
169 // $this->paymentProcessorCreate may be a better option
170 $paymentProcessor = PaypalPro
::create();
172 'title' => 'Test Contribution Page',
173 'financial_type_id' => $this->_financialTypeID
,
175 'payment_processor_id' => $paymentProcessor,
178 $contributionpage = CRM_Contribute_BAO_ContributionPage
::create($params);
179 $id = $contributionpage->id
;
180 $checkRecurring = CRM_Contribute_BAO_ContributionPage
::checkRecurPaymentProcessor($id);
181 $this->assertEquals($checkRecurring, FALSE, 'Check for false return.');
182 ContributionPage
::delete($contributionpage->id
);