CRM-13072 mark non e-notice compliant tests
[civicrm-core.git] / tests / phpunit / CRM / Contribute / BAO / ContributionPageTest.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
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. |
13 | |
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. |
18 | |
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 +--------------------------------------------------------------------+
26*/
27
28
29require_once 'CiviTest/CiviUnitTestCase.php';
30require_once 'CiviTest/Contact.php';
31require_once 'CiviTest/ContributionPage.php';
32require_once 'CiviTest/Custom.php';
33require_once 'CiviTest/PaypalPro.php';
34class CRM_Contribute_BAO_ContributionPageTest extends CiviUnitTestCase {
35 function get_info() {
36 return array(
37 'name' => 'Contribution BAOs',
38 'description' => 'Test all Contribute_BAO_ContributionPage methods.',
39 'group' => 'CiviCRM BAO Tests',
40 );
41 }
42
43 function setUp() {
44 parent::setUp();
45 $this->_contributionTypeID = $this->contributionTypeCreate();
46 }
47
48 function tearDown() {
49 $this->contributionTypeDelete();
50 }
51
52 /**
53 * create() method (create Contribution Page)
54 */
55 function testCreate() {
56
57 $params = array(
58 'qfkey' => '9a3ef3c08879ad4c8c109b21c583400e',
59 'title' => 'Test Contribution Page',
f17d75bb 60 'financial_type_id' => $this->_contributionTypeID,
6a488035
TO
61 'intro_text' => '',
62 'footer_text' => 'Thanks',
63 'is_for_organization' => 0,
64 'for_organization' => ' I am contributing on behalf of an organization',
65 'goal_amount' => '400',
66 'is_active' => 1,
67 'honor_block_title' => '',
68 'honor_block_text' => '',
69 'start_date' => '20091022105900',
70 'start_date_time' => '10:59AM',
71 'end_date' => '19700101000000',
72 'end_date_time' => '',
73 'is_credit_card_only' => '',
74 );
75
76
77 $contributionpage = CRM_Contribute_BAO_ContributionPage::create($params);
78
79 $this->assertNotNull($contributionpage->id);
80 $this->assertType('int', $contributionpage->id);
81 ContributionPage::delete($contributionpage->id);
82 }
83
84 /**
85 * test setIsActive() method
86 */
87 function testsetIsActive() {
88
89 $params = array(
90 'title' => 'Test Contribution Page',
f17d75bb 91 'financial_type_id' => $this->_contributionTypeID,
6a488035
TO
92 'is_active' => 1,
93 );
94
95 $contributionpage = CRM_Contribute_BAO_ContributionPage::create($params);
96 $id = $contributionpage->id;
97 $is_active = 1;
98 $pageActive = CRM_Contribute_BAO_ContributionPage::setIsActive($id, $is_active);
f17d75bb 99 $this->assertEquals($pageActive, true, 'Verify financial types record deletion.');
6a488035
TO
100 ContributionPage::delete($contributionpage->id);
101 }
102
103 /**
104 * test setValues() method
105 */
106 function testSetValues() {
107
108 $params = array(
109 'title' => 'Test Contribution Page',
f17d75bb 110 'financial_type_id' => $this->_contributionTypeID,
6a488035
TO
111 'is_active' => 1,
112 );
113
114 $contributionpage = CRM_Contribute_BAO_ContributionPage::create($params);
115
116 $id = $contributionpage->id;
117 $values = array();
118 $setValues = CRM_Contribute_BAO_ContributionPage::setValues($id, $values);
119
120 $this->assertEquals($params['title'], $values['title'], 'Verify contribution title.');
f17d75bb 121 $this->assertEquals($this->_contributionTypeID, $values['financial_type_id'], 'Verify financial types id.');
6a488035
TO
122 $this->assertEquals(1, $values['is_active'], 'Verify contribution is_active value.');
123 ContributionPage::delete($contributionpage->id);
124 }
125
126 /**
127 * test copy() method
128 */
129 function testcopy() {
130 $params = array(
131 'qfkey' => '9a3ef3c08879ad4c8c109b21c583400e',
132 'title' => 'Test Contribution Page',
f17d75bb 133 'financial_type_id' => $this->_contributionTypeID,
6a488035
TO
134 'intro_text' => '',
135 'footer_text' => 'Thanks',
136 'is_for_organization' => 0,
137 'for_organization' => ' I am contributing on behalf of an organization',
138 'goal_amount' => '400',
139 'is_active' => 1,
140 'honor_block_title' => '',
141 'honor_block_text' => '',
142 'start_date' => '20091022105900',
143 'start_date_time' => '10:59AM',
144 'end_date' => '19700101000000',
145 'end_date_time' => '',
146 'is_credit_card_only' => '',
147 );
148
149
150 $contributionpage = CRM_Contribute_BAO_ContributionPage::create($params);
151 $copycontributionpage = CRM_Contribute_BAO_ContributionPage::copy($contributionpage->id);
f17d75bb 152 $this->assertEquals($copycontributionpage->financial_type_id, $this->_contributionTypeID, 'Check for Financial type id.');
6a488035
TO
153 $this->assertEquals($copycontributionpage->goal_amount, 400, 'Check for goal amount.');
154 ContributionPage::delete($contributionpage->id);
155 ContributionPage::delete($copycontributionpage->id);
156 }
157
158 /**
159 * test checkRecurPaymentProcessor() method
160 */
161 function testcheckRecurPaymentProcessor() {
162 $paymentProcessor = PaypalPro::create();
163 $params = array(
164 'title' => 'Test Contribution Page',
165 'financial_type_id' => $this->_contributionTypeID,
166 'is_active' => 1,
167 'payment_processor_id' => $paymentProcessor,
168 );
169
170 $contributionpage = CRM_Contribute_BAO_ContributionPage::create($params);
171 $id = $contributionpage->id;
172 $checkRecurring = CRM_Contribute_BAO_ContributionPage::checkRecurPaymentProcessor($id);
173 $this->assertEquals($checkRecurring, FALSE, 'Check for false return.');
174 ContributionPage::delete($contributionpage->id);
175 }
176}
177
178