3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License along with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
27 require_once 'CiviTest/CiviSeleniumTestCase.php';
30 * Class WebTest_Contribute_OnBehalfOfOrganization
32 class WebTest_Contribute_OnBehalfOfOrganization
extends CiviSeleniumTestCase
{
33 protected $pageno = '';
34 protected function setUp() {
38 function testOnBehalfOfOrganization() {
39 $this->webtestLogin();
41 // create new individual
42 $firstName = 'John_' . substr(sha1(rand()), 0, 7);
43 $lastName = 'Anderson_' . substr(sha1(rand()), 0, 7);
44 $email = "{$firstName}.{$lastName}@example.com";
45 $contactParams = array(
46 'first_name' => $firstName,
47 'last_name' => $lastName,
50 $streetAddress = "100 Main Street";
52 //adding contact for membership sign up
53 $this->webtestAddContact($firstName, $lastName, $email);
54 $cid = $this->urlArg('cid');
56 // We need a payment processor
57 $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7);
58 $processorType = 'Dummy';
59 $pageTitle = substr(sha1(rand()), 0, 7);
61 $hash = substr(sha1(rand()), 0, 7);
62 $amountSection = TRUE;
64 $onBehalf = 'optional';
68 $memPriceSetId = NULL;
71 $profilePostId = NULL;
75 $honoreeSection = FALSE;
76 $isAddPaymentProcessor = TRUE;
77 $isPcpApprovalNeeded = FALSE;
78 $isSeparatePayment = FALSE;
80 // create a new online contribution page
81 // create contribution page with randomized title and default params
82 $pageId = $this->webtestAddContributionPage($hash,
85 array($processorName => $processorType),
99 $isAddPaymentProcessor,
100 $isPcpApprovalNeeded,
106 $this->webtestLogout();
107 //$this->_testAnomoyousOganization($pageId, $cid, $pageTitle);
108 $this->webtestLogout();
109 $this->_testUserWithOneRelationship($pageId, $cid, $pageTitle);
110 $this->webtestLogout();
111 $this->_testUserWithMoreThanOneRelationship($pageId, $cid, $pageTitle);
114 function testOnBehalfOfOrganizationWithMembershipData() {
115 $this->webtestLogin();
117 // create new individual
118 $this->openCiviPage("profile/edit", "reset=1&gid=4");
119 $firstName = 'John_x_' . substr(sha1(rand()), 0, 7);
120 $lastName = 'Anderson_c_' . substr(sha1(rand()), 0, 7);
122 $this->waitForPageToLoad($this->getTimeoutMsec());
123 $this->waitForElementPresent("_qf_Edit_next");
124 $this->type("first_name", $firstName);
125 $this->type("last_name", $lastName);
126 $this->clickLink("_qf_Edit_next", "profilewrap4");
128 // Is status message correct?
129 $this->assertTextPresent("Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!");
133 $this->openCiviPage("admin/custom/group", "action=add&reset=1");
135 //fill custom group title
136 $customGroupTitle = 'custom_' . substr(sha1(rand()), 0, 7);
137 $this->click("title");
138 $this->type("title", $customGroupTitle);
140 //custom group extends
141 $this->click("extends[0]");
142 $this->select("extends[0]", "value=Membership");
143 //$this->click("//option[@value='Contact']");
144 $this->click("_qf_Group_next-bottom");
145 $this->waitForElementPresent("_qf_Field_cancel-bottom");
147 //Is custom group created?
148 $this->assertTrue($this->isTextPresent("Your custom field set '{$customGroupTitle}' has been added. You can add custom fields now."));
150 //add custom field - alphanumeric checkbox
151 $checkboxFieldLabel = 'custom_field' . substr(sha1(rand()), 0, 4);
152 $this->click("label");
153 $this->type("label", $checkboxFieldLabel);
154 $this->click("data_type[1]");
155 $this->select("data_type[1]", "value=CheckBox");
156 $this->click("//option[@value='CheckBox']");
157 $checkboxOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
158 $this->type("option_label_1", $checkboxOptionLabel1);
159 $this->type("option_value_1", "1");
160 $checkboxOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
161 $this->type("option_label_2", $checkboxOptionLabel2);
162 $this->type("option_value_2", "2");
163 $this->click("link=another choice");
164 $checkboxOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
165 $this->type("option_label_3", $checkboxOptionLabel3);
166 $this->type("option_value_3", "3");
168 //enter options per line
169 $this->type("options_per_line", "2");
171 //enter pre help message
172 $this->type("help_pre", "this is field pre help");
174 //enter post help message
175 $this->type("help_post", "this field post help");
178 $this->click("is_searchable");
181 $this->click("_qf_Field_next");
182 $this->waitForPageToLoad($this->getTimeoutMsec());
184 //Is custom field created?
185 $this->assertTrue($this->isTextPresent("Your custom field '$checkboxFieldLabel' has been saved."));
187 //create another custom field - Integer Radio
188 $this->click("//a[@id='newCustomField']/span");
189 $this->waitForPageToLoad($this->getTimeoutMsec());
190 $this->click("data_type[0]");
191 $this->select("data_type[0]", "value=1");
192 $this->click("//option[@value='1']");
193 $this->click("data_type[1]");
194 $this->select("data_type[1]", "value=Radio");
195 $this->click("//option[@value='Radio']");
197 $radioFieldLabel = 'custom_field' . substr(sha1(rand()), 0, 4);
198 $this->type("label", $radioFieldLabel);
199 $radioOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
200 $this->type("option_label_1", $radioOptionLabel1);
201 $this->type("option_value_1", "1");
202 $radioOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
203 $this->type("option_label_2", $radioOptionLabel2);
204 $this->type("option_value_2", "2");
205 $this->click("link=another choice");
206 $radioOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
207 $this->type("option_label_3", $radioOptionLabel3);
208 $this->type("option_value_3", "3");
210 //select options per line
211 $this->type("options_per_line", "3");
214 $this->type("help_pre", "this is field pre help");
216 //enter post help msg
217 $this->type("help_post", "this is field post help");
220 $this->click("is_searchable");
223 $this->click("_qf_Field_next");
224 $this->waitForPageToLoad($this->getTimeoutMsec());
226 //Is custom field created
227 $this->assertTrue($this->isTextPresent("Your custom field '$radioFieldLabel' has been saved."));
229 //add the above custom data to the On Behalf of Profile
230 $this->openCiviPage("admin/uf/group", "reset=1");
231 $this->click("link=Reserved Profiles");
233 $this->click("xpath=//div[@id='reserved-profiles']/div/div/table/tbody//tr/td[1][text()='On Behalf Of Organization']/../td[5]/span/a[text()='Fields']");
234 $this->waitForPageToLoad($this->getTimeoutMsec());
236 $this->click("link=Add Field");
237 $this->waitForElementPresent('_qf_Field_next-bottom');
238 $this->select('field_name[0]', 'value=Membership');
239 $label = $checkboxFieldLabel.' :: '. $customGroupTitle;
240 $this->select('field_name[1]', "label=$label");
241 $this->click('field_name[1]');
242 $this->click('_qf_Field_next_new-bottom');
243 $this->waitForPageToLoad($this->getTimeoutMsec());
245 $this->select('field_name[0]', 'value=Membership');
246 $label = $radioFieldLabel.' :: '. $customGroupTitle;
247 $this->select('field_name[1]', "label=$label");
248 $this->click('field_name[1]');
249 $this->click('_qf_Field_next-bottom');
250 $this->waitForPageToLoad($this->getTimeoutMsec());
251 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$radioFieldLabel}' has been saved to 'On Behalf Of Organization'."));
253 //create organisation
254 $orgName = "Org WebAccess ". substr(sha1(rand()), 0, 7);
255 $orgEmail = "org". substr(sha1(rand()), 0, 7) . "@web.com";
256 $this->webtestAddOrganization($orgName, $orgEmail);
258 $this->waitForPageToLoad($this->getTimeoutMsec());
259 $this->click("css=li#tab_member a");
261 $this->waitForElementPresent('link=Add Membership');
262 $this->click('link=Add Membership');
264 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
266 // fill in Membership Organization and Type
267 $this->select('membership_type_id[0]', "value=1");
268 $this->select('membership_type_id[1]', "value=1");
271 $sourceText = 'On behalf Membership Webtest';
272 $this->type('source', $sourceText);
274 $this->waitForElementPresent("css=div#{$customGroupTitle} div.crm-accordion-header");
275 $this->click("css=div#{$customGroupTitle} div.crm-accordion-header");
276 //$this->waitForElementPresent('_qf_Membership_cancel-bottom111');
278 // select newly created processor
279 $xpath = "xpath=//label[text() = '{$checkboxOptionLabel1}']/preceding-sibling::input[1]";
280 $this->assertTrue($this->isTextPresent($checkboxOptionLabel1));
281 $this->check($xpath);
283 $xpath = "xpath=//label[text() = '{$checkboxOptionLabel3}']/preceding-sibling::input[1]";
284 $this->assertTrue($this->isTextPresent($checkboxOptionLabel3));
285 $this->check($xpath);
287 $xpath = "xpath=//label[text() = '{$radioOptionLabel1}']/preceding-sibling::input[1]";
288 $this->assertTrue($this->isTextPresent($radioOptionLabel1));
289 $this->check($xpath);
291 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
292 $this->click('_qf_Membership_upload-bottom');
294 $this->waitForPageToLoad($this->getTimeoutMsec());
295 $this->click("css=li#tab_rel a");
297 $this->waitForElementPresent('link=Add Relationship');
298 $this->click('link=Add Relationship');
300 $this->waitForElementPresent('relationship_type_id');
301 $this->click("relationship_type_id");
302 $this->select("relationship_type_id", "label=Employer of");
303 // search organization
304 $this->type('contact_1', $firstName);
305 $this->click("contact_1");
306 $this->waitForElementPresent("css=div.ac_results-inner li");
307 $this->click("css=div.ac_results-inner li");
308 $this->assertContains($firstName, $this->getValue('contact_1'), "autocomplete expected $firstName but didn’t find it in " . $this->getValue('contact_1'));
311 $this->click("is_permission_a_b");
312 $this->click("is_permission_b_a");
315 $this->click("details-save");
316 $this->waitForPageToLoad($this->getTimeoutMsec());
318 // We need a payment processor
319 $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7);
320 $processorType = 'Dummy';
321 $pageTitle = substr(sha1(rand()), 0, 7);
323 $hash = substr(sha1(rand()), 0, 7);
324 $amountSection = TRUE;
330 $memPriceSetId = NULL;
332 $profilePreId = NULL;
333 $profilePostId = NULL;
337 $honoreeSection = FALSE;
338 $isAddPaymentProcessor = TRUE;
339 $isPcpApprovalNeeded = FALSE;
340 $isSeparatePayment = FALSE;
342 // create a new online contribution page
343 // create contribution page with randomized title and default params
344 $pageId = $this->webtestAddContributionPage($hash,
347 array($processorName => $processorType),
361 $isAddPaymentProcessor,
362 $isPcpApprovalNeeded,
368 //scenario 1 : add membership data in pre / post profile and check for formRule
370 $this->openCiviPage("admin/uf/group", "reset=1");
371 $this->click('link=Add Profile');
373 $profileTitle = "test profile" . substr(sha1(rand()), 0, 7);
374 // Add membership custom data field to profile
375 $this->waitForElementPresent('_qf_Group_cancel-bottom');
376 $this->type('title', $profileTitle);
377 $this->click('_qf_Group_next-bottom');
379 $this->waitForElementPresent('_qf_Field_cancel-bottom');
380 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now."));
382 $this->select('field_name[0]', "value=Membership");
383 $this->select('field_name[1]', "label={$checkboxFieldLabel} :: {$customGroupTitle}");
384 $this->click('field_name[1]');
385 $this->click('label');
387 // Clicking save and new
388 $this->click('_qf_Field_next_new-bottom');
389 $this->waitForPageToLoad($this->getTimeoutMsec());
390 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$checkboxFieldLabel}' has been saved to '{$profileTitle}'."));
392 $this->openCiviPage("admin/contribute/custom", "reset=1&action=update&id={$pageId}", '_qf_Custom_next-bottom');
393 $this->select('custom_pre_id', "label={$profileTitle}");
394 $this->click('_qf_Custom_next-bottom');
395 $this->waitForPageToLoad($this->getTimeoutMsec());
396 // Because it tends to cause problems, all uses of sleep() must be justified in comments
397 // Sleep should never be used for wait for anything to load from the server
398 // Justification for this instance: FIXME
400 $this->assertTrue($this->isTextPresent('You should move the membership related fields in the "On Behalf" profile for this Contribution Page'), "Form rule didn't showed up while incorrectly configuring membership fields profile for 'on behalf of' contribution page");
402 $this->select('custom_pre_id', "- select -");
403 $this->select('custom_post_id', "label={$profileTitle}");
404 $this->click('_qf_Custom_next-bottom');
405 $this->waitForPageToLoad($this->getTimeoutMsec());
406 // Because it tends to cause problems, all uses of sleep() must be justified in comments
407 // Sleep should never be used for wait for anything to load from the server
408 // Justification for this instance: FIXME
410 $this->assertTrue($this->isTextPresent('You should move the membership related fields in the "On Behalf" profile for this Contribution Page'), "Form rule didn't showed up while incorrectly configuring membership fields profile for 'on behalf of' contribution page");
412 //scenario 2 : disable 'on behalf of', add membership data in pre / post profile
413 //then try to add 'on behalf of' and check for formRule
414 //disable 'on behalf of'
415 $this->openCiviPage("admin/contribute/settings", "reset=1&action=update&id={$pageId}", '_qf_Settings_next-bottom');
416 $this->uncheck('is_organization');
417 $this->click('_qf_Settings_next-bottom');
418 $this->waitForPageToLoad($this->getTimeoutMsec());
420 //set a membership field profile for this contribution page
421 $this->click('css=li#tab_custom a');
422 $this->waitForElementPresent('_qf_Custom_next-bottom');
423 $this->select('custom_pre_id', "label={$profileTitle}");
424 $this->click('_qf_Custom_next-bottom');
425 $this->waitForPageToLoad($this->getTimeoutMsec());
427 //now visit the title settings page and configure the profile as on behalf of
428 $this->click('css=li#tab_settings a');
429 $this->waitForElementPresent('_qf_Settings_next-bottom');
430 $this->check('is_organization');
431 $this->click('_qf_Settings_next-bottom');
432 $this->waitForPageToLoad($this->getTimeoutMsec());
433 // Because it tends to cause problems, all uses of sleep() must be justified in comments
434 // Sleep should never be used for wait for anything to load from the server
435 // Justification for this instance: FIXME
437 $this->assertTrue($this->isTextPresent("You should move the membership related fields configured in 'Includes Profile (top of page)' to the 'On Behalf' profile for this Contribution Page"), "Form rule 'You should move the membership related fields configured in 'Includes Profile (top of page)' to the 'On Behalf' profile for this Contribution Page' didn't showed up");
440 $this->webtestLogout();
443 function testOnBehalfOfOrganizationWithOrgData() {
444 $this->webtestLogin();
446 $this->openCiviPage("profile/edit", "reset=1&gid=4");
447 $firstName = 'John_x_' . substr(sha1(rand()), 0, 7);
448 $lastName = 'Anderson_c_' . substr(sha1(rand()), 0, 7);
450 $this->waitForPageToLoad($this->getTimeoutMsec());
451 $this->waitForElementPresent("_qf_Edit_next");
452 $this->type("first_name", $firstName);
453 $this->type("last_name", $lastName);
454 $this->clickLink("_qf_Edit_next", "profilewrap4");
456 $cid = $this->urlArg('id');
457 // Is status message correct?
458 $this->assertTextPresent("Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!");
460 //add org fields to profile
461 $this->openCiviPage("admin/uf/group", "reset=1");
462 $this->click("link=Reserved Profiles");
464 $this->click("xpath=//div[@id='reserved-profiles']/div/div/table/tbody//tr/td[1][text()='On Behalf Of Organization']/../td[5]/span/a[text()='Fields']");
465 $this->waitForPageToLoad($this->getTimeoutMsec());
467 $this->click("link=Add Field");
468 $this->waitForElementPresent('_qf_Field_next-bottom');
470 $this->select('field_name[0]', 'value=Organization');
471 $this->select('field_name[1]', 'label=Legal Identifier');
472 $this->click('field_name[1]');
473 $this->click('_qf_Field_next_new-bottom');
474 $this->waitForPageToLoad($this->getTimeoutMsec());
476 $this->select('field_name[0]', 'value=Organization');
477 $this->select('field_name[1]', 'label=Legal Name');
478 $this->click('field_name[1]');
479 $this->click('_qf_Field_next-bottom');
480 $this->waitForPageToLoad($this->getTimeoutMsec());
482 //create organisation
483 $orgName = "Org WebAccess ". substr(sha1(rand()), 0, 7);
484 $orgEmail = "org". substr(sha1(rand()), 0, 7) . "@web.com";
485 $this->webtestAddOrganization($orgName, $orgEmail);
487 $this->waitForPageToLoad($this->getTimeoutMsec());
488 $this->click("css=li#tab_rel a");
490 $this->waitForElementPresent('link=Add Relationship');
491 $this->click('link=Add Relationship');
493 $this->waitForElementPresent('relationship_type_id');
494 $this->click("relationship_type_id");
495 $this->select("relationship_type_id", "label=Employer of");
496 // search organization
497 $this->type('contact_1', $firstName);
498 $this->click("contact_1");
499 $this->waitForElementPresent("css=div.ac_results-inner li");
500 $this->click("css=div.ac_results-inner li");
501 $this->assertContains($firstName, $this->getValue('contact_1'), "autocomplete expected $firstName but didn’t find it in " . $this->getValue('contact_1'));
504 $this->click("is_permission_a_b");
505 $this->click("is_permission_b_a");
508 $this->waitForElementPresent("details-save");
509 $this->click("details-save");
510 $this->waitForElementPresent("Relationships");
512 $pageTitle = substr(sha1(rand()), 0, 7);
514 $hash = substr(sha1(rand()), 0, 7);
515 $amountSection = TRUE;
521 $memPriceSetId = NULL;
523 $profilePreId = NULL;
524 $profilePostId = NULL;
528 $honoreeSection = FALSE;
529 $isAddPaymentProcessor = FALSE;
530 $isPcpApprovalNeeded = FALSE;
531 $isSeparatePayment = FALSE;
533 // create a new online contribution page
534 // create contribution page with randomized title and default params
535 $pageId = $this->webtestAddContributionPage($hash,
552 $isAddPaymentProcessor,
553 $isPcpApprovalNeeded,
558 $this->_testOrganization($pageId, $cid, $pageTitle);
566 function _testOrganization($pageId, $cid, $pageTitle) {
567 //Open Live Contribution Page
568 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom");
570 $this->waitForElementPresent("onbehalf_state_province-3");
572 $this->waitForElementPresent("onbehalf_phone-3-1");
573 $this->type("onbehalf_phone-3-1", 9999999999);
574 $this->waitForElementPresent("onbehalf_email-3");
575 $this->type("onbehalf_email-3", "org@example.com");
576 $this->type("onbehalf_street_address-3", "Test Street Address");
577 $this->type("onbehalf_city-3", "Test City");
578 $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
579 $this->click("onbehalf_country-3");
580 $this->select("onbehalf_country-3", "label=United States");
581 $this->click("onbehalf_state_province-3");
582 $this->select("onbehalf_state_province-3", "label=Alabama");
584 $this->waitForElementPresent("_qf_Main_upload-bottom");
585 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
587 $this->click("_qf_Confirm_next-bottom");
588 $this->waitForPageToLoad($this->getTimeoutMsec());
597 function _testAnomoyousOganization($pageId, $cid, $pageTitle) {
598 //Open Live Contribution Page
599 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom");
601 $this->click('CIVICRM_QFID_0_8');
602 $this->type('css=div.other_amount-section input', 60);
604 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
605 $lastName = 'An' . substr(sha1(rand()), 0, 7);
606 $orgName = 'org_11_' . substr(sha1(rand()), 0, 7);
607 $this->type("email-5", $firstName . "@example.com");
609 // enable onbehalforganization block
610 $this->click("is_for_organization");
611 $this->waitForElementPresent("onbehalf_state_province-3");
613 // onbehalforganization info
614 $this->type("onbehalf_organization_name", $orgName);
615 $this->type("onbehalf_phone-3-1", 9999999999);
616 $this->type("onbehalf_email-3", "{$orgName}@example.com");
617 $this->type("onbehalf_street_address-3", "Test Street Address");
618 $this->type("onbehalf_city-3", "Test City");
619 $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
620 $this->click("onbehalf_country-3");
621 $this->select("onbehalf_country-3", "label=United States");
622 $this->click("onbehalf_state_province-3");
623 $this->select("onbehalf_state_province-3", "label=Alabama");
626 $this->select("credit_card_type", "value=Visa");
627 $this->type("credit_card_number", "4111111111111111");
628 $this->type("cvv2", "000");
629 $this->select("credit_card_exp_date[M]", "value=1");
630 $this->select("credit_card_exp_date[Y]", "value=2020");
633 $this->type("billing_first_name", $firstName . 'billing');
634 $this->type("billing_last_name", $lastName . 'billing');
635 $this->type("billing_street_address-5", "0121 Mount Highschool.");
636 $this->type(" billing_city-5", "Shangai");
637 $this->select("billing_country_id-5", "value=1228");
638 $this->select("billing_state_province_id-5", "value=1004");
639 $this->type("billing_postal_code-5", "94129");
640 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
642 $this->click("_qf_Confirm_next-bottom");
643 $this->waitForPageToLoad($this->getTimeoutMsec());
645 //login to check contribution
647 // Log in using webtestLogin() method
648 $this->webtestLogin();
651 $this->openCiviPage("contribute/search", "reset=1");
652 $this->type("sort_name", $orgName);
653 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
654 $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom");
656 // verify contrb created
662 foreach ($expected as $value => $label) {
663 $this->verifyText("xpath=id( 'ContributionView' )/div[2]/table[1]/tbody/tr[$value]/td[2]", preg_quote($label));
672 function _testUserWithOneRelationship($pageId, $cid, $pageTitle) {
673 $this->webtestLogin('admin');
676 $groupName = $this->WebtestAddGroup();
677 $this->openCiviPage("group", "reset=1", "_qf_Search_refresh");
678 $groupId = $this->getText("xpath=//table[@id='crm-group-selector']/tbody//tr/td[text()='{$groupName}']/../td[2]");
680 $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
682 $this->click('link=Edit');
683 $this->waitForElementPresent('_qf_Contact_cancel-bottom');
684 $this->click('addressBlock');
685 $this->waitForElementPresent('link=Another Address');
688 $this->select('address_1_location_type_id', 'label=Billing');
689 $this->type('address_1_street_address', '0121 Mount Highschool.');
690 $this->type('address_1_city', "Shangai");
691 $this->type('address_1_postal_code', "94129");
692 $this->select('address_1_country_id', "value=1228");
693 $this->select('address_1_state_province_id', "value=1004");
694 $this->click('_qf_Contact_upload_view-bottom');
695 $this->waitForPageToLoad($this->getTimeoutMsec());
697 // add contact to group
699 $this->click("css=li#tab_group a");
700 $this->waitForElementPresent("group_id");
703 $this->select("group_id", "label={$groupName}");
704 $this->click("_qf_GroupContact_next");
705 $this->waitForPageToLoad($this->getTimeoutMsec());
707 $this->openCiviPage("admin/custom/group", "action=add&reset=1", "_qf_Group_next-bottom");
709 // fill in a unique title for the custom group
710 $groupTitle = "Custom Group" . substr(sha1(rand()), 0, 7);
711 $this->type("title", $groupTitle);
713 // select the group this custom data set extends
714 $this->select("extends[0]", "value=Contribution");
715 $this->waitForElementPresent("extends[1]");
717 // save the custom group
718 $this->click("_qf_Group_next-bottom");
719 $this->waitForElementPresent("_qf_Field_next_new-bottom");
720 $this->assertTrue($this->isTextPresent("Your custom field set '$groupTitle' has been added. You can add custom fields now."));
722 // add a custom field to the custom group
723 $fieldTitle = "Custom Field " . substr(sha1(rand()), 0, 7);
724 $this->type("label", $fieldTitle);
726 $this->select("data_type[1]", "value=Text");
727 $this->click('_qf_Field_next-bottom');
729 $this->waitForPageToLoad($this->getTimeoutMsec());
730 $this->assertTrue($this->isTextPresent("Your custom field '$fieldTitle' has been saved."));
731 $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"));
733 // Enable CiviCampaign module if necessary
734 $this->enableComponents("CiviCampaign");
736 // add the required permission
737 $permission = array('edit-2-administer-civicampaign');
738 $this->changePermissions($permission);
740 // Log in as normal user
741 $this->webtestLogin();
743 $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom");
745 $title = 'Campaign ' . substr(sha1(rand()), 0, 7);
746 $this->type("title", $title);
748 // select the campaign type
749 $this->select("campaign_type_id", "value=2");
751 // fill in the description
752 $this->type("description", "This is a test campaign");
754 // include groups for the campaign
755 $this->addSelection("includeGroups-f", "label={$groupName}");
756 $this->click("//option[@value={$groupId}]");
759 // fill the end date for campaign
760 $this->webtestFillDate("end_date", "+1 year");
762 // select campaign status
763 $this->select("status_id", "value=2");
766 $this->click("_qf_Campaign_upload-bottom");
767 $this->waitForElementPresent("xpath=//div[@id='campaigns_wrapper']//table[@id='campaigns']/tbody//tr/td[3][text()='{$title}']");
768 $this->assertTrue($this->isTextPresent("Campaign {$title} has been saved."), "Status message didn't show up after saving!");
770 $this->openCiviPage("admin/uf/group", "reset=1");
771 $this->click("link=Reserved Profiles");
773 $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']");
774 $this->waitForPageToLoad($this->getTimeoutMsec());
776 $this->click("link=Add Field");
777 $this->waitForElementPresent('_qf_Field_next-bottom');
778 $this->select('field_name[0]', 'value=Contribution');
779 $this->select('field_name[1]', 'label=Campaign');
780 $this->click('field_name[1]');
781 $this->click('_qf_Field_next_new-bottom');
782 $this->waitForPageToLoad($this->getTimeoutMsec());
784 $this->select('field_name[0]', 'value=Contribution');
785 $this->select('field_name[1]', "label=$fieldTitle :: $groupTitle");
786 $this->click('field_name[1]');
787 $this->click('_qf_Field_next-bottom');
788 $this->waitForPageToLoad($this->getTimeoutMsec());
789 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$fieldTitle}' has been saved to 'On Behalf Of Organization'."));
791 // Open Page to create Organization
792 $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom");
793 $orgName1 = 'org1_' . substr(sha1(rand()), 0, 7);
795 // Type Organization name
796 $this->type("organization_name", $orgName1);
798 // Type Organizatio email for main
799 $this->type("email_1_email", "{$orgName1}@example.com");
800 $this->select("email_1_location_type_id", "value=3");
802 // type phone no for main
803 $this->type("phone_1_phone", 9999999999);
804 $this->select("phone_1_location_type_id", "value=3");
807 $this->click("addressBlock");
808 $this->waitForElementPresent("address_1_street_address");
810 //fill in address 1 for main
811 $this->select("address_1_location_type_id", "value=3");
812 $this->type("address_1_street_address", "{$orgName1} street address");
813 $this->type("address_1_city", "{$orgName1} city");
814 $this->type("address_1_postal_code", substr(sha1(rand()), 0, 4));
815 $this->assertTrue($this->isTextPresent("- select - United States"));
816 $this->select("address_1_state_province_id", "value=1019");
817 $this->type("address_1_geo_code_1", "1234");
818 $this->type("address_1_geo_code_2", "5678");
820 // Save the Organization
821 $this->click("_qf_Contact_upload_view-bottom");
822 $this->waitForPageToLoad($this->getTimeoutMsec());
825 $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1");
827 // select relationship type
828 $this->click("relationship_type_id");
829 $this->select("relationship_type_id", "value=4_a_b");
831 // search organization
832 $this->type('contact_1', $orgName1);
833 $this->click("contact_1");
834 $this->waitForElementPresent("css=div.ac_results-inner li");
835 $this->click("css=div.ac_results-inner li");
836 $this->assertContains($orgName1, $this->getValue('contact_1'), "autocomplete expected $orgName1 but didn’t find it in " . $this->getValue('contact_1'));
838 $this->waitForElementPresent("add_current_employer");
839 $this->click("add_current_employer");
842 $this->click("is_permission_a_b");
843 $this->click("is_permission_b_a");
846 $this->waitForElementPresent("details-save");
847 $this->click("details-save");
849 //Open Live Contribution Page
850 $this->openCiviPage("contribute/transact", "reset=1&id={$pageId}&cid=$cid", "onbehalf_state_province-3");
851 $this->click('CIVICRM_QFID_amount_other_radio_4');
852 $this->type('amount_other', 60);
853 $this->click('onbehalf_contribution_campaign_id');
854 $this->select('onbehalf_contribution_campaign_id', "label={$title}");
855 $this->type("onbehalf_custom_{$fieldId}", 'Test Subject');
858 $this->select("credit_card_type", "value=Visa");
859 $this->type("credit_card_number", "4111111111111111");
860 $this->type("cvv2", "000");
861 $this->select("credit_card_exp_date[M]", "value=1");
862 $this->select("credit_card_exp_date[Y]", "value=2020");
865 $this->type("billing_street_address-5", "0121 Mount Highschool.");
866 $this->type(" billing_city-5", "Shangai");
867 $this->select("billing_country_id-5", "value=1228");
868 $this->select("billing_state_province_id-5", "value=1004");
869 $this->type("billing_postal_code-5", "94129");
871 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
872 $this->click("_qf_Confirm_next-bottom");
873 $this->waitForPageToLoad($this->getTimeoutMsec());
876 $this->openCiviPage("contribute/search", "reset=1");
877 $this->type("sort_name", $orgName1);
878 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
879 $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom");
881 // verify contrb created
888 foreach ($expected as $value => $label) {
889 $this->verifyText("xpath=id( 'ContributionView' )/div[2]/table[1]/tbody/tr[$value]/td[2]", preg_quote($label));
892 $this->openCiviPage("admin/uf/group", "reset=1");
893 $this->click("link=Reserved Profiles");
895 $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']");
896 $this->waitForPageToLoad($this->getTimeoutMsec());
898 $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']");
899 $this->waitForElementPresent('_qf_Field_next-bottom');
901 $this->click('_qf_Field_next-bottom');
902 $this->waitForPageToLoad($this->getTimeoutMsec());
903 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'), "Status message didn't show up after saving!");
905 $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']");
906 $this->waitForElementPresent('_qf_Field_next-bottom');
908 $this->click('_qf_Field_next-bottom');
909 $this->waitForPageToLoad($this->getTimeoutMsec());
910 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'), "Status message didn't show up after saving!");
918 function _testUserWithMoreThanOneRelationship($pageId, $cid, $pageTitle) {
919 $this->webtestLogin('admin');
920 $this->waitForPageToLoad($this->getTimeoutMsec());
923 $groupName = $this->WebtestAddGroup();
924 $this->openCiviPage("group", "reset=1", '_qf_Search_refresh');
925 $this->click('_qf_Search_refresh');
926 $this->waitForElementPresent("xpath=//div[@id='group']/div[3]/table/tbody//tr/td[text()='{$groupName}']/../td[2]");
927 $groupId = $this->getText("xpath=//div[@id='group']/div[3]/table/tbody//tr/td[text()='{$groupName}']/../td[2]");
929 $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
931 $this->click('link=Edit');
932 $this->waitForElementPresent('_qf_Contact_cancel-bottom');
933 $this->click('addressBlock');
934 $this->waitForElementPresent('link=Another Address');
937 $this->select('address_1_location_type_id', 'label=Billing');
938 $this->type('address_1_street_address', '0121 Mount Highschool.');
939 $this->type('address_1_city', "Shangai");
940 $this->type('address_1_postal_code', "94129");
941 $this->select('address_1_country_id', "value=1228");
942 $this->select('address_1_state_province_id', "value=1004");
943 $this->click('_qf_Contact_upload_view-bottom');
944 $this->waitForPageToLoad($this->getTimeoutMsec());
946 // add contact to group
948 $this->click("css=li#tab_group a");
949 $this->waitForElementPresent("group_id");
952 $this->select("group_id", "label=$groupName");
953 $this->click("_qf_GroupContact_next");
954 $this->waitForPageToLoad($this->getTimeoutMsec());
956 $this->openCiviPage("admin/custom/group", "action=add&reset=1", "_qf_Group_next-bottom");
958 // fill in a unique title for the c$groupIdustom group
959 $groupTitle = "Members Custom Group" . substr(sha1(rand()), 0, 7);
960 $this->type("title", $groupTitle);
962 // select the group this custom data set extends
963 $this->select("extends[0]", "value=Membership");
964 $this->waitForElementPresent("extends[1]");
966 // save the custom group
967 $this->click("_qf_Group_next-bottom");
969 $this->waitForElementPresent("_qf_Field_next_new-bottom");
970 $this->assertTrue($this->isTextPresent("Your custom field set '$groupTitle' has been added. You can add custom fields now."));
972 // add a custom field to the custom group
973 $fieldTitle = "Member Custom Field " . substr(sha1(rand()), 0, 7);
974 $this->type("label", $fieldTitle);
976 $this->select("data_type[1]", "value=Text");
977 $this->click('_qf_Field_next-bottom');
979 $this->waitForPageToLoad($this->getTimeoutMsec());
980 $this->assertTrue($this->isTextPresent("Your custom field '$fieldTitle' has been saved."));
981 $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"));
983 // Enable CiviCampaign module if necessary
984 $this->enableComponents("CiviCampaign");
986 // add the required permission
987 $permission = array('edit-2-administer-civicampaign');
988 $this->changePermissions($permission);
990 // Log in as normal user
991 $this->webtestLogin();
993 $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom");
995 $title = 'Campaign ' . substr(sha1(rand()), 0, 7);
996 $this->type("title", $title);
998 // select the campaign type
999 $this->select("campaign_type_id", "value=2");
1001 // fill in the description
1002 $this->type("description", "This is a test campaign");
1004 // include groups for the campaign
1005 $this->addSelection("includeGroups-f", "label={$groupName}");
1006 $this->click("//option[@value={$groupId}]");
1007 $this->click("add");
1009 // fill the end date for campaign
1010 $this->webtestFillDate("end_date", "+1 year");
1012 // select campaign status
1013 $this->select("status_id", "value=2");
1016 $this->click("_qf_Campaign_upload-bottom");
1017 $this->waitForPageToLoad($this->getTimeoutMsec());
1019 $this->assertTrue($this->isTextPresent("Campaign {$title} has been saved."), "Status message didn't show up after saving!");
1021 $this->openCiviPage("admin/uf/group", "reset=1");
1022 $this->click("link=Reserved Profiles");
1023 $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']");
1024 $this->waitForPageToLoad($this->getTimeoutMsec());
1026 $this->click("link=Add Field");
1027 $this->waitForElementPresent('_qf_Field_next-bottom');
1028 $this->select('field_name[0]', 'value=Membership');
1029 $this->select('field_name[1]', 'label=Campaign');
1030 $this->click('field_name[1]');
1031 $this->clickLink('_qf_Field_next_new-bottom', '_qf_Field_cancel-bottom');
1033 $this->select('field_name[0]', 'value=Membership');
1034 $this->select('field_name[1]', "label=$fieldTitle :: $groupTitle");
1035 $this->click('field_name[1]');
1036 $this->click('_qf_Field_next-bottom');
1037 $this->waitForPageToLoad($this->getTimeoutMsec());
1038 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$fieldTitle}' has been saved to 'On Behalf Of Organization'."),
1039 "Status message didn't show up after saving!"
1042 // Open Page to create Organization 1
1043 $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom");
1044 $orgName1 = 'org1_' . substr(sha1(rand()), 0, 7);
1046 // Type Organization name
1047 $this->type("organization_name", $orgName1);
1049 // Type Organizatio email for main
1050 $this->type("email_1_email", "{$orgName1}@example.com");
1051 $this->select("email_1_location_type_id", "value=3");
1053 // type phone no for main
1054 $this->type("phone_1_phone", substr(sha1(rand()), 0, 4));
1055 $this->select("phone_1_location_type_id", "value=3");
1058 $this->click("addressBlock");
1059 $this->waitForElementPresent("address_1_street_address");
1061 //fill in address 1 for main
1062 $this->select("address_1_location_type_id", "value=3");
1063 $this->type("address_1_street_address", "{$orgName1} street address");
1064 $this->type("address_1_city", "{$orgName1} city");
1065 $this->type("address_1_postal_code", "9999999999");
1066 $this->assertTrue($this->isTextPresent("- select - United States"));
1067 $this->select("address_1_state_province_id", "value=1019");
1068 $this->type("address_1_geo_code_1", "1234");
1069 $this->type("address_1_geo_code_2", "5678");
1071 // Save the Organization
1072 $this->click("_qf_Contact_upload_view-bottom");
1073 $this->waitForPageToLoad($this->getTimeoutMsec());
1075 // create second orzanization
1076 $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom");
1077 $orgName2 = 'org2_' . substr(sha1(rand()), 0, 7);
1079 // Type Organization name
1080 $this->type("organization_name", $orgName2);
1082 // Type Organizatio email for main
1083 $this->type("email_1_email", "{$orgName2}@example.com");
1084 $this->select("email_1_location_type_id", "value=3");
1086 // type phone no for main
1087 $this->type("phone_1_phone", substr(sha1(rand()), 0, 4));
1088 $this->select("phone_1_location_type_id", "value=3");
1091 $this->click("addressBlock");
1092 $this->waitForElementPresent("address_1_street_address");
1094 //fill in address 1 for main
1095 $this->select("address_1_location_type_id", "value=3");
1096 $this->type("address_1_street_address", "{$orgName2} street address");
1097 $this->type("address_1_city", "{$orgName2} city");
1098 $this->type("address_1_postal_code", "7777777777");
1099 $this->assertTrue($this->isTextPresent("- select - United States"));
1100 $this->select("address_1_state_province_id", "value=1019");
1101 $this->type("address_1_geo_code_1", "1224");
1102 $this->type("address_1_geo_code_2", "5628");
1104 // Save the Organization
1105 $this->click("_qf_Contact_upload_view-bottom");
1106 $this->waitForPageToLoad($this->getTimeoutMsec());
1108 // create Membership type
1109 $title1 = "Membership Type" . substr(sha1(rand()), 0, 7);
1110 $this->openCiviPage("admin/member/membershipType", "reset=1&action=browse");
1112 $this->click("link=Add Membership Type");
1113 $this->waitForElementPresent('_qf_MembershipType_cancel-bottom');
1115 $this->type('name', $title1);
1116 $this->type('member_org', $orgName1);
1117 $this->click('_qf_MembershipType_refresh');
1118 $this->waitForElementPresent("xpath=//div[@id='membership_type_form']/fieldset/table[2]/tbody/tr[2]/td[2]");
1120 $this->type('minimum_fee', '50');
1122 $this->select( 'financial_type_id', 'value=2' );
1124 $this->type('duration_interval', 1);
1125 $this->select('duration_unit', "label=year");
1127 $this->select('period_type', "label=fixed");
1128 $this->waitForElementPresent('fixed_period_rollover_day[d]');
1130 $this->select('fixed_period_start_day[M]', 'value=4');
1131 $this->select('fixed_period_rollover_day[M]', 'value=1');
1133 $this->select('relationship_type_id', 'value=4_b_a');
1135 $this->click('_qf_MembershipType_upload-bottom');
1136 $this->waitForElementPresent('link=Add Membership Type');
1137 $this->assertTrue($this->isTextPresent("The membership type '$title1' has been saved."));
1138 $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"));
1141 $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1");
1143 // select relationship type
1144 $this->click("relationship_type_id");
1145 $this->select("relationship_type_id", "value=4_a_b");
1147 // search organization
1148 $this->type('contact_1', $orgName1);
1149 $this->click("contact_1");
1150 $this->waitForElementPresent("css=div.ac_results-inner li");
1151 $this->click("css=div.ac_results-inner li");
1152 $this->assertContains($orgName1, $this->getValue('contact_1'), "autocomplete expected $orgName1 but didn’t find it in " . $this->getValue('contact_1'));
1155 $this->click("is_permission_a_b");
1156 $this->click("is_permission_b_a");
1158 // save relationship
1159 $this->click("details-save");
1162 $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1");
1164 // select relationship type
1165 $this->click("relationship_type_id");
1166 $this->select("relationship_type_id", "value=4_a_b");
1168 // search organization
1169 $this->type('contact_1', $orgName2);
1170 $this->click("contact_1");
1171 $this->waitForElementPresent("css=div.ac_results-inner li");
1172 $this->click("css=div.ac_results-inner li");
1173 $this->assertContains($orgName2, $this->getValue('contact_1'), "autocomplete expected $orgName2 but didn’t find it in " . $this->getValue('contact_1'));
1176 $this->click("is_permission_a_b");
1177 $this->click("is_permission_b_a");
1179 // save relationship
1180 $this->click("details-save");
1182 // set membership type
1183 $this->openCiviPage("admin/contribute/membership", "reset=1&action=update&id=$pageId", "_qf_MembershipBlock_upload_done-bottom");
1184 $this->click("member_is_active");
1185 $this->click("membership_type[{$typeId}]");
1186 $this->click("xpath=//div[@id='memberFields']//table[@class='report']/tbody//tr/td[1]/label[text()='{$title1}']/../../td[2]/input");
1187 $this->click('_qf_MembershipBlock_upload_done-bottom');
1188 $this->waitForPageToLoad($this->getTimeoutMsec());
1190 //Open Live Membership Page
1191 $this->openCiviPage('contribute/transact', "reset=1&id=$pageId&cid=$cid", "_qf_Main_upload-bottom");
1192 $this->click('CIVICRM_QFID_amount_other_radio_4');
1193 $this->type('amount_other', 60);
1194 $this->click('onbehalf_organization_name');
1195 $this->type('onbehalf_organization_name', $orgName1);
1196 $this->typeKeys('onbehalf_organization_name', $orgName1);
1197 $this->click("onbehalf_organization_name");
1198 $this->waitForElementPresent("css=div.ac_results-inner li");
1199 $this->click("css=div.ac_results-inner li");
1200 // Because it tends to cause problems, all uses of sleep() must be justified in comments
1201 // Sleep should never be used for wait for anything to load from the server
1202 // Justification for this instance: FIXME
1204 $this->click('onbehalf_member_campaign_id');
1205 $this->select('onbehalf_member_campaign_id', "label={$title}");
1206 $this->type("onbehalf_custom_{$fieldId}", 'Test Subject');
1208 $this->assertContains($orgName1, $this->getValue('onbehalf_organization_name'), "autocomplete expected $orgName1 but didn’t find it in " . $this->getValue('onbehalf_organization_name'));
1211 $this->select("credit_card_type", "value=Visa");
1212 $this->type("credit_card_number", "4111111111111111");
1213 $this->type("cvv2", "000");
1214 $this->select("credit_card_exp_date[M]", "value=1");
1215 $this->select("credit_card_exp_date[Y]", "value=2020");
1217 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
1218 $this->click("_qf_Confirm_next-bottom");
1219 $this->waitForPageToLoad($this->getTimeoutMsec());
1221 //Find Membership for organization
1222 $this->openCiviPage("member/search", "reset=1");
1223 $this->type("sort_name", $orgName1);
1224 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='memberSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
1225 $this->clickLink("xpath=//div[@id='memberSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_MembershipView_cancel-bottom");
1227 //verify contrb created
1233 foreach ($expected as $value => $label) {
1234 $this->verifyText("xpath=//form[@id='MembershipView']/div[2]/div/table/tbody/tr[$value]/td[2]", preg_quote($label));
1237 // find membership for contact in relationship
1238 $this->openCiviPage("contact/view", "reset=1&force=1&cid={$cid}");
1239 $this->click("css=li#tab_member a");
1240 $this->waitForElementPresent("xpath=//div[@id='memberships']/div/table//tbody//tr/td[1][text()='{$title1}']");
1241 $this->click("xpath=//div[@id='memberships']/div/table//tbody//tr/td[1][text()='{$title1}']/../td[7]/span/a[text()='View']");
1242 $this->waitForPageToLoad($this->getTimeoutMsec());
1244 //verify contrb created
1249 foreach ($expected as $value => $label) {
1250 $this->verifyText("xpath=//form[@id='MembershipView']/div[2]/div/table/tbody/tr[$value]/td[2]", preg_quote($label));
1253 $this->openCiviPage("admin/uf/group", "reset=1");
1254 $this->click("link=Reserved Profiles");
1255 $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']");
1256 $this->waitForPageToLoad($this->getTimeoutMsec());
1258 $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']");
1259 $this->waitForElementPresent('_qf_Field_next-bottom');
1261 $this->click('_qf_Field_next-bottom');
1262 $this->waitForPageToLoad($this->getTimeoutMsec());
1263 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'),
1264 "Status message didn't show up after saving!"
1267 $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']");
1268 $this->waitForElementPresent('_qf_Field_next-bottom');
1270 $this->click('_qf_Field_next-bottom');
1271 $this->waitForPageToLoad($this->getTimeoutMsec());
1272 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'),
1273 "Status message didn't show up after saving!"
1276 $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
1277 $this->click("css=li#tab_rel a");
1279 $this->waitForElementPresent("xpath=//div[@id='current-relationships']/div/table/tbody//tr/td[2]/a[text()='{$orgName1}']");
1280 $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']");
1282 // Check confirmation alert.
1283 $this->assertTrue((bool)preg_match("/^Are you sure you want to delete this relationship?/",
1284 $this->getConfirmation()
1286 $this->chooseOkOnNextConfirmation();
1287 $this->waitForPageToLoad($this->getTimeoutMsec());
1288 $this->assertTrue($this->isTextPresent('Selected relationship has been deleted successfully.'),
1289 "Status message didn't show up after saving!"
1293 function testOnBehalfOfOrganizationWithImage() {
1294 $this->webtestLogin();
1296 $this->openCiviPage("profile/edit", "reset=1&gid=4");
1297 $firstName = 'John_x_' . substr(sha1(rand()), 0, 7);
1298 $lastName = 'Anderson_c_' . substr(sha1(rand()), 0, 7);
1300 $this->waitForPageToLoad($this->getTimeoutMsec());
1301 $this->waitForElementPresent("_qf_Edit_next");
1302 $this->type("first_name", $firstName);
1303 $this->type("last_name", $lastName);
1304 $this->clickLink("_qf_Edit_next", "profilewrap4");
1306 $cid = $this->urlArg('id');
1307 $this->assertType('numeric', $cid);
1308 // Is status message correct?
1309 $this->assertTextPresent("Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!");
1311 $this->openCiviPage("admin/uf/group", "reset=1");
1312 $this->click("link=Reserved Profiles");
1314 $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']");
1315 $this->waitForPageToLoad($this->getTimeoutMsec());
1317 $this->click("link=Add Field");
1318 $this->waitForElementPresent('_qf_Field_next-bottom');
1320 $this->select('field_name[0]', 'value=Contact');
1321 $this->select('field_name[1]', 'label=Image Url');
1322 $this->click('field_name[1]');
1323 $this->click('_qf_Field_next-bottom');
1324 $this->waitForPageToLoad($this->getTimeoutMsec());
1326 // We need a payment processor
1327 $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7);
1328 $processorType = 'Dummy';
1329 $pageTitle = substr(sha1(rand()), 0, 7);
1331 $hash = substr(sha1(rand()), 0, 7);
1332 $amountSection = TRUE;
1337 $memberships = FALSE;
1338 $memPriceSetId = NULL;
1340 $profilePreId = NULL;
1341 $profilePostId = NULL;
1345 $honoreeSection = FALSE;
1346 $isAddPaymentProcessor = TRUE;
1347 $isPcpApprovalNeeded = FALSE;
1348 $isSeparatePayment = FALSE;
1350 // create a new online contribution page
1351 // create contribution page with randomized title and default params
1352 $pageId = $this->webtestAddContributionPage($hash,
1355 array($processorName => $processorType),
1369 $isAddPaymentProcessor,
1370 $isPcpApprovalNeeded,
1375 $this->_testOrganizationWithImageUpload($pageId, $cid, $pageTitle);
1377 $this->openCiviPage("admin/uf/group", "reset=1");
1378 $this->click("link=Reserved Profiles");
1380 $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']");
1381 $this->waitForPageToLoad($this->getTimeoutMsec());
1382 $this->click("xpath=//table[@id='option11']/tbody//tr/td/span[text()='Image Url']/../following-sibling::td[8]/span[2]/ul/li[2]/a");
1383 $this->waitForPageToLoad($this->getTimeoutMsec());
1384 $this->click('_qf_Field_next-bottom');
1385 $this->waitForPageToLoad($this->getTimeoutMsec());
1386 $this->waitForText('crm-notification-container', "Selected Profile Field has been deleted.");
1394 function _testOrganizationWithImageUpload($pageId, $cid, $pageTitle) {
1395 //Open Live Contribution Page
1396 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", '_qf_Main_upload-bottom');
1398 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
1399 $lastName = 'An' . substr(sha1(rand()), 0, 7);
1400 $orgName = 'org_11_' . substr(sha1(rand()), 0, 7);
1401 $this->type("email-5", $firstName . "@example.com");
1403 // onbehalforganization info
1404 $this->type("onbehalf_organization_name", $orgName);
1405 $this->type("onbehalf_phone-3-1", 9999999999);
1406 $this->type("onbehalf_email-3", "{$orgName}@example.com");
1407 $this->type("onbehalf_street_address-3", "Test Street Address");
1408 $this->type("onbehalf_city-3", "Test City");
1409 $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
1410 $this->click("onbehalf_country-3");
1411 $this->select("onbehalf_country-3", "label=United States");
1412 $this->click("onbehalf_state_province-3");
1413 $this->select("onbehalf_state_province-3", "label=Alabama");
1415 // check for upload field.
1416 $this->waitForElementPresent("onbehalf_image_URL");
1418 //header("Content-Type: image/png");
1419 $im = imagecreate(110, 20)
1420 or die("Cannot Initialize new GD image stream");
1421 $background_color = imagecolorallocate($im, 0, 0, 0);
1422 $text_color = imagecolorallocate($im, 233, 14, 91);
1423 imagestring($im, 1, 5, 5, "On Behalf-Org Logo", $text_color);
1424 imagepng($im,"/tmp/file.png");
1426 $imagePath = "/tmp/file.png";
1427 $this->webtestAttachFile('onbehalf_image_URL', $imagePath);
1431 $this->select("credit_card_type", "value=Visa");
1432 $this->type("credit_card_number", "4111111111111111");
1433 $this->type("cvv2", "000");
1434 $this->select("credit_card_exp_date[M]", "value=1");
1435 $this->select("credit_card_exp_date[Y]", "value=2020");
1438 $this->type("billing_first_name", $firstName . 'billing');
1439 $this->type("billing_last_name", $lastName . 'billing');
1440 $this->type("billing_street_address-5", "0121 Mount Highschool.");
1441 $this->type(" billing_city-5", "Shangai");
1442 $this->select("billing_country_id-5", "value=1228");
1443 $this->select("billing_state_province_id-5", "value=1004");
1444 $this->type("billing_postal_code-5", "94129");
1445 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
1447 $this->click("_qf_Confirm_next-bottom");
1448 $this->waitForPageToLoad($this->getTimeoutMsec());
1450 // Type search name in autocomplete.
1451 $this->click('sort_name_navigation');
1452 $this->type('css=input#sort_name_navigation', $orgName);
1453 $this->typeKeys('css=input#sort_name_navigation', $orgName);
1455 // Wait for result list.
1456 $this->waitForElementPresent("css=div.ac_results-inner li");
1458 // Visit organization page.
1459 $this->click("css=div.ac_results-inner li");
1460 $this->waitForPageToLoad($this->getTimeoutMsec());
1462 //check whether the image is present
1463 $this->assertTrue($this->isElementPresent("xpath=//div[@id='crm-contact-thumbnail']/div/a/img"));