3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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);
557 function _testOrganization($pageId, $cid, $pageTitle) {
558 //Open Live Contribution Page
559 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom");
561 $this->waitForElementPresent("onbehalf_state_province-3");
563 $this->waitForElementPresent("onbehalf_phone-3-1");
564 $this->type("onbehalf_phone-3-1", 9999999999);
565 $this->waitForElementPresent("onbehalf_email-3");
566 $this->type("onbehalf_email-3", "org@example.com");
567 $this->type("onbehalf_street_address-3", "Test Street Address");
568 $this->type("onbehalf_city-3", "Test City");
569 $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
570 $this->click("onbehalf_country-3");
571 $this->select("onbehalf_country-3", "label=United States");
572 $this->click("onbehalf_state_province-3");
573 $this->select("onbehalf_state_province-3", "label=Alabama");
575 $this->waitForElementPresent("_qf_Main_upload-bottom");
576 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
578 $this->click("_qf_Confirm_next-bottom");
579 $this->waitForPageToLoad($this->getTimeoutMsec());
583 function _testAnomoyousOganization($pageId, $cid, $pageTitle) {
584 //Open Live Contribution Page
585 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom");
587 $this->click('CIVICRM_QFID_0_8');
588 $this->type('css=div.other_amount-section input', 60);
590 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
591 $lastName = 'An' . substr(sha1(rand()), 0, 7);
592 $orgName = 'org_11_' . substr(sha1(rand()), 0, 7);
593 $this->type("email-5", $firstName . "@example.com");
595 // enable onbehalforganization block
596 $this->click("is_for_organization");
597 $this->waitForElementPresent("onbehalf_state_province-3");
599 // onbehalforganization info
600 $this->type("onbehalf_organization_name", $orgName);
601 $this->type("onbehalf_phone-3-1", 9999999999);
602 $this->type("onbehalf_email-3", "{$orgName}@example.com");
603 $this->type("onbehalf_street_address-3", "Test Street Address");
604 $this->type("onbehalf_city-3", "Test City");
605 $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
606 $this->click("onbehalf_country-3");
607 $this->select("onbehalf_country-3", "label=United States");
608 $this->click("onbehalf_state_province-3");
609 $this->select("onbehalf_state_province-3", "label=Alabama");
612 $this->select("credit_card_type", "value=Visa");
613 $this->type("credit_card_number", "4111111111111111");
614 $this->type("cvv2", "000");
615 $this->select("credit_card_exp_date[M]", "value=1");
616 $this->select("credit_card_exp_date[Y]", "value=2020");
619 $this->type("billing_first_name", $firstName . 'billing');
620 $this->type("billing_last_name", $lastName . 'billing');
621 $this->type("billing_street_address-5", "0121 Mount Highschool.");
622 $this->type(" billing_city-5", "Shangai");
623 $this->select("billing_country_id-5", "value=1228");
624 $this->select("billing_state_province_id-5", "value=1004");
625 $this->type("billing_postal_code-5", "94129");
626 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
628 $this->click("_qf_Confirm_next-bottom");
629 $this->waitForPageToLoad($this->getTimeoutMsec());
631 //login to check contribution
633 // Log in using webtestLogin() method
634 $this->webtestLogin();
637 $this->openCiviPage("contribute/search", "reset=1");
638 $this->type("sort_name", $orgName);
639 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
640 $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom");
642 // verify contrb created
648 foreach ($expected as $value => $label) {
649 $this->verifyText("xpath=id( 'ContributionView' )/div[2]/table[1]/tbody/tr[$value]/td[2]", preg_quote($label));
653 function _testUserWithOneRelationship($pageId, $cid, $pageTitle) {
654 $this->webtestLogin('admin');
657 $groupName = $this->WebtestAddGroup();
658 $this->openCiviPage("group", "reset=1", "_qf_Search_refresh");
659 $groupId = $this->getText("xpath=//table[@id='crm-group-selector']/tbody//tr/td[text()='{$groupName}']/../td[2]");
661 $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
663 $this->click('link=Edit');
664 $this->waitForElementPresent('_qf_Contact_cancel-bottom');
665 $this->click('addressBlock');
666 $this->waitForElementPresent('link=Another Address');
669 $this->select('address_1_location_type_id', 'label=Billing');
670 $this->type('address_1_street_address', '0121 Mount Highschool.');
671 $this->type('address_1_city', "Shangai");
672 $this->type('address_1_postal_code', "94129");
673 $this->select('address_1_country_id', "value=1228");
674 $this->select('address_1_state_province_id', "value=1004");
675 $this->click('_qf_Contact_upload_view-bottom');
676 $this->waitForPageToLoad($this->getTimeoutMsec());
678 // add contact to group
680 $this->click("css=li#tab_group a");
681 $this->waitForElementPresent("group_id");
684 $this->select("group_id", "label={$groupName}");
685 $this->click("_qf_GroupContact_next");
686 $this->waitForPageToLoad($this->getTimeoutMsec());
688 $this->openCiviPage("admin/custom/group", "action=add&reset=1", "_qf_Group_next-bottom");
690 // fill in a unique title for the custom group
691 $groupTitle = "Custom Group" . substr(sha1(rand()), 0, 7);
692 $this->type("title", $groupTitle);
694 // select the group this custom data set extends
695 $this->select("extends[0]", "value=Contribution");
696 $this->waitForElementPresent("extends[1]");
698 // save the custom group
699 $this->click("_qf_Group_next-bottom");
700 $this->waitForElementPresent("_qf_Field_next_new-bottom");
701 $this->assertTrue($this->isTextPresent("Your custom field set '$groupTitle' has been added. You can add custom fields now."));
703 // add a custom field to the custom group
704 $fieldTitle = "Custom Field " . substr(sha1(rand()), 0, 7);
705 $this->type("label", $fieldTitle);
707 $this->select("data_type[1]", "value=Text");
708 $this->click('_qf_Field_next-bottom');
710 $this->waitForPageToLoad($this->getTimeoutMsec());
711 $this->assertTrue($this->isTextPresent("Your custom field '$fieldTitle' has been saved."));
712 $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"));
714 // Enable CiviCampaign module if necessary
715 $this->enableComponents("CiviCampaign");
717 // add the required permission
718 $permission = array('edit-2-administer-civicampaign');
719 $this->changePermissions($permission);
721 // Log in as normal user
722 $this->webtestLogin();
724 $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom");
726 $title = 'Campaign ' . substr(sha1(rand()), 0, 7);
727 $this->type("title", $title);
729 // select the campaign type
730 $this->select("campaign_type_id", "value=2");
732 // fill in the description
733 $this->type("description", "This is a test campaign");
735 // include groups for the campaign
736 $this->addSelection("includeGroups-f", "label={$groupName}");
737 $this->click("//option[@value={$groupId}]");
740 // fill the end date for campaign
741 $this->webtestFillDate("end_date", "+1 year");
743 // select campaign status
744 $this->select("status_id", "value=2");
747 $this->click("_qf_Campaign_upload-bottom");
748 $this->waitForElementPresent("xpath=//div[@id='campaigns_wrapper']//table[@id='campaigns']/tbody//tr/td[3][text()='{$title}']");
749 $this->assertTrue($this->isTextPresent("Campaign {$title} has been saved."), "Status message didn't show up after saving!");
751 $this->openCiviPage("admin/uf/group", "reset=1");
752 $this->click("link=Reserved Profiles");
754 $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']");
755 $this->waitForPageToLoad($this->getTimeoutMsec());
757 $this->click("link=Add Field");
758 $this->waitForElementPresent('_qf_Field_next-bottom');
759 $this->select('field_name[0]', 'value=Contribution');
760 $this->select('field_name[1]', 'label=Campaign');
761 $this->click('field_name[1]');
762 $this->click('_qf_Field_next_new-bottom');
763 $this->waitForPageToLoad($this->getTimeoutMsec());
765 $this->select('field_name[0]', 'value=Contribution');
766 $this->select('field_name[1]', "label=$fieldTitle :: $groupTitle");
767 $this->click('field_name[1]');
768 $this->click('_qf_Field_next-bottom');
769 $this->waitForPageToLoad($this->getTimeoutMsec());
770 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$fieldTitle}' has been saved to 'On Behalf Of Organization'."));
772 // Open Page to create Organization
773 $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom");
774 $orgName1 = 'org1_' . substr(sha1(rand()), 0, 7);
776 // Type Organization name
777 $this->type("organization_name", $orgName1);
779 // Type Organizatio email for main
780 $this->type("email_1_email", "{$orgName1}@example.com");
781 $this->select("email_1_location_type_id", "value=3");
783 // type phone no for main
784 $this->type("phone_1_phone", 9999999999);
785 $this->select("phone_1_location_type_id", "value=3");
788 $this->click("addressBlock");
789 $this->waitForElementPresent("address_1_street_address");
791 //fill in address 1 for main
792 $this->select("address_1_location_type_id", "value=3");
793 $this->type("address_1_street_address", "{$orgName1} street address");
794 $this->type("address_1_city", "{$orgName1} city");
795 $this->type("address_1_postal_code", substr(sha1(rand()), 0, 4));
796 $this->assertTrue($this->isTextPresent("- select - United States"));
797 $this->select("address_1_state_province_id", "value=1019");
798 $this->type("address_1_geo_code_1", "1234");
799 $this->type("address_1_geo_code_2", "5678");
801 // Save the Organization
802 $this->click("_qf_Contact_upload_view-bottom");
803 $this->waitForPageToLoad($this->getTimeoutMsec());
806 $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1");
808 // select relationship type
809 $this->click("relationship_type_id");
810 $this->select("relationship_type_id", "value=4_a_b");
812 // search organization
813 $this->type('contact_1', $orgName1);
814 $this->click("contact_1");
815 $this->waitForElementPresent("css=div.ac_results-inner li");
816 $this->click("css=div.ac_results-inner li");
817 $this->assertContains($orgName1, $this->getValue('contact_1'), "autocomplete expected $orgName1 but didn’t find it in " . $this->getValue('contact_1'));
819 $this->waitForElementPresent("add_current_employer");
820 $this->click("add_current_employer");
823 $this->click("is_permission_a_b");
824 $this->click("is_permission_b_a");
827 $this->waitForElementPresent("details-save");
828 $this->click("details-save");
830 //Open Live Contribution Page
831 $this->openCiviPage("contribute/transact", "reset=1&id={$pageId}&cid=$cid", "onbehalf_state_province-3");
832 $this->click('CIVICRM_QFID_amount_other_radio_4');
833 $this->type('amount_other', 60);
834 $this->click('onbehalf_contribution_campaign_id');
835 $this->select('onbehalf_contribution_campaign_id', "label={$title}");
836 $this->type("onbehalf_custom_{$fieldId}", 'Test Subject');
839 $this->select("credit_card_type", "value=Visa");
840 $this->type("credit_card_number", "4111111111111111");
841 $this->type("cvv2", "000");
842 $this->select("credit_card_exp_date[M]", "value=1");
843 $this->select("credit_card_exp_date[Y]", "value=2020");
846 $this->type("billing_street_address-5", "0121 Mount Highschool.");
847 $this->type(" billing_city-5", "Shangai");
848 $this->select("billing_country_id-5", "value=1228");
849 $this->select("billing_state_province_id-5", "value=1004");
850 $this->type("billing_postal_code-5", "94129");
852 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
853 $this->click("_qf_Confirm_next-bottom");
854 $this->waitForPageToLoad($this->getTimeoutMsec());
857 $this->openCiviPage("contribute/search", "reset=1");
858 $this->type("sort_name", $orgName1);
859 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
860 $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom");
862 // verify contrb created
869 foreach ($expected as $value => $label) {
870 $this->verifyText("xpath=id( 'ContributionView' )/div[2]/table[1]/tbody/tr[$value]/td[2]", preg_quote($label));
873 $this->openCiviPage("admin/uf/group", "reset=1");
874 $this->click("link=Reserved Profiles");
876 $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']");
877 $this->waitForPageToLoad($this->getTimeoutMsec());
879 $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']");
880 $this->waitForElementPresent('_qf_Field_next-bottom');
882 $this->click('_qf_Field_next-bottom');
883 $this->waitForPageToLoad($this->getTimeoutMsec());
884 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'), "Status message didn't show up after saving!");
886 $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']");
887 $this->waitForElementPresent('_qf_Field_next-bottom');
889 $this->click('_qf_Field_next-bottom');
890 $this->waitForPageToLoad($this->getTimeoutMsec());
891 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'), "Status message didn't show up after saving!");
894 function _testUserWithMoreThanOneRelationship($pageId, $cid, $pageTitle) {
895 $this->webtestLogin('admin');
896 $this->waitForPageToLoad($this->getTimeoutMsec());
899 $groupName = $this->WebtestAddGroup();
900 $this->openCiviPage("group", "reset=1", '_qf_Search_refresh');
901 $this->click('_qf_Search_refresh');
902 $this->waitForElementPresent("xpath=//div[@id='group']/div[3]/table/tbody//tr/td[text()='{$groupName}']/../td[2]");
903 $groupId = $this->getText("xpath=//div[@id='group']/div[3]/table/tbody//tr/td[text()='{$groupName}']/../td[2]");
905 $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
907 $this->click('link=Edit');
908 $this->waitForElementPresent('_qf_Contact_cancel-bottom');
909 $this->click('addressBlock');
910 $this->waitForElementPresent('link=Another Address');
913 $this->select('address_1_location_type_id', 'label=Billing');
914 $this->type('address_1_street_address', '0121 Mount Highschool.');
915 $this->type('address_1_city', "Shangai");
916 $this->type('address_1_postal_code', "94129");
917 $this->select('address_1_country_id', "value=1228");
918 $this->select('address_1_state_province_id', "value=1004");
919 $this->click('_qf_Contact_upload_view-bottom');
920 $this->waitForPageToLoad($this->getTimeoutMsec());
922 // add contact to group
924 $this->click("css=li#tab_group a");
925 $this->waitForElementPresent("group_id");
928 $this->select("group_id", "label=$groupName");
929 $this->click("_qf_GroupContact_next");
930 $this->waitForPageToLoad($this->getTimeoutMsec());
932 $this->openCiviPage("admin/custom/group", "action=add&reset=1", "_qf_Group_next-bottom");
934 // fill in a unique title for the c$groupIdustom group
935 $groupTitle = "Members Custom Group" . substr(sha1(rand()), 0, 7);
936 $this->type("title", $groupTitle);
938 // select the group this custom data set extends
939 $this->select("extends[0]", "value=Membership");
940 $this->waitForElementPresent("extends[1]");
942 // save the custom group
943 $this->click("_qf_Group_next-bottom");
945 $this->waitForElementPresent("_qf_Field_next_new-bottom");
946 $this->assertTrue($this->isTextPresent("Your custom field set '$groupTitle' has been added. You can add custom fields now."));
948 // add a custom field to the custom group
949 $fieldTitle = "Member Custom Field " . substr(sha1(rand()), 0, 7);
950 $this->type("label", $fieldTitle);
952 $this->select("data_type[1]", "value=Text");
953 $this->click('_qf_Field_next-bottom');
955 $this->waitForPageToLoad($this->getTimeoutMsec());
956 $this->assertTrue($this->isTextPresent("Your custom field '$fieldTitle' has been saved."));
957 $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"));
959 // Enable CiviCampaign module if necessary
960 $this->enableComponents("CiviCampaign");
962 // add the required permission
963 $permission = array('edit-2-administer-civicampaign');
964 $this->changePermissions($permission);
966 // Log in as normal user
967 $this->webtestLogin();
969 $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom");
971 $title = 'Campaign ' . substr(sha1(rand()), 0, 7);
972 $this->type("title", $title);
974 // select the campaign type
975 $this->select("campaign_type_id", "value=2");
977 // fill in the description
978 $this->type("description", "This is a test campaign");
980 // include groups for the campaign
981 $this->addSelection("includeGroups-f", "label={$groupName}");
982 $this->click("//option[@value={$groupId}]");
985 // fill the end date for campaign
986 $this->webtestFillDate("end_date", "+1 year");
988 // select campaign status
989 $this->select("status_id", "value=2");
992 $this->click("_qf_Campaign_upload-bottom");
993 $this->waitForPageToLoad($this->getTimeoutMsec());
995 $this->assertTrue($this->isTextPresent("Campaign {$title} has been saved."), "Status message didn't show up after saving!");
997 $this->openCiviPage("admin/uf/group", "reset=1");
998 $this->click("link=Reserved Profiles");
999 $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']");
1000 $this->waitForPageToLoad($this->getTimeoutMsec());
1002 $this->click("link=Add Field");
1003 $this->waitForElementPresent('_qf_Field_next-bottom');
1004 $this->select('field_name[0]', 'value=Membership');
1005 $this->select('field_name[1]', 'label=Campaign');
1006 $this->click('field_name[1]');
1007 $this->clickLink('_qf_Field_next_new-bottom', '_qf_Field_cancel-bottom');
1009 $this->select('field_name[0]', 'value=Membership');
1010 $this->select('field_name[1]', "label=$fieldTitle :: $groupTitle");
1011 $this->click('field_name[1]');
1012 $this->click('_qf_Field_next-bottom');
1013 $this->waitForPageToLoad($this->getTimeoutMsec());
1014 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$fieldTitle}' has been saved to 'On Behalf Of Organization'."),
1015 "Status message didn't show up after saving!"
1018 // Open Page to create Organization 1
1019 $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom");
1020 $orgName1 = 'org1_' . substr(sha1(rand()), 0, 7);
1022 // Type Organization name
1023 $this->type("organization_name", $orgName1);
1025 // Type Organizatio email for main
1026 $this->type("email_1_email", "{$orgName1}@example.com");
1027 $this->select("email_1_location_type_id", "value=3");
1029 // type phone no for main
1030 $this->type("phone_1_phone", substr(sha1(rand()), 0, 4));
1031 $this->select("phone_1_location_type_id", "value=3");
1034 $this->click("addressBlock");
1035 $this->waitForElementPresent("address_1_street_address");
1037 //fill in address 1 for main
1038 $this->select("address_1_location_type_id", "value=3");
1039 $this->type("address_1_street_address", "{$orgName1} street address");
1040 $this->type("address_1_city", "{$orgName1} city");
1041 $this->type("address_1_postal_code", "9999999999");
1042 $this->assertTrue($this->isTextPresent("- select - United States"));
1043 $this->select("address_1_state_province_id", "value=1019");
1044 $this->type("address_1_geo_code_1", "1234");
1045 $this->type("address_1_geo_code_2", "5678");
1047 // Save the Organization
1048 $this->click("_qf_Contact_upload_view-bottom");
1049 $this->waitForPageToLoad($this->getTimeoutMsec());
1051 // create second orzanization
1052 $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom");
1053 $orgName2 = 'org2_' . substr(sha1(rand()), 0, 7);
1055 // Type Organization name
1056 $this->type("organization_name", $orgName2);
1058 // Type Organizatio email for main
1059 $this->type("email_1_email", "{$orgName2}@example.com");
1060 $this->select("email_1_location_type_id", "value=3");
1062 // type phone no for main
1063 $this->type("phone_1_phone", substr(sha1(rand()), 0, 4));
1064 $this->select("phone_1_location_type_id", "value=3");
1067 $this->click("addressBlock");
1068 $this->waitForElementPresent("address_1_street_address");
1070 //fill in address 1 for main
1071 $this->select("address_1_location_type_id", "value=3");
1072 $this->type("address_1_street_address", "{$orgName2} street address");
1073 $this->type("address_1_city", "{$orgName2} city");
1074 $this->type("address_1_postal_code", "7777777777");
1075 $this->assertTrue($this->isTextPresent("- select - United States"));
1076 $this->select("address_1_state_province_id", "value=1019");
1077 $this->type("address_1_geo_code_1", "1224");
1078 $this->type("address_1_geo_code_2", "5628");
1080 // Save the Organization
1081 $this->click("_qf_Contact_upload_view-bottom");
1082 $this->waitForPageToLoad($this->getTimeoutMsec());
1084 // create Membership type
1085 $title1 = "Membership Type" . substr(sha1(rand()), 0, 7);
1086 $this->openCiviPage("admin/member/membershipType", "reset=1&action=browse");
1088 $this->click("link=Add Membership Type");
1089 $this->waitForElementPresent('_qf_MembershipType_cancel-bottom');
1091 $this->type('name', $title1);
1092 $this->type('member_org', $orgName1);
1093 $this->click('_qf_MembershipType_refresh');
1094 $this->waitForElementPresent("xpath=//div[@id='membership_type_form']/fieldset/table[2]/tbody/tr[2]/td[2]");
1096 $this->type('minimum_fee', '50');
1098 $this->select( 'financial_type_id', 'value=2' );
1100 $this->type('duration_interval', 1);
1101 $this->select('duration_unit', "label=year");
1103 $this->select('period_type', "label=fixed");
1104 $this->waitForElementPresent('fixed_period_rollover_day[d]');
1106 $this->select('fixed_period_start_day[M]', 'value=4');
1107 $this->select('fixed_period_rollover_day[M]', 'value=1');
1109 $this->select('relationship_type_id', 'value=4_b_a');
1111 $this->click('_qf_MembershipType_upload-bottom');
1112 $this->waitForElementPresent('link=Add Membership Type');
1113 $this->assertTrue($this->isTextPresent("The membership type '$title1' has been saved."));
1114 $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"));
1117 $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1");
1119 // select relationship type
1120 $this->click("relationship_type_id");
1121 $this->select("relationship_type_id", "value=4_a_b");
1123 // search organization
1124 $this->type('contact_1', $orgName1);
1125 $this->click("contact_1");
1126 $this->waitForElementPresent("css=div.ac_results-inner li");
1127 $this->click("css=div.ac_results-inner li");
1128 $this->assertContains($orgName1, $this->getValue('contact_1'), "autocomplete expected $orgName1 but didn’t find it in " . $this->getValue('contact_1'));
1131 $this->click("is_permission_a_b");
1132 $this->click("is_permission_b_a");
1134 // save relationship
1135 $this->click("details-save");
1138 $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1");
1140 // select relationship type
1141 $this->click("relationship_type_id");
1142 $this->select("relationship_type_id", "value=4_a_b");
1144 // search organization
1145 $this->type('contact_1', $orgName2);
1146 $this->click("contact_1");
1147 $this->waitForElementPresent("css=div.ac_results-inner li");
1148 $this->click("css=div.ac_results-inner li");
1149 $this->assertContains($orgName2, $this->getValue('contact_1'), "autocomplete expected $orgName2 but didn’t find it in " . $this->getValue('contact_1'));
1152 $this->click("is_permission_a_b");
1153 $this->click("is_permission_b_a");
1155 // save relationship
1156 $this->click("details-save");
1158 // set membership type
1159 $this->openCiviPage("admin/contribute/membership", "reset=1&action=update&id=$pageId", "_qf_MembershipBlock_upload_done-bottom");
1160 $this->click("member_is_active");
1161 $this->click("membership_type[{$typeId}]");
1162 $this->click("xpath=//div[@id='memberFields']//table[@class='report']/tbody//tr/td[1]/label[text()='{$title1}']/../../td[2]/input");
1163 $this->click('_qf_MembershipBlock_upload_done-bottom');
1164 $this->waitForPageToLoad($this->getTimeoutMsec());
1166 //Open Live Membership Page
1167 $this->openCiviPage('contribute/transact', "reset=1&id=$pageId&cid=$cid", "_qf_Main_upload-bottom");
1168 $this->click('CIVICRM_QFID_amount_other_radio_4');
1169 $this->type('amount_other', 60);
1170 $this->click('onbehalf_organization_name');
1171 $this->type('onbehalf_organization_name', $orgName1);
1172 $this->typeKeys('onbehalf_organization_name', $orgName1);
1173 $this->click("onbehalf_organization_name");
1174 $this->waitForElementPresent("css=div.ac_results-inner li");
1175 $this->click("css=div.ac_results-inner li");
1176 // Because it tends to cause problems, all uses of sleep() must be justified in comments
1177 // Sleep should never be used for wait for anything to load from the server
1178 // Justification for this instance: FIXME
1180 $this->click('onbehalf_member_campaign_id');
1181 $this->select('onbehalf_member_campaign_id', "label={$title}");
1182 $this->type("onbehalf_custom_{$fieldId}", 'Test Subject');
1184 $this->assertContains($orgName1, $this->getValue('onbehalf_organization_name'), "autocomplete expected $orgName1 but didn’t find it in " . $this->getValue('onbehalf_organization_name'));
1187 $this->select("credit_card_type", "value=Visa");
1188 $this->type("credit_card_number", "4111111111111111");
1189 $this->type("cvv2", "000");
1190 $this->select("credit_card_exp_date[M]", "value=1");
1191 $this->select("credit_card_exp_date[Y]", "value=2020");
1193 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
1194 $this->click("_qf_Confirm_next-bottom");
1195 $this->waitForPageToLoad($this->getTimeoutMsec());
1197 //Find Membership for organization
1198 $this->openCiviPage("member/search", "reset=1");
1199 $this->type("sort_name", $orgName1);
1200 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='memberSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
1201 $this->clickLink("xpath=//div[@id='memberSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_MembershipView_cancel-bottom");
1203 //verify contrb created
1209 foreach ($expected as $value => $label) {
1210 $this->verifyText("xpath=//form[@id='MembershipView']/div[2]/div/table/tbody/tr[$value]/td[2]", preg_quote($label));
1213 // find membership for contact in relationship
1214 $this->openCiviPage("contact/view", "reset=1&force=1&cid={$cid}");
1215 $this->click("css=li#tab_member a");
1216 $this->waitForElementPresent("xpath=//div[@id='memberships']/div/table//tbody//tr/td[1][text()='{$title1}']");
1217 $this->click("xpath=//div[@id='memberships']/div/table//tbody//tr/td[1][text()='{$title1}']/../td[7]/span/a[text()='View']");
1218 $this->waitForPageToLoad($this->getTimeoutMsec());
1220 //verify contrb created
1225 foreach ($expected as $value => $label) {
1226 $this->verifyText("xpath=//form[@id='MembershipView']/div[2]/div/table/tbody/tr[$value]/td[2]", preg_quote($label));
1229 $this->openCiviPage("admin/uf/group", "reset=1");
1230 $this->click("link=Reserved Profiles");
1231 $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']");
1232 $this->waitForPageToLoad($this->getTimeoutMsec());
1234 $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']");
1235 $this->waitForElementPresent('_qf_Field_next-bottom');
1237 $this->click('_qf_Field_next-bottom');
1238 $this->waitForPageToLoad($this->getTimeoutMsec());
1239 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'),
1240 "Status message didn't show up after saving!"
1243 $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']");
1244 $this->waitForElementPresent('_qf_Field_next-bottom');
1246 $this->click('_qf_Field_next-bottom');
1247 $this->waitForPageToLoad($this->getTimeoutMsec());
1248 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'),
1249 "Status message didn't show up after saving!"
1252 $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
1253 $this->click("css=li#tab_rel a");
1255 $this->waitForElementPresent("xpath=//div[@id='current-relationships']/div/table/tbody//tr/td[2]/a[text()='{$orgName1}']");
1256 $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']");
1258 // Check confirmation alert.
1259 $this->assertTrue((bool)preg_match("/^Are you sure you want to delete this relationship?/",
1260 $this->getConfirmation()
1262 $this->chooseOkOnNextConfirmation();
1263 $this->waitForPageToLoad($this->getTimeoutMsec());
1264 $this->assertTrue($this->isTextPresent('Selected relationship has been deleted successfully.'),
1265 "Status message didn't show up after saving!"
1269 function testOnBehalfOfOrganizationWithImage() {
1270 $this->webtestLogin();
1272 $this->openCiviPage("profile/edit", "reset=1&gid=4");
1273 $firstName = 'John_x_' . substr(sha1(rand()), 0, 7);
1274 $lastName = 'Anderson_c_' . substr(sha1(rand()), 0, 7);
1276 $this->waitForPageToLoad($this->getTimeoutMsec());
1277 $this->waitForElementPresent("_qf_Edit_next");
1278 $this->type("first_name", $firstName);
1279 $this->type("last_name", $lastName);
1280 $this->clickLink("_qf_Edit_next", "profilewrap4");
1282 $cid = $this->urlArg('id');
1283 $this->assertType('numeric', $cid);
1284 // Is status message correct?
1285 $this->assertTextPresent("Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!");
1287 $this->openCiviPage("admin/uf/group", "reset=1");
1288 $this->click("link=Reserved Profiles");
1290 $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']");
1291 $this->waitForPageToLoad($this->getTimeoutMsec());
1293 $this->click("link=Add Field");
1294 $this->waitForElementPresent('_qf_Field_next-bottom');
1296 $this->select('field_name[0]', 'value=Contact');
1297 $this->select('field_name[1]', 'label=Image Url');
1298 $this->click('field_name[1]');
1299 $this->click('_qf_Field_next-bottom');
1300 $this->waitForPageToLoad($this->getTimeoutMsec());
1302 // We need a payment processor
1303 $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7);
1304 $processorType = 'Dummy';
1305 $pageTitle = substr(sha1(rand()), 0, 7);
1307 $hash = substr(sha1(rand()), 0, 7);
1308 $amountSection = TRUE;
1313 $memberships = FALSE;
1314 $memPriceSetId = NULL;
1316 $profilePreId = NULL;
1317 $profilePostId = NULL;
1321 $honoreeSection = FALSE;
1322 $isAddPaymentProcessor = TRUE;
1323 $isPcpApprovalNeeded = FALSE;
1324 $isSeparatePayment = FALSE;
1326 // create a new online contribution page
1327 // create contribution page with randomized title and default params
1328 $pageId = $this->webtestAddContributionPage($hash,
1331 array($processorName => $processorType),
1345 $isAddPaymentProcessor,
1346 $isPcpApprovalNeeded,
1351 $this->_testOrganizationWithImageUpload($pageId, $cid, $pageTitle);
1353 $this->openCiviPage("admin/uf/group", "reset=1");
1354 $this->click("link=Reserved Profiles");
1356 $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']");
1357 $this->waitForPageToLoad($this->getTimeoutMsec());
1358 $this->click("xpath=//table[@id='option11']/tbody//tr/td/span[text()='Image Url']/../following-sibling::td[8]/span[2]/ul/li[2]/a");
1359 $this->waitForPageToLoad($this->getTimeoutMsec());
1360 $this->click('_qf_Field_next-bottom');
1361 $this->waitForPageToLoad($this->getTimeoutMsec());
1362 $this->waitForText('crm-notification-container', "Selected Profile Field has been deleted.");
1365 function _testOrganizationWithImageUpload($pageId, $cid, $pageTitle) {
1366 //Open Live Contribution Page
1367 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", '_qf_Main_upload-bottom');
1369 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
1370 $lastName = 'An' . substr(sha1(rand()), 0, 7);
1371 $orgName = 'org_11_' . substr(sha1(rand()), 0, 7);
1372 $this->type("email-5", $firstName . "@example.com");
1374 // onbehalforganization info
1375 $this->type("onbehalf_organization_name", $orgName);
1376 $this->type("onbehalf_phone-3-1", 9999999999);
1377 $this->type("onbehalf_email-3", "{$orgName}@example.com");
1378 $this->type("onbehalf_street_address-3", "Test Street Address");
1379 $this->type("onbehalf_city-3", "Test City");
1380 $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
1381 $this->click("onbehalf_country-3");
1382 $this->select("onbehalf_country-3", "label=United States");
1383 $this->click("onbehalf_state_province-3");
1384 $this->select("onbehalf_state_province-3", "label=Alabama");
1386 // check for upload field.
1387 $this->waitForElementPresent("onbehalf_image_URL");
1389 //header("Content-Type: image/png");
1390 $im = imagecreate(110, 20)
1391 or die("Cannot Initialize new GD image stream");
1392 $background_color = imagecolorallocate($im, 0, 0, 0);
1393 $text_color = imagecolorallocate($im, 233, 14, 91);
1394 imagestring($im, 1, 5, 5, "On Behalf-Org Logo", $text_color);
1395 imagepng($im,"/tmp/file.png");
1397 $imagePath = "/tmp/file.png";
1398 $this->webtestAttachFile('onbehalf_image_URL', $imagePath);
1402 $this->select("credit_card_type", "value=Visa");
1403 $this->type("credit_card_number", "4111111111111111");
1404 $this->type("cvv2", "000");
1405 $this->select("credit_card_exp_date[M]", "value=1");
1406 $this->select("credit_card_exp_date[Y]", "value=2020");
1409 $this->type("billing_first_name", $firstName . 'billing');
1410 $this->type("billing_last_name", $lastName . 'billing');
1411 $this->type("billing_street_address-5", "0121 Mount Highschool.");
1412 $this->type(" billing_city-5", "Shangai");
1413 $this->select("billing_country_id-5", "value=1228");
1414 $this->select("billing_state_province_id-5", "value=1004");
1415 $this->type("billing_postal_code-5", "94129");
1416 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
1418 $this->click("_qf_Confirm_next-bottom");
1419 $this->waitForPageToLoad($this->getTimeoutMsec());
1421 // Type search name in autocomplete.
1422 $this->click('sort_name_navigation');
1423 $this->type('css=input#sort_name_navigation', $orgName);
1424 $this->typeKeys('css=input#sort_name_navigation', $orgName);
1426 // Wait for result list.
1427 $this->waitForElementPresent("css=div.ac_results-inner li");
1429 // Visit organization page.
1430 $this->click("css=div.ac_results-inner li");
1431 $this->waitForPageToLoad($this->getTimeoutMsec());
1433 //check whether the image is present
1434 $this->assertTrue($this->isElementPresent("xpath=//div[@id='crm-contact-thumbnail']/div/a/img"));