3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
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
{
40 public function setUp() {
42 $this->_financialTypeID
= 1;
45 public function tearDown() {
49 * Create() method (create Contribution Page)
51 public function testCreate() {
54 'qfkey' => '9a3ef3c08879ad4c8c109b21c583400e',
55 'title' => 'Test Contribution Page',
56 'financial_type_id' => $this->_financialTypeID
,
58 'footer_text' => 'Thanks',
59 'is_for_organization' => 0,
60 'for_organization' => ' I am contributing on behalf of an organization',
61 'goal_amount' => '400',
63 'honor_block_title' => '',
64 'honor_block_text' => '',
65 'start_date' => '20091022105900',
66 'start_date_time' => '10:59AM',
67 'end_date' => '19700101000000',
68 'end_date_time' => '',
69 'is_credit_card_only' => '',
73 $contributionpage = CRM_Contribute_BAO_ContributionPage
::create($params);
75 $this->assertNotNull($contributionpage->id
);
76 $this->assertType('int', $contributionpage->id
);
77 ContributionPage
::delete($contributionpage->id
);
81 * test setIsActive() method
83 public function testsetIsActive() {
86 'title' => 'Test Contribution Page',
87 'financial_type_id' => $this->_financialTypeID
,
91 $contributionpage = CRM_Contribute_BAO_ContributionPage
::create($params);
92 $id = $contributionpage->id
;
94 $pageActive = CRM_Contribute_BAO_ContributionPage
::setIsActive($id, $is_active);
95 $this->assertEquals($pageActive, true, 'Verify financial types record deletion.');
96 ContributionPage
::delete($contributionpage->id
);
100 * Test setValues() method
102 public function testSetValues() {
105 'title' => 'Test Contribution Page',
106 'financial_type_id' => $this->_financialTypeID
,
110 $contributionpage = CRM_Contribute_BAO_ContributionPage
::create($params);
112 $id = $contributionpage->id
;
114 $setValues = CRM_Contribute_BAO_ContributionPage
::setValues($id, $values);
116 $this->assertEquals($params['title'], $values['title'], 'Verify contribution title.');
117 $this->assertEquals($this->_financialTypeID
, $values['financial_type_id'], 'Verify financial types id.');
118 $this->assertEquals(1, $values['is_active'], 'Verify contribution is_active value.');
119 ContributionPage
::delete($contributionpage->id
);
125 public function testcopy() {
127 'qfkey' => '9a3ef3c08879ad4c8c109b21c583400e',
128 'title' => 'Test Contribution Page',
129 'financial_type_id' => $this->_financialTypeID
,
131 'footer_text' => 'Thanks',
132 'is_for_organization' => 0,
133 'for_organization' => ' I am contributing on behalf of an organization',
134 'goal_amount' => '400',
136 'honor_block_title' => '',
137 'honor_block_text' => '',
138 'start_date' => '20091022105900',
139 'start_date_time' => '10:59AM',
140 'end_date' => '19700101000000',
141 'end_date_time' => '',
142 'is_credit_card_only' => '',
146 $contributionpage = CRM_Contribute_BAO_ContributionPage
::create($params);
147 $copycontributionpage = CRM_Contribute_BAO_ContributionPage
::copy($contributionpage->id
);
148 $this->assertEquals($copycontributionpage->financial_type_id
, $this->_financialTypeID
, 'Check for Financial type id.');
149 $this->assertEquals($copycontributionpage->goal_amount
, 400, 'Check for goal amount.');
150 ContributionPage
::delete($contributionpage->id
);
151 ContributionPage
::delete($copycontributionpage->id
);
155 * Test checkRecurPaymentProcessor() method
157 public function testcheckRecurPaymentProcessor() {
158 //@todo paypalpro create seems to fail silently without causing this class to fail
159 // $this->paymentProcessorCreate may be a better option
160 $paymentProcessor = PaypalPro
::create();
162 'title' => 'Test Contribution Page',
163 'financial_type_id' => $this->_financialTypeID
,
165 'payment_processor_id' => $paymentProcessor,
168 $contributionpage = CRM_Contribute_BAO_ContributionPage
::create($params);
169 $id = $contributionpage->id
;
170 $checkRecurring = CRM_Contribute_BAO_ContributionPage
::checkRecurPaymentProcessor($id);
171 $this->assertEquals($checkRecurring, FALSE, 'Check for false return.');
172 ContributionPage
::delete($contributionpage->id
);