3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
27 require_once 'CiviTest/CiviSeleniumTestCase.php';
30 * Class WebTest_Contribute_OnBehalfOfOrganization
32 class WebTest_Contribute_OnBehalfOfOrganization
extends CiviSeleniumTestCase
{
33 protected $pageno = '';
34 protected function setUp() {
38 function testOnBehalfOfOrganization() {
39 $this->webtestLogin();
41 // create new individual
42 $firstName = 'John_' . substr(sha1(rand()), 0, 7);
43 $lastName = 'Anderson_' . substr(sha1(rand()), 0, 7);
44 $email = "{$firstName}.{$lastName}@example.com";
45 $contactParams = array(
46 'first_name' => $firstName,
47 'last_name' => $lastName,
50 $streetAddress = "100 Main Street";
52 //adding contact for membership sign up
53 $this->webtestAddContact($firstName, $lastName, $email);
54 $cid = $this->urlArg('cid');
56 // We need a payment processor
57 $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7);
58 $processorType = 'Dummy';
59 $pageTitle = substr(sha1(rand()), 0, 7);
61 $hash = substr(sha1(rand()), 0, 7);
62 $amountSection = TRUE;
64 $onBehalf = 'optional';
68 $memPriceSetId = NULL;
71 $profilePostId = NULL;
75 $honoreeSection = FALSE;
76 $isAddPaymentProcessor = TRUE;
77 $isPcpApprovalNeeded = FALSE;
78 $isSeparatePayment = FALSE;
80 // create a new online contribution page
81 // create contribution page with randomized title and default params
82 $pageId = $this->webtestAddContributionPage($hash,
85 array($processorName => $processorType),
99 $isAddPaymentProcessor,
100 $isPcpApprovalNeeded,
106 $this->webtestLogout();
107 //$this->_testAnomoyousOganization($pageId, $cid, $pageTitle);
108 $this->webtestLogout();
109 $this->_testUserWithOneRelationship($pageId, $cid, $pageTitle);
110 $this->webtestLogout();
111 $this->_testUserWithMoreThanOneRelationship($pageId, $cid, $pageTitle);
114 function testOnBehalfOfOrganizationWithMembershipData() {
115 $this->webtestLogin();
117 // create new individual
118 $this->openCiviPage("profile/edit", "reset=1&gid=4");
119 $firstName = 'John_x_' . substr(sha1(rand()), 0, 7);
120 $lastName = 'Anderson_c_' . substr(sha1(rand()), 0, 7);
122 $this->waitForPageToLoad($this->getTimeoutMsec());
123 $this->waitForElementPresent("_qf_Edit_next");
124 $this->type("first_name", $firstName);
125 $this->type("last_name", $lastName);
126 $this->clickLink("_qf_Edit_next", "profilewrap4");
128 // Is status message correct?
129 $this->assertTextPresent("Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!");
133 $this->openCiviPage("admin/custom/group", "action=add&reset=1");
135 //fill custom group title
136 $customGroupTitle = 'custom_' . substr(sha1(rand()), 0, 7);
137 $this->click("title");
138 $this->type("title", $customGroupTitle);
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");
147 //Is custom group created?
148 $this->assertTrue($this->isTextPresent("Your custom field set '{$customGroupTitle}' has been added. You can add custom fields now."));
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");
168 //enter options per line
169 $this->type("options_per_line", "2");
171 //enter pre help message
172 $this->type("help_pre", "this is field pre help");
174 //enter post help message
175 $this->type("help_post", "this field post help");
178 $this->click("is_searchable");
181 $this->click("_qf_Field_next");
182 $this->waitForPageToLoad($this->getTimeoutMsec());
184 //Is custom field created?
185 $this->assertTrue($this->isTextPresent("Your custom field '$checkboxFieldLabel' has been saved."));
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']");
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");
210 //select options per line
211 $this->type("options_per_line", "3");
214 $this->type("help_pre", "this is field pre help");
216 //enter post help msg
217 $this->type("help_post", "this is field post help");
220 $this->click("is_searchable");
223 $this->click("_qf_Field_next");
224 $this->waitForPageToLoad($this->getTimeoutMsec());
226 //Is custom field created
227 $this->assertTrue($this->isTextPresent("Your custom field '$radioFieldLabel' has been saved."));
229 //add the above custom data to the On Behalf of Profile
230 $this->openCiviPage("admin/uf/group", "reset=1");
231 $this->click("link=Reserved Profiles");
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());
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());
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'."));
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);
258 $this->waitForPageToLoad($this->getTimeoutMsec());
259 $this->click("css=li#tab_member a");
261 $this->waitForElementPresent('link=Add Membership');
262 $this->click('link=Add Membership');
264 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
266 // fill in Membership Organization and Type
267 $this->select('membership_type_id[0]', "value=1");
268 $this->select('membership_type_id[1]', "value=1");
271 $sourceText = 'On behalf Membership Webtest';
272 $this->type('source', $sourceText);
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');
278 // select newly created processor
279 $xpath = "xpath=//label[text() = '{$checkboxOptionLabel1}']/preceding-sibling::input[1]";
280 $this->assertTrue($this->isTextPresent($checkboxOptionLabel1));
281 $this->check($xpath);
283 $xpath = "xpath=//label[text() = '{$checkboxOptionLabel3}']/preceding-sibling::input[1]";
284 $this->assertTrue($this->isTextPresent($checkboxOptionLabel3));
285 $this->check($xpath);
287 $xpath = "xpath=//label[text() = '{$radioOptionLabel1}']/preceding-sibling::input[1]";
288 $this->assertTrue($this->isTextPresent($radioOptionLabel1));
289 $this->check($xpath);
291 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
292 $this->click('_qf_Membership_upload-bottom');
294 $this->waitForPageToLoad($this->getTimeoutMsec());
295 $this->click("css=li#tab_rel a");
297 $this->waitForElementPresent('link=Add Relationship');
298 $this->click('link=Add Relationship');
300 $this->waitForElementPresent('relationship_type_id');
301 $this->click("relationship_type_id");
302 $this->select("relationship_type_id", "label=Employer of");
303 // search organization
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'));
311 $this->click("is_permission_a_b");
312 $this->click("is_permission_b_a");
315 $this->click("details-save");
316 $this->waitForPageToLoad($this->getTimeoutMsec());
318 // We need a payment processor
319 $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7);
320 $processorType = 'Dummy';
321 $pageTitle = substr(sha1(rand()), 0, 7);
323 $hash = substr(sha1(rand()), 0, 7);
324 $amountSection = TRUE;
330 $memPriceSetId = NULL;
332 $profilePreId = NULL;
333 $profilePostId = NULL;
337 $honoreeSection = FALSE;
338 $isAddPaymentProcessor = TRUE;
339 $isPcpApprovalNeeded = FALSE;
340 $isSeparatePayment = FALSE;
342 // create a new online contribution page
343 // create contribution page with randomized title and default params
344 $pageId = $this->webtestAddContributionPage($hash,
347 array($processorName => $processorType),
361 $isAddPaymentProcessor,
362 $isPcpApprovalNeeded,
368 //scenario 1 : add membership data in pre / post profile and check for formRule
370 $this->openCiviPage("admin/uf/group", "reset=1");
371 $this->click('link=Add Profile');
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);
377 $this->click('_qf_Group_next-bottom');
379 $this->waitForElementPresent('_qf_Field_cancel-bottom');
380 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now."));
382 $this->select('field_name[0]', "value=Membership");
383 $this->select('field_name[1]', "label={$checkboxFieldLabel} :: {$customGroupTitle}");
384 $this->click('field_name[1]');
385 $this->click('label');
387 // Clicking save and new
388 $this->click('_qf_Field_next_new-bottom');
389 $this->waitForPageToLoad($this->getTimeoutMsec());
390 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$checkboxFieldLabel}' has been saved to '{$profileTitle}'."));
392 $this->openCiviPage("admin/contribute/custom", "reset=1&action=update&id={$pageId}", '_qf_Custom_next-bottom');
393 $this->select('custom_pre_id', "label={$profileTitle}");
394 $this->click('_qf_Custom_next-bottom');
395 $this->waitForPageToLoad($this->getTimeoutMsec());
396 // Because it tends to cause problems, all uses of sleep() must be justified in comments
397 // Sleep should never be used for wait for anything to load from the server
398 // Justification for this instance: FIXME
400 $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");
402 $this->select('custom_pre_id', "- select -");
403 $this->select('custom_post_id', "label={$profileTitle}");
404 $this->click('_qf_Custom_next-bottom');
405 $this->waitForPageToLoad($this->getTimeoutMsec());
406 // Because it tends to cause problems, all uses of sleep() must be justified in comments
407 // Sleep should never be used for wait for anything to load from the server
408 // Justification for this instance: FIXME
410 $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");
412 //scenario 2 : disable 'on behalf of', add membership data in pre / post profile
413 //then try to add 'on behalf of' and check for formRule
414 //disable 'on behalf of'
415 $this->openCiviPage("admin/contribute/settings", "reset=1&action=update&id={$pageId}", '_qf_Settings_next-bottom');
416 $this->uncheck('is_organization');
417 $this->click('_qf_Settings_next-bottom');
418 $this->waitForPageToLoad($this->getTimeoutMsec());
420 //set a membership field profile for this contribution page
421 $this->click('css=li#tab_custom a');
422 $this->waitForElementPresent('_qf_Custom_next-bottom');
423 $this->select('custom_pre_id', "label={$profileTitle}");
424 $this->click('_qf_Custom_next-bottom');
425 $this->waitForPageToLoad($this->getTimeoutMsec());
427 //now visit the title settings page and configure the profile as on behalf of
428 $this->click('css=li#tab_settings a');
429 $this->waitForElementPresent('_qf_Settings_next-bottom');
430 $this->check('is_organization');
431 $this->click('_qf_Settings_next-bottom');
432 $this->waitForPageToLoad($this->getTimeoutMsec());
433 // Because it tends to cause problems, all uses of sleep() must be justified in comments
434 // Sleep should never be used for wait for anything to load from the server
435 // Justification for this instance: FIXME
437 $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");
440 $this->webtestLogout();
443 function testOnBehalfOfOrganizationWithOrgData() {
444 $this->webtestLogin();
446 $this->openCiviPage("profile/edit", "reset=1&gid=4");
447 $firstName = 'John_x_' . substr(sha1(rand()), 0, 7);
448 $lastName = 'Anderson_c_' . substr(sha1(rand()), 0, 7);
450 $this->waitForPageToLoad($this->getTimeoutMsec());
451 $this->waitForElementPresent("_qf_Edit_next");
452 $this->type("first_name", $firstName);
453 $this->type("last_name", $lastName);
454 $this->clickLink("_qf_Edit_next", "profilewrap4");
456 $cid = $this->urlArg('id');
457 // Is status message correct?
458 $this->assertTextPresent("Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!");
460 //add org fields to profile
461 $this->openCiviPage("admin/uf/group", "reset=1");
462 $this->click("link=Reserved Profiles");
464 $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']");
465 $this->waitForPageToLoad($this->getTimeoutMsec());
467 $this->click("link=Add Field");
468 $this->waitForElementPresent('_qf_Field_next-bottom');
470 $this->select('field_name[0]', 'value=Organization');
471 $this->select('field_name[1]', 'label=Legal Identifier');
472 $this->click('field_name[1]');
473 $this->click('_qf_Field_next_new-bottom');
474 $this->waitForPageToLoad($this->getTimeoutMsec());
476 $this->select('field_name[0]', 'value=Organization');
477 $this->select('field_name[1]', 'label=Legal Name');
478 $this->click('field_name[1]');
479 $this->click('_qf_Field_next-bottom');
480 $this->waitForPageToLoad($this->getTimeoutMsec());
482 //create organisation
483 $orgName = "Org WebAccess ". substr(sha1(rand()), 0, 7);
484 $orgEmail = "org". substr(sha1(rand()), 0, 7) . "@web.com";
485 $this->webtestAddOrganization($orgName, $orgEmail);
487 $this->waitForPageToLoad($this->getTimeoutMsec());
488 $this->click("css=li#tab_rel a");
490 $this->waitForElementPresent('link=Add Relationship');
491 $this->click('link=Add Relationship');
493 $this->waitForElementPresent('relationship_type_id');
494 $this->click("relationship_type_id");
495 $this->select("relationship_type_id", "label=Employer of");
496 // search organization
497 $this->type('contact_1', $firstName);
498 $this->click("contact_1");
499 $this->waitForElementPresent("css=div.ac_results-inner li");
500 $this->click("css=div.ac_results-inner li");
501 $this->assertContains($firstName, $this->getValue('contact_1'), "autocomplete expected $firstName but didn’t find it in " . $this->getValue('contact_1'));
504 $this->click("is_permission_a_b");
505 $this->click("is_permission_b_a");
508 $this->waitForElementPresent("details-save");
509 $this->click("details-save");
510 $this->waitForElementPresent("Relationships");
512 $pageTitle = substr(sha1(rand()), 0, 7);
514 $hash = substr(sha1(rand()), 0, 7);
515 $amountSection = TRUE;
521 $memPriceSetId = NULL;
523 $profilePreId = NULL;
524 $profilePostId = NULL;
528 $honoreeSection = FALSE;
529 $isAddPaymentProcessor = FALSE;
530 $isPcpApprovalNeeded = FALSE;
531 $isSeparatePayment = FALSE;
533 // create a new online contribution page
534 // create contribution page with randomized title and default params
535 $pageId = $this->webtestAddContributionPage($hash,
552 $isAddPaymentProcessor,
553 $isPcpApprovalNeeded,
558 $this->_testOrganization($pageId, $cid, $pageTitle);
561 function testWithContactSubtypeDupe() {
562 $this->webtestLogin();
564 //create organisation
565 $orgName = "Org WebAccess ". substr(sha1(rand()), 0, 7);
566 $orgEmail = "org". substr(sha1(rand()), 0, 7) . "@web.com";
567 $contactSubType = 'Sponsor';
568 $this->webtestAddOrganization($orgName, $orgEmail, $contactSubType);
570 $this->waitForPageToLoad($this->getTimeoutMsec());
571 $cid = $this->urlArg('cid');
573 $pageTitle = substr(sha1(rand()), 0, 7);
575 $hash = substr(sha1(rand()), 0, 7);
576 $amountSection = TRUE;
581 $memberships = FALSE;
582 $memPriceSetId = NULL;
584 $profilePreId = NULL;
585 $profilePostId = NULL;
589 $honoreeSection = FALSE;
590 $isAddPaymentProcessor = FALSE;
591 $isPcpApprovalNeeded = FALSE;
592 $isSeparatePayment = FALSE;
594 // create a new online contribution page
595 // create contribution page with randomized title and default params
596 $pageId = $this->webtestAddContributionPage($hash,
613 $isAddPaymentProcessor,
614 $isPcpApprovalNeeded,
619 //Open Live Contribution Page
620 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom");
621 $this->waitForElementPresent("onbehalf_state_province-3");
623 $this->type("onbehalf_organization_name", $orgName);
624 $this->waitForElementPresent("onbehalf_phone-3-1");
625 $this->type("onbehalf_phone-3-1", 9999999999);
626 $this->waitForElementPresent("onbehalf_email-3");
627 $this->type("onbehalf_email-3", "org@example.com");
628 $this->type("onbehalf_street_address-3", "Test Street Address");
629 $this->type("onbehalf_city-3", "Test City");
630 $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
631 $this->click("onbehalf_country-3");
632 $this->select("onbehalf_country-3", "label=United States");
633 $this->click("onbehalf_state_province-3");
634 $this->select("onbehalf_state_province-3", "label=Alabama");
636 $this->waitForElementPresent("_qf_Main_upload-bottom");
637 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
639 $this->click("_qf_Confirm_next-bottom");
640 $this->waitForPageToLoad($this->getTimeoutMsec());
642 $this->openCiviPage("contact/view", "reset=1&cid=$cid", "xpath=//div[@class='crm-content crm-contact_type_label']");
644 $this->verifyText("xpath=//div[@class='crm-content crm-contact_type_label']", $contactSubType);
652 function _testOrganization($pageId, $cid, $pageTitle) {
653 //Open Live Contribution Page
654 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom");
656 $this->waitForElementPresent("onbehalf_state_province-3");
658 $this->waitForElementPresent("onbehalf_phone-3-1");
659 $this->type("onbehalf_phone-3-1", 9999999999);
660 $this->waitForElementPresent("onbehalf_email-3");
661 $this->type("onbehalf_email-3", "org@example.com");
662 $this->type("onbehalf_street_address-3", "Test Street Address");
663 $this->type("onbehalf_city-3", "Test City");
664 $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
665 $this->click("onbehalf_country-3");
666 $this->select("onbehalf_country-3", "label=United States");
667 $this->click("onbehalf_state_province-3");
668 $this->select("onbehalf_state_province-3", "label=Alabama");
670 $this->waitForElementPresent("_qf_Main_upload-bottom");
671 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
673 $this->click("_qf_Confirm_next-bottom");
674 $this->waitForPageToLoad($this->getTimeoutMsec());
683 function _testAnomoyousOganization($pageId, $cid, $pageTitle) {
684 //Open Live Contribution Page
685 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom");
687 $this->click('CIVICRM_QFID_0_8');
688 $this->type('css=div.other_amount-section input', 60);
690 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
691 $lastName = 'An' . substr(sha1(rand()), 0, 7);
692 $orgName = 'org_11_' . substr(sha1(rand()), 0, 7);
693 $this->type("email-5", $firstName . "@example.com");
695 // enable onbehalforganization block
696 $this->click("is_for_organization");
697 $this->waitForElementPresent("onbehalf_state_province-3");
699 // onbehalforganization info
700 $this->type("onbehalf_organization_name", $orgName);
701 $this->type("onbehalf_phone-3-1", 9999999999);
702 $this->type("onbehalf_email-3", "{$orgName}@example.com");
703 $this->type("onbehalf_street_address-3", "Test Street Address");
704 $this->type("onbehalf_city-3", "Test City");
705 $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
706 $this->click("onbehalf_country-3");
707 $this->select("onbehalf_country-3", "label=United States");
708 $this->click("onbehalf_state_province-3");
709 $this->select("onbehalf_state_province-3", "label=Alabama");
712 $this->select("credit_card_type", "value=Visa");
713 $this->type("credit_card_number", "4111111111111111");
714 $this->type("cvv2", "000");
715 $this->select("credit_card_exp_date[M]", "value=1");
716 $this->select("credit_card_exp_date[Y]", "value=2020");
719 $this->type("billing_first_name", $firstName . 'billing');
720 $this->type("billing_last_name", $lastName . 'billing');
721 $this->type("billing_street_address-5", "0121 Mount Highschool.");
722 $this->type(" billing_city-5", "Shangai");
723 $this->select("billing_country_id-5", "value=1228");
724 $this->select("billing_state_province_id-5", "value=1004");
725 $this->type("billing_postal_code-5", "94129");
726 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
728 $this->click("_qf_Confirm_next-bottom");
729 $this->waitForPageToLoad($this->getTimeoutMsec());
731 //login to check contribution
733 // Log in using webtestLogin() method
734 $this->webtestLogin();
737 $this->openCiviPage("contribute/search", "reset=1");
738 $this->type("sort_name", $orgName);
739 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
740 $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom");
742 // verify contrb created
748 foreach ($expected as $value => $label) {
749 $this->verifyText("xpath=id( 'ContributionView' )/div[2]/table[1]/tbody/tr[$value]/td[2]", preg_quote($label));
758 function _testUserWithOneRelationship($pageId, $cid, $pageTitle) {
759 $this->webtestLogin('admin');
762 $groupName = $this->WebtestAddGroup();
763 $this->openCiviPage("group", "reset=1", "_qf_Search_refresh");
764 $groupId = $this->getText("xpath=//table[@id='crm-group-selector']/tbody//tr/td[text()='{$groupName}']/../td[2]");
766 $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
768 $this->click('link=Edit');
769 $this->waitForElementPresent('_qf_Contact_cancel-bottom');
770 $this->click('addressBlock');
771 $this->waitForElementPresent('link=Another Address');
774 $this->select('address_1_location_type_id', 'label=Billing');
775 $this->type('address_1_street_address', '0121 Mount Highschool.');
776 $this->type('address_1_city', "Shangai");
777 $this->type('address_1_postal_code', "94129");
778 $this->select('address_1_country_id', "value=1228");
779 $this->select('address_1_state_province_id', "value=1004");
780 $this->click('_qf_Contact_upload_view-bottom');
781 $this->waitForPageToLoad($this->getTimeoutMsec());
783 // add contact to group
785 $this->click("css=li#tab_group a");
786 $this->waitForElementPresent("group_id");
789 $this->select("group_id", "label={$groupName}");
790 $this->click("_qf_GroupContact_next");
791 $this->waitForPageToLoad($this->getTimeoutMsec());
793 $this->openCiviPage("admin/custom/group", "action=add&reset=1", "_qf_Group_next-bottom");
795 // fill in a unique title for the custom group
796 $groupTitle = "Custom Group" . substr(sha1(rand()), 0, 7);
797 $this->type("title", $groupTitle);
799 // select the group this custom data set extends
800 $this->select("extends[0]", "value=Contribution");
801 $this->waitForElementPresent("extends[1]");
803 // save the custom group
804 $this->click("_qf_Group_next-bottom");
805 $this->waitForElementPresent("_qf_Field_next_new-bottom");
806 $this->assertTrue($this->isTextPresent("Your custom field set '$groupTitle' has been added. You can add custom fields now."));
808 // add a custom field to the custom group
809 $fieldTitle = "Custom Field " . substr(sha1(rand()), 0, 7);
810 $this->type("label", $fieldTitle);
812 $this->select("data_type[1]", "value=Text");
813 $this->click('_qf_Field_next-bottom');
815 $this->waitForPageToLoad($this->getTimeoutMsec());
816 $this->assertTrue($this->isTextPresent("Your custom field '$fieldTitle' has been saved."));
817 $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"));
819 // Enable CiviCampaign module if necessary
820 $this->enableComponents("CiviCampaign");
822 // add the required permission
823 $permission = array('edit-2-administer-civicampaign');
824 $this->changePermissions($permission);
826 // Log in as normal user
827 $this->webtestLogin();
829 $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom");
831 $title = 'Campaign ' . substr(sha1(rand()), 0, 7);
832 $this->type("title", $title);
834 // select the campaign type
835 $this->select("campaign_type_id", "value=2");
837 // fill in the description
838 $this->type("description", "This is a test campaign");
840 // include groups for the campaign
841 $this->addSelection("includeGroups-f", "label={$groupName}");
842 $this->click("//option[@value={$groupId}]");
845 // fill the end date for campaign
846 $this->webtestFillDate("end_date", "+1 year");
848 // select campaign status
849 $this->select("status_id", "value=2");
852 $this->click("_qf_Campaign_upload-bottom");
853 $this->waitForElementPresent("xpath=//div[@id='campaigns_wrapper']//table[@id='campaigns']/tbody//tr/td[3][text()='{$title}']");
854 $this->assertTrue($this->isTextPresent("Campaign {$title} has been saved."), "Status message didn't show up after saving!");
856 $this->openCiviPage("admin/uf/group", "reset=1");
857 $this->click("link=Reserved Profiles");
859 $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']");
860 $this->waitForPageToLoad($this->getTimeoutMsec());
862 $this->click("link=Add Field");
863 $this->waitForElementPresent('_qf_Field_next-bottom');
864 $this->select('field_name[0]', 'value=Contribution');
865 $this->select('field_name[1]', 'label=Campaign');
866 $this->click('field_name[1]');
867 $this->click('_qf_Field_next_new-bottom');
868 $this->waitForPageToLoad($this->getTimeoutMsec());
870 $this->select('field_name[0]', 'value=Contribution');
871 $this->select('field_name[1]', "label=$fieldTitle :: $groupTitle");
872 $this->click('field_name[1]');
873 $this->click('_qf_Field_next-bottom');
874 $this->waitForPageToLoad($this->getTimeoutMsec());
875 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$fieldTitle}' has been saved to 'On Behalf Of Organization'."));
877 // Open Page to create Organization
878 $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom");
879 $orgName1 = 'org1_' . substr(sha1(rand()), 0, 7);
881 // Type Organization name
882 $this->type("organization_name", $orgName1);
884 // Type Organizatio email for main
885 $this->type("email_1_email", "{$orgName1}@example.com");
886 $this->select("email_1_location_type_id", "value=3");
888 // type phone no for main
889 $this->type("phone_1_phone", 9999999999);
890 $this->select("phone_1_location_type_id", "value=3");
893 $this->click("addressBlock");
894 $this->waitForElementPresent("address_1_street_address");
896 //fill in address 1 for main
897 $this->select("address_1_location_type_id", "value=3");
898 $this->type("address_1_street_address", "{$orgName1} street address");
899 $this->type("address_1_city", "{$orgName1} city");
900 $this->type("address_1_postal_code", substr(sha1(rand()), 0, 4));
901 $this->assertTrue($this->isTextPresent("- select - United States"));
902 $this->select("address_1_state_province_id", "value=1019");
903 $this->type("address_1_geo_code_1", "1234");
904 $this->type("address_1_geo_code_2", "5678");
906 // Save the Organization
907 $this->click("_qf_Contact_upload_view-bottom");
908 $this->waitForPageToLoad($this->getTimeoutMsec());
911 $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1");
913 // select relationship type
914 $this->click("relationship_type_id");
915 $this->select("relationship_type_id", "value=4_a_b");
917 // search organization
918 $this->type('contact_1', $orgName1);
919 $this->click("contact_1");
920 $this->waitForElementPresent("css=div.ac_results-inner li");
921 $this->click("css=div.ac_results-inner li");
922 $this->assertContains($orgName1, $this->getValue('contact_1'), "autocomplete expected $orgName1 but didn’t find it in " . $this->getValue('contact_1'));
924 $this->waitForElementPresent("add_current_employer");
925 $this->click("add_current_employer");
928 $this->click("is_permission_a_b");
929 $this->click("is_permission_b_a");
932 $this->waitForElementPresent("details-save");
933 $this->click("details-save");
935 //Open Live Contribution Page
936 $this->openCiviPage("contribute/transact", "reset=1&id={$pageId}&cid=$cid", "onbehalf_state_province-3");
937 $this->click('CIVICRM_QFID_amount_other_radio_4');
938 $this->type('amount_other', 60);
939 $this->click('onbehalf_contribution_campaign_id');
940 $this->select('onbehalf_contribution_campaign_id', "label={$title}");
941 $this->type("onbehalf_custom_{$fieldId}", 'Test Subject');
944 $this->select("credit_card_type", "value=Visa");
945 $this->type("credit_card_number", "4111111111111111");
946 $this->type("cvv2", "000");
947 $this->select("credit_card_exp_date[M]", "value=1");
948 $this->select("credit_card_exp_date[Y]", "value=2020");
951 $this->type("billing_street_address-5", "0121 Mount Highschool.");
952 $this->type(" billing_city-5", "Shangai");
953 $this->select("billing_country_id-5", "value=1228");
954 $this->select("billing_state_province_id-5", "value=1004");
955 $this->type("billing_postal_code-5", "94129");
957 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
958 $this->click("_qf_Confirm_next-bottom");
959 $this->waitForPageToLoad($this->getTimeoutMsec());
962 $this->openCiviPage("contribute/search", "reset=1");
963 $this->type("sort_name", $orgName1);
964 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
965 $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom");
967 // verify contrb created
974 foreach ($expected as $value => $label) {
975 $this->verifyText("xpath=id( 'ContributionView' )/div[2]/table[1]/tbody/tr[$value]/td[2]", preg_quote($label));
978 $this->openCiviPage("admin/uf/group", "reset=1");
979 $this->click("link=Reserved Profiles");
981 $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']");
982 $this->waitForPageToLoad($this->getTimeoutMsec());
984 $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']");
985 $this->waitForElementPresent('_qf_Field_next-bottom');
987 $this->click('_qf_Field_next-bottom');
988 $this->waitForPageToLoad($this->getTimeoutMsec());
989 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'), "Status message didn't show up after saving!");
991 $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']");
992 $this->waitForElementPresent('_qf_Field_next-bottom');
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!");
1004 function _testUserWithMoreThanOneRelationship($pageId, $cid, $pageTitle) {
1005 $this->webtestLogin('admin');
1006 $this->waitForPageToLoad($this->getTimeoutMsec());
1009 $groupName = $this->WebtestAddGroup();
1010 $this->openCiviPage("group", "reset=1", '_qf_Search_refresh');
1011 $this->click('_qf_Search_refresh');
1012 $this->waitForElementPresent("xpath=//div[@id='group']/div[3]/table/tbody//tr/td[text()='{$groupName}']/../td[2]");
1013 $groupId = $this->getText("xpath=//div[@id='group']/div[3]/table/tbody//tr/td[text()='{$groupName}']/../td[2]");
1015 $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
1017 $this->click('link=Edit');
1018 $this->waitForElementPresent('_qf_Contact_cancel-bottom');
1019 $this->click('addressBlock');
1020 $this->waitForElementPresent('link=Another Address');
1023 $this->select('address_1_location_type_id', 'label=Billing');
1024 $this->type('address_1_street_address', '0121 Mount Highschool.');
1025 $this->type('address_1_city', "Shangai");
1026 $this->type('address_1_postal_code', "94129");
1027 $this->select('address_1_country_id', "value=1228");
1028 $this->select('address_1_state_province_id', "value=1004");
1029 $this->click('_qf_Contact_upload_view-bottom');
1030 $this->waitForPageToLoad($this->getTimeoutMsec());
1032 // add contact to group
1034 $this->click("css=li#tab_group a");
1035 $this->waitForElementPresent("group_id");
1038 $this->select("group_id", "label=$groupName");
1039 $this->click("_qf_GroupContact_next");
1040 $this->waitForPageToLoad($this->getTimeoutMsec());
1042 $this->openCiviPage("admin/custom/group", "action=add&reset=1", "_qf_Group_next-bottom");
1044 // fill in a unique title for the c$groupIdustom group
1045 $groupTitle = "Members Custom Group" . substr(sha1(rand()), 0, 7);
1046 $this->type("title", $groupTitle);
1048 // select the group this custom data set extends
1049 $this->select("extends[0]", "value=Membership");
1050 $this->waitForElementPresent("extends[1]");
1052 // save the custom group
1053 $this->click("_qf_Group_next-bottom");
1055 $this->waitForElementPresent("_qf_Field_next_new-bottom");
1056 $this->assertTrue($this->isTextPresent("Your custom field set '$groupTitle' has been added. You can add custom fields now."));
1058 // add a custom field to the custom group
1059 $fieldTitle = "Member Custom Field " . substr(sha1(rand()), 0, 7);
1060 $this->type("label", $fieldTitle);
1062 $this->select("data_type[1]", "value=Text");
1063 $this->click('_qf_Field_next-bottom');
1065 $this->waitForPageToLoad($this->getTimeoutMsec());
1066 $this->assertTrue($this->isTextPresent("Your custom field '$fieldTitle' has been saved."));
1067 $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"));
1069 // Enable CiviCampaign module if necessary
1070 $this->enableComponents("CiviCampaign");
1072 // add the required permission
1073 $permission = array('edit-2-administer-civicampaign');
1074 $this->changePermissions($permission);
1076 // Log in as normal user
1077 $this->webtestLogin();
1079 $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom");
1081 $title = 'Campaign ' . substr(sha1(rand()), 0, 7);
1082 $this->type("title", $title);
1084 // select the campaign type
1085 $this->select("campaign_type_id", "value=2");
1087 // fill in the description
1088 $this->type("description", "This is a test campaign");
1090 // include groups for the campaign
1091 $this->addSelection("includeGroups-f", "label={$groupName}");
1092 $this->click("//option[@value={$groupId}]");
1093 $this->click("add");
1095 // fill the end date for campaign
1096 $this->webtestFillDate("end_date", "+1 year");
1098 // select campaign status
1099 $this->select("status_id", "value=2");
1102 $this->click("_qf_Campaign_upload-bottom");
1103 $this->waitForPageToLoad($this->getTimeoutMsec());
1105 $this->assertTrue($this->isTextPresent("Campaign {$title} has been saved."), "Status message didn't show up after saving!");
1107 $this->openCiviPage("admin/uf/group", "reset=1");
1108 $this->click("link=Reserved Profiles");
1109 $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']");
1110 $this->waitForPageToLoad($this->getTimeoutMsec());
1112 $this->click("link=Add Field");
1113 $this->waitForElementPresent('_qf_Field_next-bottom');
1114 $this->select('field_name[0]', 'value=Membership');
1115 $this->select('field_name[1]', 'label=Campaign');
1116 $this->click('field_name[1]');
1117 $this->clickLink('_qf_Field_next_new-bottom', '_qf_Field_cancel-bottom');
1119 $this->select('field_name[0]', 'value=Membership');
1120 $this->select('field_name[1]', "label=$fieldTitle :: $groupTitle");
1121 $this->click('field_name[1]');
1122 $this->click('_qf_Field_next-bottom');
1123 $this->waitForPageToLoad($this->getTimeoutMsec());
1124 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$fieldTitle}' has been saved to 'On Behalf Of Organization'."),
1125 "Status message didn't show up after saving!"
1128 // Open Page to create Organization 1
1129 $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom");
1130 $orgName1 = 'org1_' . substr(sha1(rand()), 0, 7);
1132 // Type Organization name
1133 $this->type("organization_name", $orgName1);
1135 // Type Organizatio email for main
1136 $this->type("email_1_email", "{$orgName1}@example.com");
1137 $this->select("email_1_location_type_id", "value=3");
1139 // type phone no for main
1140 $this->type("phone_1_phone", substr(sha1(rand()), 0, 4));
1141 $this->select("phone_1_location_type_id", "value=3");
1144 $this->click("addressBlock");
1145 $this->waitForElementPresent("address_1_street_address");
1147 //fill in address 1 for main
1148 $this->select("address_1_location_type_id", "value=3");
1149 $this->type("address_1_street_address", "{$orgName1} street address");
1150 $this->type("address_1_city", "{$orgName1} city");
1151 $this->type("address_1_postal_code", "9999999999");
1152 $this->assertTrue($this->isTextPresent("- select - United States"));
1153 $this->select("address_1_state_province_id", "value=1019");
1154 $this->type("address_1_geo_code_1", "1234");
1155 $this->type("address_1_geo_code_2", "5678");
1157 // Save the Organization
1158 $this->click("_qf_Contact_upload_view-bottom");
1159 $this->waitForPageToLoad($this->getTimeoutMsec());
1161 // create second orzanization
1162 $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom");
1163 $orgName2 = 'org2_' . substr(sha1(rand()), 0, 7);
1165 // Type Organization name
1166 $this->type("organization_name", $orgName2);
1168 // Type Organizatio email for main
1169 $this->type("email_1_email", "{$orgName2}@example.com");
1170 $this->select("email_1_location_type_id", "value=3");
1172 // type phone no for main
1173 $this->type("phone_1_phone", substr(sha1(rand()), 0, 4));
1174 $this->select("phone_1_location_type_id", "value=3");
1177 $this->click("addressBlock");
1178 $this->waitForElementPresent("address_1_street_address");
1180 //fill in address 1 for main
1181 $this->select("address_1_location_type_id", "value=3");
1182 $this->type("address_1_street_address", "{$orgName2} street address");
1183 $this->type("address_1_city", "{$orgName2} city");
1184 $this->type("address_1_postal_code", "7777777777");
1185 $this->assertTrue($this->isTextPresent("- select - United States"));
1186 $this->select("address_1_state_province_id", "value=1019");
1187 $this->type("address_1_geo_code_1", "1224");
1188 $this->type("address_1_geo_code_2", "5628");
1190 // Save the Organization
1191 $this->click("_qf_Contact_upload_view-bottom");
1192 $this->waitForPageToLoad($this->getTimeoutMsec());
1194 // create Membership type
1195 $title1 = "Membership Type" . substr(sha1(rand()), 0, 7);
1196 $this->openCiviPage("admin/member/membershipType", "reset=1&action=browse");
1198 $this->click("link=Add Membership Type");
1199 $this->waitForElementPresent('_qf_MembershipType_cancel-bottom');
1201 $this->type('name', $title1);
1202 $this->type('member_org', $orgName1);
1203 $this->click('_qf_MembershipType_refresh');
1204 $this->waitForElementPresent("xpath=//div[@id='membership_type_form']/fieldset/table[2]/tbody/tr[2]/td[2]");
1206 $this->type('minimum_fee', '50');
1208 $this->select( 'financial_type_id', 'value=2' );
1210 $this->type('duration_interval', 1);
1211 $this->select('duration_unit', "label=year");
1213 $this->select('period_type', "label=fixed");
1214 $this->waitForElementPresent('fixed_period_rollover_day[d]');
1216 $this->select('fixed_period_start_day[M]', 'value=4');
1217 $this->select('fixed_period_rollover_day[M]', 'value=1');
1219 $this->select('relationship_type_id', 'value=4_b_a');
1221 $this->click('_qf_MembershipType_upload-bottom');
1222 $this->waitForElementPresent('link=Add Membership Type');
1223 $this->assertTrue($this->isTextPresent("The membership type '$title1' has been saved."));
1224 $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"));
1227 $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1");
1229 // select relationship type
1230 $this->click("relationship_type_id");
1231 $this->select("relationship_type_id", "value=4_a_b");
1233 // search organization
1234 $this->type('contact_1', $orgName1);
1235 $this->click("contact_1");
1236 $this->waitForElementPresent("css=div.ac_results-inner li");
1237 $this->click("css=div.ac_results-inner li");
1238 $this->assertContains($orgName1, $this->getValue('contact_1'), "autocomplete expected $orgName1 but didn’t find it in " . $this->getValue('contact_1'));
1241 $this->click("is_permission_a_b");
1242 $this->click("is_permission_b_a");
1244 // save relationship
1245 $this->click("details-save");
1248 $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1");
1250 // select relationship type
1251 $this->click("relationship_type_id");
1252 $this->select("relationship_type_id", "value=4_a_b");
1254 // search organization
1255 $this->type('contact_1', $orgName2);
1256 $this->click("contact_1");
1257 $this->waitForElementPresent("css=div.ac_results-inner li");
1258 $this->click("css=div.ac_results-inner li");
1259 $this->assertContains($orgName2, $this->getValue('contact_1'), "autocomplete expected $orgName2 but didn’t find it in " . $this->getValue('contact_1'));
1262 $this->click("is_permission_a_b");
1263 $this->click("is_permission_b_a");
1265 // save relationship
1266 $this->click("details-save");
1268 // set membership type
1269 $this->openCiviPage("admin/contribute/membership", "reset=1&action=update&id=$pageId", "_qf_MembershipBlock_upload_done-bottom");
1270 $this->click("member_is_active");
1271 $this->click("membership_type[{$typeId}]");
1272 $this->click("xpath=//div[@id='memberFields']//table[@class='report']/tbody//tr/td[1]/label[text()='{$title1}']/../../td[2]/input");
1273 $this->click('_qf_MembershipBlock_upload_done-bottom');
1274 $this->waitForPageToLoad($this->getTimeoutMsec());
1276 //Open Live Membership Page
1277 $this->openCiviPage('contribute/transact', "reset=1&id=$pageId&cid=$cid", "_qf_Main_upload-bottom");
1278 $this->click('CIVICRM_QFID_amount_other_radio_4');
1279 $this->type('amount_other', 60);
1280 $this->click('onbehalf_organization_name');
1281 $this->type('onbehalf_organization_name', $orgName1);
1282 $this->typeKeys('onbehalf_organization_name', $orgName1);
1283 $this->click("onbehalf_organization_name");
1284 $this->waitForElementPresent("css=div.ac_results-inner li");
1285 $this->click("css=div.ac_results-inner li");
1286 // Because it tends to cause problems, all uses of sleep() must be justified in comments
1287 // Sleep should never be used for wait for anything to load from the server
1288 // Justification for this instance: FIXME
1290 $this->click('onbehalf_member_campaign_id');
1291 $this->select('onbehalf_member_campaign_id', "label={$title}");
1292 $this->type("onbehalf_custom_{$fieldId}", 'Test Subject');
1294 $this->assertContains($orgName1, $this->getValue('onbehalf_organization_name'), "autocomplete expected $orgName1 but didn’t find it in " . $this->getValue('onbehalf_organization_name'));
1297 $this->select("credit_card_type", "value=Visa");
1298 $this->type("credit_card_number", "4111111111111111");
1299 $this->type("cvv2", "000");
1300 $this->select("credit_card_exp_date[M]", "value=1");
1301 $this->select("credit_card_exp_date[Y]", "value=2020");
1303 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
1304 $this->click("_qf_Confirm_next-bottom");
1305 $this->waitForPageToLoad($this->getTimeoutMsec());
1307 //Find Membership for organization
1308 $this->openCiviPage("member/search", "reset=1");
1309 $this->type("sort_name", $orgName1);
1310 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='memberSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
1311 $this->clickLink("xpath=//div[@id='memberSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_MembershipView_cancel-bottom");
1313 //verify contrb created
1319 foreach ($expected as $value => $label) {
1320 $this->verifyText("xpath=//form[@id='MembershipView']/div[2]/div/table/tbody/tr[$value]/td[2]", preg_quote($label));
1323 // find membership for contact in relationship
1324 $this->openCiviPage("contact/view", "reset=1&force=1&cid={$cid}");
1325 $this->click("css=li#tab_member a");
1326 $this->waitForElementPresent("xpath=//div[@id='memberships']/div/table//tbody//tr/td[1][text()='{$title1}']");
1327 $this->click("xpath=//div[@id='memberships']/div/table//tbody//tr/td[1][text()='{$title1}']/../td[7]/span/a[text()='View']");
1328 $this->waitForPageToLoad($this->getTimeoutMsec());
1330 //verify contrb created
1335 foreach ($expected as $value => $label) {
1336 $this->verifyText("xpath=//form[@id='MembershipView']/div[2]/div/table/tbody/tr[$value]/td[2]", preg_quote($label));
1339 $this->openCiviPage("admin/uf/group", "reset=1");
1340 $this->click("link=Reserved Profiles");
1341 $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']");
1342 $this->waitForPageToLoad($this->getTimeoutMsec());
1344 $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']");
1345 $this->waitForElementPresent('_qf_Field_next-bottom');
1347 $this->click('_qf_Field_next-bottom');
1348 $this->waitForPageToLoad($this->getTimeoutMsec());
1349 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'),
1350 "Status message didn't show up after saving!"
1353 $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']");
1354 $this->waitForElementPresent('_qf_Field_next-bottom');
1356 $this->click('_qf_Field_next-bottom');
1357 $this->waitForPageToLoad($this->getTimeoutMsec());
1358 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'),
1359 "Status message didn't show up after saving!"
1362 $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
1363 $this->click("css=li#tab_rel a");
1365 $this->waitForElementPresent("xpath=//div[@id='current-relationships']/div/table/tbody//tr/td[2]/a[text()='{$orgName1}']");
1366 $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']");
1368 // Check confirmation alert.
1369 $this->assertTrue((bool)preg_match("/^Are you sure you want to delete this relationship?/",
1370 $this->getConfirmation()
1372 $this->chooseOkOnNextConfirmation();
1373 $this->waitForPageToLoad($this->getTimeoutMsec());
1374 $this->assertTrue($this->isTextPresent('Selected relationship has been deleted successfully.'),
1375 "Status message didn't show up after saving!"
1379 function testOnBehalfOfOrganizationWithImage() {
1380 $this->webtestLogin();
1382 $this->openCiviPage("profile/edit", "reset=1&gid=4");
1383 $firstName = 'John_x_' . substr(sha1(rand()), 0, 7);
1384 $lastName = 'Anderson_c_' . substr(sha1(rand()), 0, 7);
1386 $this->waitForPageToLoad($this->getTimeoutMsec());
1387 $this->waitForElementPresent("_qf_Edit_next");
1388 $this->type("first_name", $firstName);
1389 $this->type("last_name", $lastName);
1390 $this->clickLink("_qf_Edit_next", "profilewrap4");
1392 $cid = $this->urlArg('id');
1393 $this->assertType('numeric', $cid);
1394 // Is status message correct?
1395 $this->assertTextPresent("Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!");
1397 $this->openCiviPage("admin/uf/group", "reset=1");
1398 $this->click("link=Reserved Profiles");
1400 $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']");
1401 $this->waitForPageToLoad($this->getTimeoutMsec());
1403 $this->click("link=Add Field");
1404 $this->waitForElementPresent('_qf_Field_next-bottom');
1406 $this->select('field_name[0]', 'value=Contact');
1407 $this->select('field_name[1]', 'label=Image Url');
1408 $this->click('field_name[1]');
1409 $this->click('_qf_Field_next-bottom');
1410 $this->waitForPageToLoad($this->getTimeoutMsec());
1412 // We need a payment processor
1413 $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7);
1414 $processorType = 'Dummy';
1415 $pageTitle = substr(sha1(rand()), 0, 7);
1417 $hash = substr(sha1(rand()), 0, 7);
1418 $amountSection = TRUE;
1423 $memberships = FALSE;
1424 $memPriceSetId = NULL;
1426 $profilePreId = NULL;
1427 $profilePostId = NULL;
1431 $honoreeSection = FALSE;
1432 $isAddPaymentProcessor = TRUE;
1433 $isPcpApprovalNeeded = FALSE;
1434 $isSeparatePayment = FALSE;
1436 // create a new online contribution page
1437 // create contribution page with randomized title and default params
1438 $pageId = $this->webtestAddContributionPage($hash,
1441 array($processorName => $processorType),
1455 $isAddPaymentProcessor,
1456 $isPcpApprovalNeeded,
1461 $this->_testOrganizationWithImageUpload($pageId, $cid, $pageTitle);
1463 $this->openCiviPage("admin/uf/group", "reset=1");
1464 $this->click("link=Reserved Profiles");
1466 $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']");
1467 $this->waitForPageToLoad($this->getTimeoutMsec());
1468 $this->click("xpath=//table[@id='option11']/tbody//tr/td/span[text()='Image Url']/../following-sibling::td[8]/span[2]/ul/li[2]/a");
1469 $this->waitForPageToLoad($this->getTimeoutMsec());
1470 $this->click('_qf_Field_next-bottom');
1471 $this->waitForPageToLoad($this->getTimeoutMsec());
1472 $this->waitForText('crm-notification-container', "Selected Profile Field has been deleted.");
1480 function _testOrganizationWithImageUpload($pageId, $cid, $pageTitle) {
1481 //Open Live Contribution Page
1482 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", '_qf_Main_upload-bottom');
1484 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
1485 $lastName = 'An' . substr(sha1(rand()), 0, 7);
1486 $orgName = 'org_11_' . substr(sha1(rand()), 0, 7);
1487 $this->type("email-5", $firstName . "@example.com");
1489 // onbehalforganization info
1490 $this->type("onbehalf_organization_name", $orgName);
1491 $this->type("onbehalf_phone-3-1", 9999999999);
1492 $this->type("onbehalf_email-3", "{$orgName}@example.com");
1493 $this->type("onbehalf_street_address-3", "Test Street Address");
1494 $this->type("onbehalf_city-3", "Test City");
1495 $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
1496 $this->click("onbehalf_country-3");
1497 $this->select("onbehalf_country-3", "label=United States");
1498 $this->click("onbehalf_state_province-3");
1499 $this->select("onbehalf_state_province-3", "label=Alabama");
1501 // check for upload field.
1502 $this->waitForElementPresent("onbehalf_image_URL");
1504 //header("Content-Type: image/png");
1505 $im = imagecreate(110, 20)
1506 or die("Cannot Initialize new GD image stream");
1507 $background_color = imagecolorallocate($im, 0, 0, 0);
1508 $text_color = imagecolorallocate($im, 233, 14, 91);
1509 imagestring($im, 1, 5, 5, "On Behalf-Org Logo", $text_color);
1510 imagepng($im,"/tmp/file.png");
1512 $imagePath = "/tmp/file.png";
1513 $this->webtestAttachFile('onbehalf_image_URL', $imagePath);
1517 $this->select("credit_card_type", "value=Visa");
1518 $this->type("credit_card_number", "4111111111111111");
1519 $this->type("cvv2", "000");
1520 $this->select("credit_card_exp_date[M]", "value=1");
1521 $this->select("credit_card_exp_date[Y]", "value=2020");
1524 $this->type("billing_first_name", $firstName . 'billing');
1525 $this->type("billing_last_name", $lastName . 'billing');
1526 $this->type("billing_street_address-5", "0121 Mount Highschool.");
1527 $this->type(" billing_city-5", "Shangai");
1528 $this->select("billing_country_id-5", "value=1228");
1529 $this->select("billing_state_province_id-5", "value=1004");
1530 $this->type("billing_postal_code-5", "94129");
1531 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
1533 $this->click("_qf_Confirm_next-bottom");
1534 $this->waitForPageToLoad($this->getTimeoutMsec());
1536 // Type search name in autocomplete.
1537 $this->click('sort_name_navigation');
1538 $this->type('css=input#sort_name_navigation', $orgName);
1539 $this->typeKeys('css=input#sort_name_navigation', $orgName);
1541 // Wait for result list.
1542 $this->waitForElementPresent("css=div.ac_results-inner li");
1544 // Visit organization page.
1545 $this->click("css=div.ac_results-inner li");
1546 $this->waitForPageToLoad($this->getTimeoutMsec());
1548 //check whether the image is present
1549 $this->assertTrue($this->isElementPresent("xpath=//div[@id='crm-contact-thumbnail']/div/a/img"));