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() {
20 $this->_financialTypeID
= 1;
23 public function tearDown() {
27 * Create() method (create Contribution Page)
29 public function testCreate() {
32 'qfkey' => '9a3ef3c08879ad4c8c109b21c583400e',
33 'title' => 'Test Contribution Page',
34 'financial_type_id' => $this->_financialTypeID
,
36 'footer_text' => 'Thanks',
37 'is_for_organization' => 0,
38 'for_organization' => ' I am contributing on behalf of an organization',
39 'goal_amount' => '400',
41 'honor_block_title' => '',
42 'honor_block_text' => '',
43 'start_date' => '20091022105900',
44 'start_date_time' => '10:59AM',
45 'end_date' => '19700101000000',
46 'end_date_time' => '',
47 'is_credit_card_only' => '',
50 $contributionpage = CRM_Contribute_BAO_ContributionPage
::create($params);
52 $this->assertNotNull($contributionpage->id
);
53 $this->assertType('int', $contributionpage->id
);
54 $this->callAPISuccess('ContributionPage', 'delete', ['id' => $contributionpage->id
]);
58 * test setIsActive() method
60 public function testsetIsActive() {
63 'title' => 'Test Contribution Page',
64 'financial_type_id' => $this->_financialTypeID
,
68 $contributionpage = CRM_Contribute_BAO_ContributionPage
::create($params);
69 $id = $contributionpage->id
;
71 $pageActive = CRM_Contribute_BAO_ContributionPage
::setIsActive($id, $is_active);
72 $this->assertEquals($pageActive, TRUE, 'Verify financial types record deletion.');
73 $this->callAPISuccess('ContributionPage', 'delete', ['id' => $contributionpage->id
]);
77 * Test setValues() method
79 public function testSetValues() {
82 'title' => 'Test Contribution Page',
83 'financial_type_id' => $this->_financialTypeID
,
87 $contributionPage = CRM_Contribute_BAO_ContributionPage
::create($params);
89 $id = $contributionPage->id
;
91 CRM_Contribute_BAO_ContributionPage
::setValues($id, $values);
93 $this->assertEquals($params['title'], $values['title'], 'Verify contribution title.');
94 $this->assertEquals($this->_financialTypeID
, $values['financial_type_id'], 'Verify financial types id.');
95 $this->assertEquals(1, $values['is_active'], 'Verify contribution is_active value.');
96 $this->callAPISuccess('ContributionPage', 'delete', ['id' => $contributionPage->id
]);
102 public function testcopy() {
104 'qfkey' => '9a3ef3c08879ad4c8c109b21c583400e',
105 'title' => 'Test Contribution Page',
106 'financial_type_id' => $this->_financialTypeID
,
108 'footer_text' => 'Thanks',
109 'is_for_organization' => 0,
110 'for_organization' => ' I am contributing on behalf of an organization',
111 'goal_amount' => '400',
113 'honor_block_title' => '',
114 'honor_block_text' => '',
115 'start_date' => '20091022105900',
116 'start_date_time' => '10:59AM',
117 'end_date' => '19700101000000',
118 'end_date_time' => '',
119 'is_credit_card_only' => '',
122 $contributionPage = CRM_Contribute_BAO_ContributionPage
::create($params);
123 $copyContributionPage = CRM_Contribute_BAO_ContributionPage
::copy($contributionPage->id
);
124 $this->assertEquals($copyContributionPage->financial_type_id
, $this->_financialTypeID
, 'Check for Financial type id.');
125 $this->assertEquals($copyContributionPage->goal_amount
, 400, 'Check for goal amount.');
126 $this->callAPISuccess('ContributionPage', 'delete', ['id' => $contributionPage->id
]);
127 $this->callAPISuccess('ContributionPage', 'delete', ['id' => $copyContributionPage->id
]);