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