Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
81621fee | 4 | | CiviCRM version 4.7 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
fa938177 | 6 | | Copyright CiviCRM LLC (c) 2004-2016 | |
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 along with this program; if not, contact CiviCRM LLC | | |
21 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
22 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
23 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
24 | +--------------------------------------------------------------------+ | |
25 | */ | |
26 | ||
6a488035 | 27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Contribute_OnBehalfOfOrganization | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { |
33 | protected $pageno = ''; | |
92915c55 | 34 | |
6a488035 TO |
35 | protected function setUp() { |
36 | parent::setUp(); | |
37 | } | |
38 | ||
00be9182 | 39 | public function testOnBehalfOfOrganization() { |
6a488035 TO |
40 | $this->webtestLogin(); |
41 | ||
42 | // create new individual | |
42daf119 CW |
43 | $firstName = 'John_' . substr(sha1(rand()), 0, 7); |
44 | $lastName = 'Anderson_' . substr(sha1(rand()), 0, 7); | |
45 | $email = "{$firstName}.{$lastName}@example.com"; | |
6a488035 TO |
46 | $contactParams = array( |
47 | 'first_name' => $firstName, | |
48 | 'last_name' => $lastName, | |
49 | 'email-5' => $email, | |
50 | ); | |
51 | $streetAddress = "100 Main Street"; | |
52 | ||
53 | //adding contact for membership sign up | |
54 | $this->webtestAddContact($firstName, $lastName, $email); | |
a471a3b6 | 55 | $cid = $this->urlArg('cid'); |
6a488035 | 56 | |
c3ad8633 CW |
57 | // Use default payment processor |
58 | $processorName = 'Test Processor'; | |
6a488035 TO |
59 | $processorType = 'Dummy'; |
60 | $pageTitle = substr(sha1(rand()), 0, 7); | |
61 | $rand = 100; | |
62 | $hash = substr(sha1(rand()), 0, 7); | |
63 | $amountSection = TRUE; | |
64 | $payLater = TRUE; | |
65 | $onBehalf = 'optional'; | |
66 | $pledges = FALSE; | |
67 | $recurring = FALSE; | |
68 | $memberships = FALSE; | |
69 | $memPriceSetId = NULL; | |
70 | $friend = TRUE; | |
71 | $profilePreId = NULL; | |
72 | $profilePostId = NULL; | |
73 | $premiums = FALSE; | |
74 | $widget = FALSE; | |
75 | $pcp = FALSE; | |
76 | $honoreeSection = FALSE; | |
77 | $isAddPaymentProcessor = TRUE; | |
78 | $isPcpApprovalNeeded = FALSE; | |
79 | $isSeparatePayment = FALSE; | |
80 | ||
81 | // create a new online contribution page | |
82 | // create contribution page with randomized title and default params | |
83 | $pageId = $this->webtestAddContributionPage($hash, | |
84 | $rand, | |
85 | $pageTitle, | |
86 | array($processorName => $processorType), | |
87 | $amountSection, | |
88 | $payLater, | |
89 | $onBehalf, | |
90 | $pledges, | |
91 | $recurring, | |
92 | $memberships, | |
93 | $memPriceSetId, | |
94 | $friend, | |
95 | $profilePreId, | |
96 | $profilePostId, | |
97 | $premiums, | |
98 | $widget, | |
99 | $pcp, | |
100 | $isAddPaymentProcessor, | |
101 | $isPcpApprovalNeeded, | |
102 | $isSeparatePayment, | |
103 | $honoreeSection | |
104 | ); | |
105 | ||
106 | //logout | |
42daf119 | 107 | $this->webtestLogout(); |
6a488035 | 108 | //$this->_testAnomoyousOganization($pageId, $cid, $pageTitle); |
42daf119 | 109 | $this->webtestLogout(); |
6a488035 | 110 | $this->_testUserWithOneRelationship($pageId, $cid, $pageTitle); |
42daf119 | 111 | $this->webtestLogout(); |
6a488035 TO |
112 | $this->_testUserWithMoreThanOneRelationship($pageId, $cid, $pageTitle); |
113 | } | |
114 | ||
00be9182 | 115 | public function testOnBehalfOfOrganizationWithMembershipData() { |
6a488035 TO |
116 | $this->webtestLogin(); |
117 | ||
0b49a3ec | 118 | // Create three new individual |
119 | $individuals = $organizations = array(); | |
120 | for ($i = 0; $i < 3; $i++) { | |
121 | $firstName = 'John_x_' . substr(sha1(rand()), 0, 7); | |
122 | $individuals[] = $firstName; | |
123 | $this->webtestAddContact($firstName, "Memberson", "{$firstName}@memberson.com"); | |
124 | } | |
6a488035 | 125 | |
0b49a3ec | 126 | // Create two organisations, one used for new Membership Type, and other for inherited membership purpose |
127 | for ($i = 0; $i < 2; $i++) { | |
128 | $orgName1 = "Org WebAccess" . substr(sha1(rand()), 0, 7); | |
129 | $orgEmail1 = substr(sha1(rand()), 0, 7) . "@web.com"; | |
130 | $organizations[] = array('name' => $orgName1, 'email' => $orgEmail1); | |
131 | $this->webtestAddOrganization($orgName1, $orgEmail1); | |
132 | } | |
6a488035 | 133 | |
0b49a3ec | 134 | // Create Employee relationship of last created organization $organizations[1] with all three $individuals |
135 | $this->waitForAjaxContent(); | |
6a488035 | 136 | $this->click("css=li#tab_rel a"); |
6a488035 TO |
137 | $this->waitForElementPresent('link=Add Relationship'); |
138 | $this->click('link=Add Relationship'); | |
6a488035 TO |
139 | $this->waitForElementPresent('relationship_type_id'); |
140 | $this->click("relationship_type_id"); | |
141 | $this->select("relationship_type_id", "label=Employer of"); | |
42daf119 | 142 | // search organization |
0b49a3ec | 143 | $this->select2('related_contact_id', $individuals, TRUE); |
42daf119 | 144 | // give permission |
0b49a3ec | 145 | //$this->click("is_permission_a_b"); |
146 | //$this->click("is_permission_b_a"); | |
42daf119 | 147 | // save relationship |
0b49a3ec | 148 | $this->click("_qf_Relationship_upload"); |
149 | $this->waitForAjaxContent(); | |
150 | ||
761fe7bb | 151 | $title = 'Membership Type' . substr(sha1(rand()), 0, 7); |
0b49a3ec | 152 | //Create membership type |
153 | $this->openCiviPage("admin/member/membershipType", "reset=1&action=browse"); | |
154 | $this->click("link=Add Membership Type"); | |
155 | $this->waitForElementPresent('_qf_MembershipType_cancel-bottom'); | |
156 | $this->type('name', $title); | |
157 | $this->select2('member_of_contact_id', $organizations[0]['name']); | |
158 | $this->type('minimum_fee', '100'); | |
159 | $this->select('financial_type_id', 'value=2'); | |
160 | $this->type('duration_interval', 1); | |
161 | $this->select('duration_unit', "label=year"); | |
162 | $this->select('period_type', "value=rolling"); | |
163 | //Choose 'Employer of' relationship | |
164 | $this->select('relationship_type_id', 'value=5_b_a'); | |
165 | $this->click('_qf_MembershipType_upload-bottom'); | |
166 | $this->waitForAjaxContent(); | |
167 | $this->waitForText('crm-notification-container', "The membership type '$title' has been saved."); | |
168 | //Retrieve membership type ID from newly created membership type | |
169 | $memTypeId = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td[1]/div[text()='{$title}']/../../td[12]/span/a[3]@href")); | |
170 | $memTypeId = $memTypeId[1]; | |
42daf119 | 171 | |
c3ad8633 CW |
172 | // Use default payment processor |
173 | $processorName = 'Test Processor'; | |
6a488035 TO |
174 | $processorType = 'Dummy'; |
175 | $pageTitle = substr(sha1(rand()), 0, 7); | |
176 | $rand = 100; | |
177 | $hash = substr(sha1(rand()), 0, 7); | |
178 | $amountSection = TRUE; | |
179 | $payLater = TRUE; | |
0b49a3ec | 180 | $onBehalf = 'optional'; |
6a488035 TO |
181 | $pledges = FALSE; |
182 | $recurring = FALSE; | |
0b49a3ec | 183 | $memberships = array(array('id' => $memTypeId, 'name' => $title, 'default' => 1)); |
6a488035 TO |
184 | $memPriceSetId = NULL; |
185 | $friend = TRUE; | |
186 | $profilePreId = NULL; | |
187 | $profilePostId = NULL; | |
188 | $premiums = FALSE; | |
189 | $widget = FALSE; | |
190 | $pcp = FALSE; | |
191 | $honoreeSection = FALSE; | |
192 | $isAddPaymentProcessor = TRUE; | |
193 | $isPcpApprovalNeeded = FALSE; | |
194 | $isSeparatePayment = FALSE; | |
195 | ||
196 | // create a new online contribution page | |
197 | // create contribution page with randomized title and default params | |
198 | $pageId = $this->webtestAddContributionPage($hash, | |
199 | $rand, | |
200 | $pageTitle, | |
201 | array($processorName => $processorType), | |
202 | $amountSection, | |
203 | $payLater, | |
204 | $onBehalf, | |
205 | $pledges, | |
206 | $recurring, | |
207 | $memberships, | |
208 | $memPriceSetId, | |
209 | $friend, | |
210 | $profilePreId, | |
211 | $profilePostId, | |
212 | $premiums, | |
213 | $widget, | |
214 | $pcp, | |
215 | $isAddPaymentProcessor, | |
216 | $isPcpApprovalNeeded, | |
217 | $isSeparatePayment, | |
218 | $honoreeSection | |
219 | ); | |
42daf119 | 220 | |
0b49a3ec | 221 | $this->_testAnomoyousOrganization($pageId, $organizations[1], $pageTitle); |
222 | ||
223 | //Check if all three of the individuals has inherited membership | |
224 | $this->openCiviPage("member/search", "reset=1"); | |
225 | $this->multiselect2("membership_type_id", array($title)); | |
226 | $this->click("CIVICRM_QFID_0_member_is_primary"); | |
227 | $this->click('_qf_Search_refresh'); | |
228 | // It suppose to be 3 but since we are registring contribution onBehalf of anonymous contact(email-5) | |
229 | $this->waitForText('search-status', "4 Results"); | |
230 | foreach ($individuals as $individual) { | |
231 | $this->isTextPresent($individual); | |
232 | } | |
6a488035 TO |
233 | } |
234 | ||
00be9182 | 235 | public function testOnBehalfOfOrganizationWithOrgData() { |
6a488035 TO |
236 | $this->webtestLogin(); |
237 | ||
071a6d2e | 238 | $this->openCiviPage("profile/edit", "reset=1&gid=4"); |
42daf119 CW |
239 | $firstName = 'John_x_' . substr(sha1(rand()), 0, 7); |
240 | $lastName = 'Anderson_c_' . substr(sha1(rand()), 0, 7); | |
6a488035 TO |
241 | |
242 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
243 | $this->waitForElementPresent("_qf_Edit_next"); | |
244 | $this->type("first_name", $firstName); | |
245 | $this->type("last_name", $lastName); | |
225a8648 | 246 | $this->clickLink("_qf_Edit_next", "profilewrap4"); |
6a488035 | 247 | |
a471a3b6 | 248 | $cid = $this->urlArg('id'); |
42daf119 | 249 | // Is status message correct? |
6a488035 TO |
250 | $this->assertTextPresent("Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!"); |
251 | ||
6a488035 | 252 | //add org fields to profile |
071a6d2e | 253 | $this->openCiviPage("admin/uf/group", "reset=1"); |
6a488035 TO |
254 | $this->click("link=Reserved Profiles"); |
255 | ||
256 | $this->click("xpath=//div[@id='reserved-profiles']/div/div/table/tbody//tr/td[1][text()='On Behalf Of Organization']/../td[5]/span/a[text()='Fields']"); | |
257 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
258 | ||
259 | $this->click("link=Add Field"); | |
260 | $this->waitForElementPresent('_qf_Field_next-bottom'); | |
42daf119 | 261 | |
6a488035 TO |
262 | $this->select('field_name[0]', 'value=Organization'); |
263 | $this->select('field_name[1]', 'label=Legal Identifier'); | |
264 | $this->click('field_name[1]'); | |
265 | $this->click('_qf_Field_next_new-bottom'); | |
266 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
267 | ||
268 | $this->select('field_name[0]', 'value=Organization'); | |
269 | $this->select('field_name[1]', 'label=Legal Name'); | |
270 | $this->click('field_name[1]'); | |
271 | $this->click('_qf_Field_next-bottom'); | |
272 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
42daf119 | 273 | |
6a488035 | 274 | //create organisation |
86bfa4f6 TO |
275 | $orgName = "Org WebAccess " . substr(sha1(rand()), 0, 7); |
276 | $orgEmail = "org" . substr(sha1(rand()), 0, 7) . "@web.com"; | |
6a488035 TO |
277 | $this->webtestAddOrganization($orgName, $orgEmail); |
278 | ||
279 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
280 | $this->click("css=li#tab_rel a"); | |
281 | ||
282 | $this->waitForElementPresent('link=Add Relationship'); | |
283 | $this->click('link=Add Relationship'); | |
284 | ||
285 | $this->waitForElementPresent('relationship_type_id'); | |
286 | $this->click("relationship_type_id"); | |
287 | $this->select("relationship_type_id", "label=Employer of"); | |
42daf119 | 288 | // search organization |
6a488035 TO |
289 | $this->type('contact_1', $firstName); |
290 | $this->click("contact_1"); | |
291 | $this->waitForElementPresent("css=div.ac_results-inner li"); | |
292 | $this->click("css=div.ac_results-inner li"); | |
293 | $this->assertContains($firstName, $this->getValue('contact_1'), "autocomplete expected $firstName but didn’t find it in " . $this->getValue('contact_1')); | |
294 | ||
42daf119 | 295 | // give permission |
6a488035 TO |
296 | $this->click("is_permission_a_b"); |
297 | $this->click("is_permission_b_a"); | |
298 | ||
42daf119 | 299 | // save relationship |
6a488035 TO |
300 | $this->waitForElementPresent("details-save"); |
301 | $this->click("details-save"); | |
302 | $this->waitForElementPresent("Relationships"); | |
303 | ||
304 | $pageTitle = substr(sha1(rand()), 0, 7); | |
305 | $rand = 100; | |
306 | $hash = substr(sha1(rand()), 0, 7); | |
307 | $amountSection = TRUE; | |
308 | $payLater = TRUE; | |
309 | $onBehalf = TRUE; | |
310 | $pledges = FALSE; | |
311 | $recurring = FALSE; | |
312 | $memberships = TRUE; | |
313 | $memPriceSetId = NULL; | |
314 | $friend = TRUE; | |
315 | $profilePreId = NULL; | |
316 | $profilePostId = NULL; | |
317 | $premiums = FALSE; | |
318 | $widget = FALSE; | |
319 | $pcp = FALSE; | |
320 | $honoreeSection = FALSE; | |
321 | $isAddPaymentProcessor = FALSE; | |
322 | $isPcpApprovalNeeded = FALSE; | |
323 | $isSeparatePayment = FALSE; | |
324 | ||
325 | // create a new online contribution page | |
326 | // create contribution page with randomized title and default params | |
327 | $pageId = $this->webtestAddContributionPage($hash, | |
328 | $rand, | |
329 | $pageTitle, | |
6c6e6187 | 330 | NULL, |
6a488035 TO |
331 | $amountSection, |
332 | $payLater, | |
333 | $onBehalf, | |
334 | $pledges, | |
335 | $recurring, | |
336 | $memberships, | |
337 | $memPriceSetId, | |
338 | $friend, | |
339 | $profilePreId, | |
340 | $profilePostId, | |
341 | $premiums, | |
342 | $widget, | |
343 | $pcp, | |
344 | $isAddPaymentProcessor, | |
345 | $isPcpApprovalNeeded, | |
346 | $isSeparatePayment, | |
347 | $honoreeSection | |
348 | ); | |
349 | ||
6c6e6187 | 350 | $this->_testOrganization($pageId, $cid, $pageTitle); |
6a488035 TO |
351 | } |
352 | ||
00be9182 | 353 | public function testWithContactSubtypeDupe() { |
130ad870 JP |
354 | $this->webtestLogin(); |
355 | ||
356 | //create organisation | |
86bfa4f6 TO |
357 | $orgName = "Org WebAccess " . substr(sha1(rand()), 0, 7); |
358 | $orgEmail = "org" . substr(sha1(rand()), 0, 7) . "@web.com"; | |
130ad870 JP |
359 | $contactSubType = 'Sponsor'; |
360 | $this->webtestAddOrganization($orgName, $orgEmail, $contactSubType); | |
361 | ||
362 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
363 | $cid = $this->urlArg('cid'); | |
364 | ||
365 | $pageTitle = substr(sha1(rand()), 0, 7); | |
366 | $rand = 100; | |
367 | $hash = substr(sha1(rand()), 0, 7); | |
368 | $amountSection = TRUE; | |
369 | $payLater = TRUE; | |
370 | $onBehalf = TRUE; | |
371 | $pledges = FALSE; | |
372 | $recurring = FALSE; | |
373 | $memberships = FALSE; | |
374 | $memPriceSetId = NULL; | |
375 | $friend = FALSE; | |
376 | $profilePreId = NULL; | |
377 | $profilePostId = NULL; | |
378 | $premiums = FALSE; | |
379 | $widget = FALSE; | |
380 | $pcp = FALSE; | |
381 | $honoreeSection = FALSE; | |
382 | $isAddPaymentProcessor = FALSE; | |
383 | $isPcpApprovalNeeded = FALSE; | |
384 | $isSeparatePayment = FALSE; | |
385 | ||
386 | // create a new online contribution page | |
387 | // create contribution page with randomized title and default params | |
388 | $pageId = $this->webtestAddContributionPage($hash, | |
389 | $rand, | |
390 | $pageTitle, | |
6c6e6187 | 391 | NULL, |
130ad870 JP |
392 | $amountSection, |
393 | $payLater, | |
394 | $onBehalf, | |
395 | $pledges, | |
396 | $recurring, | |
397 | $memberships, | |
398 | $memPriceSetId, | |
399 | $friend, | |
400 | $profilePreId, | |
401 | $profilePostId, | |
402 | $premiums, | |
403 | $widget, | |
404 | $pcp, | |
405 | $isAddPaymentProcessor, | |
406 | $isPcpApprovalNeeded, | |
407 | $isSeparatePayment, | |
408 | $honoreeSection | |
409 | ); | |
410 | ||
6c6e6187 | 411 | //Open Live Contribution Page |
130ad870 JP |
412 | $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom"); |
413 | $this->waitForElementPresent("onbehalf_state_province-3"); | |
414 | ||
415 | $this->type("onbehalf_organization_name", $orgName); | |
416 | $this->waitForElementPresent("onbehalf_phone-3-1"); | |
417 | $this->type("onbehalf_phone-3-1", 9999999999); | |
418 | $this->waitForElementPresent("onbehalf_email-3"); | |
419 | $this->type("onbehalf_email-3", "org@example.com"); | |
420 | $this->type("onbehalf_street_address-3", "Test Street Address"); | |
421 | $this->type("onbehalf_city-3", "Test City"); | |
422 | $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6)); | |
423 | $this->click("onbehalf_country-3"); | |
86797006 | 424 | $this->select("onbehalf_country-3", "label=UNITED STATES"); |
130ad870 JP |
425 | $this->click("onbehalf_state_province-3"); |
426 | $this->select("onbehalf_state_province-3", "label=Alabama"); | |
427 | ||
428 | $this->waitForElementPresent("_qf_Main_upload-bottom"); | |
429 | $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); | |
430 | ||
431 | $this->click("_qf_Confirm_next-bottom"); | |
432 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
433 | ||
434 | $this->openCiviPage("contact/view", "reset=1&cid=$cid", "xpath=//div[@class='crm-content crm-contact_type_label']"); | |
435 | ||
436 | $this->verifyText("xpath=//div[@class='crm-content crm-contact_type_label']", $contactSubType); | |
437 | } | |
438 | ||
4cbe18b8 | 439 | /** |
100fef9d CW |
440 | * @param int $pageId |
441 | * @param int $cid | |
4cbe18b8 EM |
442 | * @param $pageTitle |
443 | */ | |
00be9182 | 444 | public function _testOrganization($pageId, $cid, $pageTitle) { |
6a488035 | 445 | //Open Live Contribution Page |
071a6d2e | 446 | $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom"); |
6a488035 TO |
447 | |
448 | $this->waitForElementPresent("onbehalf_state_province-3"); | |
449 | ||
450 | $this->waitForElementPresent("onbehalf_phone-3-1"); | |
451 | $this->type("onbehalf_phone-3-1", 9999999999); | |
452 | $this->waitForElementPresent("onbehalf_email-3"); | |
453 | $this->type("onbehalf_email-3", "org@example.com"); | |
454 | $this->type("onbehalf_street_address-3", "Test Street Address"); | |
455 | $this->type("onbehalf_city-3", "Test City"); | |
456 | $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6)); | |
457 | $this->click("onbehalf_country-3"); | |
86797006 | 458 | $this->select("onbehalf_country-3", "label=UNITED STATES"); |
6a488035 TO |
459 | $this->click("onbehalf_state_province-3"); |
460 | $this->select("onbehalf_state_province-3", "label=Alabama"); | |
461 | ||
462 | $this->waitForElementPresent("_qf_Main_upload-bottom"); | |
225a8648 | 463 | $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); |
6a488035 TO |
464 | |
465 | $this->click("_qf_Confirm_next-bottom"); | |
466 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
467 | ||
468 | } | |
469 | ||
4cbe18b8 | 470 | /** |
100fef9d | 471 | * @param int $pageId |
761fe7bb | 472 | * @param int $orgName |
4cbe18b8 EM |
473 | * @param $pageTitle |
474 | */ | |
0b49a3ec | 475 | public function _testAnomoyousOrganization($pageId, $orgName, $pageTitle) { |
476 | $this->webtestLogout(); | |
6a488035 | 477 | //Open Live Contribution Page |
071a6d2e | 478 | $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom"); |
6a488035 | 479 | |
6a488035 | 480 | $firstName = 'Ma' . substr(sha1(rand()), 0, 4); |
42daf119 | 481 | $lastName = 'An' . substr(sha1(rand()), 0, 7); |
6a488035 TO |
482 | $this->type("email-5", $firstName . "@example.com"); |
483 | ||
0b49a3ec | 484 | $this->click('CIVICRM_QFID_0_12'); |
485 | $this->type('css=div.other_amount-section input', 60); | |
486 | ||
6a488035 TO |
487 | // enable onbehalforganization block |
488 | $this->click("is_for_organization"); | |
489 | $this->waitForElementPresent("onbehalf_state_province-3"); | |
490 | ||
491 | // onbehalforganization info | |
0b49a3ec | 492 | $this->type("onbehalf_organization_name", $orgName['name']); |
6a488035 | 493 | $this->type("onbehalf_phone-3-1", 9999999999); |
0b49a3ec | 494 | $this->type("onbehalf_email-3", $orgName['email']); |
6a488035 TO |
495 | $this->type("onbehalf_street_address-3", "Test Street Address"); |
496 | $this->type("onbehalf_city-3", "Test City"); | |
497 | $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6)); | |
498 | $this->click("onbehalf_country-3"); | |
86797006 | 499 | $this->select("onbehalf_country-3", "label=UNITED STATES"); |
6a488035 TO |
500 | $this->click("onbehalf_state_province-3"); |
501 | $this->select("onbehalf_state_province-3", "label=Alabama"); | |
502 | ||
6a488035 TO |
503 | // Credit Card Info |
504 | $this->select("credit_card_type", "value=Visa"); | |
505 | $this->type("credit_card_number", "4111111111111111"); | |
506 | $this->type("cvv2", "000"); | |
507 | $this->select("credit_card_exp_date[M]", "value=1"); | |
508 | $this->select("credit_card_exp_date[Y]", "value=2020"); | |
509 | ||
510 | //Billing Info | |
511 | $this->type("billing_first_name", $firstName . 'billing'); | |
512 | $this->type("billing_last_name", $lastName . 'billing'); | |
513 | $this->type("billing_street_address-5", "0121 Mount Highschool."); | |
514 | $this->type(" billing_city-5", "Shangai"); | |
515 | $this->select("billing_country_id-5", "value=1228"); | |
516 | $this->select("billing_state_province_id-5", "value=1004"); | |
517 | $this->type("billing_postal_code-5", "94129"); | |
225a8648 | 518 | $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); |
6a488035 TO |
519 | |
520 | $this->click("_qf_Confirm_next-bottom"); | |
521 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
522 | ||
6a488035 TO |
523 | // Log in using webtestLogin() method |
524 | $this->webtestLogin(); | |
525 | ||
0b49a3ec | 526 | // TODO: webtestVerifyTabularData function is causing timeout error, reason why most of the Webtests are failing |
527 | // where its been called to assert tabular data | |
761fe7bb | 528 | |
529 | /** | |
6a488035 | 530 | //Find Contribution |
071a6d2e | 531 | $this->openCiviPage("contribute/search", "reset=1"); |
0b49a3ec | 532 | $this->type("sort_name", $orgName['name']); |
225a8648 | 533 | $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']"); |
761fe7bb | 534 | $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom"); |
6a488035 TO |
535 | |
536 | // verify contrb created | |
537 | $expected = array( | |
0b49a3ec | 538 | 'From' => $orgName['name'], |
539 | 'Financial Type' => 'Donation', | |
540 | 'Online Contribution Page' => $pageTitle, | |
6a488035 | 541 | ); |
0b49a3ec | 542 | $this->webtestVerifyTabularData($expected); |
543 | */ | |
6a488035 TO |
544 | } |
545 | ||
4cbe18b8 | 546 | /** |
100fef9d CW |
547 | * @param int $pageId |
548 | * @param int $cid | |
4cbe18b8 EM |
549 | * @param $pageTitle |
550 | */ | |
00be9182 | 551 | public function _testUserWithOneRelationship($pageId, $cid, $pageTitle) { |
42daf119 | 552 | $this->webtestLogin('admin'); |
6a488035 TO |
553 | |
554 | // Create new group | |
555 | $groupName = $this->WebtestAddGroup(); | |
42daf119 | 556 | $this->openCiviPage("group", "reset=1", "_qf_Search_refresh"); |
6a488035 TO |
557 | $groupId = $this->getText("xpath=//table[@id='crm-group-selector']/tbody//tr/td[text()='{$groupName}']/../td[2]"); |
558 | ||
071a6d2e | 559 | $this->openCiviPage("contact/view", "reset=1&cid={$cid}"); |
6a488035 TO |
560 | |
561 | $this->click('link=Edit'); | |
562 | $this->waitForElementPresent('_qf_Contact_cancel-bottom'); | |
563 | $this->click('addressBlock'); | |
564 | $this->waitForElementPresent('link=Another Address'); | |
565 | ||
566 | //Billing Info | |
567 | $this->select('address_1_location_type_id', 'label=Billing'); | |
568 | $this->type('address_1_street_address', '0121 Mount Highschool.'); | |
569 | $this->type('address_1_city', "Shangai"); | |
570 | $this->type('address_1_postal_code', "94129"); | |
571 | $this->select('address_1_country_id', "value=1228"); | |
572 | $this->select('address_1_state_province_id', "value=1004"); | |
573 | $this->click('_qf_Contact_upload_view-bottom'); | |
574 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
575 | ||
576 | // add contact to group | |
577 | // visit group tab | |
578 | $this->click("css=li#tab_group a"); | |
579 | $this->waitForElementPresent("group_id"); | |
580 | ||
581 | // add to group | |
582 | $this->select("group_id", "label={$groupName}"); | |
583 | $this->click("_qf_GroupContact_next"); | |
584 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
585 | ||
42daf119 | 586 | $this->openCiviPage("admin/custom/group", "action=add&reset=1", "_qf_Group_next-bottom"); |
6a488035 TO |
587 | |
588 | // fill in a unique title for the custom group | |
589 | $groupTitle = "Custom Group" . substr(sha1(rand()), 0, 7); | |
590 | $this->type("title", $groupTitle); | |
591 | ||
592 | // select the group this custom data set extends | |
593 | $this->select("extends[0]", "value=Contribution"); | |
594 | $this->waitForElementPresent("extends[1]"); | |
595 | ||
596 | // save the custom group | |
597 | $this->click("_qf_Group_next-bottom"); | |
598 | $this->waitForElementPresent("_qf_Field_next_new-bottom"); | |
599 | $this->assertTrue($this->isTextPresent("Your custom field set '$groupTitle' has been added. You can add custom fields now.")); | |
600 | ||
601 | // add a custom field to the custom group | |
602 | $fieldTitle = "Custom Field " . substr(sha1(rand()), 0, 7); | |
603 | $this->type("label", $fieldTitle); | |
604 | ||
605 | $this->select("data_type[1]", "value=Text"); | |
606 | $this->click('_qf_Field_next-bottom'); | |
607 | ||
608 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
39a2888d | 609 | $this->assertTrue($this->isTextPresent("Custom field '$fieldTitle' has been saved.")); |
a471a3b6 | 610 | $fieldId = $this->urlArg('id', $this->getAttribute("xpath=//div[@id='field_page']/div[2]/table/tbody//tr/td[1][text()='$fieldTitle']/../td[8]/span/a@href")); |
6a488035 TO |
611 | |
612 | // Enable CiviCampaign module if necessary | |
b9715b8a | 613 | $this->enableComponents("CiviCampaign"); |
6a488035 | 614 | |
42daf119 | 615 | // add the required permission |
6a488035 TO |
616 | $permission = array('edit-2-administer-civicampaign'); |
617 | $this->changePermissions($permission); | |
618 | ||
42daf119 CW |
619 | // Log in as normal user |
620 | $this->webtestLogin(); | |
6a488035 | 621 | |
42daf119 | 622 | $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom"); |
6a488035 | 623 | |
6a488035 TO |
624 | $title = 'Campaign ' . substr(sha1(rand()), 0, 7); |
625 | $this->type("title", $title); | |
626 | ||
627 | // select the campaign type | |
628 | $this->select("campaign_type_id", "value=2"); | |
629 | ||
630 | // fill in the description | |
631 | $this->type("description", "This is a test campaign"); | |
632 | ||
633 | // include groups for the campaign | |
634 | $this->addSelection("includeGroups-f", "label={$groupName}"); | |
635 | $this->click("//option[@value={$groupId}]"); | |
636 | $this->click("add"); | |
637 | ||
638 | // fill the end date for campaign | |
639 | $this->webtestFillDate("end_date", "+1 year"); | |
640 | ||
641 | // select campaign status | |
642 | $this->select("status_id", "value=2"); | |
643 | ||
644 | // click save | |
645 | $this->click("_qf_Campaign_upload-bottom"); | |
646 | $this->waitForElementPresent("xpath=//div[@id='campaigns_wrapper']//table[@id='campaigns']/tbody//tr/td[3][text()='{$title}']"); | |
647 | $this->assertTrue($this->isTextPresent("Campaign {$title} has been saved."), "Status message didn't show up after saving!"); | |
648 | ||
071a6d2e | 649 | $this->openCiviPage("admin/uf/group", "reset=1"); |
6a488035 TO |
650 | $this->click("link=Reserved Profiles"); |
651 | ||
652 | $this->click("xpath=//div[@id='reserved-profiles']/div/div/table/tbody//tr/td[1][text()='On Behalf Of Organization']/../td[5]/span/a[text()='Fields']"); | |
653 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
654 | ||
655 | $this->click("link=Add Field"); | |
656 | $this->waitForElementPresent('_qf_Field_next-bottom'); | |
657 | $this->select('field_name[0]', 'value=Contribution'); | |
658 | $this->select('field_name[1]', 'label=Campaign'); | |
659 | $this->click('field_name[1]'); | |
660 | $this->click('_qf_Field_next_new-bottom'); | |
661 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
662 | ||
663 | $this->select('field_name[0]', 'value=Contribution'); | |
664 | $this->select('field_name[1]', "label=$fieldTitle :: $groupTitle"); | |
665 | $this->click('field_name[1]'); | |
666 | $this->click('_qf_Field_next-bottom'); | |
667 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
668 | $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$fieldTitle}' has been saved to 'On Behalf Of Organization'.")); | |
669 | ||
670 | // Open Page to create Organization | |
42daf119 | 671 | $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom"); |
6a488035 TO |
672 | $orgName1 = 'org1_' . substr(sha1(rand()), 0, 7); |
673 | ||
674 | // Type Organization name | |
675 | $this->type("organization_name", $orgName1); | |
676 | ||
677 | // Type Organizatio email for main | |
678 | $this->type("email_1_email", "{$orgName1}@example.com"); | |
679 | $this->select("email_1_location_type_id", "value=3"); | |
680 | ||
681 | // type phone no for main | |
682 | $this->type("phone_1_phone", 9999999999); | |
683 | $this->select("phone_1_location_type_id", "value=3"); | |
684 | ||
685 | //address section | |
686 | $this->click("addressBlock"); | |
687 | $this->waitForElementPresent("address_1_street_address"); | |
688 | ||
689 | //fill in address 1 for main | |
690 | $this->select("address_1_location_type_id", "value=3"); | |
691 | $this->type("address_1_street_address", "{$orgName1} street address"); | |
692 | $this->type("address_1_city", "{$orgName1} city"); | |
693 | $this->type("address_1_postal_code", substr(sha1(rand()), 0, 4)); | |
86797006 | 694 | $this->assertTrue($this->isTextPresent("- select - UNITED STATES")); |
6a488035 TO |
695 | $this->select("address_1_state_province_id", "value=1019"); |
696 | $this->type("address_1_geo_code_1", "1234"); | |
697 | $this->type("address_1_geo_code_2", "5678"); | |
698 | ||
699 | // Save the Organization | |
700 | $this->click("_qf_Contact_upload_view-bottom"); | |
701 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
702 | ||
703 | // open contact | |
071a6d2e | 704 | $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1"); |
6a488035 TO |
705 | |
706 | // select relationship type | |
707 | $this->click("relationship_type_id"); | |
708 | $this->select("relationship_type_id", "value=4_a_b"); | |
709 | ||
710 | // search organization | |
711 | $this->type('contact_1', $orgName1); | |
712 | $this->click("contact_1"); | |
713 | $this->waitForElementPresent("css=div.ac_results-inner li"); | |
714 | $this->click("css=div.ac_results-inner li"); | |
715 | $this->assertContains($orgName1, $this->getValue('contact_1'), "autocomplete expected $orgName1 but didn’t find it in " . $this->getValue('contact_1')); | |
716 | ||
717 | $this->waitForElementPresent("add_current_employer"); | |
718 | $this->click("add_current_employer"); | |
719 | ||
720 | // give permission | |
721 | $this->click("is_permission_a_b"); | |
722 | $this->click("is_permission_b_a"); | |
723 | ||
724 | // save relationship | |
725 | $this->waitForElementPresent("details-save"); | |
726 | $this->click("details-save"); | |
727 | ||
728 | //Open Live Contribution Page | |
071a6d2e | 729 | $this->openCiviPage("contribute/transact", "reset=1&id={$pageId}&cid=$cid", "onbehalf_state_province-3"); |
6a488035 TO |
730 | $this->click('CIVICRM_QFID_amount_other_radio_4'); |
731 | $this->type('amount_other', 60); | |
732 | $this->click('onbehalf_contribution_campaign_id'); | |
733 | $this->select('onbehalf_contribution_campaign_id', "label={$title}"); | |
734 | $this->type("onbehalf_custom_{$fieldId}", 'Test Subject'); | |
735 | ||
736 | // Credit Card Info | |
737 | $this->select("credit_card_type", "value=Visa"); | |
738 | $this->type("credit_card_number", "4111111111111111"); | |
739 | $this->type("cvv2", "000"); | |
740 | $this->select("credit_card_exp_date[M]", "value=1"); | |
741 | $this->select("credit_card_exp_date[Y]", "value=2020"); | |
742 | ||
743 | //Billing Info | |
744 | $this->type("billing_street_address-5", "0121 Mount Highschool."); | |
745 | $this->type(" billing_city-5", "Shangai"); | |
746 | $this->select("billing_country_id-5", "value=1228"); | |
747 | $this->select("billing_state_province_id-5", "value=1004"); | |
748 | $this->type("billing_postal_code-5", "94129"); | |
749 | ||
225a8648 | 750 | $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); |
6a488035 TO |
751 | $this->click("_qf_Confirm_next-bottom"); |
752 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
753 | ||
754 | //Find Contribution | |
071a6d2e | 755 | $this->openCiviPage("contribute/search", "reset=1"); |
6a488035 | 756 | $this->type("sort_name", $orgName1); |
225a8648 CW |
757 | $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']"); |
758 | $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom"); | |
6a488035 TO |
759 | |
760 | // verify contrb created | |
761 | $expected = array( | |
762 | 1 => $orgName1, | |
763 | 2 => 'Donation', | |
764 | 10 => $title, | |
765 | 11 => $pageTitle, | |
766 | ); | |
767 | foreach ($expected as $value => $label) { | |
768 | $this->verifyText("xpath=id( 'ContributionView' )/div[2]/table[1]/tbody/tr[$value]/td[2]", preg_quote($label)); | |
769 | } | |
770 | ||
071a6d2e | 771 | $this->openCiviPage("admin/uf/group", "reset=1"); |
6a488035 TO |
772 | $this->click("link=Reserved Profiles"); |
773 | ||
774 | $this->click("xpath=//div[@id='reserved-profiles']/div/div/table/tbody//tr/td[1][text()='On Behalf Of Organization']/../td[5]/span/a[text()='Fields']"); | |
775 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
776 | ||
777 | $this->click("xpath=//div[@id='field_page']/div[3]/table/tbody//tr/td[1][text()='Campaign']/../td[9]/span[2][text()='more ']/ul/li[2]/a[text()='Delete']"); | |
778 | $this->waitForElementPresent('_qf_Field_next-bottom'); | |
779 | ||
780 | $this->click('_qf_Field_next-bottom'); | |
781 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
782 | $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'), "Status message didn't show up after saving!"); | |
783 | ||
784 | $this->click("xpath=//div[@id='field_page']/div[3]/table/tbody//tr/td[1][text()='{$fieldTitle}']/../td[9]/span[2][text()='more ']/ul/li[2]/a[text()='Delete']"); | |
785 | $this->waitForElementPresent('_qf_Field_next-bottom'); | |
786 | ||
787 | $this->click('_qf_Field_next-bottom'); | |
788 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
789 | $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'), "Status message didn't show up after saving!"); | |
790 | } | |
791 | ||
4cbe18b8 | 792 | /** |
100fef9d CW |
793 | * @param int $pageId |
794 | * @param int $cid | |
4cbe18b8 EM |
795 | * @param $pageTitle |
796 | */ | |
00be9182 | 797 | public function _testUserWithMoreThanOneRelationship($pageId, $cid, $pageTitle) { |
42daf119 | 798 | $this->webtestLogin('admin'); |
6a488035 TO |
799 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
800 | ||
801 | // Create new group | |
802 | $groupName = $this->WebtestAddGroup(); | |
42daf119 | 803 | $this->openCiviPage("group", "reset=1", '_qf_Search_refresh'); |
6a488035 TO |
804 | $this->click('_qf_Search_refresh'); |
805 | $this->waitForElementPresent("xpath=//div[@id='group']/div[3]/table/tbody//tr/td[text()='{$groupName}']/../td[2]"); | |
806 | $groupId = $this->getText("xpath=//div[@id='group']/div[3]/table/tbody//tr/td[text()='{$groupName}']/../td[2]"); | |
807 | ||
071a6d2e | 808 | $this->openCiviPage("contact/view", "reset=1&cid={$cid}"); |
6a488035 TO |
809 | |
810 | $this->click('link=Edit'); | |
811 | $this->waitForElementPresent('_qf_Contact_cancel-bottom'); | |
812 | $this->click('addressBlock'); | |
813 | $this->waitForElementPresent('link=Another Address'); | |
814 | ||
815 | //Billing Info | |
816 | $this->select('address_1_location_type_id', 'label=Billing'); | |
817 | $this->type('address_1_street_address', '0121 Mount Highschool.'); | |
818 | $this->type('address_1_city', "Shangai"); | |
819 | $this->type('address_1_postal_code', "94129"); | |
820 | $this->select('address_1_country_id', "value=1228"); | |
821 | $this->select('address_1_state_province_id', "value=1004"); | |
822 | $this->click('_qf_Contact_upload_view-bottom'); | |
823 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
824 | ||
825 | // add contact to group | |
826 | // visit group tab | |
827 | $this->click("css=li#tab_group a"); | |
828 | $this->waitForElementPresent("group_id"); | |
829 | ||
830 | // add to group | |
831 | $this->select("group_id", "label=$groupName"); | |
832 | $this->click("_qf_GroupContact_next"); | |
833 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
834 | ||
42daf119 | 835 | $this->openCiviPage("admin/custom/group", "action=add&reset=1", "_qf_Group_next-bottom"); |
6a488035 TO |
836 | |
837 | // fill in a unique title for the c$groupIdustom group | |
838 | $groupTitle = "Members Custom Group" . substr(sha1(rand()), 0, 7); | |
839 | $this->type("title", $groupTitle); | |
840 | ||
841 | // select the group this custom data set extends | |
842 | $this->select("extends[0]", "value=Membership"); | |
843 | $this->waitForElementPresent("extends[1]"); | |
844 | ||
845 | // save the custom group | |
846 | $this->click("_qf_Group_next-bottom"); | |
847 | ||
848 | $this->waitForElementPresent("_qf_Field_next_new-bottom"); | |
849 | $this->assertTrue($this->isTextPresent("Your custom field set '$groupTitle' has been added. You can add custom fields now.")); | |
850 | ||
851 | // add a custom field to the custom group | |
852 | $fieldTitle = "Member Custom Field " . substr(sha1(rand()), 0, 7); | |
853 | $this->type("label", $fieldTitle); | |
854 | ||
855 | $this->select("data_type[1]", "value=Text"); | |
856 | $this->click('_qf_Field_next-bottom'); | |
857 | ||
858 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
39a2888d | 859 | $this->assertTrue($this->isTextPresent("Custom field '$fieldTitle' has been saved.")); |
a471a3b6 | 860 | $fieldId = $this->urlArg('id', $this->getAttribute("xpath=//div[@id='field_page']/div[2]/table/tbody//tr/td[1]/span[text()='$fieldTitle']/../td[8]/span/a@href")); |
6a488035 TO |
861 | |
862 | // Enable CiviCampaign module if necessary | |
b9715b8a | 863 | $this->enableComponents("CiviCampaign"); |
6a488035 | 864 | |
42daf119 | 865 | // add the required permission |
6a488035 TO |
866 | $permission = array('edit-2-administer-civicampaign'); |
867 | $this->changePermissions($permission); | |
868 | ||
42daf119 CW |
869 | // Log in as normal user |
870 | $this->webtestLogin(); | |
6a488035 | 871 | |
42daf119 | 872 | $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom"); |
6a488035 | 873 | |
6a488035 TO |
874 | $title = 'Campaign ' . substr(sha1(rand()), 0, 7); |
875 | $this->type("title", $title); | |
876 | ||
877 | // select the campaign type | |
878 | $this->select("campaign_type_id", "value=2"); | |
879 | ||
880 | // fill in the description | |
881 | $this->type("description", "This is a test campaign"); | |
882 | ||
883 | // include groups for the campaign | |
884 | $this->addSelection("includeGroups-f", "label={$groupName}"); | |
885 | $this->click("//option[@value={$groupId}]"); | |
886 | $this->click("add"); | |
887 | ||
888 | // fill the end date for campaign | |
889 | $this->webtestFillDate("end_date", "+1 year"); | |
890 | ||
891 | // select campaign status | |
892 | $this->select("status_id", "value=2"); | |
893 | ||
894 | // click save | |
895 | $this->click("_qf_Campaign_upload-bottom"); | |
896 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
897 | ||
898 | $this->assertTrue($this->isTextPresent("Campaign {$title} has been saved."), "Status message didn't show up after saving!"); | |
899 | ||
071a6d2e | 900 | $this->openCiviPage("admin/uf/group", "reset=1"); |
6a488035 TO |
901 | $this->click("link=Reserved Profiles"); |
902 | $this->click("xpath=//div[@id='reserved-profiles']/div/div/table/tbody//tr/td[1][text()='On Behalf Of Organization']/../td[5]/span/a[text()='Fields']"); | |
903 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
904 | ||
905 | $this->click("link=Add Field"); | |
906 | $this->waitForElementPresent('_qf_Field_next-bottom'); | |
907 | $this->select('field_name[0]', 'value=Membership'); | |
908 | $this->select('field_name[1]', 'label=Campaign'); | |
909 | $this->click('field_name[1]'); | |
225a8648 | 910 | $this->clickLink('_qf_Field_next_new-bottom', '_qf_Field_cancel-bottom'); |
6a488035 TO |
911 | |
912 | $this->select('field_name[0]', 'value=Membership'); | |
913 | $this->select('field_name[1]', "label=$fieldTitle :: $groupTitle"); | |
914 | $this->click('field_name[1]'); | |
915 | $this->click('_qf_Field_next-bottom'); | |
916 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
917 | $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$fieldTitle}' has been saved to 'On Behalf Of Organization'."), | |
918 | "Status message didn't show up after saving!" | |
919 | ); | |
920 | ||
921 | // Open Page to create Organization 1 | |
42daf119 | 922 | $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom"); |
6a488035 TO |
923 | $orgName1 = 'org1_' . substr(sha1(rand()), 0, 7); |
924 | ||
925 | // Type Organization name | |
926 | $this->type("organization_name", $orgName1); | |
927 | ||
928 | // Type Organizatio email for main | |
929 | $this->type("email_1_email", "{$orgName1}@example.com"); | |
930 | $this->select("email_1_location_type_id", "value=3"); | |
931 | ||
932 | // type phone no for main | |
933 | $this->type("phone_1_phone", substr(sha1(rand()), 0, 4)); | |
934 | $this->select("phone_1_location_type_id", "value=3"); | |
935 | ||
936 | //address section | |
937 | $this->click("addressBlock"); | |
938 | $this->waitForElementPresent("address_1_street_address"); | |
939 | ||
940 | //fill in address 1 for main | |
941 | $this->select("address_1_location_type_id", "value=3"); | |
942 | $this->type("address_1_street_address", "{$orgName1} street address"); | |
943 | $this->type("address_1_city", "{$orgName1} city"); | |
944 | $this->type("address_1_postal_code", "9999999999"); | |
86797006 | 945 | $this->assertTrue($this->isTextPresent("- select - UNITED STATES")); |
6a488035 TO |
946 | $this->select("address_1_state_province_id", "value=1019"); |
947 | $this->type("address_1_geo_code_1", "1234"); | |
948 | $this->type("address_1_geo_code_2", "5678"); | |
949 | ||
950 | // Save the Organization | |
951 | $this->click("_qf_Contact_upload_view-bottom"); | |
952 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
953 | ||
954 | // create second orzanization | |
42daf119 | 955 | $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom"); |
6a488035 TO |
956 | $orgName2 = 'org2_' . substr(sha1(rand()), 0, 7); |
957 | ||
958 | // Type Organization name | |
959 | $this->type("organization_name", $orgName2); | |
960 | ||
961 | // Type Organizatio email for main | |
962 | $this->type("email_1_email", "{$orgName2}@example.com"); | |
963 | $this->select("email_1_location_type_id", "value=3"); | |
964 | ||
965 | // type phone no for main | |
966 | $this->type("phone_1_phone", substr(sha1(rand()), 0, 4)); | |
967 | $this->select("phone_1_location_type_id", "value=3"); | |
968 | ||
969 | //address section | |
970 | $this->click("addressBlock"); | |
971 | $this->waitForElementPresent("address_1_street_address"); | |
972 | ||
973 | //fill in address 1 for main | |
974 | $this->select("address_1_location_type_id", "value=3"); | |
975 | $this->type("address_1_street_address", "{$orgName2} street address"); | |
976 | $this->type("address_1_city", "{$orgName2} city"); | |
977 | $this->type("address_1_postal_code", "7777777777"); | |
86797006 | 978 | $this->assertTrue($this->isTextPresent("- select - UNITED STATES")); |
6a488035 TO |
979 | $this->select("address_1_state_province_id", "value=1019"); |
980 | $this->type("address_1_geo_code_1", "1224"); | |
981 | $this->type("address_1_geo_code_2", "5628"); | |
982 | ||
983 | // Save the Organization | |
984 | $this->click("_qf_Contact_upload_view-bottom"); | |
985 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
986 | ||
6a488035 TO |
987 | // create Membership type |
988 | $title1 = "Membership Type" . substr(sha1(rand()), 0, 7); | |
071a6d2e | 989 | $this->openCiviPage("admin/member/membershipType", "reset=1&action=browse"); |
6a488035 TO |
990 | |
991 | $this->click("link=Add Membership Type"); | |
992 | $this->waitForElementPresent('_qf_MembershipType_cancel-bottom'); | |
993 | ||
994 | $this->type('name', $title1); | |
995 | $this->type('member_org', $orgName1); | |
996 | $this->click('_qf_MembershipType_refresh'); | |
997 | $this->waitForElementPresent("xpath=//div[@id='membership_type_form']/fieldset/table[2]/tbody/tr[2]/td[2]"); | |
998 | ||
999 | $this->type('minimum_fee', '50'); | |
1000 | ||
481a74f4 | 1001 | $this->select('financial_type_id', 'value=2'); |
6a488035 TO |
1002 | |
1003 | $this->type('duration_interval', 1); | |
1004 | $this->select('duration_unit', "label=year"); | |
1005 | ||
1006 | $this->select('period_type', "label=fixed"); | |
1007 | $this->waitForElementPresent('fixed_period_rollover_day[d]'); | |
1008 | ||
1009 | $this->select('fixed_period_start_day[M]', 'value=4'); | |
1010 | $this->select('fixed_period_rollover_day[M]', 'value=1'); | |
1011 | ||
1012 | $this->select('relationship_type_id', 'value=4_b_a'); | |
1013 | ||
1014 | $this->click('_qf_MembershipType_upload-bottom'); | |
1015 | $this->waitForElementPresent('link=Add Membership Type'); | |
1016 | $this->assertTrue($this->isTextPresent("The membership type '$title1' has been saved.")); | |
a471a3b6 | 1017 | $typeId = $this->urlArg('id', $this->getAttribute("xpath=//div[@id='membership_type']/div[2]/table/tbody//tr/td[1][text()='{$title1}']/../td[10]/span/a[3]@href")); |
6a488035 TO |
1018 | |
1019 | // open contact | |
071a6d2e | 1020 | $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1"); |
6a488035 TO |
1021 | |
1022 | // select relationship type | |
1023 | $this->click("relationship_type_id"); | |
1024 | $this->select("relationship_type_id", "value=4_a_b"); | |
1025 | ||
1026 | // search organization | |
1027 | $this->type('contact_1', $orgName1); | |
1028 | $this->click("contact_1"); | |
1029 | $this->waitForElementPresent("css=div.ac_results-inner li"); | |
1030 | $this->click("css=div.ac_results-inner li"); | |
1031 | $this->assertContains($orgName1, $this->getValue('contact_1'), "autocomplete expected $orgName1 but didn’t find it in " . $this->getValue('contact_1')); | |
1032 | ||
1033 | // give permission | |
1034 | $this->click("is_permission_a_b"); | |
1035 | $this->click("is_permission_b_a"); | |
1036 | ||
1037 | // save relationship | |
1038 | $this->click("details-save"); | |
1039 | ||
1040 | // open contact | |
071a6d2e | 1041 | $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1"); |
6a488035 TO |
1042 | |
1043 | // select relationship type | |
1044 | $this->click("relationship_type_id"); | |
1045 | $this->select("relationship_type_id", "value=4_a_b"); | |
1046 | ||
1047 | // search organization | |
1048 | $this->type('contact_1', $orgName2); | |
1049 | $this->click("contact_1"); | |
1050 | $this->waitForElementPresent("css=div.ac_results-inner li"); | |
1051 | $this->click("css=div.ac_results-inner li"); | |
1052 | $this->assertContains($orgName2, $this->getValue('contact_1'), "autocomplete expected $orgName2 but didn’t find it in " . $this->getValue('contact_1')); | |
1053 | ||
1054 | // give permission | |
1055 | $this->click("is_permission_a_b"); | |
1056 | $this->click("is_permission_b_a"); | |
1057 | ||
1058 | // save relationship | |
1059 | $this->click("details-save"); | |
1060 | ||
1061 | // set membership type | |
071a6d2e | 1062 | $this->openCiviPage("admin/contribute/membership", "reset=1&action=update&id=$pageId", "_qf_MembershipBlock_upload_done-bottom"); |
6a488035 TO |
1063 | $this->click("member_is_active"); |
1064 | $this->click("membership_type[{$typeId}]"); | |
1065 | $this->click("xpath=//div[@id='memberFields']//table[@class='report']/tbody//tr/td[1]/label[text()='{$title1}']/../../td[2]/input"); | |
1066 | $this->click('_qf_MembershipBlock_upload_done-bottom'); | |
1067 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
1068 | ||
1069 | //Open Live Membership Page | |
b45c587e | 1070 | $this->openCiviPage('contribute/transact', "reset=1&id=$pageId&cid=$cid", "_qf_Main_upload-bottom"); |
6a488035 TO |
1071 | $this->click('CIVICRM_QFID_amount_other_radio_4'); |
1072 | $this->type('amount_other', 60); | |
1073 | $this->click('onbehalf_organization_name'); | |
1074 | $this->type('onbehalf_organization_name', $orgName1); | |
1075 | $this->typeKeys('onbehalf_organization_name', $orgName1); | |
1076 | $this->click("onbehalf_organization_name"); | |
1077 | $this->waitForElementPresent("css=div.ac_results-inner li"); | |
1078 | $this->click("css=div.ac_results-inner li"); | |
efb29358 CW |
1079 | // Because it tends to cause problems, all uses of sleep() must be justified in comments |
1080 | // Sleep should never be used for wait for anything to load from the server | |
1081 | // Justification for this instance: FIXME | |
6a488035 TO |
1082 | sleep(5); |
1083 | $this->click('onbehalf_member_campaign_id'); | |
1084 | $this->select('onbehalf_member_campaign_id', "label={$title}"); | |
1085 | $this->type("onbehalf_custom_{$fieldId}", 'Test Subject'); | |
1086 | ||
1087 | $this->assertContains($orgName1, $this->getValue('onbehalf_organization_name'), "autocomplete expected $orgName1 but didn’t find it in " . $this->getValue('onbehalf_organization_name')); | |
1088 | ||
1089 | // Credit Card Info | |
1090 | $this->select("credit_card_type", "value=Visa"); | |
1091 | $this->type("credit_card_number", "4111111111111111"); | |
1092 | $this->type("cvv2", "000"); | |
1093 | $this->select("credit_card_exp_date[M]", "value=1"); | |
1094 | $this->select("credit_card_exp_date[Y]", "value=2020"); | |
1095 | ||
225a8648 | 1096 | $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); |
6a488035 TO |
1097 | $this->click("_qf_Confirm_next-bottom"); |
1098 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
1099 | ||
1100 | //Find Membership for organization | |
071a6d2e | 1101 | $this->openCiviPage("member/search", "reset=1"); |
6a488035 | 1102 | $this->type("sort_name", $orgName1); |
225a8648 CW |
1103 | $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='memberSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']"); |
1104 | $this->clickLink("xpath=//div[@id='memberSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_MembershipView_cancel-bottom"); | |
6a488035 TO |
1105 | |
1106 | //verify contrb created | |
1107 | $expected = array( | |
1108 | 1 => $orgName1, | |
1109 | 2 => $title1, | |
1110 | 3 => 'New', | |
1111 | ); | |
1112 | foreach ($expected as $value => $label) { | |
1113 | $this->verifyText("xpath=//form[@id='MembershipView']/div[2]/div/table/tbody/tr[$value]/td[2]", preg_quote($label)); | |
1114 | } | |
1115 | ||
1116 | // find membership for contact in relationship | |
071a6d2e | 1117 | $this->openCiviPage("contact/view", "reset=1&force=1&cid={$cid}"); |
6a488035 TO |
1118 | $this->click("css=li#tab_member a"); |
1119 | $this->waitForElementPresent("xpath=//div[@id='memberships']/div/table//tbody//tr/td[1][text()='{$title1}']"); | |
1120 | $this->click("xpath=//div[@id='memberships']/div/table//tbody//tr/td[1][text()='{$title1}']/../td[7]/span/a[text()='View']"); | |
1121 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
1122 | ||
1123 | //verify contrb created | |
1124 | $expected = array( | |
1125 | 3 => $title1, | |
1126 | 4 => 'New', | |
1127 | ); | |
1128 | foreach ($expected as $value => $label) { | |
1129 | $this->verifyText("xpath=//form[@id='MembershipView']/div[2]/div/table/tbody/tr[$value]/td[2]", preg_quote($label)); | |
1130 | } | |
1131 | ||
071a6d2e | 1132 | $this->openCiviPage("admin/uf/group", "reset=1"); |
6a488035 TO |
1133 | $this->click("link=Reserved Profiles"); |
1134 | $this->click("xpath=//div[@id='reserved-profiles']/div/div/table/tbody//tr/td[1][text()='On Behalf Of Organization']/../td[5]/span/a[text()='Fields']"); | |
1135 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
1136 | ||
1137 | $this->click("xpath=//div[@id='field_page']/div[3]/table/tbody//tr/td[1][text()='Campaign']/../td[9]/span[2][text()='more ']/ul/li[2]/a[text()='Delete']"); | |
1138 | $this->waitForElementPresent('_qf_Field_next-bottom'); | |
1139 | ||
1140 | $this->click('_qf_Field_next-bottom'); | |
1141 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
1142 | $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'), | |
1143 | "Status message didn't show up after saving!" | |
1144 | ); | |
1145 | ||
1146 | $this->click("xpath=//div[@id='field_page']/div[3]/table/tbody//tr/td[1][text()='{$fieldTitle}']/../td[9]/span[2][text()='more ']/ul/li[2]/a[text()='Delete']"); | |
1147 | $this->waitForElementPresent('_qf_Field_next-bottom'); | |
1148 | ||
1149 | $this->click('_qf_Field_next-bottom'); | |
1150 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
1151 | $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'), | |
1152 | "Status message didn't show up after saving!" | |
1153 | ); | |
1154 | ||
071a6d2e | 1155 | $this->openCiviPage("contact/view", "reset=1&cid={$cid}"); |
6a488035 TO |
1156 | $this->click("css=li#tab_rel a"); |
1157 | ||
1158 | $this->waitForElementPresent("xpath=//div[@id='current-relationships']/div/table/tbody//tr/td[2]/a[text()='{$orgName1}']"); | |
1159 | $this->click("xpath=//div[@id='current-relationships']/div/table/tbody//tr/td[2]/a[text()='{$orgName1}']/../../td[9]/span[2][text()='more ']/ul/li[2]/a[text()='Delete']"); | |
1160 | ||
1161 | // Check confirmation alert. | |
6c6e6187 | 1162 | $this->assertTrue((bool) preg_match("/^Are you sure you want to delete this relationship?/", |
92915c55 TO |
1163 | $this->getConfirmation() |
1164 | )); | |
6a488035 TO |
1165 | $this->chooseOkOnNextConfirmation(); |
1166 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
1167 | $this->assertTrue($this->isTextPresent('Selected relationship has been deleted successfully.'), | |
1168 | "Status message didn't show up after saving!" | |
1169 | ); | |
1170 | } | |
1171 | ||
00be9182 | 1172 | public function testOnBehalfOfOrganizationWithImage() { |
071a6d2e | 1173 | $this->webtestLogin(); |
42daf119 | 1174 | |
071a6d2e | 1175 | $this->openCiviPage("profile/edit", "reset=1&gid=4"); |
42daf119 CW |
1176 | $firstName = 'John_x_' . substr(sha1(rand()), 0, 7); |
1177 | $lastName = 'Anderson_c_' . substr(sha1(rand()), 0, 7); | |
1178 | ||
6a488035 TO |
1179 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
1180 | $this->waitForElementPresent("_qf_Edit_next"); | |
1181 | $this->type("first_name", $firstName); | |
1182 | $this->type("last_name", $lastName); | |
225a8648 | 1183 | $this->clickLink("_qf_Edit_next", "profilewrap4"); |
42daf119 | 1184 | |
a471a3b6 | 1185 | $cid = $this->urlArg('id'); |
6a488035 | 1186 | $this->assertType('numeric', $cid); |
42daf119 | 1187 | // Is status message correct? |
6a488035 TO |
1188 | $this->assertTextPresent("Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!"); |
1189 | ||
071a6d2e | 1190 | $this->openCiviPage("admin/uf/group", "reset=1"); |
6a488035 | 1191 | $this->click("link=Reserved Profiles"); |
42daf119 | 1192 | |
6a488035 TO |
1193 | $this->click("xpath=//div[@id='reserved-profiles']/div/div/table/tbody//tr/td[1][text()='On Behalf Of Organization']/../td[5]/span/a[text()='Fields']"); |
1194 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
42daf119 | 1195 | |
6a488035 TO |
1196 | $this->click("link=Add Field"); |
1197 | $this->waitForElementPresent('_qf_Field_next-bottom'); | |
1198 | ||
1199 | $this->select('field_name[0]', 'value=Contact'); | |
1200 | $this->select('field_name[1]', 'label=Image Url'); | |
1201 | $this->click('field_name[1]'); | |
1202 | $this->click('_qf_Field_next-bottom'); | |
1203 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
1204 | ||
c3ad8633 CW |
1205 | // Use default payment processor |
1206 | $processorName = 'Test Processor'; | |
6a488035 TO |
1207 | $processorType = 'Dummy'; |
1208 | $pageTitle = substr(sha1(rand()), 0, 7); | |
1209 | $rand = 100; | |
1210 | $hash = substr(sha1(rand()), 0, 7); | |
1211 | $amountSection = TRUE; | |
1212 | $payLater = TRUE; | |
1213 | $onBehalf = TRUE; | |
1214 | $pledges = FALSE; | |
1215 | $recurring = FALSE; | |
1216 | $memberships = FALSE; | |
1217 | $memPriceSetId = NULL; | |
1218 | $friend = TRUE; | |
1219 | $profilePreId = NULL; | |
1220 | $profilePostId = NULL; | |
1221 | $premiums = FALSE; | |
1222 | $widget = FALSE; | |
1223 | $pcp = FALSE; | |
1224 | $honoreeSection = FALSE; | |
1225 | $isAddPaymentProcessor = TRUE; | |
1226 | $isPcpApprovalNeeded = FALSE; | |
1227 | $isSeparatePayment = FALSE; | |
1228 | ||
1229 | // create a new online contribution page | |
1230 | // create contribution page with randomized title and default params | |
1231 | $pageId = $this->webtestAddContributionPage($hash, | |
1232 | $rand, | |
1233 | $pageTitle, | |
1234 | array($processorName => $processorType), | |
1235 | $amountSection, | |
1236 | $payLater, | |
1237 | $onBehalf, | |
1238 | $pledges, | |
1239 | $recurring, | |
1240 | $memberships, | |
1241 | $memPriceSetId, | |
1242 | $friend, | |
1243 | $profilePreId, | |
1244 | $profilePostId, | |
1245 | $premiums, | |
1246 | $widget, | |
1247 | $pcp, | |
1248 | $isAddPaymentProcessor, | |
1249 | $isPcpApprovalNeeded, | |
1250 | $isSeparatePayment, | |
1251 | $honoreeSection | |
1252 | ); | |
1253 | ||
42daf119 CW |
1254 | $this->_testOrganizationWithImageUpload($pageId, $cid, $pageTitle); |
1255 | ||
071a6d2e | 1256 | $this->openCiviPage("admin/uf/group", "reset=1"); |
6a488035 | 1257 | $this->click("link=Reserved Profiles"); |
42daf119 | 1258 | |
6a488035 TO |
1259 | $this->click("xpath=//div[@id='reserved-profiles']/div/div/table/tbody//tr/td[1][text()='On Behalf Of Organization']/../td[5]/span/a[text()='Fields']"); |
1260 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
1261 | $this->click("xpath=//table[@id='option11']/tbody//tr/td/span[text()='Image Url']/../following-sibling::td[8]/span[2]/ul/li[2]/a"); | |
1262 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
1263 | $this->click('_qf_Field_next-bottom'); | |
1264 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
6c5f7368 | 1265 | $this->waitForText('crm-notification-container', "Selected Profile Field has been deleted."); |
6a488035 TO |
1266 | } |
1267 | ||
4cbe18b8 | 1268 | /** |
100fef9d CW |
1269 | * @param int $pageId |
1270 | * @param int $cid | |
4cbe18b8 EM |
1271 | * @param $pageTitle |
1272 | */ | |
00be9182 | 1273 | public function _testOrganizationWithImageUpload($pageId, $cid, $pageTitle) { |
6a488035 | 1274 | //Open Live Contribution Page |
b45c587e | 1275 | $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", '_qf_Main_upload-bottom'); |
6a488035 TO |
1276 | |
1277 | $firstName = 'Ma' . substr(sha1(rand()), 0, 4); | |
42daf119 CW |
1278 | $lastName = 'An' . substr(sha1(rand()), 0, 7); |
1279 | $orgName = 'org_11_' . substr(sha1(rand()), 0, 7); | |
6a488035 TO |
1280 | $this->type("email-5", $firstName . "@example.com"); |
1281 | ||
1282 | // onbehalforganization info | |
1283 | $this->type("onbehalf_organization_name", $orgName); | |
1284 | $this->type("onbehalf_phone-3-1", 9999999999); | |
1285 | $this->type("onbehalf_email-3", "{$orgName}@example.com"); | |
1286 | $this->type("onbehalf_street_address-3", "Test Street Address"); | |
1287 | $this->type("onbehalf_city-3", "Test City"); | |
1288 | $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6)); | |
1289 | $this->click("onbehalf_country-3"); | |
86797006 | 1290 | $this->select("onbehalf_country-3", "label=UNITED STATES"); |
6a488035 TO |
1291 | $this->click("onbehalf_state_province-3"); |
1292 | $this->select("onbehalf_state_province-3", "label=Alabama"); | |
1293 | ||
1294 | // check for upload field. | |
1295 | $this->waitForElementPresent("onbehalf_image_URL"); | |
1296 | ||
1297 | //header("Content-Type: image/png"); | |
1298 | $im = imagecreate(110, 20) | |
92915c55 | 1299 | or die("Cannot Initialize new GD image stream"); |
6a488035 TO |
1300 | $background_color = imagecolorallocate($im, 0, 0, 0); |
1301 | $text_color = imagecolorallocate($im, 233, 14, 91); | |
6c6e6187 TO |
1302 | imagestring($im, 1, 5, 5, "On Behalf-Org Logo", $text_color); |
1303 | imagepng($im, "/tmp/file.png"); | |
42daf119 | 1304 | |
6a488035 TO |
1305 | $imagePath = "/tmp/file.png"; |
1306 | $this->webtestAttachFile('onbehalf_image_URL', $imagePath); | |
1307 | unlink($imagePath); | |
1308 | ||
1309 | // Credit Card Info | |
1310 | $this->select("credit_card_type", "value=Visa"); | |
1311 | $this->type("credit_card_number", "4111111111111111"); | |
1312 | $this->type("cvv2", "000"); | |
1313 | $this->select("credit_card_exp_date[M]", "value=1"); | |
1314 | $this->select("credit_card_exp_date[Y]", "value=2020"); | |
1315 | ||
1316 | //Billing Info | |
1317 | $this->type("billing_first_name", $firstName . 'billing'); | |
1318 | $this->type("billing_last_name", $lastName . 'billing'); | |
1319 | $this->type("billing_street_address-5", "0121 Mount Highschool."); | |
1320 | $this->type(" billing_city-5", "Shangai"); | |
1321 | $this->select("billing_country_id-5", "value=1228"); | |
1322 | $this->select("billing_state_province_id-5", "value=1004"); | |
1323 | $this->type("billing_postal_code-5", "94129"); | |
225a8648 | 1324 | $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); |
6a488035 TO |
1325 | |
1326 | $this->click("_qf_Confirm_next-bottom"); | |
1327 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
1328 | ||
1329 | // Type search name in autocomplete. | |
1330 | $this->click('sort_name_navigation'); | |
1331 | $this->type('css=input#sort_name_navigation', $orgName); | |
1332 | $this->typeKeys('css=input#sort_name_navigation', $orgName); | |
1333 | ||
1334 | // Wait for result list. | |
1335 | $this->waitForElementPresent("css=div.ac_results-inner li"); | |
42daf119 | 1336 | |
6a488035 TO |
1337 | // Visit organization page. |
1338 | $this->click("css=div.ac_results-inner li"); | |
1339 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
42daf119 | 1340 | |
6a488035 TO |
1341 | //check whether the image is present |
1342 | $this->assertTrue($this->isElementPresent("xpath=//div[@id='crm-contact-thumbnail']/div/a/img")); | |
1343 | } | |
96025800 | 1344 | |
d1a39946 E |
1345 | public function testOnBehalfSetDefaults() { |
1346 | $this->webtestLogin(); | |
1347 | $hash = substr(sha1(rand()), 0, 7); | |
1348 | $pageTitle = 'Donate Online ' . $hash; | |
1349 | $rand = 2 * rand(2, 50); | |
1350 | ||
1351 | // go to the New Contribution Page page | |
1352 | $this->openCiviPage('admin/contribute', 'action=add&reset=1'); | |
1353 | ||
1354 | // fill in step 1 (Title and Settings) | |
1355 | $this->type('title', $pageTitle); | |
1356 | ||
1357 | //to select financial type | |
1358 | $this->select('financial_type_id', "label=Donation"); | |
1359 | $this->clickLink('_qf_Settings_next'); | |
1360 | ||
1361 | $this->click('link=Profiles'); | |
1362 | $this->waitForElementPresent('_qf_Custom_next-bottom'); | |
1363 | $this->select('css=tr.crm-contribution-contributionpage-custom-form-block-custom_pre_id span.crm-profile-selector-select select', "value=1"); | |
1364 | $this->click('_qf_Custom_next-bottom'); | |
1365 | $this->waitForElementPresent('_qf_Custom_next-bottom'); | |
1366 | ||
1367 | $this->click('link=Title'); | |
1368 | $this->waitForElementPresent('_qf_Settings_next'); | |
1369 | $this->click('is_organization'); | |
1370 | $this->clickLink('_qf_Settings_next'); | |
1371 | $this->waitForElementPresent('_qf_Settings_next'); | |
1372 | $this->click('is_organization'); | |
1373 | $this->clickLink('_qf_Settings_next'); | |
1374 | $this->waitForElementPresent('_qf_Settings_next'); | |
1375 | $this->click('is_organization'); | |
1376 | $this->waitForElementPresent("xpath=//*[@id='select2-chosen-2']"); | |
1377 | $sel = $this->getText("xpath=//*[@id='select2-chosen-2']"); | |
1378 | $this->assertEquals($sel, 'On Behalf Of Organization'); | |
1379 | } | |
1380 | ||
6a488035 | 1381 | } |