3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
13 * Class CRM_Contribute_BAO_ContributionPageTest
16 class CRM_Contribute_BAO_ContributionPageTest
extends CiviUnitTestCase
{
18 public function setUp(): void
{
20 $this->_financialTypeID
= 1;
24 * Create() method (create Contribution Page)
26 public function testCreate() {
29 'qfkey' => '9a3ef3c08879ad4c8c109b21c583400e',
30 'title' => 'Test Contribution Page',
31 'financial_type_id' => $this->_financialTypeID
,
33 'footer_text' => 'Thanks',
34 'is_for_organization' => 0,
35 'for_organization' => ' I am contributing on behalf of an organization',
36 'goal_amount' => '400',
38 'honor_block_title' => '',
39 'honor_block_text' => '',
40 'start_date' => '20091022105900',
41 'start_date_time' => '10:59AM',
42 'end_date' => '19700101000000',
43 'end_date_time' => '',
44 'is_credit_card_only' => '',
47 $contributionpage = CRM_Contribute_BAO_ContributionPage
::create($params);
49 $this->assertNotNull($contributionpage->id
);
50 $this->assertIsInt($contributionpage->id
);
51 $this->callAPISuccess('ContributionPage', 'delete', ['id' => $contributionpage->id
]);
55 * test setIsActive() method
57 public function testsetIsActive() {
60 'title' => 'Test Contribution Page',
61 'financial_type_id' => $this->_financialTypeID
,
65 $contributionpage = CRM_Contribute_BAO_ContributionPage
::create($params);
66 $id = $contributionpage->id
;
68 $pageActive = CRM_Contribute_BAO_ContributionPage
::setIsActive($id, $is_active);
69 $this->assertEquals($pageActive, TRUE, 'Verify financial types record deletion.');
70 $this->callAPISuccess('ContributionPage', 'delete', ['id' => $contributionpage->id
]);
74 * Test setValues() method
76 public function testSetValues() {
79 'title' => 'Test Contribution Page',
80 'financial_type_id' => $this->_financialTypeID
,
84 $contributionPage = CRM_Contribute_BAO_ContributionPage
::create($params);
86 $id = $contributionPage->id
;
88 CRM_Contribute_BAO_ContributionPage
::setValues($id, $values);
90 $this->assertEquals($params['title'], $values['title'], 'Verify contribution title.');
91 $this->assertEquals($this->_financialTypeID
, $values['financial_type_id'], 'Verify financial types id.');
92 $this->assertEquals(1, $values['is_active'], 'Verify contribution is_active value.');
93 $this->callAPISuccess('ContributionPage', 'delete', ['id' => $contributionPage->id
]);
99 public function testcopy() {
101 'qfkey' => '9a3ef3c08879ad4c8c109b21c583400e',
102 'title' => 'Test Contribution Page',
103 'financial_type_id' => $this->_financialTypeID
,
105 'footer_text' => 'Thanks',
106 'is_for_organization' => 0,
107 'for_organization' => ' I am contributing on behalf of an organization',
108 'goal_amount' => '400',
110 'honor_block_title' => '',
111 'honor_block_text' => '',
112 'start_date' => '20091022105900',
113 'start_date_time' => '10:59AM',
114 'end_date' => '19700101000000',
115 'end_date_time' => '',
116 'is_credit_card_only' => '',
119 $contributionPage = CRM_Contribute_BAO_ContributionPage
::create($params);
120 $copyContributionPage = CRM_Contribute_BAO_ContributionPage
::copy($contributionPage->id
);
121 $this->assertEquals($copyContributionPage->financial_type_id
, $this->_financialTypeID
, 'Check for Financial type id.');
122 $this->assertEquals($copyContributionPage->goal_amount
, 400, 'Check for goal amount.');
123 $this->callAPISuccess('ContributionPage', 'delete', ['id' => $contributionPage->id
]);
124 $this->callAPISuccess('ContributionPage', 'delete', ['id' => $copyContributionPage->id
]);