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