Merge pull request #4909 from pratikshad/broken-webtest
[civicrm-core.git] / tests / phpunit / WebTest / Contribute / OnBehalfOfOrganization.php
CommitLineData
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 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 27require_once 'CiviTest/CiviSeleniumTestCase.php';
e9479dcf
EM
28
29/**
30 * Class WebTest_Contribute_OnBehalfOfOrganization
31 */
6a488035
TO
32class 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
118 // create new individual
071a6d2e 119 $this->openCiviPage("profile/edit", "reset=1&gid=4");
42daf119
CW
120 $firstName = 'John_x_' . substr(sha1(rand()), 0, 7);
121 $lastName = 'Anderson_c_' . substr(sha1(rand()), 0, 7);
6a488035
TO
122
123 $this->waitForPageToLoad($this->getTimeoutMsec());
124 $this->waitForElementPresent("_qf_Edit_next");
125 $this->type("first_name", $firstName);
126 $this->type("last_name", $lastName);
225a8648 127 $this->clickLink("_qf_Edit_next", "profilewrap4");
6a488035 128
42daf119 129 // Is status message correct?
6a488035
TO
130 $this->assertTextPresent("Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!");
131
132 //custom data
42daf119 133
071a6d2e 134 $this->openCiviPage("admin/custom/group", "action=add&reset=1");
6a488035
TO
135
136 //fill custom group title
137 $customGroupTitle = 'custom_' . substr(sha1(rand()), 0, 7);
138 $this->click("title");
139 $this->type("title", $customGroupTitle);
140
141 //custom group extends
142 $this->click("extends[0]");
143 $this->select("extends[0]", "value=Membership");
144 //$this->click("//option[@value='Contact']");
145 $this->click("_qf_Group_next-bottom");
146 $this->waitForElementPresent("_qf_Field_cancel-bottom");
147
148 //Is custom group created?
149 $this->assertTrue($this->isTextPresent("Your custom field set '{$customGroupTitle}' has been added. You can add custom fields now."));
150
151 //add custom field - alphanumeric checkbox
152 $checkboxFieldLabel = 'custom_field' . substr(sha1(rand()), 0, 4);
153 $this->click("label");
154 $this->type("label", $checkboxFieldLabel);
155 $this->click("data_type[1]");
156 $this->select("data_type[1]", "value=CheckBox");
157 $this->click("//option[@value='CheckBox']");
158 $checkboxOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
159 $this->type("option_label_1", $checkboxOptionLabel1);
160 $this->type("option_value_1", "1");
161 $checkboxOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
162 $this->type("option_label_2", $checkboxOptionLabel2);
163 $this->type("option_value_2", "2");
164 $this->click("link=another choice");
165 $checkboxOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
166 $this->type("option_label_3", $checkboxOptionLabel3);
167 $this->type("option_value_3", "3");
168
169 //enter options per line
170 $this->type("options_per_line", "2");
171
172 //enter pre help message
173 $this->type("help_pre", "this is field pre help");
174
175 //enter post help message
176 $this->type("help_post", "this field post help");
177
178 //Is searchable?
179 $this->click("is_searchable");
180
181 //clicking save
182 $this->click("_qf_Field_next");
183 $this->waitForPageToLoad($this->getTimeoutMsec());
184
185 //Is custom field created?
39a2888d 186 $this->assertTrue($this->isTextPresent("Custom field '$checkboxFieldLabel' has been saved."));
6a488035
TO
187
188 //create another custom field - Integer Radio
189 $this->click("//a[@id='newCustomField']/span");
190 $this->waitForPageToLoad($this->getTimeoutMsec());
191 $this->click("data_type[0]");
192 $this->select("data_type[0]", "value=1");
193 $this->click("//option[@value='1']");
194 $this->click("data_type[1]");
195 $this->select("data_type[1]", "value=Radio");
196 $this->click("//option[@value='Radio']");
197
198 $radioFieldLabel = 'custom_field' . substr(sha1(rand()), 0, 4);
199 $this->type("label", $radioFieldLabel);
200 $radioOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
201 $this->type("option_label_1", $radioOptionLabel1);
202 $this->type("option_value_1", "1");
203 $radioOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
204 $this->type("option_label_2", $radioOptionLabel2);
205 $this->type("option_value_2", "2");
206 $this->click("link=another choice");
207 $radioOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
208 $this->type("option_label_3", $radioOptionLabel3);
209 $this->type("option_value_3", "3");
210
211 //select options per line
212 $this->type("options_per_line", "3");
213
214 //enter pre help msg
215 $this->type("help_pre", "this is field pre help");
216
217 //enter post help msg
218 $this->type("help_post", "this is field post help");
219
220 //Is searchable?
221 $this->click("is_searchable");
222
223 //clicking save
224 $this->click("_qf_Field_next");
225 $this->waitForPageToLoad($this->getTimeoutMsec());
226
227 //Is custom field created
39a2888d 228 $this->assertTrue($this->isTextPresent("Custom field '$radioFieldLabel' has been saved."));
42daf119 229
6a488035 230 //add the above custom data to the On Behalf of Profile
071a6d2e 231 $this->openCiviPage("admin/uf/group", "reset=1");
6a488035
TO
232 $this->click("link=Reserved Profiles");
233
234 $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']");
235 $this->waitForPageToLoad($this->getTimeoutMsec());
236
237 $this->click("link=Add Field");
238 $this->waitForElementPresent('_qf_Field_next-bottom');
239 $this->select('field_name[0]', 'value=Membership');
86bfa4f6 240 $label = $checkboxFieldLabel . ' :: ' . $customGroupTitle;
6a488035
TO
241 $this->select('field_name[1]', "label=$label");
242 $this->click('field_name[1]');
243 $this->click('_qf_Field_next_new-bottom');
244 $this->waitForPageToLoad($this->getTimeoutMsec());
245
246 $this->select('field_name[0]', 'value=Membership');
86bfa4f6 247 $label = $radioFieldLabel . ' :: ' . $customGroupTitle;
6a488035
TO
248 $this->select('field_name[1]', "label=$label");
249 $this->click('field_name[1]');
250 $this->click('_qf_Field_next-bottom');
251 $this->waitForPageToLoad($this->getTimeoutMsec());
252 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$radioFieldLabel}' has been saved to 'On Behalf Of Organization'."));
253
254 //create organisation
86bfa4f6
TO
255 $orgName = "Org WebAccess " . substr(sha1(rand()), 0, 7);
256 $orgEmail = "org" . substr(sha1(rand()), 0, 7) . "@web.com";
6a488035
TO
257 $this->webtestAddOrganization($orgName, $orgEmail);
258
259 $this->waitForPageToLoad($this->getTimeoutMsec());
260 $this->click("css=li#tab_member a");
261
262 $this->waitForElementPresent('link=Add Membership');
263 $this->click('link=Add Membership');
264
265 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
266
42daf119 267 // fill in Membership Organization and Type
6a488035
TO
268 $this->select('membership_type_id[0]', "value=1");
269 $this->select('membership_type_id[1]', "value=1");
270
42daf119 271 // fill in Source
6a488035
TO
272 $sourceText = 'On behalf Membership Webtest';
273 $this->type('source', $sourceText);
274
275 $this->waitForElementPresent("css=div#{$customGroupTitle} div.crm-accordion-header");
276 $this->click("css=div#{$customGroupTitle} div.crm-accordion-header");
277 //$this->waitForElementPresent('_qf_Membership_cancel-bottom111');
278
42daf119 279 // select newly created processor
6a488035
TO
280 $xpath = "xpath=//label[text() = '{$checkboxOptionLabel1}']/preceding-sibling::input[1]";
281 $this->assertTrue($this->isTextPresent($checkboxOptionLabel1));
282 $this->check($xpath);
42daf119 283
6a488035
TO
284 $xpath = "xpath=//label[text() = '{$checkboxOptionLabel3}']/preceding-sibling::input[1]";
285 $this->assertTrue($this->isTextPresent($checkboxOptionLabel3));
286 $this->check($xpath);
287
288 $xpath = "xpath=//label[text() = '{$radioOptionLabel1}']/preceding-sibling::input[1]";
289 $this->assertTrue($this->isTextPresent($radioOptionLabel1));
290 $this->check($xpath);
291
292 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
293 $this->click('_qf_Membership_upload-bottom');
294
6a488035
TO
295 $this->waitForPageToLoad($this->getTimeoutMsec());
296 $this->click("css=li#tab_rel a");
297
298 $this->waitForElementPresent('link=Add Relationship');
299 $this->click('link=Add Relationship');
300
301 $this->waitForElementPresent('relationship_type_id');
302 $this->click("relationship_type_id");
303 $this->select("relationship_type_id", "label=Employer of");
42daf119 304 // search organization
6a488035
TO
305 $this->type('contact_1', $firstName);
306 $this->click("contact_1");
307 $this->waitForElementPresent("css=div.ac_results-inner li");
308 $this->click("css=div.ac_results-inner li");
309 $this->assertContains($firstName, $this->getValue('contact_1'), "autocomplete expected $firstName but didn’t find it in " . $this->getValue('contact_1'));
310
42daf119 311 // give permission
6a488035
TO
312 $this->click("is_permission_a_b");
313 $this->click("is_permission_b_a");
314
42daf119 315 // save relationship
6a488035
TO
316 $this->click("details-save");
317 $this->waitForPageToLoad($this->getTimeoutMsec());
42daf119 318
c3ad8633
CW
319 // Use default payment processor
320 $processorName = 'Test Processor';
6a488035
TO
321 $processorType = 'Dummy';
322 $pageTitle = substr(sha1(rand()), 0, 7);
323 $rand = 100;
324 $hash = substr(sha1(rand()), 0, 7);
325 $amountSection = TRUE;
326 $payLater = TRUE;
327 $onBehalf = TRUE;
328 $pledges = FALSE;
329 $recurring = FALSE;
330 $memberships = TRUE;
331 $memPriceSetId = NULL;
332 $friend = TRUE;
333 $profilePreId = NULL;
334 $profilePostId = NULL;
335 $premiums = FALSE;
336 $widget = FALSE;
337 $pcp = FALSE;
338 $honoreeSection = FALSE;
339 $isAddPaymentProcessor = TRUE;
340 $isPcpApprovalNeeded = FALSE;
341 $isSeparatePayment = FALSE;
342
343 // create a new online contribution page
344 // create contribution page with randomized title and default params
345 $pageId = $this->webtestAddContributionPage($hash,
346 $rand,
347 $pageTitle,
348 array($processorName => $processorType),
349 $amountSection,
350 $payLater,
351 $onBehalf,
352 $pledges,
353 $recurring,
354 $memberships,
355 $memPriceSetId,
356 $friend,
357 $profilePreId,
358 $profilePostId,
359 $premiums,
360 $widget,
361 $pcp,
362 $isAddPaymentProcessor,
363 $isPcpApprovalNeeded,
364 $isSeparatePayment,
365 $honoreeSection
366 );
42daf119 367
6a488035
TO
368 //check for formRule
369 //scenario 1 : add membership data in pre / post profile and check for formRule
42daf119 370 //add new profile
071a6d2e 371 $this->openCiviPage("admin/uf/group", "reset=1");
6a488035
TO
372 $this->click('link=Add Profile');
373
374 $profileTitle = "test profile" . substr(sha1(rand()), 0, 7);
375 // Add membership custom data field to profile
376 $this->waitForElementPresent('_qf_Group_cancel-bottom');
377 $this->type('title', $profileTitle);
39a2888d 378 $this->clickLink('_qf_Group_next-bottom');
6a488035 379
6a488035
TO
380 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now."));
381
39a2888d
CW
382 $gid = $this->urlArg('gid');
383
92915c55
TO
384 $this->openCiviPage('admin/uf/group/field/add', array(
385 'action' => 'add',
386 'reset' => 1,
387 'gid' => $gid
388 ), 'field_name[0]');
6a488035
TO
389 $this->select('field_name[0]', "value=Membership");
390 $this->select('field_name[1]', "label={$checkboxFieldLabel} :: {$customGroupTitle}");
391 $this->click('field_name[1]');
392 $this->click('label');
393
394 // Clicking save and new
395 $this->click('_qf_Field_next_new-bottom');
396 $this->waitForPageToLoad($this->getTimeoutMsec());
397 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$checkboxFieldLabel}' has been saved to '{$profileTitle}'."));
42daf119
CW
398
399 $this->openCiviPage("admin/contribute/custom", "reset=1&action=update&id={$pageId}", '_qf_Custom_next-bottom');
6a488035
TO
400 $this->select('custom_pre_id', "label={$profileTitle}");
401 $this->click('_qf_Custom_next-bottom');
402 $this->waitForPageToLoad($this->getTimeoutMsec());
efb29358
CW
403 // Because it tends to cause problems, all uses of sleep() must be justified in comments
404 // Sleep should never be used for wait for anything to load from the server
405 // Justification for this instance: FIXME
6a488035
TO
406 sleep(3);
407 $this->assertTrue($this->isTextPresent('You should move the membership related fields in the "On Behalf" profile for this Contribution Page'), "Form rule didn't showed up while incorrectly configuring membership fields profile for 'on behalf of' contribution page");
42daf119 408
6a488035
TO
409 $this->select('custom_pre_id', "- select -");
410 $this->select('custom_post_id', "label={$profileTitle}");
411 $this->click('_qf_Custom_next-bottom');
412 $this->waitForPageToLoad($this->getTimeoutMsec());
efb29358
CW
413 // Because it tends to cause problems, all uses of sleep() must be justified in comments
414 // Sleep should never be used for wait for anything to load from the server
415 // Justification for this instance: FIXME
6a488035
TO
416 sleep(3);
417 $this->assertTrue($this->isTextPresent('You should move the membership related fields in the "On Behalf" profile for this Contribution Page'), "Form rule didn't showed up while incorrectly configuring membership fields profile for 'on behalf of' contribution page");
42daf119
CW
418
419 //scenario 2 : disable 'on behalf of', add membership data in pre / post profile
6a488035
TO
420 //then try to add 'on behalf of' and check for formRule
421 //disable 'on behalf of'
42daf119 422 $this->openCiviPage("admin/contribute/settings", "reset=1&action=update&id={$pageId}", '_qf_Settings_next-bottom');
6a488035
TO
423 $this->uncheck('is_organization');
424 $this->click('_qf_Settings_next-bottom');
425 $this->waitForPageToLoad($this->getTimeoutMsec());
42daf119 426
6a488035
TO
427 //set a membership field profile for this contribution page
428 $this->click('css=li#tab_custom a');
429 $this->waitForElementPresent('_qf_Custom_next-bottom');
430 $this->select('custom_pre_id', "label={$profileTitle}");
431 $this->click('_qf_Custom_next-bottom');
432 $this->waitForPageToLoad($this->getTimeoutMsec());
433
434 //now visit the title settings page and configure the profile as on behalf of
435 $this->click('css=li#tab_settings a');
436 $this->waitForElementPresent('_qf_Settings_next-bottom');
437 $this->check('is_organization');
438 $this->click('_qf_Settings_next-bottom');
439 $this->waitForPageToLoad($this->getTimeoutMsec());
efb29358
CW
440 // Because it tends to cause problems, all uses of sleep() must be justified in comments
441 // Sleep should never be used for wait for anything to load from the server
442 // Justification for this instance: FIXME
42daf119 443 sleep(3);
6a488035 444 $this->assertTrue($this->isTextPresent("You should move the membership related fields configured in 'Includes Profile (top of page)' to the 'On Behalf' profile for this Contribution Page"), "Form rule 'You should move the membership related fields configured in 'Includes Profile (top of page)' to the 'On Behalf' profile for this Contribution Page' didn't showed up");
42daf119 445
6a488035 446 //logout
42daf119 447 $this->webtestLogout();
6a488035
TO
448 }
449
00be9182 450 public function testOnBehalfOfOrganizationWithOrgData() {
6a488035
TO
451 $this->webtestLogin();
452
071a6d2e 453 $this->openCiviPage("profile/edit", "reset=1&gid=4");
42daf119
CW
454 $firstName = 'John_x_' . substr(sha1(rand()), 0, 7);
455 $lastName = 'Anderson_c_' . substr(sha1(rand()), 0, 7);
6a488035
TO
456
457 $this->waitForPageToLoad($this->getTimeoutMsec());
458 $this->waitForElementPresent("_qf_Edit_next");
459 $this->type("first_name", $firstName);
460 $this->type("last_name", $lastName);
225a8648 461 $this->clickLink("_qf_Edit_next", "profilewrap4");
6a488035 462
a471a3b6 463 $cid = $this->urlArg('id');
42daf119 464 // Is status message correct?
6a488035
TO
465 $this->assertTextPresent("Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!");
466
6a488035 467 //add org fields to profile
071a6d2e 468 $this->openCiviPage("admin/uf/group", "reset=1");
6a488035
TO
469 $this->click("link=Reserved Profiles");
470
471 $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']");
472 $this->waitForPageToLoad($this->getTimeoutMsec());
473
474 $this->click("link=Add Field");
475 $this->waitForElementPresent('_qf_Field_next-bottom');
42daf119 476
6a488035
TO
477 $this->select('field_name[0]', 'value=Organization');
478 $this->select('field_name[1]', 'label=Legal Identifier');
479 $this->click('field_name[1]');
480 $this->click('_qf_Field_next_new-bottom');
481 $this->waitForPageToLoad($this->getTimeoutMsec());
482
483 $this->select('field_name[0]', 'value=Organization');
484 $this->select('field_name[1]', 'label=Legal Name');
485 $this->click('field_name[1]');
486 $this->click('_qf_Field_next-bottom');
487 $this->waitForPageToLoad($this->getTimeoutMsec());
42daf119 488
6a488035 489 //create organisation
86bfa4f6
TO
490 $orgName = "Org WebAccess " . substr(sha1(rand()), 0, 7);
491 $orgEmail = "org" . substr(sha1(rand()), 0, 7) . "@web.com";
6a488035
TO
492 $this->webtestAddOrganization($orgName, $orgEmail);
493
494 $this->waitForPageToLoad($this->getTimeoutMsec());
495 $this->click("css=li#tab_rel a");
496
497 $this->waitForElementPresent('link=Add Relationship');
498 $this->click('link=Add Relationship');
499
500 $this->waitForElementPresent('relationship_type_id');
501 $this->click("relationship_type_id");
502 $this->select("relationship_type_id", "label=Employer of");
42daf119 503 // search organization
6a488035
TO
504 $this->type('contact_1', $firstName);
505 $this->click("contact_1");
506 $this->waitForElementPresent("css=div.ac_results-inner li");
507 $this->click("css=div.ac_results-inner li");
508 $this->assertContains($firstName, $this->getValue('contact_1'), "autocomplete expected $firstName but didn’t find it in " . $this->getValue('contact_1'));
509
42daf119 510 // give permission
6a488035
TO
511 $this->click("is_permission_a_b");
512 $this->click("is_permission_b_a");
513
42daf119 514 // save relationship
6a488035
TO
515 $this->waitForElementPresent("details-save");
516 $this->click("details-save");
517 $this->waitForElementPresent("Relationships");
518
519 $pageTitle = substr(sha1(rand()), 0, 7);
520 $rand = 100;
521 $hash = substr(sha1(rand()), 0, 7);
522 $amountSection = TRUE;
523 $payLater = TRUE;
524 $onBehalf = TRUE;
525 $pledges = FALSE;
526 $recurring = FALSE;
527 $memberships = TRUE;
528 $memPriceSetId = NULL;
529 $friend = TRUE;
530 $profilePreId = NULL;
531 $profilePostId = NULL;
532 $premiums = FALSE;
533 $widget = FALSE;
534 $pcp = FALSE;
535 $honoreeSection = FALSE;
536 $isAddPaymentProcessor = FALSE;
537 $isPcpApprovalNeeded = FALSE;
538 $isSeparatePayment = FALSE;
539
540 // create a new online contribution page
541 // create contribution page with randomized title and default params
542 $pageId = $this->webtestAddContributionPage($hash,
543 $rand,
544 $pageTitle,
6c6e6187 545 NULL,
6a488035
TO
546 $amountSection,
547 $payLater,
548 $onBehalf,
549 $pledges,
550 $recurring,
551 $memberships,
552 $memPriceSetId,
553 $friend,
554 $profilePreId,
555 $profilePostId,
556 $premiums,
557 $widget,
558 $pcp,
559 $isAddPaymentProcessor,
560 $isPcpApprovalNeeded,
561 $isSeparatePayment,
562 $honoreeSection
563 );
564
6c6e6187 565 $this->_testOrganization($pageId, $cid, $pageTitle);
6a488035
TO
566 }
567
00be9182 568 public function testWithContactSubtypeDupe() {
130ad870
JP
569 $this->webtestLogin();
570
571 //create organisation
86bfa4f6
TO
572 $orgName = "Org WebAccess " . substr(sha1(rand()), 0, 7);
573 $orgEmail = "org" . substr(sha1(rand()), 0, 7) . "@web.com";
130ad870
JP
574 $contactSubType = 'Sponsor';
575 $this->webtestAddOrganization($orgName, $orgEmail, $contactSubType);
576
577 $this->waitForPageToLoad($this->getTimeoutMsec());
578 $cid = $this->urlArg('cid');
579
580 $pageTitle = substr(sha1(rand()), 0, 7);
581 $rand = 100;
582 $hash = substr(sha1(rand()), 0, 7);
583 $amountSection = TRUE;
584 $payLater = TRUE;
585 $onBehalf = TRUE;
586 $pledges = FALSE;
587 $recurring = FALSE;
588 $memberships = FALSE;
589 $memPriceSetId = NULL;
590 $friend = FALSE;
591 $profilePreId = NULL;
592 $profilePostId = NULL;
593 $premiums = FALSE;
594 $widget = FALSE;
595 $pcp = FALSE;
596 $honoreeSection = FALSE;
597 $isAddPaymentProcessor = FALSE;
598 $isPcpApprovalNeeded = FALSE;
599 $isSeparatePayment = FALSE;
600
601 // create a new online contribution page
602 // create contribution page with randomized title and default params
603 $pageId = $this->webtestAddContributionPage($hash,
604 $rand,
605 $pageTitle,
6c6e6187 606 NULL,
130ad870
JP
607 $amountSection,
608 $payLater,
609 $onBehalf,
610 $pledges,
611 $recurring,
612 $memberships,
613 $memPriceSetId,
614 $friend,
615 $profilePreId,
616 $profilePostId,
617 $premiums,
618 $widget,
619 $pcp,
620 $isAddPaymentProcessor,
621 $isPcpApprovalNeeded,
622 $isSeparatePayment,
623 $honoreeSection
624 );
625
6c6e6187 626 //Open Live Contribution Page
130ad870
JP
627 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom");
628 $this->waitForElementPresent("onbehalf_state_province-3");
629
630 $this->type("onbehalf_organization_name", $orgName);
631 $this->waitForElementPresent("onbehalf_phone-3-1");
632 $this->type("onbehalf_phone-3-1", 9999999999);
633 $this->waitForElementPresent("onbehalf_email-3");
634 $this->type("onbehalf_email-3", "org@example.com");
635 $this->type("onbehalf_street_address-3", "Test Street Address");
636 $this->type("onbehalf_city-3", "Test City");
637 $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
638 $this->click("onbehalf_country-3");
639 $this->select("onbehalf_country-3", "label=United States");
640 $this->click("onbehalf_state_province-3");
641 $this->select("onbehalf_state_province-3", "label=Alabama");
642
643 $this->waitForElementPresent("_qf_Main_upload-bottom");
644 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
645
646 $this->click("_qf_Confirm_next-bottom");
647 $this->waitForPageToLoad($this->getTimeoutMsec());
648
649 $this->openCiviPage("contact/view", "reset=1&cid=$cid", "xpath=//div[@class='crm-content crm-contact_type_label']");
650
651 $this->verifyText("xpath=//div[@class='crm-content crm-contact_type_label']", $contactSubType);
652 }
653
4cbe18b8 654 /**
100fef9d
CW
655 * @param int $pageId
656 * @param int $cid
4cbe18b8
EM
657 * @param $pageTitle
658 */
00be9182 659 public function _testOrganization($pageId, $cid, $pageTitle) {
6a488035 660 //Open Live Contribution Page
071a6d2e 661 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom");
6a488035
TO
662
663 $this->waitForElementPresent("onbehalf_state_province-3");
664
665 $this->waitForElementPresent("onbehalf_phone-3-1");
666 $this->type("onbehalf_phone-3-1", 9999999999);
667 $this->waitForElementPresent("onbehalf_email-3");
668 $this->type("onbehalf_email-3", "org@example.com");
669 $this->type("onbehalf_street_address-3", "Test Street Address");
670 $this->type("onbehalf_city-3", "Test City");
671 $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
672 $this->click("onbehalf_country-3");
673 $this->select("onbehalf_country-3", "label=United States");
674 $this->click("onbehalf_state_province-3");
675 $this->select("onbehalf_state_province-3", "label=Alabama");
676
677 $this->waitForElementPresent("_qf_Main_upload-bottom");
225a8648 678 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
6a488035
TO
679
680 $this->click("_qf_Confirm_next-bottom");
681 $this->waitForPageToLoad($this->getTimeoutMsec());
682
683 }
684
4cbe18b8 685 /**
100fef9d
CW
686 * @param int $pageId
687 * @param int $cid
4cbe18b8
EM
688 * @param $pageTitle
689 */
00be9182 690 public function _testAnomoyousOganization($pageId, $cid, $pageTitle) {
6a488035 691 //Open Live Contribution Page
071a6d2e 692 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom");
6a488035
TO
693
694 $this->click('CIVICRM_QFID_0_8');
695 $this->type('css=div.other_amount-section input', 60);
696
697 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
42daf119
CW
698 $lastName = 'An' . substr(sha1(rand()), 0, 7);
699 $orgName = 'org_11_' . substr(sha1(rand()), 0, 7);
6a488035
TO
700 $this->type("email-5", $firstName . "@example.com");
701
702 // enable onbehalforganization block
703 $this->click("is_for_organization");
704 $this->waitForElementPresent("onbehalf_state_province-3");
705
706 // onbehalforganization info
707 $this->type("onbehalf_organization_name", $orgName);
708 $this->type("onbehalf_phone-3-1", 9999999999);
709 $this->type("onbehalf_email-3", "{$orgName}@example.com");
710 $this->type("onbehalf_street_address-3", "Test Street Address");
711 $this->type("onbehalf_city-3", "Test City");
712 $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
713 $this->click("onbehalf_country-3");
714 $this->select("onbehalf_country-3", "label=United States");
715 $this->click("onbehalf_state_province-3");
716 $this->select("onbehalf_state_province-3", "label=Alabama");
717
6a488035
TO
718 // Credit Card Info
719 $this->select("credit_card_type", "value=Visa");
720 $this->type("credit_card_number", "4111111111111111");
721 $this->type("cvv2", "000");
722 $this->select("credit_card_exp_date[M]", "value=1");
723 $this->select("credit_card_exp_date[Y]", "value=2020");
724
725 //Billing Info
726 $this->type("billing_first_name", $firstName . 'billing');
727 $this->type("billing_last_name", $lastName . 'billing');
728 $this->type("billing_street_address-5", "0121 Mount Highschool.");
729 $this->type(" billing_city-5", "Shangai");
730 $this->select("billing_country_id-5", "value=1228");
731 $this->select("billing_state_province_id-5", "value=1004");
732 $this->type("billing_postal_code-5", "94129");
225a8648 733 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
6a488035
TO
734
735 $this->click("_qf_Confirm_next-bottom");
736 $this->waitForPageToLoad($this->getTimeoutMsec());
737
738 //login to check contribution
6a488035
TO
739
740 // Log in using webtestLogin() method
741 $this->webtestLogin();
742
743 //Find Contribution
071a6d2e 744 $this->openCiviPage("contribute/search", "reset=1");
6a488035 745 $this->type("sort_name", $orgName);
225a8648
CW
746 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
747 $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom");
6a488035
TO
748
749 // verify contrb created
750 $expected = array(
751 1 => $orgName,
752 2 => 'Donation',
753 10 => $pageTitle,
754 );
755 foreach ($expected as $value => $label) {
756 $this->verifyText("xpath=id( 'ContributionView' )/div[2]/table[1]/tbody/tr[$value]/td[2]", preg_quote($label));
757 }
758 }
759
4cbe18b8 760 /**
100fef9d
CW
761 * @param int $pageId
762 * @param int $cid
4cbe18b8
EM
763 * @param $pageTitle
764 */
00be9182 765 public function _testUserWithOneRelationship($pageId, $cid, $pageTitle) {
42daf119 766 $this->webtestLogin('admin');
6a488035
TO
767
768 // Create new group
769 $groupName = $this->WebtestAddGroup();
42daf119 770 $this->openCiviPage("group", "reset=1", "_qf_Search_refresh");
6a488035
TO
771 $groupId = $this->getText("xpath=//table[@id='crm-group-selector']/tbody//tr/td[text()='{$groupName}']/../td[2]");
772
071a6d2e 773 $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
6a488035
TO
774
775 $this->click('link=Edit');
776 $this->waitForElementPresent('_qf_Contact_cancel-bottom');
777 $this->click('addressBlock');
778 $this->waitForElementPresent('link=Another Address');
779
780 //Billing Info
781 $this->select('address_1_location_type_id', 'label=Billing');
782 $this->type('address_1_street_address', '0121 Mount Highschool.');
783 $this->type('address_1_city', "Shangai");
784 $this->type('address_1_postal_code', "94129");
785 $this->select('address_1_country_id', "value=1228");
786 $this->select('address_1_state_province_id', "value=1004");
787 $this->click('_qf_Contact_upload_view-bottom');
788 $this->waitForPageToLoad($this->getTimeoutMsec());
789
790 // add contact to group
791 // visit group tab
792 $this->click("css=li#tab_group a");
793 $this->waitForElementPresent("group_id");
794
795 // add to group
796 $this->select("group_id", "label={$groupName}");
797 $this->click("_qf_GroupContact_next");
798 $this->waitForPageToLoad($this->getTimeoutMsec());
799
42daf119 800 $this->openCiviPage("admin/custom/group", "action=add&reset=1", "_qf_Group_next-bottom");
6a488035
TO
801
802 // fill in a unique title for the custom group
803 $groupTitle = "Custom Group" . substr(sha1(rand()), 0, 7);
804 $this->type("title", $groupTitle);
805
806 // select the group this custom data set extends
807 $this->select("extends[0]", "value=Contribution");
808 $this->waitForElementPresent("extends[1]");
809
810 // save the custom group
811 $this->click("_qf_Group_next-bottom");
812 $this->waitForElementPresent("_qf_Field_next_new-bottom");
813 $this->assertTrue($this->isTextPresent("Your custom field set '$groupTitle' has been added. You can add custom fields now."));
814
815 // add a custom field to the custom group
816 $fieldTitle = "Custom Field " . substr(sha1(rand()), 0, 7);
817 $this->type("label", $fieldTitle);
818
819 $this->select("data_type[1]", "value=Text");
820 $this->click('_qf_Field_next-bottom');
821
822 $this->waitForPageToLoad($this->getTimeoutMsec());
39a2888d 823 $this->assertTrue($this->isTextPresent("Custom field '$fieldTitle' has been saved."));
a471a3b6 824 $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
825
826 // Enable CiviCampaign module if necessary
b9715b8a 827 $this->enableComponents("CiviCampaign");
6a488035 828
42daf119 829 // add the required permission
6a488035
TO
830 $permission = array('edit-2-administer-civicampaign');
831 $this->changePermissions($permission);
832
42daf119
CW
833 // Log in as normal user
834 $this->webtestLogin();
6a488035 835
42daf119 836 $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom");
6a488035 837
6a488035
TO
838 $title = 'Campaign ' . substr(sha1(rand()), 0, 7);
839 $this->type("title", $title);
840
841 // select the campaign type
842 $this->select("campaign_type_id", "value=2");
843
844 // fill in the description
845 $this->type("description", "This is a test campaign");
846
847 // include groups for the campaign
848 $this->addSelection("includeGroups-f", "label={$groupName}");
849 $this->click("//option[@value={$groupId}]");
850 $this->click("add");
851
852 // fill the end date for campaign
853 $this->webtestFillDate("end_date", "+1 year");
854
855 // select campaign status
856 $this->select("status_id", "value=2");
857
858 // click save
859 $this->click("_qf_Campaign_upload-bottom");
860 $this->waitForElementPresent("xpath=//div[@id='campaigns_wrapper']//table[@id='campaigns']/tbody//tr/td[3][text()='{$title}']");
861 $this->assertTrue($this->isTextPresent("Campaign {$title} has been saved."), "Status message didn't show up after saving!");
862
071a6d2e 863 $this->openCiviPage("admin/uf/group", "reset=1");
6a488035
TO
864 $this->click("link=Reserved Profiles");
865
866 $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']");
867 $this->waitForPageToLoad($this->getTimeoutMsec());
868
869 $this->click("link=Add Field");
870 $this->waitForElementPresent('_qf_Field_next-bottom');
871 $this->select('field_name[0]', 'value=Contribution');
872 $this->select('field_name[1]', 'label=Campaign');
873 $this->click('field_name[1]');
874 $this->click('_qf_Field_next_new-bottom');
875 $this->waitForPageToLoad($this->getTimeoutMsec());
876
877 $this->select('field_name[0]', 'value=Contribution');
878 $this->select('field_name[1]', "label=$fieldTitle :: $groupTitle");
879 $this->click('field_name[1]');
880 $this->click('_qf_Field_next-bottom');
881 $this->waitForPageToLoad($this->getTimeoutMsec());
882 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$fieldTitle}' has been saved to 'On Behalf Of Organization'."));
883
884 // Open Page to create Organization
42daf119 885 $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom");
6a488035
TO
886 $orgName1 = 'org1_' . substr(sha1(rand()), 0, 7);
887
888 // Type Organization name
889 $this->type("organization_name", $orgName1);
890
891 // Type Organizatio email for main
892 $this->type("email_1_email", "{$orgName1}@example.com");
893 $this->select("email_1_location_type_id", "value=3");
894
895 // type phone no for main
896 $this->type("phone_1_phone", 9999999999);
897 $this->select("phone_1_location_type_id", "value=3");
898
899 //address section
900 $this->click("addressBlock");
901 $this->waitForElementPresent("address_1_street_address");
902
903 //fill in address 1 for main
904 $this->select("address_1_location_type_id", "value=3");
905 $this->type("address_1_street_address", "{$orgName1} street address");
906 $this->type("address_1_city", "{$orgName1} city");
907 $this->type("address_1_postal_code", substr(sha1(rand()), 0, 4));
908 $this->assertTrue($this->isTextPresent("- select - United States"));
909 $this->select("address_1_state_province_id", "value=1019");
910 $this->type("address_1_geo_code_1", "1234");
911 $this->type("address_1_geo_code_2", "5678");
912
913 // Save the Organization
914 $this->click("_qf_Contact_upload_view-bottom");
915 $this->waitForPageToLoad($this->getTimeoutMsec());
916
917 // open contact
071a6d2e 918 $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1");
6a488035
TO
919
920 // select relationship type
921 $this->click("relationship_type_id");
922 $this->select("relationship_type_id", "value=4_a_b");
923
924 // search organization
925 $this->type('contact_1', $orgName1);
926 $this->click("contact_1");
927 $this->waitForElementPresent("css=div.ac_results-inner li");
928 $this->click("css=div.ac_results-inner li");
929 $this->assertContains($orgName1, $this->getValue('contact_1'), "autocomplete expected $orgName1 but didn’t find it in " . $this->getValue('contact_1'));
930
931 $this->waitForElementPresent("add_current_employer");
932 $this->click("add_current_employer");
933
934 // give permission
935 $this->click("is_permission_a_b");
936 $this->click("is_permission_b_a");
937
938 // save relationship
939 $this->waitForElementPresent("details-save");
940 $this->click("details-save");
941
942 //Open Live Contribution Page
071a6d2e 943 $this->openCiviPage("contribute/transact", "reset=1&id={$pageId}&cid=$cid", "onbehalf_state_province-3");
6a488035
TO
944 $this->click('CIVICRM_QFID_amount_other_radio_4');
945 $this->type('amount_other', 60);
946 $this->click('onbehalf_contribution_campaign_id');
947 $this->select('onbehalf_contribution_campaign_id', "label={$title}");
948 $this->type("onbehalf_custom_{$fieldId}", 'Test Subject');
949
950 // Credit Card Info
951 $this->select("credit_card_type", "value=Visa");
952 $this->type("credit_card_number", "4111111111111111");
953 $this->type("cvv2", "000");
954 $this->select("credit_card_exp_date[M]", "value=1");
955 $this->select("credit_card_exp_date[Y]", "value=2020");
956
957 //Billing Info
958 $this->type("billing_street_address-5", "0121 Mount Highschool.");
959 $this->type(" billing_city-5", "Shangai");
960 $this->select("billing_country_id-5", "value=1228");
961 $this->select("billing_state_province_id-5", "value=1004");
962 $this->type("billing_postal_code-5", "94129");
963
225a8648 964 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
6a488035
TO
965 $this->click("_qf_Confirm_next-bottom");
966 $this->waitForPageToLoad($this->getTimeoutMsec());
967
968 //Find Contribution
071a6d2e 969 $this->openCiviPage("contribute/search", "reset=1");
6a488035 970 $this->type("sort_name", $orgName1);
225a8648
CW
971 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
972 $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom");
6a488035
TO
973
974 // verify contrb created
975 $expected = array(
976 1 => $orgName1,
977 2 => 'Donation',
978 10 => $title,
979 11 => $pageTitle,
980 );
981 foreach ($expected as $value => $label) {
982 $this->verifyText("xpath=id( 'ContributionView' )/div[2]/table[1]/tbody/tr[$value]/td[2]", preg_quote($label));
983 }
984
071a6d2e 985 $this->openCiviPage("admin/uf/group", "reset=1");
6a488035
TO
986 $this->click("link=Reserved Profiles");
987
988 $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']");
989 $this->waitForPageToLoad($this->getTimeoutMsec());
990
991 $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']");
992 $this->waitForElementPresent('_qf_Field_next-bottom');
993
994 $this->click('_qf_Field_next-bottom');
995 $this->waitForPageToLoad($this->getTimeoutMsec());
996 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'), "Status message didn't show up after saving!");
997
998 $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']");
999 $this->waitForElementPresent('_qf_Field_next-bottom');
1000
1001 $this->click('_qf_Field_next-bottom');
1002 $this->waitForPageToLoad($this->getTimeoutMsec());
1003 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'), "Status message didn't show up after saving!");
1004 }
1005
4cbe18b8 1006 /**
100fef9d
CW
1007 * @param int $pageId
1008 * @param int $cid
4cbe18b8
EM
1009 * @param $pageTitle
1010 */
00be9182 1011 public function _testUserWithMoreThanOneRelationship($pageId, $cid, $pageTitle) {
42daf119 1012 $this->webtestLogin('admin');
6a488035
TO
1013 $this->waitForPageToLoad($this->getTimeoutMsec());
1014
1015 // Create new group
1016 $groupName = $this->WebtestAddGroup();
42daf119 1017 $this->openCiviPage("group", "reset=1", '_qf_Search_refresh');
6a488035
TO
1018 $this->click('_qf_Search_refresh');
1019 $this->waitForElementPresent("xpath=//div[@id='group']/div[3]/table/tbody//tr/td[text()='{$groupName}']/../td[2]");
1020 $groupId = $this->getText("xpath=//div[@id='group']/div[3]/table/tbody//tr/td[text()='{$groupName}']/../td[2]");
1021
071a6d2e 1022 $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
6a488035
TO
1023
1024 $this->click('link=Edit');
1025 $this->waitForElementPresent('_qf_Contact_cancel-bottom');
1026 $this->click('addressBlock');
1027 $this->waitForElementPresent('link=Another Address');
1028
1029 //Billing Info
1030 $this->select('address_1_location_type_id', 'label=Billing');
1031 $this->type('address_1_street_address', '0121 Mount Highschool.');
1032 $this->type('address_1_city', "Shangai");
1033 $this->type('address_1_postal_code', "94129");
1034 $this->select('address_1_country_id', "value=1228");
1035 $this->select('address_1_state_province_id', "value=1004");
1036 $this->click('_qf_Contact_upload_view-bottom');
1037 $this->waitForPageToLoad($this->getTimeoutMsec());
1038
1039 // add contact to group
1040 // visit group tab
1041 $this->click("css=li#tab_group a");
1042 $this->waitForElementPresent("group_id");
1043
1044 // add to group
1045 $this->select("group_id", "label=$groupName");
1046 $this->click("_qf_GroupContact_next");
1047 $this->waitForPageToLoad($this->getTimeoutMsec());
1048
42daf119 1049 $this->openCiviPage("admin/custom/group", "action=add&reset=1", "_qf_Group_next-bottom");
6a488035
TO
1050
1051 // fill in a unique title for the c$groupIdustom group
1052 $groupTitle = "Members Custom Group" . substr(sha1(rand()), 0, 7);
1053 $this->type("title", $groupTitle);
1054
1055 // select the group this custom data set extends
1056 $this->select("extends[0]", "value=Membership");
1057 $this->waitForElementPresent("extends[1]");
1058
1059 // save the custom group
1060 $this->click("_qf_Group_next-bottom");
1061
1062 $this->waitForElementPresent("_qf_Field_next_new-bottom");
1063 $this->assertTrue($this->isTextPresent("Your custom field set '$groupTitle' has been added. You can add custom fields now."));
1064
1065 // add a custom field to the custom group
1066 $fieldTitle = "Member Custom Field " . substr(sha1(rand()), 0, 7);
1067 $this->type("label", $fieldTitle);
1068
1069 $this->select("data_type[1]", "value=Text");
1070 $this->click('_qf_Field_next-bottom');
1071
1072 $this->waitForPageToLoad($this->getTimeoutMsec());
39a2888d 1073 $this->assertTrue($this->isTextPresent("Custom field '$fieldTitle' has been saved."));
a471a3b6 1074 $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
1075
1076 // Enable CiviCampaign module if necessary
b9715b8a 1077 $this->enableComponents("CiviCampaign");
6a488035 1078
42daf119 1079 // add the required permission
6a488035
TO
1080 $permission = array('edit-2-administer-civicampaign');
1081 $this->changePermissions($permission);
1082
42daf119
CW
1083 // Log in as normal user
1084 $this->webtestLogin();
6a488035 1085
42daf119 1086 $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom");
6a488035 1087
6a488035
TO
1088 $title = 'Campaign ' . substr(sha1(rand()), 0, 7);
1089 $this->type("title", $title);
1090
1091 // select the campaign type
1092 $this->select("campaign_type_id", "value=2");
1093
1094 // fill in the description
1095 $this->type("description", "This is a test campaign");
1096
1097 // include groups for the campaign
1098 $this->addSelection("includeGroups-f", "label={$groupName}");
1099 $this->click("//option[@value={$groupId}]");
1100 $this->click("add");
1101
1102 // fill the end date for campaign
1103 $this->webtestFillDate("end_date", "+1 year");
1104
1105 // select campaign status
1106 $this->select("status_id", "value=2");
1107
1108 // click save
1109 $this->click("_qf_Campaign_upload-bottom");
1110 $this->waitForPageToLoad($this->getTimeoutMsec());
1111
1112 $this->assertTrue($this->isTextPresent("Campaign {$title} has been saved."), "Status message didn't show up after saving!");
1113
071a6d2e 1114 $this->openCiviPage("admin/uf/group", "reset=1");
6a488035
TO
1115 $this->click("link=Reserved Profiles");
1116 $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']");
1117 $this->waitForPageToLoad($this->getTimeoutMsec());
1118
1119 $this->click("link=Add Field");
1120 $this->waitForElementPresent('_qf_Field_next-bottom');
1121 $this->select('field_name[0]', 'value=Membership');
1122 $this->select('field_name[1]', 'label=Campaign');
1123 $this->click('field_name[1]');
225a8648 1124 $this->clickLink('_qf_Field_next_new-bottom', '_qf_Field_cancel-bottom');
6a488035
TO
1125
1126 $this->select('field_name[0]', 'value=Membership');
1127 $this->select('field_name[1]', "label=$fieldTitle :: $groupTitle");
1128 $this->click('field_name[1]');
1129 $this->click('_qf_Field_next-bottom');
1130 $this->waitForPageToLoad($this->getTimeoutMsec());
1131 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$fieldTitle}' has been saved to 'On Behalf Of Organization'."),
1132 "Status message didn't show up after saving!"
1133 );
1134
1135 // Open Page to create Organization 1
42daf119 1136 $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom");
6a488035
TO
1137 $orgName1 = 'org1_' . substr(sha1(rand()), 0, 7);
1138
1139 // Type Organization name
1140 $this->type("organization_name", $orgName1);
1141
1142 // Type Organizatio email for main
1143 $this->type("email_1_email", "{$orgName1}@example.com");
1144 $this->select("email_1_location_type_id", "value=3");
1145
1146 // type phone no for main
1147 $this->type("phone_1_phone", substr(sha1(rand()), 0, 4));
1148 $this->select("phone_1_location_type_id", "value=3");
1149
1150 //address section
1151 $this->click("addressBlock");
1152 $this->waitForElementPresent("address_1_street_address");
1153
1154 //fill in address 1 for main
1155 $this->select("address_1_location_type_id", "value=3");
1156 $this->type("address_1_street_address", "{$orgName1} street address");
1157 $this->type("address_1_city", "{$orgName1} city");
1158 $this->type("address_1_postal_code", "9999999999");
1159 $this->assertTrue($this->isTextPresent("- select - United States"));
1160 $this->select("address_1_state_province_id", "value=1019");
1161 $this->type("address_1_geo_code_1", "1234");
1162 $this->type("address_1_geo_code_2", "5678");
1163
1164 // Save the Organization
1165 $this->click("_qf_Contact_upload_view-bottom");
1166 $this->waitForPageToLoad($this->getTimeoutMsec());
1167
1168 // create second orzanization
42daf119 1169 $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom");
6a488035
TO
1170 $orgName2 = 'org2_' . substr(sha1(rand()), 0, 7);
1171
1172 // Type Organization name
1173 $this->type("organization_name", $orgName2);
1174
1175 // Type Organizatio email for main
1176 $this->type("email_1_email", "{$orgName2}@example.com");
1177 $this->select("email_1_location_type_id", "value=3");
1178
1179 // type phone no for main
1180 $this->type("phone_1_phone", substr(sha1(rand()), 0, 4));
1181 $this->select("phone_1_location_type_id", "value=3");
1182
1183 //address section
1184 $this->click("addressBlock");
1185 $this->waitForElementPresent("address_1_street_address");
1186
1187 //fill in address 1 for main
1188 $this->select("address_1_location_type_id", "value=3");
1189 $this->type("address_1_street_address", "{$orgName2} street address");
1190 $this->type("address_1_city", "{$orgName2} city");
1191 $this->type("address_1_postal_code", "7777777777");
1192 $this->assertTrue($this->isTextPresent("- select - United States"));
1193 $this->select("address_1_state_province_id", "value=1019");
1194 $this->type("address_1_geo_code_1", "1224");
1195 $this->type("address_1_geo_code_2", "5628");
1196
1197 // Save the Organization
1198 $this->click("_qf_Contact_upload_view-bottom");
1199 $this->waitForPageToLoad($this->getTimeoutMsec());
1200
6a488035
TO
1201 // create Membership type
1202 $title1 = "Membership Type" . substr(sha1(rand()), 0, 7);
071a6d2e 1203 $this->openCiviPage("admin/member/membershipType", "reset=1&action=browse");
6a488035
TO
1204
1205 $this->click("link=Add Membership Type");
1206 $this->waitForElementPresent('_qf_MembershipType_cancel-bottom');
1207
1208 $this->type('name', $title1);
1209 $this->type('member_org', $orgName1);
1210 $this->click('_qf_MembershipType_refresh');
1211 $this->waitForElementPresent("xpath=//div[@id='membership_type_form']/fieldset/table[2]/tbody/tr[2]/td[2]");
1212
1213 $this->type('minimum_fee', '50');
1214
481a74f4 1215 $this->select('financial_type_id', 'value=2');
6a488035
TO
1216
1217 $this->type('duration_interval', 1);
1218 $this->select('duration_unit', "label=year");
1219
1220 $this->select('period_type', "label=fixed");
1221 $this->waitForElementPresent('fixed_period_rollover_day[d]');
1222
1223 $this->select('fixed_period_start_day[M]', 'value=4');
1224 $this->select('fixed_period_rollover_day[M]', 'value=1');
1225
1226 $this->select('relationship_type_id', 'value=4_b_a');
1227
1228 $this->click('_qf_MembershipType_upload-bottom');
1229 $this->waitForElementPresent('link=Add Membership Type');
1230 $this->assertTrue($this->isTextPresent("The membership type '$title1' has been saved."));
a471a3b6 1231 $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
1232
1233 // open contact
071a6d2e 1234 $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1");
6a488035
TO
1235
1236 // select relationship type
1237 $this->click("relationship_type_id");
1238 $this->select("relationship_type_id", "value=4_a_b");
1239
1240 // search organization
1241 $this->type('contact_1', $orgName1);
1242 $this->click("contact_1");
1243 $this->waitForElementPresent("css=div.ac_results-inner li");
1244 $this->click("css=div.ac_results-inner li");
1245 $this->assertContains($orgName1, $this->getValue('contact_1'), "autocomplete expected $orgName1 but didn’t find it in " . $this->getValue('contact_1'));
1246
1247 // give permission
1248 $this->click("is_permission_a_b");
1249 $this->click("is_permission_b_a");
1250
1251 // save relationship
1252 $this->click("details-save");
1253
1254 // open contact
071a6d2e 1255 $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1");
6a488035
TO
1256
1257 // select relationship type
1258 $this->click("relationship_type_id");
1259 $this->select("relationship_type_id", "value=4_a_b");
1260
1261 // search organization
1262 $this->type('contact_1', $orgName2);
1263 $this->click("contact_1");
1264 $this->waitForElementPresent("css=div.ac_results-inner li");
1265 $this->click("css=div.ac_results-inner li");
1266 $this->assertContains($orgName2, $this->getValue('contact_1'), "autocomplete expected $orgName2 but didn’t find it in " . $this->getValue('contact_1'));
1267
1268 // give permission
1269 $this->click("is_permission_a_b");
1270 $this->click("is_permission_b_a");
1271
1272 // save relationship
1273 $this->click("details-save");
1274
1275 // set membership type
071a6d2e 1276 $this->openCiviPage("admin/contribute/membership", "reset=1&action=update&id=$pageId", "_qf_MembershipBlock_upload_done-bottom");
6a488035
TO
1277 $this->click("member_is_active");
1278 $this->click("membership_type[{$typeId}]");
1279 $this->click("xpath=//div[@id='memberFields']//table[@class='report']/tbody//tr/td[1]/label[text()='{$title1}']/../../td[2]/input");
1280 $this->click('_qf_MembershipBlock_upload_done-bottom');
1281 $this->waitForPageToLoad($this->getTimeoutMsec());
1282
1283 //Open Live Membership Page
b45c587e 1284 $this->openCiviPage('contribute/transact', "reset=1&id=$pageId&cid=$cid", "_qf_Main_upload-bottom");
6a488035
TO
1285 $this->click('CIVICRM_QFID_amount_other_radio_4');
1286 $this->type('amount_other', 60);
1287 $this->click('onbehalf_organization_name');
1288 $this->type('onbehalf_organization_name', $orgName1);
1289 $this->typeKeys('onbehalf_organization_name', $orgName1);
1290 $this->click("onbehalf_organization_name");
1291 $this->waitForElementPresent("css=div.ac_results-inner li");
1292 $this->click("css=div.ac_results-inner li");
efb29358
CW
1293 // Because it tends to cause problems, all uses of sleep() must be justified in comments
1294 // Sleep should never be used for wait for anything to load from the server
1295 // Justification for this instance: FIXME
6a488035
TO
1296 sleep(5);
1297 $this->click('onbehalf_member_campaign_id');
1298 $this->select('onbehalf_member_campaign_id', "label={$title}");
1299 $this->type("onbehalf_custom_{$fieldId}", 'Test Subject');
1300
1301 $this->assertContains($orgName1, $this->getValue('onbehalf_organization_name'), "autocomplete expected $orgName1 but didn’t find it in " . $this->getValue('onbehalf_organization_name'));
1302
1303 // Credit Card Info
1304 $this->select("credit_card_type", "value=Visa");
1305 $this->type("credit_card_number", "4111111111111111");
1306 $this->type("cvv2", "000");
1307 $this->select("credit_card_exp_date[M]", "value=1");
1308 $this->select("credit_card_exp_date[Y]", "value=2020");
1309
225a8648 1310 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
6a488035
TO
1311 $this->click("_qf_Confirm_next-bottom");
1312 $this->waitForPageToLoad($this->getTimeoutMsec());
1313
1314 //Find Membership for organization
071a6d2e 1315 $this->openCiviPage("member/search", "reset=1");
6a488035 1316 $this->type("sort_name", $orgName1);
225a8648
CW
1317 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='memberSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
1318 $this->clickLink("xpath=//div[@id='memberSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_MembershipView_cancel-bottom");
6a488035
TO
1319
1320 //verify contrb created
1321 $expected = array(
1322 1 => $orgName1,
1323 2 => $title1,
1324 3 => 'New',
1325 );
1326 foreach ($expected as $value => $label) {
1327 $this->verifyText("xpath=//form[@id='MembershipView']/div[2]/div/table/tbody/tr[$value]/td[2]", preg_quote($label));
1328 }
1329
1330 // find membership for contact in relationship
071a6d2e 1331 $this->openCiviPage("contact/view", "reset=1&force=1&cid={$cid}");
6a488035
TO
1332 $this->click("css=li#tab_member a");
1333 $this->waitForElementPresent("xpath=//div[@id='memberships']/div/table//tbody//tr/td[1][text()='{$title1}']");
1334 $this->click("xpath=//div[@id='memberships']/div/table//tbody//tr/td[1][text()='{$title1}']/../td[7]/span/a[text()='View']");
1335 $this->waitForPageToLoad($this->getTimeoutMsec());
1336
1337 //verify contrb created
1338 $expected = array(
1339 3 => $title1,
1340 4 => 'New',
1341 );
1342 foreach ($expected as $value => $label) {
1343 $this->verifyText("xpath=//form[@id='MembershipView']/div[2]/div/table/tbody/tr[$value]/td[2]", preg_quote($label));
1344 }
1345
071a6d2e 1346 $this->openCiviPage("admin/uf/group", "reset=1");
6a488035
TO
1347 $this->click("link=Reserved Profiles");
1348 $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']");
1349 $this->waitForPageToLoad($this->getTimeoutMsec());
1350
1351 $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']");
1352 $this->waitForElementPresent('_qf_Field_next-bottom');
1353
1354 $this->click('_qf_Field_next-bottom');
1355 $this->waitForPageToLoad($this->getTimeoutMsec());
1356 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'),
1357 "Status message didn't show up after saving!"
1358 );
1359
1360 $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']");
1361 $this->waitForElementPresent('_qf_Field_next-bottom');
1362
1363 $this->click('_qf_Field_next-bottom');
1364 $this->waitForPageToLoad($this->getTimeoutMsec());
1365 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'),
1366 "Status message didn't show up after saving!"
1367 );
1368
071a6d2e 1369 $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
6a488035
TO
1370 $this->click("css=li#tab_rel a");
1371
1372 $this->waitForElementPresent("xpath=//div[@id='current-relationships']/div/table/tbody//tr/td[2]/a[text()='{$orgName1}']");
1373 $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']");
1374
1375 // Check confirmation alert.
6c6e6187 1376 $this->assertTrue((bool) preg_match("/^Are you sure you want to delete this relationship?/",
92915c55
TO
1377 $this->getConfirmation()
1378 ));
6a488035
TO
1379 $this->chooseOkOnNextConfirmation();
1380 $this->waitForPageToLoad($this->getTimeoutMsec());
1381 $this->assertTrue($this->isTextPresent('Selected relationship has been deleted successfully.'),
1382 "Status message didn't show up after saving!"
1383 );
1384 }
1385
00be9182 1386 public function testOnBehalfOfOrganizationWithImage() {
071a6d2e 1387 $this->webtestLogin();
42daf119 1388
071a6d2e 1389 $this->openCiviPage("profile/edit", "reset=1&gid=4");
42daf119
CW
1390 $firstName = 'John_x_' . substr(sha1(rand()), 0, 7);
1391 $lastName = 'Anderson_c_' . substr(sha1(rand()), 0, 7);
1392
6a488035
TO
1393 $this->waitForPageToLoad($this->getTimeoutMsec());
1394 $this->waitForElementPresent("_qf_Edit_next");
1395 $this->type("first_name", $firstName);
1396 $this->type("last_name", $lastName);
225a8648 1397 $this->clickLink("_qf_Edit_next", "profilewrap4");
42daf119 1398
a471a3b6 1399 $cid = $this->urlArg('id');
6a488035 1400 $this->assertType('numeric', $cid);
42daf119 1401 // Is status message correct?
6a488035
TO
1402 $this->assertTextPresent("Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!");
1403
071a6d2e 1404 $this->openCiviPage("admin/uf/group", "reset=1");
6a488035 1405 $this->click("link=Reserved Profiles");
42daf119 1406
6a488035
TO
1407 $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']");
1408 $this->waitForPageToLoad($this->getTimeoutMsec());
42daf119 1409
6a488035
TO
1410 $this->click("link=Add Field");
1411 $this->waitForElementPresent('_qf_Field_next-bottom');
1412
1413 $this->select('field_name[0]', 'value=Contact');
1414 $this->select('field_name[1]', 'label=Image Url');
1415 $this->click('field_name[1]');
1416 $this->click('_qf_Field_next-bottom');
1417 $this->waitForPageToLoad($this->getTimeoutMsec());
1418
c3ad8633
CW
1419 // Use default payment processor
1420 $processorName = 'Test Processor';
6a488035
TO
1421 $processorType = 'Dummy';
1422 $pageTitle = substr(sha1(rand()), 0, 7);
1423 $rand = 100;
1424 $hash = substr(sha1(rand()), 0, 7);
1425 $amountSection = TRUE;
1426 $payLater = TRUE;
1427 $onBehalf = TRUE;
1428 $pledges = FALSE;
1429 $recurring = FALSE;
1430 $memberships = FALSE;
1431 $memPriceSetId = NULL;
1432 $friend = TRUE;
1433 $profilePreId = NULL;
1434 $profilePostId = NULL;
1435 $premiums = FALSE;
1436 $widget = FALSE;
1437 $pcp = FALSE;
1438 $honoreeSection = FALSE;
1439 $isAddPaymentProcessor = TRUE;
1440 $isPcpApprovalNeeded = FALSE;
1441 $isSeparatePayment = FALSE;
1442
1443 // create a new online contribution page
1444 // create contribution page with randomized title and default params
1445 $pageId = $this->webtestAddContributionPage($hash,
1446 $rand,
1447 $pageTitle,
1448 array($processorName => $processorType),
1449 $amountSection,
1450 $payLater,
1451 $onBehalf,
1452 $pledges,
1453 $recurring,
1454 $memberships,
1455 $memPriceSetId,
1456 $friend,
1457 $profilePreId,
1458 $profilePostId,
1459 $premiums,
1460 $widget,
1461 $pcp,
1462 $isAddPaymentProcessor,
1463 $isPcpApprovalNeeded,
1464 $isSeparatePayment,
1465 $honoreeSection
1466 );
1467
42daf119
CW
1468 $this->_testOrganizationWithImageUpload($pageId, $cid, $pageTitle);
1469
071a6d2e 1470 $this->openCiviPage("admin/uf/group", "reset=1");
6a488035 1471 $this->click("link=Reserved Profiles");
42daf119 1472
6a488035
TO
1473 $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']");
1474 $this->waitForPageToLoad($this->getTimeoutMsec());
1475 $this->click("xpath=//table[@id='option11']/tbody//tr/td/span[text()='Image Url']/../following-sibling::td[8]/span[2]/ul/li[2]/a");
1476 $this->waitForPageToLoad($this->getTimeoutMsec());
1477 $this->click('_qf_Field_next-bottom');
1478 $this->waitForPageToLoad($this->getTimeoutMsec());
6c5f7368 1479 $this->waitForText('crm-notification-container', "Selected Profile Field has been deleted.");
6a488035
TO
1480 }
1481
4cbe18b8 1482 /**
100fef9d
CW
1483 * @param int $pageId
1484 * @param int $cid
4cbe18b8
EM
1485 * @param $pageTitle
1486 */
00be9182 1487 public function _testOrganizationWithImageUpload($pageId, $cid, $pageTitle) {
6a488035 1488 //Open Live Contribution Page
b45c587e 1489 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", '_qf_Main_upload-bottom');
6a488035
TO
1490
1491 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
42daf119
CW
1492 $lastName = 'An' . substr(sha1(rand()), 0, 7);
1493 $orgName = 'org_11_' . substr(sha1(rand()), 0, 7);
6a488035
TO
1494 $this->type("email-5", $firstName . "@example.com");
1495
1496 // onbehalforganization info
1497 $this->type("onbehalf_organization_name", $orgName);
1498 $this->type("onbehalf_phone-3-1", 9999999999);
1499 $this->type("onbehalf_email-3", "{$orgName}@example.com");
1500 $this->type("onbehalf_street_address-3", "Test Street Address");
1501 $this->type("onbehalf_city-3", "Test City");
1502 $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
1503 $this->click("onbehalf_country-3");
1504 $this->select("onbehalf_country-3", "label=United States");
1505 $this->click("onbehalf_state_province-3");
1506 $this->select("onbehalf_state_province-3", "label=Alabama");
1507
1508 // check for upload field.
1509 $this->waitForElementPresent("onbehalf_image_URL");
1510
1511 //header("Content-Type: image/png");
1512 $im = imagecreate(110, 20)
92915c55 1513 or die("Cannot Initialize new GD image stream");
6a488035
TO
1514 $background_color = imagecolorallocate($im, 0, 0, 0);
1515 $text_color = imagecolorallocate($im, 233, 14, 91);
6c6e6187
TO
1516 imagestring($im, 1, 5, 5, "On Behalf-Org Logo", $text_color);
1517 imagepng($im, "/tmp/file.png");
42daf119 1518
6a488035
TO
1519 $imagePath = "/tmp/file.png";
1520 $this->webtestAttachFile('onbehalf_image_URL', $imagePath);
1521 unlink($imagePath);
1522
1523 // Credit Card Info
1524 $this->select("credit_card_type", "value=Visa");
1525 $this->type("credit_card_number", "4111111111111111");
1526 $this->type("cvv2", "000");
1527 $this->select("credit_card_exp_date[M]", "value=1");
1528 $this->select("credit_card_exp_date[Y]", "value=2020");
1529
1530 //Billing Info
1531 $this->type("billing_first_name", $firstName . 'billing');
1532 $this->type("billing_last_name", $lastName . 'billing');
1533 $this->type("billing_street_address-5", "0121 Mount Highschool.");
1534 $this->type(" billing_city-5", "Shangai");
1535 $this->select("billing_country_id-5", "value=1228");
1536 $this->select("billing_state_province_id-5", "value=1004");
1537 $this->type("billing_postal_code-5", "94129");
225a8648 1538 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
6a488035
TO
1539
1540 $this->click("_qf_Confirm_next-bottom");
1541 $this->waitForPageToLoad($this->getTimeoutMsec());
1542
1543 // Type search name in autocomplete.
1544 $this->click('sort_name_navigation');
1545 $this->type('css=input#sort_name_navigation', $orgName);
1546 $this->typeKeys('css=input#sort_name_navigation', $orgName);
1547
1548 // Wait for result list.
1549 $this->waitForElementPresent("css=div.ac_results-inner li");
42daf119 1550
6a488035
TO
1551 // Visit organization page.
1552 $this->click("css=div.ac_results-inner li");
1553 $this->waitForPageToLoad($this->getTimeoutMsec());
42daf119 1554
6a488035
TO
1555 //check whether the image is present
1556 $this->assertTrue($this->isElementPresent("xpath=//div[@id='crm-contact-thumbnail']/div/a/img"));
1557 }
1558}