3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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 +--------------------------------------------------------------------+
28 require_once 'CiviTest/Contact.php';
29 require_once 'CiviTest/ContributionPage.php';
30 require_once 'CiviTest/Custom.php';
31 require_once 'CiviTest/PaypalPro.php';
34 * Class CRM_Contribute_BAO_ContributionPageTest
37 class CRM_Contribute_BAO_ContributionPageTest
extends CiviUnitTestCase
{
39 public function setUp() {
41 $this->_financialTypeID
= 1;
44 public function tearDown() {
48 * Create() method (create Contribution Page)
50 public function testCreate() {
53 'qfkey' => '9a3ef3c08879ad4c8c109b21c583400e',
54 'title' => 'Test Contribution Page',
55 'financial_type_id' => $this->_financialTypeID
,
57 'footer_text' => 'Thanks',
58 'is_for_organization' => 0,
59 'for_organization' => ' I am contributing on behalf of an organization',
60 'goal_amount' => '400',
62 'honor_block_title' => '',
63 'honor_block_text' => '',
64 'start_date' => '20091022105900',
65 'start_date_time' => '10:59AM',
66 'end_date' => '19700101000000',
67 'end_date_time' => '',
68 'is_credit_card_only' => '',
71 $contributionpage = CRM_Contribute_BAO_ContributionPage
::create($params);
73 $this->assertNotNull($contributionpage->id
);
74 $this->assertType('int', $contributionpage->id
);
75 ContributionPage
::delete($contributionpage->id
);
79 * test setIsActive() method
81 public function testsetIsActive() {
84 'title' => 'Test Contribution Page',
85 'financial_type_id' => $this->_financialTypeID
,
89 $contributionpage = CRM_Contribute_BAO_ContributionPage
::create($params);
90 $id = $contributionpage->id
;
92 $pageActive = CRM_Contribute_BAO_ContributionPage
::setIsActive($id, $is_active);
93 $this->assertEquals($pageActive, TRUE, 'Verify financial types record deletion.');
94 ContributionPage
::delete($contributionpage->id
);
98 * Test setValues() method
100 public function testSetValues() {
103 'title' => 'Test Contribution Page',
104 'financial_type_id' => $this->_financialTypeID
,
108 $contributionpage = CRM_Contribute_BAO_ContributionPage
::create($params);
110 $id = $contributionpage->id
;
112 $setValues = CRM_Contribute_BAO_ContributionPage
::setValues($id, $values);
114 $this->assertEquals($params['title'], $values['title'], 'Verify contribution title.');
115 $this->assertEquals($this->_financialTypeID
, $values['financial_type_id'], 'Verify financial types id.');
116 $this->assertEquals(1, $values['is_active'], 'Verify contribution is_active value.');
117 ContributionPage
::delete($contributionpage->id
);
123 public function testcopy() {
125 'qfkey' => '9a3ef3c08879ad4c8c109b21c583400e',
126 'title' => 'Test Contribution Page',
127 'financial_type_id' => $this->_financialTypeID
,
129 'footer_text' => 'Thanks',
130 'is_for_organization' => 0,
131 'for_organization' => ' I am contributing on behalf of an organization',
132 'goal_amount' => '400',
134 'honor_block_title' => '',
135 'honor_block_text' => '',
136 'start_date' => '20091022105900',
137 'start_date_time' => '10:59AM',
138 'end_date' => '19700101000000',
139 'end_date_time' => '',
140 'is_credit_card_only' => '',
143 $contributionpage = CRM_Contribute_BAO_ContributionPage
::create($params);
144 $copycontributionpage = CRM_Contribute_BAO_ContributionPage
::copy($contributionpage->id
);
145 $this->assertEquals($copycontributionpage->financial_type_id
, $this->_financialTypeID
, 'Check for Financial type id.');
146 $this->assertEquals($copycontributionpage->goal_amount
, 400, 'Check for goal amount.');
147 ContributionPage
::delete($contributionpage->id
);
148 ContributionPage
::delete($copycontributionpage->id
);