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