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