3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
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 * Class CRM_Contribute_BAO_ContributionPageTest
32 class CRM_Contribute_BAO_ContributionPageTest
extends CiviUnitTestCase
{
34 public function setUp() {
36 $this->_financialTypeID
= 1;
39 public function tearDown() {
43 * Create() method (create Contribution Page)
45 public function testCreate() {
48 'qfkey' => '9a3ef3c08879ad4c8c109b21c583400e',
49 'title' => 'Test Contribution Page',
50 'financial_type_id' => $this->_financialTypeID
,
52 'footer_text' => 'Thanks',
53 'is_for_organization' => 0,
54 'for_organization' => ' I am contributing on behalf of an organization',
55 'goal_amount' => '400',
57 'honor_block_title' => '',
58 'honor_block_text' => '',
59 'start_date' => '20091022105900',
60 'start_date_time' => '10:59AM',
61 'end_date' => '19700101000000',
62 'end_date_time' => '',
63 'is_credit_card_only' => '',
66 $contributionpage = CRM_Contribute_BAO_ContributionPage
::create($params);
68 $this->assertNotNull($contributionpage->id
);
69 $this->assertType('int', $contributionpage->id
);
70 $this->callAPISuccess('ContributionPage', 'delete', array('id' => $contributionpage->id
));
74 * test setIsActive() method
76 public function testsetIsActive() {
79 'title' => 'Test Contribution Page',
80 'financial_type_id' => $this->_financialTypeID
,
84 $contributionpage = CRM_Contribute_BAO_ContributionPage
::create($params);
85 $id = $contributionpage->id
;
87 $pageActive = CRM_Contribute_BAO_ContributionPage
::setIsActive($id, $is_active);
88 $this->assertEquals($pageActive, TRUE, 'Verify financial types record deletion.');
89 $this->callAPISuccess('ContributionPage', 'delete', array('id' => $contributionpage->id
));
93 * Test setValues() method
95 public function testSetValues() {
98 'title' => 'Test Contribution Page',
99 'financial_type_id' => $this->_financialTypeID
,
103 $contributionPage = CRM_Contribute_BAO_ContributionPage
::create($params);
105 $id = $contributionPage->id
;
107 CRM_Contribute_BAO_ContributionPage
::setValues($id, $values);
109 $this->assertEquals($params['title'], $values['title'], 'Verify contribution title.');
110 $this->assertEquals($this->_financialTypeID
, $values['financial_type_id'], 'Verify financial types id.');
111 $this->assertEquals(1, $values['is_active'], 'Verify contribution is_active value.');
112 $this->callAPISuccess('ContributionPage', 'delete', array('id' => $contributionPage->id
));
118 public function testcopy() {
120 'qfkey' => '9a3ef3c08879ad4c8c109b21c583400e',
121 'title' => 'Test Contribution Page',
122 'financial_type_id' => $this->_financialTypeID
,
124 'footer_text' => 'Thanks',
125 'is_for_organization' => 0,
126 'for_organization' => ' I am contributing on behalf of an organization',
127 'goal_amount' => '400',
129 'honor_block_title' => '',
130 'honor_block_text' => '',
131 'start_date' => '20091022105900',
132 'start_date_time' => '10:59AM',
133 'end_date' => '19700101000000',
134 'end_date_time' => '',
135 'is_credit_card_only' => '',
138 $contributionPage = CRM_Contribute_BAO_ContributionPage
::create($params);
139 $copyContributionPage = CRM_Contribute_BAO_ContributionPage
::copy($contributionPage->id
);
140 $this->assertEquals($copyContributionPage->financial_type_id
, $this->_financialTypeID
, 'Check for Financial type id.');
141 $this->assertEquals($copyContributionPage->goal_amount
, 400, 'Check for goal amount.');
142 $this->callAPISuccess('ContributionPage', 'delete', array('id' => $contributionPage->id
));
143 $this->callAPISuccess('ContributionPage', 'delete', array('id' => $copyContributionPage->id
));