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';
28 class WebTest_Contribute_OnBehalfOfOrganization
extends CiviSeleniumTestCase
{
29 protected $pageno = '';
30 protected function setUp() {
34 function testOnBehalfOfOrganization() {
35 $this->webtestLogin();
37 // create new individual
38 $firstName = 'John_' . substr(sha1(rand()), 0, 7);
39 $lastName = 'Anderson_' . substr(sha1(rand()), 0, 7);
40 $email = "{$firstName}.{$lastName}@example.com";
41 $contactParams = array(
42 'first_name' => $firstName,
43 'last_name' => $lastName,
46 $streetAddress = "100 Main Street";
48 //adding contact for membership sign up
49 $this->webtestAddContact($firstName, $lastName, $email);
50 $cid = $this->urlArg('cid');
52 // We need a payment processor
53 $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7);
54 $processorType = 'Dummy';
55 $pageTitle = substr(sha1(rand()), 0, 7);
57 $hash = substr(sha1(rand()), 0, 7);
58 $amountSection = TRUE;
60 $onBehalf = 'optional';
64 $memPriceSetId = NULL;
67 $profilePostId = NULL;
71 $honoreeSection = FALSE;
72 $isAddPaymentProcessor = TRUE;
73 $isPcpApprovalNeeded = FALSE;
74 $isSeparatePayment = FALSE;
76 // create a new online contribution page
77 // create contribution page with randomized title and default params
78 $pageId = $this->webtestAddContributionPage($hash,
81 array($processorName => $processorType),
95 $isAddPaymentProcessor,
102 $this->webtestLogout();
103 //$this->_testAnomoyousOganization($pageId, $cid, $pageTitle);
104 $this->webtestLogout();
105 $this->_testUserWithOneRelationship($pageId, $cid, $pageTitle);
106 $this->webtestLogout();
107 $this->_testUserWithMoreThanOneRelationship($pageId, $cid, $pageTitle);
110 function testOnBehalfOfOrganizationWithMembershipData() {
111 $this->webtestLogin();
113 // create new individual
114 $this->openCiviPage("profile/edit", "reset=1&gid=4");
115 $firstName = 'John_x_' . substr(sha1(rand()), 0, 7);
116 $lastName = 'Anderson_c_' . substr(sha1(rand()), 0, 7);
118 $this->waitForPageToLoad($this->getTimeoutMsec());
119 $this->waitForElementPresent("_qf_Edit_next");
120 $this->type("first_name", $firstName);
121 $this->type("last_name", $lastName);
122 $this->clickLink("_qf_Edit_next", "profilewrap4");
124 // Is status message correct?
125 $this->assertTextPresent("Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!");
129 $this->openCiviPage("admin/custom/group", "action=add&reset=1");
131 //fill custom group title
132 $customGroupTitle = 'custom_' . substr(sha1(rand()), 0, 7);
133 $this->click("title");
134 $this->type("title", $customGroupTitle);
136 //custom group extends
137 $this->click("extends[0]");
138 $this->select("extends[0]", "value=Membership");
139 //$this->click("//option[@value='Contact']");
140 $this->click("_qf_Group_next-bottom");
141 $this->waitForElementPresent("_qf_Field_cancel-bottom");
143 //Is custom group created?
144 $this->assertTrue($this->isTextPresent("Your custom field set '{$customGroupTitle}' has been added. You can add custom fields now."));
146 //add custom field - alphanumeric checkbox
147 $checkboxFieldLabel = 'custom_field' . substr(sha1(rand()), 0, 4);
148 $this->click("label");
149 $this->type("label", $checkboxFieldLabel);
150 $this->click("data_type[1]");
151 $this->select("data_type[1]", "value=CheckBox");
152 $this->click("//option[@value='CheckBox']");
153 $checkboxOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
154 $this->type("option_label_1", $checkboxOptionLabel1);
155 $this->type("option_value_1", "1");
156 $checkboxOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
157 $this->type("option_label_2", $checkboxOptionLabel2);
158 $this->type("option_value_2", "2");
159 $this->click("link=another choice");
160 $checkboxOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
161 $this->type("option_label_3", $checkboxOptionLabel3);
162 $this->type("option_value_3", "3");
164 //enter options per line
165 $this->type("options_per_line", "2");
167 //enter pre help message
168 $this->type("help_pre", "this is field pre help");
170 //enter post help message
171 $this->type("help_post", "this field post help");
174 $this->click("is_searchable");
177 $this->click("_qf_Field_next");
178 $this->waitForPageToLoad($this->getTimeoutMsec());
180 //Is custom field created?
181 $this->assertTrue($this->isTextPresent("Your custom field '$checkboxFieldLabel' has been saved."));
183 //create another custom field - Integer Radio
184 $this->click("//a[@id='newCustomField']/span");
185 $this->waitForPageToLoad($this->getTimeoutMsec());
186 $this->click("data_type[0]");
187 $this->select("data_type[0]", "value=1");
188 $this->click("//option[@value='1']");
189 $this->click("data_type[1]");
190 $this->select("data_type[1]", "value=Radio");
191 $this->click("//option[@value='Radio']");
193 $radioFieldLabel = 'custom_field' . substr(sha1(rand()), 0, 4);
194 $this->type("label", $radioFieldLabel);
195 $radioOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
196 $this->type("option_label_1", $radioOptionLabel1);
197 $this->type("option_value_1", "1");
198 $radioOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
199 $this->type("option_label_2", $radioOptionLabel2);
200 $this->type("option_value_2", "2");
201 $this->click("link=another choice");
202 $radioOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
203 $this->type("option_label_3", $radioOptionLabel3);
204 $this->type("option_value_3", "3");
206 //select options per line
207 $this->type("options_per_line", "3");
210 $this->type("help_pre", "this is field pre help");
212 //enter post help msg
213 $this->type("help_post", "this is field post help");
216 $this->click("is_searchable");
219 $this->click("_qf_Field_next");
220 $this->waitForPageToLoad($this->getTimeoutMsec());
222 //Is custom field created
223 $this->assertTrue($this->isTextPresent("Your custom field '$radioFieldLabel' has been saved."));
225 //add the above custom data to the On Behalf of Profile
226 $this->openCiviPage("admin/uf/group", "reset=1");
227 $this->click("link=Reserved Profiles");
229 $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']");
230 $this->waitForPageToLoad($this->getTimeoutMsec());
232 $this->click("link=Add Field");
233 $this->waitForElementPresent('_qf_Field_next-bottom');
234 $this->select('field_name[0]', 'value=Membership');
235 $label = $checkboxFieldLabel.' :: '. $customGroupTitle;
236 $this->select('field_name[1]', "label=$label");
237 $this->click('field_name[1]');
238 $this->click('_qf_Field_next_new-bottom');
239 $this->waitForPageToLoad($this->getTimeoutMsec());
241 $this->select('field_name[0]', 'value=Membership');
242 $label = $radioFieldLabel.' :: '. $customGroupTitle;
243 $this->select('field_name[1]', "label=$label");
244 $this->click('field_name[1]');
245 $this->click('_qf_Field_next-bottom');
246 $this->waitForPageToLoad($this->getTimeoutMsec());
247 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$radioFieldLabel}' has been saved to 'On Behalf Of Organization'."));
249 //create organisation
250 $orgName = "Org WebAccess ". substr(sha1(rand()), 0, 7);
251 $orgEmail = "org". substr(sha1(rand()), 0, 7) . "@web.com";
252 $this->webtestAddOrganization($orgName, $orgEmail);
254 $this->waitForPageToLoad($this->getTimeoutMsec());
255 $this->click("css=li#tab_member a");
257 $this->waitForElementPresent('link=Add Membership');
258 $this->click('link=Add Membership');
260 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
262 // fill in Membership Organization and Type
263 $this->select('membership_type_id[0]', "value=1");
264 $this->select('membership_type_id[1]', "value=1");
267 $sourceText = 'On behalf Membership Webtest';
268 $this->type('source', $sourceText);
270 $this->waitForElementPresent("css=div#{$customGroupTitle} div.crm-accordion-header");
271 $this->click("css=div#{$customGroupTitle} div.crm-accordion-header");
272 //$this->waitForElementPresent('_qf_Membership_cancel-bottom111');
274 // select newly created processor
275 $xpath = "xpath=//label[text() = '{$checkboxOptionLabel1}']/preceding-sibling::input[1]";
276 $this->assertTrue($this->isTextPresent($checkboxOptionLabel1));
277 $this->check($xpath);
279 $xpath = "xpath=//label[text() = '{$checkboxOptionLabel3}']/preceding-sibling::input[1]";
280 $this->assertTrue($this->isTextPresent($checkboxOptionLabel3));
281 $this->check($xpath);
283 $xpath = "xpath=//label[text() = '{$radioOptionLabel1}']/preceding-sibling::input[1]";
284 $this->assertTrue($this->isTextPresent($radioOptionLabel1));
285 $this->check($xpath);
287 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
288 $this->click('_qf_Membership_upload-bottom');
290 $this->waitForPageToLoad($this->getTimeoutMsec());
291 $this->click("css=li#tab_rel a");
293 $this->waitForElementPresent('link=Add Relationship');
294 $this->click('link=Add Relationship');
296 $this->waitForElementPresent('relationship_type_id');
297 $this->click("relationship_type_id");
298 $this->select("relationship_type_id", "label=Employer of");
299 // search organization
300 $this->type('contact_1', $firstName);
301 $this->click("contact_1");
302 $this->waitForElementPresent("css=div.ac_results-inner li");
303 $this->click("css=div.ac_results-inner li");
304 $this->assertContains($firstName, $this->getValue('contact_1'), "autocomplete expected $firstName but didn’t find it in " . $this->getValue('contact_1'));
307 $this->click("is_permission_a_b");
308 $this->click("is_permission_b_a");
311 $this->click("details-save");
312 $this->waitForPageToLoad($this->getTimeoutMsec());
314 // We need a payment processor
315 $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7);
316 $processorType = 'Dummy';
317 $pageTitle = substr(sha1(rand()), 0, 7);
319 $hash = substr(sha1(rand()), 0, 7);
320 $amountSection = TRUE;
326 $memPriceSetId = NULL;
328 $profilePreId = NULL;
329 $profilePostId = NULL;
333 $honoreeSection = FALSE;
334 $isAddPaymentProcessor = TRUE;
335 $isPcpApprovalNeeded = FALSE;
336 $isSeparatePayment = FALSE;
338 // create a new online contribution page
339 // create contribution page with randomized title and default params
340 $pageId = $this->webtestAddContributionPage($hash,
343 array($processorName => $processorType),
357 $isAddPaymentProcessor,
358 $isPcpApprovalNeeded,
364 //scenario 1 : add membership data in pre / post profile and check for formRule
366 $this->openCiviPage("admin/uf/group", "reset=1");
367 $this->click('link=Add Profile');
369 $profileTitle = "test profile" . substr(sha1(rand()), 0, 7);
370 // Add membership custom data field to profile
371 $this->waitForElementPresent('_qf_Group_cancel-bottom');
372 $this->type('title', $profileTitle);
373 $this->click('_qf_Group_next-bottom');
375 $this->waitForElementPresent('_qf_Field_cancel-bottom');
376 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now."));
378 $this->select('field_name[0]', "value=Membership");
379 $this->select('field_name[1]', "label={$checkboxFieldLabel} :: {$customGroupTitle}");
380 $this->click('field_name[1]');
381 $this->click('label');
383 // Clicking save and new
384 $this->click('_qf_Field_next_new-bottom');
385 $this->waitForPageToLoad($this->getTimeoutMsec());
386 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$checkboxFieldLabel}' has been saved to '{$profileTitle}'."));
388 $this->openCiviPage("admin/contribute/custom", "reset=1&action=update&id={$pageId}", '_qf_Custom_next-bottom');
389 $this->select('custom_pre_id', "label={$profileTitle}");
390 $this->click('_qf_Custom_next-bottom');
391 $this->waitForPageToLoad($this->getTimeoutMsec());
392 // Because it tends to cause problems, all uses of sleep() must be justified in comments
393 // Sleep should never be used for wait for anything to load from the server
394 // Justification for this instance: FIXME
396 $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");
398 $this->select('custom_pre_id', "- select -");
399 $this->select('custom_post_id', "label={$profileTitle}");
400 $this->click('_qf_Custom_next-bottom');
401 $this->waitForPageToLoad($this->getTimeoutMsec());
402 // Because it tends to cause problems, all uses of sleep() must be justified in comments
403 // Sleep should never be used for wait for anything to load from the server
404 // Justification for this instance: FIXME
406 $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");
408 //scenario 2 : disable 'on behalf of', add membership data in pre / post profile
409 //then try to add 'on behalf of' and check for formRule
410 //disable 'on behalf of'
411 $this->openCiviPage("admin/contribute/settings", "reset=1&action=update&id={$pageId}", '_qf_Settings_next-bottom');
412 $this->uncheck('is_organization');
413 $this->click('_qf_Settings_next-bottom');
414 $this->waitForPageToLoad($this->getTimeoutMsec());
416 //set a membership field profile for this contribution page
417 $this->click('css=li#tab_custom a');
418 $this->waitForElementPresent('_qf_Custom_next-bottom');
419 $this->select('custom_pre_id', "label={$profileTitle}");
420 $this->click('_qf_Custom_next-bottom');
421 $this->waitForPageToLoad($this->getTimeoutMsec());
423 //now visit the title settings page and configure the profile as on behalf of
424 $this->click('css=li#tab_settings a');
425 $this->waitForElementPresent('_qf_Settings_next-bottom');
426 $this->check('is_organization');
427 $this->click('_qf_Settings_next-bottom');
428 $this->waitForPageToLoad($this->getTimeoutMsec());
429 // Because it tends to cause problems, all uses of sleep() must be justified in comments
430 // Sleep should never be used for wait for anything to load from the server
431 // Justification for this instance: FIXME
433 $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");
436 $this->webtestLogout();
439 function testOnBehalfOfOrganizationWithOrgData() {
440 $this->webtestLogin();
442 $this->openCiviPage("profile/edit", "reset=1&gid=4");
443 $firstName = 'John_x_' . substr(sha1(rand()), 0, 7);
444 $lastName = 'Anderson_c_' . substr(sha1(rand()), 0, 7);
446 $this->waitForPageToLoad($this->getTimeoutMsec());
447 $this->waitForElementPresent("_qf_Edit_next");
448 $this->type("first_name", $firstName);
449 $this->type("last_name", $lastName);
450 $this->clickLink("_qf_Edit_next", "profilewrap4");
452 $cid = $this->urlArg('id');
453 // Is status message correct?
454 $this->assertTextPresent("Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!");
456 //add org fields to profile
457 $this->openCiviPage("admin/uf/group", "reset=1");
458 $this->click("link=Reserved Profiles");
460 $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']");
461 $this->waitForPageToLoad($this->getTimeoutMsec());
463 $this->click("link=Add Field");
464 $this->waitForElementPresent('_qf_Field_next-bottom');
466 $this->select('field_name[0]', 'value=Organization');
467 $this->select('field_name[1]', 'label=Legal Identifier');
468 $this->click('field_name[1]');
469 $this->click('_qf_Field_next_new-bottom');
470 $this->waitForPageToLoad($this->getTimeoutMsec());
472 $this->select('field_name[0]', 'value=Organization');
473 $this->select('field_name[1]', 'label=Legal Name');
474 $this->click('field_name[1]');
475 $this->click('_qf_Field_next-bottom');
476 $this->waitForPageToLoad($this->getTimeoutMsec());
478 //create organisation
479 $orgName = "Org WebAccess ". substr(sha1(rand()), 0, 7);
480 $orgEmail = "org". substr(sha1(rand()), 0, 7) . "@web.com";
481 $this->webtestAddOrganization($orgName, $orgEmail);
483 $this->waitForPageToLoad($this->getTimeoutMsec());
484 $this->click("css=li#tab_rel a");
486 $this->waitForElementPresent('link=Add Relationship');
487 $this->click('link=Add Relationship');
489 $this->waitForElementPresent('relationship_type_id');
490 $this->click("relationship_type_id");
491 $this->select("relationship_type_id", "label=Employer of");
492 // search organization
493 $this->type('contact_1', $firstName);
494 $this->click("contact_1");
495 $this->waitForElementPresent("css=div.ac_results-inner li");
496 $this->click("css=div.ac_results-inner li");
497 $this->assertContains($firstName, $this->getValue('contact_1'), "autocomplete expected $firstName but didn’t find it in " . $this->getValue('contact_1'));
500 $this->click("is_permission_a_b");
501 $this->click("is_permission_b_a");
504 $this->waitForElementPresent("details-save");
505 $this->click("details-save");
506 $this->waitForElementPresent("Relationships");
508 $pageTitle = substr(sha1(rand()), 0, 7);
510 $hash = substr(sha1(rand()), 0, 7);
511 $amountSection = TRUE;
517 $memPriceSetId = NULL;
519 $profilePreId = NULL;
520 $profilePostId = NULL;
524 $honoreeSection = FALSE;
525 $isAddPaymentProcessor = FALSE;
526 $isPcpApprovalNeeded = FALSE;
527 $isSeparatePayment = FALSE;
529 // create a new online contribution page
530 // create contribution page with randomized title and default params
531 $pageId = $this->webtestAddContributionPage($hash,
548 $isAddPaymentProcessor,
549 $isPcpApprovalNeeded,
554 $this->_testOrganization($pageId, $cid, $pageTitle);
562 function _testOrganization($pageId, $cid, $pageTitle) {
563 //Open Live Contribution Page
564 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom");
566 $this->waitForElementPresent("onbehalf_state_province-3");
568 $this->waitForElementPresent("onbehalf_phone-3-1");
569 $this->type("onbehalf_phone-3-1", 9999999999);
570 $this->waitForElementPresent("onbehalf_email-3");
571 $this->type("onbehalf_email-3", "org@example.com");
572 $this->type("onbehalf_street_address-3", "Test Street Address");
573 $this->type("onbehalf_city-3", "Test City");
574 $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
575 $this->click("onbehalf_country-3");
576 $this->select("onbehalf_country-3", "label=United States");
577 $this->click("onbehalf_state_province-3");
578 $this->select("onbehalf_state_province-3", "label=Alabama");
580 $this->waitForElementPresent("_qf_Main_upload-bottom");
581 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
583 $this->click("_qf_Confirm_next-bottom");
584 $this->waitForPageToLoad($this->getTimeoutMsec());
593 function _testAnomoyousOganization($pageId, $cid, $pageTitle) {
594 //Open Live Contribution Page
595 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom");
597 $this->click('CIVICRM_QFID_0_8');
598 $this->type('css=div.other_amount-section input', 60);
600 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
601 $lastName = 'An' . substr(sha1(rand()), 0, 7);
602 $orgName = 'org_11_' . substr(sha1(rand()), 0, 7);
603 $this->type("email-5", $firstName . "@example.com");
605 // enable onbehalforganization block
606 $this->click("is_for_organization");
607 $this->waitForElementPresent("onbehalf_state_province-3");
609 // onbehalforganization info
610 $this->type("onbehalf_organization_name", $orgName);
611 $this->type("onbehalf_phone-3-1", 9999999999);
612 $this->type("onbehalf_email-3", "{$orgName}@example.com");
613 $this->type("onbehalf_street_address-3", "Test Street Address");
614 $this->type("onbehalf_city-3", "Test City");
615 $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
616 $this->click("onbehalf_country-3");
617 $this->select("onbehalf_country-3", "label=United States");
618 $this->click("onbehalf_state_province-3");
619 $this->select("onbehalf_state_province-3", "label=Alabama");
622 $this->select("credit_card_type", "value=Visa");
623 $this->type("credit_card_number", "4111111111111111");
624 $this->type("cvv2", "000");
625 $this->select("credit_card_exp_date[M]", "value=1");
626 $this->select("credit_card_exp_date[Y]", "value=2020");
629 $this->type("billing_first_name", $firstName . 'billing');
630 $this->type("billing_last_name", $lastName . 'billing');
631 $this->type("billing_street_address-5", "0121 Mount Highschool.");
632 $this->type(" billing_city-5", "Shangai");
633 $this->select("billing_country_id-5", "value=1228");
634 $this->select("billing_state_province_id-5", "value=1004");
635 $this->type("billing_postal_code-5", "94129");
636 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
638 $this->click("_qf_Confirm_next-bottom");
639 $this->waitForPageToLoad($this->getTimeoutMsec());
641 //login to check contribution
643 // Log in using webtestLogin() method
644 $this->webtestLogin();
647 $this->openCiviPage("contribute/search", "reset=1");
648 $this->type("sort_name", $orgName);
649 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
650 $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom");
652 // verify contrb created
658 foreach ($expected as $value => $label) {
659 $this->verifyText("xpath=id( 'ContributionView' )/div[2]/table[1]/tbody/tr[$value]/td[2]", preg_quote($label));
668 function _testUserWithOneRelationship($pageId, $cid, $pageTitle) {
669 $this->webtestLogin('admin');
672 $groupName = $this->WebtestAddGroup();
673 $this->openCiviPage("group", "reset=1", "_qf_Search_refresh");
674 $groupId = $this->getText("xpath=//table[@id='crm-group-selector']/tbody//tr/td[text()='{$groupName}']/../td[2]");
676 $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
678 $this->click('link=Edit');
679 $this->waitForElementPresent('_qf_Contact_cancel-bottom');
680 $this->click('addressBlock');
681 $this->waitForElementPresent('link=Another Address');
684 $this->select('address_1_location_type_id', 'label=Billing');
685 $this->type('address_1_street_address', '0121 Mount Highschool.');
686 $this->type('address_1_city', "Shangai");
687 $this->type('address_1_postal_code', "94129");
688 $this->select('address_1_country_id', "value=1228");
689 $this->select('address_1_state_province_id', "value=1004");
690 $this->click('_qf_Contact_upload_view-bottom');
691 $this->waitForPageToLoad($this->getTimeoutMsec());
693 // add contact to group
695 $this->click("css=li#tab_group a");
696 $this->waitForElementPresent("group_id");
699 $this->select("group_id", "label={$groupName}");
700 $this->click("_qf_GroupContact_next");
701 $this->waitForPageToLoad($this->getTimeoutMsec());
703 $this->openCiviPage("admin/custom/group", "action=add&reset=1", "_qf_Group_next-bottom");
705 // fill in a unique title for the custom group
706 $groupTitle = "Custom Group" . substr(sha1(rand()), 0, 7);
707 $this->type("title", $groupTitle);
709 // select the group this custom data set extends
710 $this->select("extends[0]", "value=Contribution");
711 $this->waitForElementPresent("extends[1]");
713 // save the custom group
714 $this->click("_qf_Group_next-bottom");
715 $this->waitForElementPresent("_qf_Field_next_new-bottom");
716 $this->assertTrue($this->isTextPresent("Your custom field set '$groupTitle' has been added. You can add custom fields now."));
718 // add a custom field to the custom group
719 $fieldTitle = "Custom Field " . substr(sha1(rand()), 0, 7);
720 $this->type("label", $fieldTitle);
722 $this->select("data_type[1]", "value=Text");
723 $this->click('_qf_Field_next-bottom');
725 $this->waitForPageToLoad($this->getTimeoutMsec());
726 $this->assertTrue($this->isTextPresent("Your custom field '$fieldTitle' has been saved."));
727 $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"));
729 // Enable CiviCampaign module if necessary
730 $this->enableComponents("CiviCampaign");
732 // add the required permission
733 $permission = array('edit-2-administer-civicampaign');
734 $this->changePermissions($permission);
736 // Log in as normal user
737 $this->webtestLogin();
739 $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom");
741 $title = 'Campaign ' . substr(sha1(rand()), 0, 7);
742 $this->type("title", $title);
744 // select the campaign type
745 $this->select("campaign_type_id", "value=2");
747 // fill in the description
748 $this->type("description", "This is a test campaign");
750 // include groups for the campaign
751 $this->addSelection("includeGroups-f", "label={$groupName}");
752 $this->click("//option[@value={$groupId}]");
755 // fill the end date for campaign
756 $this->webtestFillDate("end_date", "+1 year");
758 // select campaign status
759 $this->select("status_id", "value=2");
762 $this->click("_qf_Campaign_upload-bottom");
763 $this->waitForElementPresent("xpath=//div[@id='campaigns_wrapper']//table[@id='campaigns']/tbody//tr/td[3][text()='{$title}']");
764 $this->assertTrue($this->isTextPresent("Campaign {$title} has been saved."), "Status message didn't show up after saving!");
766 $this->openCiviPage("admin/uf/group", "reset=1");
767 $this->click("link=Reserved Profiles");
769 $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']");
770 $this->waitForPageToLoad($this->getTimeoutMsec());
772 $this->click("link=Add Field");
773 $this->waitForElementPresent('_qf_Field_next-bottom');
774 $this->select('field_name[0]', 'value=Contribution');
775 $this->select('field_name[1]', 'label=Campaign');
776 $this->click('field_name[1]');
777 $this->click('_qf_Field_next_new-bottom');
778 $this->waitForPageToLoad($this->getTimeoutMsec());
780 $this->select('field_name[0]', 'value=Contribution');
781 $this->select('field_name[1]', "label=$fieldTitle :: $groupTitle");
782 $this->click('field_name[1]');
783 $this->click('_qf_Field_next-bottom');
784 $this->waitForPageToLoad($this->getTimeoutMsec());
785 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$fieldTitle}' has been saved to 'On Behalf Of Organization'."));
787 // Open Page to create Organization
788 $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom");
789 $orgName1 = 'org1_' . substr(sha1(rand()), 0, 7);
791 // Type Organization name
792 $this->type("organization_name", $orgName1);
794 // Type Organizatio email for main
795 $this->type("email_1_email", "{$orgName1}@example.com");
796 $this->select("email_1_location_type_id", "value=3");
798 // type phone no for main
799 $this->type("phone_1_phone", 9999999999);
800 $this->select("phone_1_location_type_id", "value=3");
803 $this->click("addressBlock");
804 $this->waitForElementPresent("address_1_street_address");
806 //fill in address 1 for main
807 $this->select("address_1_location_type_id", "value=3");
808 $this->type("address_1_street_address", "{$orgName1} street address");
809 $this->type("address_1_city", "{$orgName1} city");
810 $this->type("address_1_postal_code", substr(sha1(rand()), 0, 4));
811 $this->assertTrue($this->isTextPresent("- select - United States"));
812 $this->select("address_1_state_province_id", "value=1019");
813 $this->type("address_1_geo_code_1", "1234");
814 $this->type("address_1_geo_code_2", "5678");
816 // Save the Organization
817 $this->click("_qf_Contact_upload_view-bottom");
818 $this->waitForPageToLoad($this->getTimeoutMsec());
821 $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1");
823 // select relationship type
824 $this->click("relationship_type_id");
825 $this->select("relationship_type_id", "value=4_a_b");
827 // search organization
828 $this->type('contact_1', $orgName1);
829 $this->click("contact_1");
830 $this->waitForElementPresent("css=div.ac_results-inner li");
831 $this->click("css=div.ac_results-inner li");
832 $this->assertContains($orgName1, $this->getValue('contact_1'), "autocomplete expected $orgName1 but didn’t find it in " . $this->getValue('contact_1'));
834 $this->waitForElementPresent("add_current_employer");
835 $this->click("add_current_employer");
838 $this->click("is_permission_a_b");
839 $this->click("is_permission_b_a");
842 $this->waitForElementPresent("details-save");
843 $this->click("details-save");
845 //Open Live Contribution Page
846 $this->openCiviPage("contribute/transact", "reset=1&id={$pageId}&cid=$cid", "onbehalf_state_province-3");
847 $this->click('CIVICRM_QFID_amount_other_radio_4');
848 $this->type('amount_other', 60);
849 $this->click('onbehalf_contribution_campaign_id');
850 $this->select('onbehalf_contribution_campaign_id', "label={$title}");
851 $this->type("onbehalf_custom_{$fieldId}", 'Test Subject');
854 $this->select("credit_card_type", "value=Visa");
855 $this->type("credit_card_number", "4111111111111111");
856 $this->type("cvv2", "000");
857 $this->select("credit_card_exp_date[M]", "value=1");
858 $this->select("credit_card_exp_date[Y]", "value=2020");
861 $this->type("billing_street_address-5", "0121 Mount Highschool.");
862 $this->type(" billing_city-5", "Shangai");
863 $this->select("billing_country_id-5", "value=1228");
864 $this->select("billing_state_province_id-5", "value=1004");
865 $this->type("billing_postal_code-5", "94129");
867 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
868 $this->click("_qf_Confirm_next-bottom");
869 $this->waitForPageToLoad($this->getTimeoutMsec());
872 $this->openCiviPage("contribute/search", "reset=1");
873 $this->type("sort_name", $orgName1);
874 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
875 $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom");
877 // verify contrb created
884 foreach ($expected as $value => $label) {
885 $this->verifyText("xpath=id( 'ContributionView' )/div[2]/table[1]/tbody/tr[$value]/td[2]", preg_quote($label));
888 $this->openCiviPage("admin/uf/group", "reset=1");
889 $this->click("link=Reserved Profiles");
891 $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']");
892 $this->waitForPageToLoad($this->getTimeoutMsec());
894 $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']");
895 $this->waitForElementPresent('_qf_Field_next-bottom');
897 $this->click('_qf_Field_next-bottom');
898 $this->waitForPageToLoad($this->getTimeoutMsec());
899 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'), "Status message didn't show up after saving!");
901 $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']");
902 $this->waitForElementPresent('_qf_Field_next-bottom');
904 $this->click('_qf_Field_next-bottom');
905 $this->waitForPageToLoad($this->getTimeoutMsec());
906 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'), "Status message didn't show up after saving!");
914 function _testUserWithMoreThanOneRelationship($pageId, $cid, $pageTitle) {
915 $this->webtestLogin('admin');
916 $this->waitForPageToLoad($this->getTimeoutMsec());
919 $groupName = $this->WebtestAddGroup();
920 $this->openCiviPage("group", "reset=1", '_qf_Search_refresh');
921 $this->click('_qf_Search_refresh');
922 $this->waitForElementPresent("xpath=//div[@id='group']/div[3]/table/tbody//tr/td[text()='{$groupName}']/../td[2]");
923 $groupId = $this->getText("xpath=//div[@id='group']/div[3]/table/tbody//tr/td[text()='{$groupName}']/../td[2]");
925 $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
927 $this->click('link=Edit');
928 $this->waitForElementPresent('_qf_Contact_cancel-bottom');
929 $this->click('addressBlock');
930 $this->waitForElementPresent('link=Another Address');
933 $this->select('address_1_location_type_id', 'label=Billing');
934 $this->type('address_1_street_address', '0121 Mount Highschool.');
935 $this->type('address_1_city', "Shangai");
936 $this->type('address_1_postal_code', "94129");
937 $this->select('address_1_country_id', "value=1228");
938 $this->select('address_1_state_province_id', "value=1004");
939 $this->click('_qf_Contact_upload_view-bottom');
940 $this->waitForPageToLoad($this->getTimeoutMsec());
942 // add contact to group
944 $this->click("css=li#tab_group a");
945 $this->waitForElementPresent("group_id");
948 $this->select("group_id", "label=$groupName");
949 $this->click("_qf_GroupContact_next");
950 $this->waitForPageToLoad($this->getTimeoutMsec());
952 $this->openCiviPage("admin/custom/group", "action=add&reset=1", "_qf_Group_next-bottom");
954 // fill in a unique title for the c$groupIdustom group
955 $groupTitle = "Members Custom Group" . substr(sha1(rand()), 0, 7);
956 $this->type("title", $groupTitle);
958 // select the group this custom data set extends
959 $this->select("extends[0]", "value=Membership");
960 $this->waitForElementPresent("extends[1]");
962 // save the custom group
963 $this->click("_qf_Group_next-bottom");
965 $this->waitForElementPresent("_qf_Field_next_new-bottom");
966 $this->assertTrue($this->isTextPresent("Your custom field set '$groupTitle' has been added. You can add custom fields now."));
968 // add a custom field to the custom group
969 $fieldTitle = "Member Custom Field " . substr(sha1(rand()), 0, 7);
970 $this->type("label", $fieldTitle);
972 $this->select("data_type[1]", "value=Text");
973 $this->click('_qf_Field_next-bottom');
975 $this->waitForPageToLoad($this->getTimeoutMsec());
976 $this->assertTrue($this->isTextPresent("Your custom field '$fieldTitle' has been saved."));
977 $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"));
979 // Enable CiviCampaign module if necessary
980 $this->enableComponents("CiviCampaign");
982 // add the required permission
983 $permission = array('edit-2-administer-civicampaign');
984 $this->changePermissions($permission);
986 // Log in as normal user
987 $this->webtestLogin();
989 $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom");
991 $title = 'Campaign ' . substr(sha1(rand()), 0, 7);
992 $this->type("title", $title);
994 // select the campaign type
995 $this->select("campaign_type_id", "value=2");
997 // fill in the description
998 $this->type("description", "This is a test campaign");
1000 // include groups for the campaign
1001 $this->addSelection("includeGroups-f", "label={$groupName}");
1002 $this->click("//option[@value={$groupId}]");
1003 $this->click("add");
1005 // fill the end date for campaign
1006 $this->webtestFillDate("end_date", "+1 year");
1008 // select campaign status
1009 $this->select("status_id", "value=2");
1012 $this->click("_qf_Campaign_upload-bottom");
1013 $this->waitForPageToLoad($this->getTimeoutMsec());
1015 $this->assertTrue($this->isTextPresent("Campaign {$title} has been saved."), "Status message didn't show up after saving!");
1017 $this->openCiviPage("admin/uf/group", "reset=1");
1018 $this->click("link=Reserved Profiles");
1019 $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']");
1020 $this->waitForPageToLoad($this->getTimeoutMsec());
1022 $this->click("link=Add Field");
1023 $this->waitForElementPresent('_qf_Field_next-bottom');
1024 $this->select('field_name[0]', 'value=Membership');
1025 $this->select('field_name[1]', 'label=Campaign');
1026 $this->click('field_name[1]');
1027 $this->clickLink('_qf_Field_next_new-bottom', '_qf_Field_cancel-bottom');
1029 $this->select('field_name[0]', 'value=Membership');
1030 $this->select('field_name[1]', "label=$fieldTitle :: $groupTitle");
1031 $this->click('field_name[1]');
1032 $this->click('_qf_Field_next-bottom');
1033 $this->waitForPageToLoad($this->getTimeoutMsec());
1034 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$fieldTitle}' has been saved to 'On Behalf Of Organization'."),
1035 "Status message didn't show up after saving!"
1038 // Open Page to create Organization 1
1039 $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom");
1040 $orgName1 = 'org1_' . substr(sha1(rand()), 0, 7);
1042 // Type Organization name
1043 $this->type("organization_name", $orgName1);
1045 // Type Organizatio email for main
1046 $this->type("email_1_email", "{$orgName1}@example.com");
1047 $this->select("email_1_location_type_id", "value=3");
1049 // type phone no for main
1050 $this->type("phone_1_phone", substr(sha1(rand()), 0, 4));
1051 $this->select("phone_1_location_type_id", "value=3");
1054 $this->click("addressBlock");
1055 $this->waitForElementPresent("address_1_street_address");
1057 //fill in address 1 for main
1058 $this->select("address_1_location_type_id", "value=3");
1059 $this->type("address_1_street_address", "{$orgName1} street address");
1060 $this->type("address_1_city", "{$orgName1} city");
1061 $this->type("address_1_postal_code", "9999999999");
1062 $this->assertTrue($this->isTextPresent("- select - United States"));
1063 $this->select("address_1_state_province_id", "value=1019");
1064 $this->type("address_1_geo_code_1", "1234");
1065 $this->type("address_1_geo_code_2", "5678");
1067 // Save the Organization
1068 $this->click("_qf_Contact_upload_view-bottom");
1069 $this->waitForPageToLoad($this->getTimeoutMsec());
1071 // create second orzanization
1072 $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom");
1073 $orgName2 = 'org2_' . substr(sha1(rand()), 0, 7);
1075 // Type Organization name
1076 $this->type("organization_name", $orgName2);
1078 // Type Organizatio email for main
1079 $this->type("email_1_email", "{$orgName2}@example.com");
1080 $this->select("email_1_location_type_id", "value=3");
1082 // type phone no for main
1083 $this->type("phone_1_phone", substr(sha1(rand()), 0, 4));
1084 $this->select("phone_1_location_type_id", "value=3");
1087 $this->click("addressBlock");
1088 $this->waitForElementPresent("address_1_street_address");
1090 //fill in address 1 for main
1091 $this->select("address_1_location_type_id", "value=3");
1092 $this->type("address_1_street_address", "{$orgName2} street address");
1093 $this->type("address_1_city", "{$orgName2} city");
1094 $this->type("address_1_postal_code", "7777777777");
1095 $this->assertTrue($this->isTextPresent("- select - United States"));
1096 $this->select("address_1_state_province_id", "value=1019");
1097 $this->type("address_1_geo_code_1", "1224");
1098 $this->type("address_1_geo_code_2", "5628");
1100 // Save the Organization
1101 $this->click("_qf_Contact_upload_view-bottom");
1102 $this->waitForPageToLoad($this->getTimeoutMsec());
1104 // create Membership type
1105 $title1 = "Membership Type" . substr(sha1(rand()), 0, 7);
1106 $this->openCiviPage("admin/member/membershipType", "reset=1&action=browse");
1108 $this->click("link=Add Membership Type");
1109 $this->waitForElementPresent('_qf_MembershipType_cancel-bottom');
1111 $this->type('name', $title1);
1112 $this->type('member_org', $orgName1);
1113 $this->click('_qf_MembershipType_refresh');
1114 $this->waitForElementPresent("xpath=//div[@id='membership_type_form']/fieldset/table[2]/tbody/tr[2]/td[2]");
1116 $this->type('minimum_fee', '50');
1118 $this->select( 'financial_type_id', 'value=2' );
1120 $this->type('duration_interval', 1);
1121 $this->select('duration_unit', "label=year");
1123 $this->select('period_type', "label=fixed");
1124 $this->waitForElementPresent('fixed_period_rollover_day[d]');
1126 $this->select('fixed_period_start_day[M]', 'value=4');
1127 $this->select('fixed_period_rollover_day[M]', 'value=1');
1129 $this->select('relationship_type_id', 'value=4_b_a');
1131 $this->click('_qf_MembershipType_upload-bottom');
1132 $this->waitForElementPresent('link=Add Membership Type');
1133 $this->assertTrue($this->isTextPresent("The membership type '$title1' has been saved."));
1134 $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"));
1137 $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1");
1139 // select relationship type
1140 $this->click("relationship_type_id");
1141 $this->select("relationship_type_id", "value=4_a_b");
1143 // search organization
1144 $this->type('contact_1', $orgName1);
1145 $this->click("contact_1");
1146 $this->waitForElementPresent("css=div.ac_results-inner li");
1147 $this->click("css=div.ac_results-inner li");
1148 $this->assertContains($orgName1, $this->getValue('contact_1'), "autocomplete expected $orgName1 but didn’t find it in " . $this->getValue('contact_1'));
1151 $this->click("is_permission_a_b");
1152 $this->click("is_permission_b_a");
1154 // save relationship
1155 $this->click("details-save");
1158 $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1");
1160 // select relationship type
1161 $this->click("relationship_type_id");
1162 $this->select("relationship_type_id", "value=4_a_b");
1164 // search organization
1165 $this->type('contact_1', $orgName2);
1166 $this->click("contact_1");
1167 $this->waitForElementPresent("css=div.ac_results-inner li");
1168 $this->click("css=div.ac_results-inner li");
1169 $this->assertContains($orgName2, $this->getValue('contact_1'), "autocomplete expected $orgName2 but didn’t find it in " . $this->getValue('contact_1'));
1172 $this->click("is_permission_a_b");
1173 $this->click("is_permission_b_a");
1175 // save relationship
1176 $this->click("details-save");
1178 // set membership type
1179 $this->openCiviPage("admin/contribute/membership", "reset=1&action=update&id=$pageId", "_qf_MembershipBlock_upload_done-bottom");
1180 $this->click("member_is_active");
1181 $this->click("membership_type[{$typeId}]");
1182 $this->click("xpath=//div[@id='memberFields']//table[@class='report']/tbody//tr/td[1]/label[text()='{$title1}']/../../td[2]/input");
1183 $this->click('_qf_MembershipBlock_upload_done-bottom');
1184 $this->waitForPageToLoad($this->getTimeoutMsec());
1186 //Open Live Membership Page
1187 $this->openCiviPage('contribute/transact', "reset=1&id=$pageId&cid=$cid", "_qf_Main_upload-bottom");
1188 $this->click('CIVICRM_QFID_amount_other_radio_4');
1189 $this->type('amount_other', 60);
1190 $this->click('onbehalf_organization_name');
1191 $this->type('onbehalf_organization_name', $orgName1);
1192 $this->typeKeys('onbehalf_organization_name', $orgName1);
1193 $this->click("onbehalf_organization_name");
1194 $this->waitForElementPresent("css=div.ac_results-inner li");
1195 $this->click("css=div.ac_results-inner li");
1196 // Because it tends to cause problems, all uses of sleep() must be justified in comments
1197 // Sleep should never be used for wait for anything to load from the server
1198 // Justification for this instance: FIXME
1200 $this->click('onbehalf_member_campaign_id');
1201 $this->select('onbehalf_member_campaign_id', "label={$title}");
1202 $this->type("onbehalf_custom_{$fieldId}", 'Test Subject');
1204 $this->assertContains($orgName1, $this->getValue('onbehalf_organization_name'), "autocomplete expected $orgName1 but didn’t find it in " . $this->getValue('onbehalf_organization_name'));
1207 $this->select("credit_card_type", "value=Visa");
1208 $this->type("credit_card_number", "4111111111111111");
1209 $this->type("cvv2", "000");
1210 $this->select("credit_card_exp_date[M]", "value=1");
1211 $this->select("credit_card_exp_date[Y]", "value=2020");
1213 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
1214 $this->click("_qf_Confirm_next-bottom");
1215 $this->waitForPageToLoad($this->getTimeoutMsec());
1217 //Find Membership for organization
1218 $this->openCiviPage("member/search", "reset=1");
1219 $this->type("sort_name", $orgName1);
1220 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='memberSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
1221 $this->clickLink("xpath=//div[@id='memberSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_MembershipView_cancel-bottom");
1223 //verify contrb created
1229 foreach ($expected as $value => $label) {
1230 $this->verifyText("xpath=//form[@id='MembershipView']/div[2]/div/table/tbody/tr[$value]/td[2]", preg_quote($label));
1233 // find membership for contact in relationship
1234 $this->openCiviPage("contact/view", "reset=1&force=1&cid={$cid}");
1235 $this->click("css=li#tab_member a");
1236 $this->waitForElementPresent("xpath=//div[@id='memberships']/div/table//tbody//tr/td[1][text()='{$title1}']");
1237 $this->click("xpath=//div[@id='memberships']/div/table//tbody//tr/td[1][text()='{$title1}']/../td[7]/span/a[text()='View']");
1238 $this->waitForPageToLoad($this->getTimeoutMsec());
1240 //verify contrb created
1245 foreach ($expected as $value => $label) {
1246 $this->verifyText("xpath=//form[@id='MembershipView']/div[2]/div/table/tbody/tr[$value]/td[2]", preg_quote($label));
1249 $this->openCiviPage("admin/uf/group", "reset=1");
1250 $this->click("link=Reserved Profiles");
1251 $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']");
1252 $this->waitForPageToLoad($this->getTimeoutMsec());
1254 $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']");
1255 $this->waitForElementPresent('_qf_Field_next-bottom');
1257 $this->click('_qf_Field_next-bottom');
1258 $this->waitForPageToLoad($this->getTimeoutMsec());
1259 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'),
1260 "Status message didn't show up after saving!"
1263 $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']");
1264 $this->waitForElementPresent('_qf_Field_next-bottom');
1266 $this->click('_qf_Field_next-bottom');
1267 $this->waitForPageToLoad($this->getTimeoutMsec());
1268 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'),
1269 "Status message didn't show up after saving!"
1272 $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
1273 $this->click("css=li#tab_rel a");
1275 $this->waitForElementPresent("xpath=//div[@id='current-relationships']/div/table/tbody//tr/td[2]/a[text()='{$orgName1}']");
1276 $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']");
1278 // Check confirmation alert.
1279 $this->assertTrue((bool)preg_match("/^Are you sure you want to delete this relationship?/",
1280 $this->getConfirmation()
1282 $this->chooseOkOnNextConfirmation();
1283 $this->waitForPageToLoad($this->getTimeoutMsec());
1284 $this->assertTrue($this->isTextPresent('Selected relationship has been deleted successfully.'),
1285 "Status message didn't show up after saving!"
1289 function testOnBehalfOfOrganizationWithImage() {
1290 $this->webtestLogin();
1292 $this->openCiviPage("profile/edit", "reset=1&gid=4");
1293 $firstName = 'John_x_' . substr(sha1(rand()), 0, 7);
1294 $lastName = 'Anderson_c_' . substr(sha1(rand()), 0, 7);
1296 $this->waitForPageToLoad($this->getTimeoutMsec());
1297 $this->waitForElementPresent("_qf_Edit_next");
1298 $this->type("first_name", $firstName);
1299 $this->type("last_name", $lastName);
1300 $this->clickLink("_qf_Edit_next", "profilewrap4");
1302 $cid = $this->urlArg('id');
1303 $this->assertType('numeric', $cid);
1304 // Is status message correct?
1305 $this->assertTextPresent("Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!");
1307 $this->openCiviPage("admin/uf/group", "reset=1");
1308 $this->click("link=Reserved Profiles");
1310 $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']");
1311 $this->waitForPageToLoad($this->getTimeoutMsec());
1313 $this->click("link=Add Field");
1314 $this->waitForElementPresent('_qf_Field_next-bottom');
1316 $this->select('field_name[0]', 'value=Contact');
1317 $this->select('field_name[1]', 'label=Image Url');
1318 $this->click('field_name[1]');
1319 $this->click('_qf_Field_next-bottom');
1320 $this->waitForPageToLoad($this->getTimeoutMsec());
1322 // We need a payment processor
1323 $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7);
1324 $processorType = 'Dummy';
1325 $pageTitle = substr(sha1(rand()), 0, 7);
1327 $hash = substr(sha1(rand()), 0, 7);
1328 $amountSection = TRUE;
1333 $memberships = FALSE;
1334 $memPriceSetId = NULL;
1336 $profilePreId = NULL;
1337 $profilePostId = NULL;
1341 $honoreeSection = FALSE;
1342 $isAddPaymentProcessor = TRUE;
1343 $isPcpApprovalNeeded = FALSE;
1344 $isSeparatePayment = FALSE;
1346 // create a new online contribution page
1347 // create contribution page with randomized title and default params
1348 $pageId = $this->webtestAddContributionPage($hash,
1351 array($processorName => $processorType),
1365 $isAddPaymentProcessor,
1366 $isPcpApprovalNeeded,
1371 $this->_testOrganizationWithImageUpload($pageId, $cid, $pageTitle);
1373 $this->openCiviPage("admin/uf/group", "reset=1");
1374 $this->click("link=Reserved Profiles");
1376 $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']");
1377 $this->waitForPageToLoad($this->getTimeoutMsec());
1378 $this->click("xpath=//table[@id='option11']/tbody//tr/td/span[text()='Image Url']/../following-sibling::td[8]/span[2]/ul/li[2]/a");
1379 $this->waitForPageToLoad($this->getTimeoutMsec());
1380 $this->click('_qf_Field_next-bottom');
1381 $this->waitForPageToLoad($this->getTimeoutMsec());
1382 $this->waitForText('crm-notification-container', "Selected Profile Field has been deleted.");
1390 function _testOrganizationWithImageUpload($pageId, $cid, $pageTitle) {
1391 //Open Live Contribution Page
1392 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", '_qf_Main_upload-bottom');
1394 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
1395 $lastName = 'An' . substr(sha1(rand()), 0, 7);
1396 $orgName = 'org_11_' . substr(sha1(rand()), 0, 7);
1397 $this->type("email-5", $firstName . "@example.com");
1399 // onbehalforganization info
1400 $this->type("onbehalf_organization_name", $orgName);
1401 $this->type("onbehalf_phone-3-1", 9999999999);
1402 $this->type("onbehalf_email-3", "{$orgName}@example.com");
1403 $this->type("onbehalf_street_address-3", "Test Street Address");
1404 $this->type("onbehalf_city-3", "Test City");
1405 $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
1406 $this->click("onbehalf_country-3");
1407 $this->select("onbehalf_country-3", "label=United States");
1408 $this->click("onbehalf_state_province-3");
1409 $this->select("onbehalf_state_province-3", "label=Alabama");
1411 // check for upload field.
1412 $this->waitForElementPresent("onbehalf_image_URL");
1414 //header("Content-Type: image/png");
1415 $im = imagecreate(110, 20)
1416 or die("Cannot Initialize new GD image stream");
1417 $background_color = imagecolorallocate($im, 0, 0, 0);
1418 $text_color = imagecolorallocate($im, 233, 14, 91);
1419 imagestring($im, 1, 5, 5, "On Behalf-Org Logo", $text_color);
1420 imagepng($im,"/tmp/file.png");
1422 $imagePath = "/tmp/file.png";
1423 $this->webtestAttachFile('onbehalf_image_URL', $imagePath);
1427 $this->select("credit_card_type", "value=Visa");
1428 $this->type("credit_card_number", "4111111111111111");
1429 $this->type("cvv2", "000");
1430 $this->select("credit_card_exp_date[M]", "value=1");
1431 $this->select("credit_card_exp_date[Y]", "value=2020");
1434 $this->type("billing_first_name", $firstName . 'billing');
1435 $this->type("billing_last_name", $lastName . 'billing');
1436 $this->type("billing_street_address-5", "0121 Mount Highschool.");
1437 $this->type(" billing_city-5", "Shangai");
1438 $this->select("billing_country_id-5", "value=1228");
1439 $this->select("billing_state_province_id-5", "value=1004");
1440 $this->type("billing_postal_code-5", "94129");
1441 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
1443 $this->click("_qf_Confirm_next-bottom");
1444 $this->waitForPageToLoad($this->getTimeoutMsec());
1446 // Type search name in autocomplete.
1447 $this->click('sort_name_navigation');
1448 $this->type('css=input#sort_name_navigation', $orgName);
1449 $this->typeKeys('css=input#sort_name_navigation', $orgName);
1451 // Wait for result list.
1452 $this->waitForElementPresent("css=div.ac_results-inner li");
1454 // Visit organization page.
1455 $this->click("css=div.ac_results-inner li");
1456 $this->waitForPageToLoad($this->getTimeoutMsec());
1458 //check whether the image is present
1459 $this->assertTrue($this->isElementPresent("xpath=//div[@id='crm-contact-thumbnail']/div/a/img"));