3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
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 // Use default payment processor
57 $processorName = 'Test Processor';
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("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("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 // Use default payment processor
319 $processorName = 'Test Processor';
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->clickLink('_qf_Group_next-bottom');
379 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now."));
381 $gid = $this->urlArg('gid');
383 $this->openCiviPage('admin/uf/group/field/add', array('action' => 'add', 'reset' => 1, 'gid' => $gid), 'field_name[0]');
384 $this->select('field_name[0]', "value=Membership");
385 $this->select('field_name[1]', "label={$checkboxFieldLabel} :: {$customGroupTitle}");
386 $this->click('field_name[1]');
387 $this->click('label');
389 // Clicking save and new
390 $this->click('_qf_Field_next_new-bottom');
391 $this->waitForPageToLoad($this->getTimeoutMsec());
392 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$checkboxFieldLabel}' has been saved to '{$profileTitle}'."));
394 $this->openCiviPage("admin/contribute/custom", "reset=1&action=update&id={$pageId}", '_qf_Custom_next-bottom');
395 $this->select('custom_pre_id', "label={$profileTitle}");
396 $this->click('_qf_Custom_next-bottom');
397 $this->waitForPageToLoad($this->getTimeoutMsec());
398 // Because it tends to cause problems, all uses of sleep() must be justified in comments
399 // Sleep should never be used for wait for anything to load from the server
400 // Justification for this instance: FIXME
402 $this->assertTrue($this->isTextPresent('You should move the membership related fields in the "On Behalf" profile for this Contribution Page'), "Form rule didn't showed up while incorrectly configuring membership fields profile for 'on behalf of' contribution page");
404 $this->select('custom_pre_id', "- select -");
405 $this->select('custom_post_id', "label={$profileTitle}");
406 $this->click('_qf_Custom_next-bottom');
407 $this->waitForPageToLoad($this->getTimeoutMsec());
408 // Because it tends to cause problems, all uses of sleep() must be justified in comments
409 // Sleep should never be used for wait for anything to load from the server
410 // Justification for this instance: FIXME
412 $this->assertTrue($this->isTextPresent('You should move the membership related fields in the "On Behalf" profile for this Contribution Page'), "Form rule didn't showed up while incorrectly configuring membership fields profile for 'on behalf of' contribution page");
414 //scenario 2 : disable 'on behalf of', add membership data in pre / post profile
415 //then try to add 'on behalf of' and check for formRule
416 //disable 'on behalf of'
417 $this->openCiviPage("admin/contribute/settings", "reset=1&action=update&id={$pageId}", '_qf_Settings_next-bottom');
418 $this->uncheck('is_organization');
419 $this->click('_qf_Settings_next-bottom');
420 $this->waitForPageToLoad($this->getTimeoutMsec());
422 //set a membership field profile for this contribution page
423 $this->click('css=li#tab_custom a');
424 $this->waitForElementPresent('_qf_Custom_next-bottom');
425 $this->select('custom_pre_id', "label={$profileTitle}");
426 $this->click('_qf_Custom_next-bottom');
427 $this->waitForPageToLoad($this->getTimeoutMsec());
429 //now visit the title settings page and configure the profile as on behalf of
430 $this->click('css=li#tab_settings a');
431 $this->waitForElementPresent('_qf_Settings_next-bottom');
432 $this->check('is_organization');
433 $this->click('_qf_Settings_next-bottom');
434 $this->waitForPageToLoad($this->getTimeoutMsec());
435 // Because it tends to cause problems, all uses of sleep() must be justified in comments
436 // Sleep should never be used for wait for anything to load from the server
437 // Justification for this instance: FIXME
439 $this->assertTrue($this->isTextPresent("You should move the membership related fields configured in 'Includes Profile (top of page)' to the 'On Behalf' profile for this Contribution Page"), "Form rule 'You should move the membership related fields configured in 'Includes Profile (top of page)' to the 'On Behalf' profile for this Contribution Page' didn't showed up");
442 $this->webtestLogout();
445 function testOnBehalfOfOrganizationWithOrgData() {
446 $this->webtestLogin();
448 $this->openCiviPage("profile/edit", "reset=1&gid=4");
449 $firstName = 'John_x_' . substr(sha1(rand()), 0, 7);
450 $lastName = 'Anderson_c_' . substr(sha1(rand()), 0, 7);
452 $this->waitForPageToLoad($this->getTimeoutMsec());
453 $this->waitForElementPresent("_qf_Edit_next");
454 $this->type("first_name", $firstName);
455 $this->type("last_name", $lastName);
456 $this->clickLink("_qf_Edit_next", "profilewrap4");
458 $cid = $this->urlArg('id');
459 // Is status message correct?
460 $this->assertTextPresent("Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!");
462 //add org fields to profile
463 $this->openCiviPage("admin/uf/group", "reset=1");
464 $this->click("link=Reserved Profiles");
466 $this->click("xpath=//div[@id='reserved-profiles']/div/div/table/tbody//tr/td[1][text()='On Behalf Of Organization']/../td[5]/span/a[text()='Fields']");
467 $this->waitForPageToLoad($this->getTimeoutMsec());
469 $this->click("link=Add Field");
470 $this->waitForElementPresent('_qf_Field_next-bottom');
472 $this->select('field_name[0]', 'value=Organization');
473 $this->select('field_name[1]', 'label=Legal Identifier');
474 $this->click('field_name[1]');
475 $this->click('_qf_Field_next_new-bottom');
476 $this->waitForPageToLoad($this->getTimeoutMsec());
478 $this->select('field_name[0]', 'value=Organization');
479 $this->select('field_name[1]', 'label=Legal Name');
480 $this->click('field_name[1]');
481 $this->click('_qf_Field_next-bottom');
482 $this->waitForPageToLoad($this->getTimeoutMsec());
484 //create organisation
485 $orgName = "Org WebAccess ". substr(sha1(rand()), 0, 7);
486 $orgEmail = "org". substr(sha1(rand()), 0, 7) . "@web.com";
487 $this->webtestAddOrganization($orgName, $orgEmail);
489 $this->waitForPageToLoad($this->getTimeoutMsec());
490 $this->click("css=li#tab_rel a");
492 $this->waitForElementPresent('link=Add Relationship');
493 $this->click('link=Add Relationship');
495 $this->waitForElementPresent('relationship_type_id');
496 $this->click("relationship_type_id");
497 $this->select("relationship_type_id", "label=Employer of");
498 // search organization
499 $this->type('contact_1', $firstName);
500 $this->click("contact_1");
501 $this->waitForElementPresent("css=div.ac_results-inner li");
502 $this->click("css=div.ac_results-inner li");
503 $this->assertContains($firstName, $this->getValue('contact_1'), "autocomplete expected $firstName but didn’t find it in " . $this->getValue('contact_1'));
506 $this->click("is_permission_a_b");
507 $this->click("is_permission_b_a");
510 $this->waitForElementPresent("details-save");
511 $this->click("details-save");
512 $this->waitForElementPresent("Relationships");
514 $pageTitle = substr(sha1(rand()), 0, 7);
516 $hash = substr(sha1(rand()), 0, 7);
517 $amountSection = TRUE;
523 $memPriceSetId = NULL;
525 $profilePreId = NULL;
526 $profilePostId = NULL;
530 $honoreeSection = FALSE;
531 $isAddPaymentProcessor = FALSE;
532 $isPcpApprovalNeeded = FALSE;
533 $isSeparatePayment = FALSE;
535 // create a new online contribution page
536 // create contribution page with randomized title and default params
537 $pageId = $this->webtestAddContributionPage($hash,
554 $isAddPaymentProcessor,
555 $isPcpApprovalNeeded,
560 $this->_testOrganization($pageId, $cid, $pageTitle);
563 function testWithContactSubtypeDupe() {
564 $this->webtestLogin();
566 //create organisation
567 $orgName = "Org WebAccess ". substr(sha1(rand()), 0, 7);
568 $orgEmail = "org". substr(sha1(rand()), 0, 7) . "@web.com";
569 $contactSubType = 'Sponsor';
570 $this->webtestAddOrganization($orgName, $orgEmail, $contactSubType);
572 $this->waitForPageToLoad($this->getTimeoutMsec());
573 $cid = $this->urlArg('cid');
575 $pageTitle = substr(sha1(rand()), 0, 7);
577 $hash = substr(sha1(rand()), 0, 7);
578 $amountSection = TRUE;
583 $memberships = FALSE;
584 $memPriceSetId = NULL;
586 $profilePreId = NULL;
587 $profilePostId = NULL;
591 $honoreeSection = FALSE;
592 $isAddPaymentProcessor = FALSE;
593 $isPcpApprovalNeeded = FALSE;
594 $isSeparatePayment = FALSE;
596 // create a new online contribution page
597 // create contribution page with randomized title and default params
598 $pageId = $this->webtestAddContributionPage($hash,
615 $isAddPaymentProcessor,
616 $isPcpApprovalNeeded,
621 //Open Live Contribution Page
622 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom");
623 $this->waitForElementPresent("onbehalf_state_province-3");
625 $this->type("onbehalf_organization_name", $orgName);
626 $this->waitForElementPresent("onbehalf_phone-3-1");
627 $this->type("onbehalf_phone-3-1", 9999999999);
628 $this->waitForElementPresent("onbehalf_email-3");
629 $this->type("onbehalf_email-3", "org@example.com");
630 $this->type("onbehalf_street_address-3", "Test Street Address");
631 $this->type("onbehalf_city-3", "Test City");
632 $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
633 $this->click("onbehalf_country-3");
634 $this->select("onbehalf_country-3", "label=United States");
635 $this->click("onbehalf_state_province-3");
636 $this->select("onbehalf_state_province-3", "label=Alabama");
638 $this->waitForElementPresent("_qf_Main_upload-bottom");
639 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
641 $this->click("_qf_Confirm_next-bottom");
642 $this->waitForPageToLoad($this->getTimeoutMsec());
644 $this->openCiviPage("contact/view", "reset=1&cid=$cid", "xpath=//div[@class='crm-content crm-contact_type_label']");
646 $this->verifyText("xpath=//div[@class='crm-content crm-contact_type_label']", $contactSubType);
654 function _testOrganization($pageId, $cid, $pageTitle) {
655 //Open Live Contribution Page
656 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom");
658 $this->waitForElementPresent("onbehalf_state_province-3");
660 $this->waitForElementPresent("onbehalf_phone-3-1");
661 $this->type("onbehalf_phone-3-1", 9999999999);
662 $this->waitForElementPresent("onbehalf_email-3");
663 $this->type("onbehalf_email-3", "org@example.com");
664 $this->type("onbehalf_street_address-3", "Test Street Address");
665 $this->type("onbehalf_city-3", "Test City");
666 $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
667 $this->click("onbehalf_country-3");
668 $this->select("onbehalf_country-3", "label=United States");
669 $this->click("onbehalf_state_province-3");
670 $this->select("onbehalf_state_province-3", "label=Alabama");
672 $this->waitForElementPresent("_qf_Main_upload-bottom");
673 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
675 $this->click("_qf_Confirm_next-bottom");
676 $this->waitForPageToLoad($this->getTimeoutMsec());
685 function _testAnomoyousOganization($pageId, $cid, $pageTitle) {
686 //Open Live Contribution Page
687 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom");
689 $this->click('CIVICRM_QFID_0_8');
690 $this->type('css=div.other_amount-section input', 60);
692 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
693 $lastName = 'An' . substr(sha1(rand()), 0, 7);
694 $orgName = 'org_11_' . substr(sha1(rand()), 0, 7);
695 $this->type("email-5", $firstName . "@example.com");
697 // enable onbehalforganization block
698 $this->click("is_for_organization");
699 $this->waitForElementPresent("onbehalf_state_province-3");
701 // onbehalforganization info
702 $this->type("onbehalf_organization_name", $orgName);
703 $this->type("onbehalf_phone-3-1", 9999999999);
704 $this->type("onbehalf_email-3", "{$orgName}@example.com");
705 $this->type("onbehalf_street_address-3", "Test Street Address");
706 $this->type("onbehalf_city-3", "Test City");
707 $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
708 $this->click("onbehalf_country-3");
709 $this->select("onbehalf_country-3", "label=United States");
710 $this->click("onbehalf_state_province-3");
711 $this->select("onbehalf_state_province-3", "label=Alabama");
714 $this->select("credit_card_type", "value=Visa");
715 $this->type("credit_card_number", "4111111111111111");
716 $this->type("cvv2", "000");
717 $this->select("credit_card_exp_date[M]", "value=1");
718 $this->select("credit_card_exp_date[Y]", "value=2020");
721 $this->type("billing_first_name", $firstName . 'billing');
722 $this->type("billing_last_name", $lastName . 'billing');
723 $this->type("billing_street_address-5", "0121 Mount Highschool.");
724 $this->type(" billing_city-5", "Shangai");
725 $this->select("billing_country_id-5", "value=1228");
726 $this->select("billing_state_province_id-5", "value=1004");
727 $this->type("billing_postal_code-5", "94129");
728 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
730 $this->click("_qf_Confirm_next-bottom");
731 $this->waitForPageToLoad($this->getTimeoutMsec());
733 //login to check contribution
735 // Log in using webtestLogin() method
736 $this->webtestLogin();
739 $this->openCiviPage("contribute/search", "reset=1");
740 $this->type("sort_name", $orgName);
741 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
742 $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom");
744 // verify contrb created
750 foreach ($expected as $value => $label) {
751 $this->verifyText("xpath=id( 'ContributionView' )/div[2]/table[1]/tbody/tr[$value]/td[2]", preg_quote($label));
760 function _testUserWithOneRelationship($pageId, $cid, $pageTitle) {
761 $this->webtestLogin('admin');
764 $groupName = $this->WebtestAddGroup();
765 $this->openCiviPage("group", "reset=1", "_qf_Search_refresh");
766 $groupId = $this->getText("xpath=//table[@id='crm-group-selector']/tbody//tr/td[text()='{$groupName}']/../td[2]");
768 $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
770 $this->click('link=Edit');
771 $this->waitForElementPresent('_qf_Contact_cancel-bottom');
772 $this->click('addressBlock');
773 $this->waitForElementPresent('link=Another Address');
776 $this->select('address_1_location_type_id', 'label=Billing');
777 $this->type('address_1_street_address', '0121 Mount Highschool.');
778 $this->type('address_1_city', "Shangai");
779 $this->type('address_1_postal_code', "94129");
780 $this->select('address_1_country_id', "value=1228");
781 $this->select('address_1_state_province_id', "value=1004");
782 $this->click('_qf_Contact_upload_view-bottom');
783 $this->waitForPageToLoad($this->getTimeoutMsec());
785 // add contact to group
787 $this->click("css=li#tab_group a");
788 $this->waitForElementPresent("group_id");
791 $this->select("group_id", "label={$groupName}");
792 $this->click("_qf_GroupContact_next");
793 $this->waitForPageToLoad($this->getTimeoutMsec());
795 $this->openCiviPage("admin/custom/group", "action=add&reset=1", "_qf_Group_next-bottom");
797 // fill in a unique title for the custom group
798 $groupTitle = "Custom Group" . substr(sha1(rand()), 0, 7);
799 $this->type("title", $groupTitle);
801 // select the group this custom data set extends
802 $this->select("extends[0]", "value=Contribution");
803 $this->waitForElementPresent("extends[1]");
805 // save the custom group
806 $this->click("_qf_Group_next-bottom");
807 $this->waitForElementPresent("_qf_Field_next_new-bottom");
808 $this->assertTrue($this->isTextPresent("Your custom field set '$groupTitle' has been added. You can add custom fields now."));
810 // add a custom field to the custom group
811 $fieldTitle = "Custom Field " . substr(sha1(rand()), 0, 7);
812 $this->type("label", $fieldTitle);
814 $this->select("data_type[1]", "value=Text");
815 $this->click('_qf_Field_next-bottom');
817 $this->waitForPageToLoad($this->getTimeoutMsec());
818 $this->assertTrue($this->isTextPresent("Custom field '$fieldTitle' has been saved."));
819 $fieldId = $this->urlArg('id', $this->getAttribute("xpath=//div[@id='field_page']/div[2]/table/tbody//tr/td[1][text()='$fieldTitle']/../td[8]/span/a@href"));
821 // Enable CiviCampaign module if necessary
822 $this->enableComponents("CiviCampaign");
824 // add the required permission
825 $permission = array('edit-2-administer-civicampaign');
826 $this->changePermissions($permission);
828 // Log in as normal user
829 $this->webtestLogin();
831 $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom");
833 $title = 'Campaign ' . substr(sha1(rand()), 0, 7);
834 $this->type("title", $title);
836 // select the campaign type
837 $this->select("campaign_type_id", "value=2");
839 // fill in the description
840 $this->type("description", "This is a test campaign");
842 // include groups for the campaign
843 $this->addSelection("includeGroups-f", "label={$groupName}");
844 $this->click("//option[@value={$groupId}]");
847 // fill the end date for campaign
848 $this->webtestFillDate("end_date", "+1 year");
850 // select campaign status
851 $this->select("status_id", "value=2");
854 $this->click("_qf_Campaign_upload-bottom");
855 $this->waitForElementPresent("xpath=//div[@id='campaigns_wrapper']//table[@id='campaigns']/tbody//tr/td[3][text()='{$title}']");
856 $this->assertTrue($this->isTextPresent("Campaign {$title} has been saved."), "Status message didn't show up after saving!");
858 $this->openCiviPage("admin/uf/group", "reset=1");
859 $this->click("link=Reserved Profiles");
861 $this->click("xpath=//div[@id='reserved-profiles']/div/div/table/tbody//tr/td[1][text()='On Behalf Of Organization']/../td[5]/span/a[text()='Fields']");
862 $this->waitForPageToLoad($this->getTimeoutMsec());
864 $this->click("link=Add Field");
865 $this->waitForElementPresent('_qf_Field_next-bottom');
866 $this->select('field_name[0]', 'value=Contribution');
867 $this->select('field_name[1]', 'label=Campaign');
868 $this->click('field_name[1]');
869 $this->click('_qf_Field_next_new-bottom');
870 $this->waitForPageToLoad($this->getTimeoutMsec());
872 $this->select('field_name[0]', 'value=Contribution');
873 $this->select('field_name[1]', "label=$fieldTitle :: $groupTitle");
874 $this->click('field_name[1]');
875 $this->click('_qf_Field_next-bottom');
876 $this->waitForPageToLoad($this->getTimeoutMsec());
877 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$fieldTitle}' has been saved to 'On Behalf Of Organization'."));
879 // Open Page to create Organization
880 $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom");
881 $orgName1 = 'org1_' . substr(sha1(rand()), 0, 7);
883 // Type Organization name
884 $this->type("organization_name", $orgName1);
886 // Type Organizatio email for main
887 $this->type("email_1_email", "{$orgName1}@example.com");
888 $this->select("email_1_location_type_id", "value=3");
890 // type phone no for main
891 $this->type("phone_1_phone", 9999999999);
892 $this->select("phone_1_location_type_id", "value=3");
895 $this->click("addressBlock");
896 $this->waitForElementPresent("address_1_street_address");
898 //fill in address 1 for main
899 $this->select("address_1_location_type_id", "value=3");
900 $this->type("address_1_street_address", "{$orgName1} street address");
901 $this->type("address_1_city", "{$orgName1} city");
902 $this->type("address_1_postal_code", substr(sha1(rand()), 0, 4));
903 $this->assertTrue($this->isTextPresent("- select - United States"));
904 $this->select("address_1_state_province_id", "value=1019");
905 $this->type("address_1_geo_code_1", "1234");
906 $this->type("address_1_geo_code_2", "5678");
908 // Save the Organization
909 $this->click("_qf_Contact_upload_view-bottom");
910 $this->waitForPageToLoad($this->getTimeoutMsec());
913 $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1");
915 // select relationship type
916 $this->click("relationship_type_id");
917 $this->select("relationship_type_id", "value=4_a_b");
919 // search organization
920 $this->type('contact_1', $orgName1);
921 $this->click("contact_1");
922 $this->waitForElementPresent("css=div.ac_results-inner li");
923 $this->click("css=div.ac_results-inner li");
924 $this->assertContains($orgName1, $this->getValue('contact_1'), "autocomplete expected $orgName1 but didn’t find it in " . $this->getValue('contact_1'));
926 $this->waitForElementPresent("add_current_employer");
927 $this->click("add_current_employer");
930 $this->click("is_permission_a_b");
931 $this->click("is_permission_b_a");
934 $this->waitForElementPresent("details-save");
935 $this->click("details-save");
937 //Open Live Contribution Page
938 $this->openCiviPage("contribute/transact", "reset=1&id={$pageId}&cid=$cid", "onbehalf_state_province-3");
939 $this->click('CIVICRM_QFID_amount_other_radio_4');
940 $this->type('amount_other', 60);
941 $this->click('onbehalf_contribution_campaign_id');
942 $this->select('onbehalf_contribution_campaign_id', "label={$title}");
943 $this->type("onbehalf_custom_{$fieldId}", 'Test Subject');
946 $this->select("credit_card_type", "value=Visa");
947 $this->type("credit_card_number", "4111111111111111");
948 $this->type("cvv2", "000");
949 $this->select("credit_card_exp_date[M]", "value=1");
950 $this->select("credit_card_exp_date[Y]", "value=2020");
953 $this->type("billing_street_address-5", "0121 Mount Highschool.");
954 $this->type(" billing_city-5", "Shangai");
955 $this->select("billing_country_id-5", "value=1228");
956 $this->select("billing_state_province_id-5", "value=1004");
957 $this->type("billing_postal_code-5", "94129");
959 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
960 $this->click("_qf_Confirm_next-bottom");
961 $this->waitForPageToLoad($this->getTimeoutMsec());
964 $this->openCiviPage("contribute/search", "reset=1");
965 $this->type("sort_name", $orgName1);
966 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
967 $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom");
969 // verify contrb created
976 foreach ($expected as $value => $label) {
977 $this->verifyText("xpath=id( 'ContributionView' )/div[2]/table[1]/tbody/tr[$value]/td[2]", preg_quote($label));
980 $this->openCiviPage("admin/uf/group", "reset=1");
981 $this->click("link=Reserved Profiles");
983 $this->click("xpath=//div[@id='reserved-profiles']/div/div/table/tbody//tr/td[1][text()='On Behalf Of Organization']/../td[5]/span/a[text()='Fields']");
984 $this->waitForPageToLoad($this->getTimeoutMsec());
986 $this->click("xpath=//div[@id='field_page']/div[3]/table/tbody//tr/td[1][text()='Campaign']/../td[9]/span[2][text()='more ']/ul/li[2]/a[text()='Delete']");
987 $this->waitForElementPresent('_qf_Field_next-bottom');
989 $this->click('_qf_Field_next-bottom');
990 $this->waitForPageToLoad($this->getTimeoutMsec());
991 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'), "Status message didn't show up after saving!");
993 $this->click("xpath=//div[@id='field_page']/div[3]/table/tbody//tr/td[1][text()='{$fieldTitle}']/../td[9]/span[2][text()='more ']/ul/li[2]/a[text()='Delete']");
994 $this->waitForElementPresent('_qf_Field_next-bottom');
996 $this->click('_qf_Field_next-bottom');
997 $this->waitForPageToLoad($this->getTimeoutMsec());
998 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'), "Status message didn't show up after saving!");
1002 * @param int $pageId
1006 function _testUserWithMoreThanOneRelationship($pageId, $cid, $pageTitle) {
1007 $this->webtestLogin('admin');
1008 $this->waitForPageToLoad($this->getTimeoutMsec());
1011 $groupName = $this->WebtestAddGroup();
1012 $this->openCiviPage("group", "reset=1", '_qf_Search_refresh');
1013 $this->click('_qf_Search_refresh');
1014 $this->waitForElementPresent("xpath=//div[@id='group']/div[3]/table/tbody//tr/td[text()='{$groupName}']/../td[2]");
1015 $groupId = $this->getText("xpath=//div[@id='group']/div[3]/table/tbody//tr/td[text()='{$groupName}']/../td[2]");
1017 $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
1019 $this->click('link=Edit');
1020 $this->waitForElementPresent('_qf_Contact_cancel-bottom');
1021 $this->click('addressBlock');
1022 $this->waitForElementPresent('link=Another Address');
1025 $this->select('address_1_location_type_id', 'label=Billing');
1026 $this->type('address_1_street_address', '0121 Mount Highschool.');
1027 $this->type('address_1_city', "Shangai");
1028 $this->type('address_1_postal_code', "94129");
1029 $this->select('address_1_country_id', "value=1228");
1030 $this->select('address_1_state_province_id', "value=1004");
1031 $this->click('_qf_Contact_upload_view-bottom');
1032 $this->waitForPageToLoad($this->getTimeoutMsec());
1034 // add contact to group
1036 $this->click("css=li#tab_group a");
1037 $this->waitForElementPresent("group_id");
1040 $this->select("group_id", "label=$groupName");
1041 $this->click("_qf_GroupContact_next");
1042 $this->waitForPageToLoad($this->getTimeoutMsec());
1044 $this->openCiviPage("admin/custom/group", "action=add&reset=1", "_qf_Group_next-bottom");
1046 // fill in a unique title for the c$groupIdustom group
1047 $groupTitle = "Members Custom Group" . substr(sha1(rand()), 0, 7);
1048 $this->type("title", $groupTitle);
1050 // select the group this custom data set extends
1051 $this->select("extends[0]", "value=Membership");
1052 $this->waitForElementPresent("extends[1]");
1054 // save the custom group
1055 $this->click("_qf_Group_next-bottom");
1057 $this->waitForElementPresent("_qf_Field_next_new-bottom");
1058 $this->assertTrue($this->isTextPresent("Your custom field set '$groupTitle' has been added. You can add custom fields now."));
1060 // add a custom field to the custom group
1061 $fieldTitle = "Member Custom Field " . substr(sha1(rand()), 0, 7);
1062 $this->type("label", $fieldTitle);
1064 $this->select("data_type[1]", "value=Text");
1065 $this->click('_qf_Field_next-bottom');
1067 $this->waitForPageToLoad($this->getTimeoutMsec());
1068 $this->assertTrue($this->isTextPresent("Custom field '$fieldTitle' has been saved."));
1069 $fieldId = $this->urlArg('id', $this->getAttribute("xpath=//div[@id='field_page']/div[2]/table/tbody//tr/td[1]/span[text()='$fieldTitle']/../td[8]/span/a@href"));
1071 // Enable CiviCampaign module if necessary
1072 $this->enableComponents("CiviCampaign");
1074 // add the required permission
1075 $permission = array('edit-2-administer-civicampaign');
1076 $this->changePermissions($permission);
1078 // Log in as normal user
1079 $this->webtestLogin();
1081 $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom");
1083 $title = 'Campaign ' . substr(sha1(rand()), 0, 7);
1084 $this->type("title", $title);
1086 // select the campaign type
1087 $this->select("campaign_type_id", "value=2");
1089 // fill in the description
1090 $this->type("description", "This is a test campaign");
1092 // include groups for the campaign
1093 $this->addSelection("includeGroups-f", "label={$groupName}");
1094 $this->click("//option[@value={$groupId}]");
1095 $this->click("add");
1097 // fill the end date for campaign
1098 $this->webtestFillDate("end_date", "+1 year");
1100 // select campaign status
1101 $this->select("status_id", "value=2");
1104 $this->click("_qf_Campaign_upload-bottom");
1105 $this->waitForPageToLoad($this->getTimeoutMsec());
1107 $this->assertTrue($this->isTextPresent("Campaign {$title} has been saved."), "Status message didn't show up after saving!");
1109 $this->openCiviPage("admin/uf/group", "reset=1");
1110 $this->click("link=Reserved Profiles");
1111 $this->click("xpath=//div[@id='reserved-profiles']/div/div/table/tbody//tr/td[1][text()='On Behalf Of Organization']/../td[5]/span/a[text()='Fields']");
1112 $this->waitForPageToLoad($this->getTimeoutMsec());
1114 $this->click("link=Add Field");
1115 $this->waitForElementPresent('_qf_Field_next-bottom');
1116 $this->select('field_name[0]', 'value=Membership');
1117 $this->select('field_name[1]', 'label=Campaign');
1118 $this->click('field_name[1]');
1119 $this->clickLink('_qf_Field_next_new-bottom', '_qf_Field_cancel-bottom');
1121 $this->select('field_name[0]', 'value=Membership');
1122 $this->select('field_name[1]', "label=$fieldTitle :: $groupTitle");
1123 $this->click('field_name[1]');
1124 $this->click('_qf_Field_next-bottom');
1125 $this->waitForPageToLoad($this->getTimeoutMsec());
1126 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$fieldTitle}' has been saved to 'On Behalf Of Organization'."),
1127 "Status message didn't show up after saving!"
1130 // Open Page to create Organization 1
1131 $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom");
1132 $orgName1 = 'org1_' . substr(sha1(rand()), 0, 7);
1134 // Type Organization name
1135 $this->type("organization_name", $orgName1);
1137 // Type Organizatio email for main
1138 $this->type("email_1_email", "{$orgName1}@example.com");
1139 $this->select("email_1_location_type_id", "value=3");
1141 // type phone no for main
1142 $this->type("phone_1_phone", substr(sha1(rand()), 0, 4));
1143 $this->select("phone_1_location_type_id", "value=3");
1146 $this->click("addressBlock");
1147 $this->waitForElementPresent("address_1_street_address");
1149 //fill in address 1 for main
1150 $this->select("address_1_location_type_id", "value=3");
1151 $this->type("address_1_street_address", "{$orgName1} street address");
1152 $this->type("address_1_city", "{$orgName1} city");
1153 $this->type("address_1_postal_code", "9999999999");
1154 $this->assertTrue($this->isTextPresent("- select - United States"));
1155 $this->select("address_1_state_province_id", "value=1019");
1156 $this->type("address_1_geo_code_1", "1234");
1157 $this->type("address_1_geo_code_2", "5678");
1159 // Save the Organization
1160 $this->click("_qf_Contact_upload_view-bottom");
1161 $this->waitForPageToLoad($this->getTimeoutMsec());
1163 // create second orzanization
1164 $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom");
1165 $orgName2 = 'org2_' . substr(sha1(rand()), 0, 7);
1167 // Type Organization name
1168 $this->type("organization_name", $orgName2);
1170 // Type Organizatio email for main
1171 $this->type("email_1_email", "{$orgName2}@example.com");
1172 $this->select("email_1_location_type_id", "value=3");
1174 // type phone no for main
1175 $this->type("phone_1_phone", substr(sha1(rand()), 0, 4));
1176 $this->select("phone_1_location_type_id", "value=3");
1179 $this->click("addressBlock");
1180 $this->waitForElementPresent("address_1_street_address");
1182 //fill in address 1 for main
1183 $this->select("address_1_location_type_id", "value=3");
1184 $this->type("address_1_street_address", "{$orgName2} street address");
1185 $this->type("address_1_city", "{$orgName2} city");
1186 $this->type("address_1_postal_code", "7777777777");
1187 $this->assertTrue($this->isTextPresent("- select - United States"));
1188 $this->select("address_1_state_province_id", "value=1019");
1189 $this->type("address_1_geo_code_1", "1224");
1190 $this->type("address_1_geo_code_2", "5628");
1192 // Save the Organization
1193 $this->click("_qf_Contact_upload_view-bottom");
1194 $this->waitForPageToLoad($this->getTimeoutMsec());
1196 // create Membership type
1197 $title1 = "Membership Type" . substr(sha1(rand()), 0, 7);
1198 $this->openCiviPage("admin/member/membershipType", "reset=1&action=browse");
1200 $this->click("link=Add Membership Type");
1201 $this->waitForElementPresent('_qf_MembershipType_cancel-bottom');
1203 $this->type('name', $title1);
1204 $this->type('member_org', $orgName1);
1205 $this->click('_qf_MembershipType_refresh');
1206 $this->waitForElementPresent("xpath=//div[@id='membership_type_form']/fieldset/table[2]/tbody/tr[2]/td[2]");
1208 $this->type('minimum_fee', '50');
1210 $this->select( 'financial_type_id', 'value=2' );
1212 $this->type('duration_interval', 1);
1213 $this->select('duration_unit', "label=year");
1215 $this->select('period_type', "label=fixed");
1216 $this->waitForElementPresent('fixed_period_rollover_day[d]');
1218 $this->select('fixed_period_start_day[M]', 'value=4');
1219 $this->select('fixed_period_rollover_day[M]', 'value=1');
1221 $this->select('relationship_type_id', 'value=4_b_a');
1223 $this->click('_qf_MembershipType_upload-bottom');
1224 $this->waitForElementPresent('link=Add Membership Type');
1225 $this->assertTrue($this->isTextPresent("The membership type '$title1' has been saved."));
1226 $typeId = $this->urlArg('id', $this->getAttribute("xpath=//div[@id='membership_type']/div[2]/table/tbody//tr/td[1][text()='{$title1}']/../td[10]/span/a[3]@href"));
1229 $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1");
1231 // select relationship type
1232 $this->click("relationship_type_id");
1233 $this->select("relationship_type_id", "value=4_a_b");
1235 // search organization
1236 $this->type('contact_1', $orgName1);
1237 $this->click("contact_1");
1238 $this->waitForElementPresent("css=div.ac_results-inner li");
1239 $this->click("css=div.ac_results-inner li");
1240 $this->assertContains($orgName1, $this->getValue('contact_1'), "autocomplete expected $orgName1 but didn’t find it in " . $this->getValue('contact_1'));
1243 $this->click("is_permission_a_b");
1244 $this->click("is_permission_b_a");
1246 // save relationship
1247 $this->click("details-save");
1250 $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1");
1252 // select relationship type
1253 $this->click("relationship_type_id");
1254 $this->select("relationship_type_id", "value=4_a_b");
1256 // search organization
1257 $this->type('contact_1', $orgName2);
1258 $this->click("contact_1");
1259 $this->waitForElementPresent("css=div.ac_results-inner li");
1260 $this->click("css=div.ac_results-inner li");
1261 $this->assertContains($orgName2, $this->getValue('contact_1'), "autocomplete expected $orgName2 but didn’t find it in " . $this->getValue('contact_1'));
1264 $this->click("is_permission_a_b");
1265 $this->click("is_permission_b_a");
1267 // save relationship
1268 $this->click("details-save");
1270 // set membership type
1271 $this->openCiviPage("admin/contribute/membership", "reset=1&action=update&id=$pageId", "_qf_MembershipBlock_upload_done-bottom");
1272 $this->click("member_is_active");
1273 $this->click("membership_type[{$typeId}]");
1274 $this->click("xpath=//div[@id='memberFields']//table[@class='report']/tbody//tr/td[1]/label[text()='{$title1}']/../../td[2]/input");
1275 $this->click('_qf_MembershipBlock_upload_done-bottom');
1276 $this->waitForPageToLoad($this->getTimeoutMsec());
1278 //Open Live Membership Page
1279 $this->openCiviPage('contribute/transact', "reset=1&id=$pageId&cid=$cid", "_qf_Main_upload-bottom");
1280 $this->click('CIVICRM_QFID_amount_other_radio_4');
1281 $this->type('amount_other', 60);
1282 $this->click('onbehalf_organization_name');
1283 $this->type('onbehalf_organization_name', $orgName1);
1284 $this->typeKeys('onbehalf_organization_name', $orgName1);
1285 $this->click("onbehalf_organization_name");
1286 $this->waitForElementPresent("css=div.ac_results-inner li");
1287 $this->click("css=div.ac_results-inner li");
1288 // Because it tends to cause problems, all uses of sleep() must be justified in comments
1289 // Sleep should never be used for wait for anything to load from the server
1290 // Justification for this instance: FIXME
1292 $this->click('onbehalf_member_campaign_id');
1293 $this->select('onbehalf_member_campaign_id', "label={$title}");
1294 $this->type("onbehalf_custom_{$fieldId}", 'Test Subject');
1296 $this->assertContains($orgName1, $this->getValue('onbehalf_organization_name'), "autocomplete expected $orgName1 but didn’t find it in " . $this->getValue('onbehalf_organization_name'));
1299 $this->select("credit_card_type", "value=Visa");
1300 $this->type("credit_card_number", "4111111111111111");
1301 $this->type("cvv2", "000");
1302 $this->select("credit_card_exp_date[M]", "value=1");
1303 $this->select("credit_card_exp_date[Y]", "value=2020");
1305 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
1306 $this->click("_qf_Confirm_next-bottom");
1307 $this->waitForPageToLoad($this->getTimeoutMsec());
1309 //Find Membership for organization
1310 $this->openCiviPage("member/search", "reset=1");
1311 $this->type("sort_name", $orgName1);
1312 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='memberSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
1313 $this->clickLink("xpath=//div[@id='memberSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_MembershipView_cancel-bottom");
1315 //verify contrb created
1321 foreach ($expected as $value => $label) {
1322 $this->verifyText("xpath=//form[@id='MembershipView']/div[2]/div/table/tbody/tr[$value]/td[2]", preg_quote($label));
1325 // find membership for contact in relationship
1326 $this->openCiviPage("contact/view", "reset=1&force=1&cid={$cid}");
1327 $this->click("css=li#tab_member a");
1328 $this->waitForElementPresent("xpath=//div[@id='memberships']/div/table//tbody//tr/td[1][text()='{$title1}']");
1329 $this->click("xpath=//div[@id='memberships']/div/table//tbody//tr/td[1][text()='{$title1}']/../td[7]/span/a[text()='View']");
1330 $this->waitForPageToLoad($this->getTimeoutMsec());
1332 //verify contrb created
1337 foreach ($expected as $value => $label) {
1338 $this->verifyText("xpath=//form[@id='MembershipView']/div[2]/div/table/tbody/tr[$value]/td[2]", preg_quote($label));
1341 $this->openCiviPage("admin/uf/group", "reset=1");
1342 $this->click("link=Reserved Profiles");
1343 $this->click("xpath=//div[@id='reserved-profiles']/div/div/table/tbody//tr/td[1][text()='On Behalf Of Organization']/../td[5]/span/a[text()='Fields']");
1344 $this->waitForPageToLoad($this->getTimeoutMsec());
1346 $this->click("xpath=//div[@id='field_page']/div[3]/table/tbody//tr/td[1][text()='Campaign']/../td[9]/span[2][text()='more ']/ul/li[2]/a[text()='Delete']");
1347 $this->waitForElementPresent('_qf_Field_next-bottom');
1349 $this->click('_qf_Field_next-bottom');
1350 $this->waitForPageToLoad($this->getTimeoutMsec());
1351 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'),
1352 "Status message didn't show up after saving!"
1355 $this->click("xpath=//div[@id='field_page']/div[3]/table/tbody//tr/td[1][text()='{$fieldTitle}']/../td[9]/span[2][text()='more ']/ul/li[2]/a[text()='Delete']");
1356 $this->waitForElementPresent('_qf_Field_next-bottom');
1358 $this->click('_qf_Field_next-bottom');
1359 $this->waitForPageToLoad($this->getTimeoutMsec());
1360 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'),
1361 "Status message didn't show up after saving!"
1364 $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
1365 $this->click("css=li#tab_rel a");
1367 $this->waitForElementPresent("xpath=//div[@id='current-relationships']/div/table/tbody//tr/td[2]/a[text()='{$orgName1}']");
1368 $this->click("xpath=//div[@id='current-relationships']/div/table/tbody//tr/td[2]/a[text()='{$orgName1}']/../../td[9]/span[2][text()='more ']/ul/li[2]/a[text()='Delete']");
1370 // Check confirmation alert.
1371 $this->assertTrue((bool)preg_match("/^Are you sure you want to delete this relationship?/",
1372 $this->getConfirmation()
1374 $this->chooseOkOnNextConfirmation();
1375 $this->waitForPageToLoad($this->getTimeoutMsec());
1376 $this->assertTrue($this->isTextPresent('Selected relationship has been deleted successfully.'),
1377 "Status message didn't show up after saving!"
1381 function testOnBehalfOfOrganizationWithImage() {
1382 $this->webtestLogin();
1384 $this->openCiviPage("profile/edit", "reset=1&gid=4");
1385 $firstName = 'John_x_' . substr(sha1(rand()), 0, 7);
1386 $lastName = 'Anderson_c_' . substr(sha1(rand()), 0, 7);
1388 $this->waitForPageToLoad($this->getTimeoutMsec());
1389 $this->waitForElementPresent("_qf_Edit_next");
1390 $this->type("first_name", $firstName);
1391 $this->type("last_name", $lastName);
1392 $this->clickLink("_qf_Edit_next", "profilewrap4");
1394 $cid = $this->urlArg('id');
1395 $this->assertType('numeric', $cid);
1396 // Is status message correct?
1397 $this->assertTextPresent("Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!");
1399 $this->openCiviPage("admin/uf/group", "reset=1");
1400 $this->click("link=Reserved Profiles");
1402 $this->click("xpath=//div[@id='reserved-profiles']/div/div/table/tbody//tr/td[1][text()='On Behalf Of Organization']/../td[5]/span/a[text()='Fields']");
1403 $this->waitForPageToLoad($this->getTimeoutMsec());
1405 $this->click("link=Add Field");
1406 $this->waitForElementPresent('_qf_Field_next-bottom');
1408 $this->select('field_name[0]', 'value=Contact');
1409 $this->select('field_name[1]', 'label=Image Url');
1410 $this->click('field_name[1]');
1411 $this->click('_qf_Field_next-bottom');
1412 $this->waitForPageToLoad($this->getTimeoutMsec());
1414 // Use default payment processor
1415 $processorName = 'Test Processor';
1416 $processorType = 'Dummy';
1417 $pageTitle = substr(sha1(rand()), 0, 7);
1419 $hash = substr(sha1(rand()), 0, 7);
1420 $amountSection = TRUE;
1425 $memberships = FALSE;
1426 $memPriceSetId = NULL;
1428 $profilePreId = NULL;
1429 $profilePostId = NULL;
1433 $honoreeSection = FALSE;
1434 $isAddPaymentProcessor = TRUE;
1435 $isPcpApprovalNeeded = FALSE;
1436 $isSeparatePayment = FALSE;
1438 // create a new online contribution page
1439 // create contribution page with randomized title and default params
1440 $pageId = $this->webtestAddContributionPage($hash,
1443 array($processorName => $processorType),
1457 $isAddPaymentProcessor,
1458 $isPcpApprovalNeeded,
1463 $this->_testOrganizationWithImageUpload($pageId, $cid, $pageTitle);
1465 $this->openCiviPage("admin/uf/group", "reset=1");
1466 $this->click("link=Reserved Profiles");
1468 $this->click("xpath=//div[@id='reserved-profiles']/div/div/table/tbody//tr/td[1][text()='On Behalf Of Organization']/../td[5]/span/a[text()='Fields']");
1469 $this->waitForPageToLoad($this->getTimeoutMsec());
1470 $this->click("xpath=//table[@id='option11']/tbody//tr/td/span[text()='Image Url']/../following-sibling::td[8]/span[2]/ul/li[2]/a");
1471 $this->waitForPageToLoad($this->getTimeoutMsec());
1472 $this->click('_qf_Field_next-bottom');
1473 $this->waitForPageToLoad($this->getTimeoutMsec());
1474 $this->waitForText('crm-notification-container', "Selected Profile Field has been deleted.");
1478 * @param int $pageId
1482 function _testOrganizationWithImageUpload($pageId, $cid, $pageTitle) {
1483 //Open Live Contribution Page
1484 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", '_qf_Main_upload-bottom');
1486 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
1487 $lastName = 'An' . substr(sha1(rand()), 0, 7);
1488 $orgName = 'org_11_' . substr(sha1(rand()), 0, 7);
1489 $this->type("email-5", $firstName . "@example.com");
1491 // onbehalforganization info
1492 $this->type("onbehalf_organization_name", $orgName);
1493 $this->type("onbehalf_phone-3-1", 9999999999);
1494 $this->type("onbehalf_email-3", "{$orgName}@example.com");
1495 $this->type("onbehalf_street_address-3", "Test Street Address");
1496 $this->type("onbehalf_city-3", "Test City");
1497 $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
1498 $this->click("onbehalf_country-3");
1499 $this->select("onbehalf_country-3", "label=United States");
1500 $this->click("onbehalf_state_province-3");
1501 $this->select("onbehalf_state_province-3", "label=Alabama");
1503 // check for upload field.
1504 $this->waitForElementPresent("onbehalf_image_URL");
1506 //header("Content-Type: image/png");
1507 $im = imagecreate(110, 20)
1508 or die("Cannot Initialize new GD image stream");
1509 $background_color = imagecolorallocate($im, 0, 0, 0);
1510 $text_color = imagecolorallocate($im, 233, 14, 91);
1511 imagestring($im, 1, 5, 5, "On Behalf-Org Logo", $text_color);
1512 imagepng($im,"/tmp/file.png");
1514 $imagePath = "/tmp/file.png";
1515 $this->webtestAttachFile('onbehalf_image_URL', $imagePath);
1519 $this->select("credit_card_type", "value=Visa");
1520 $this->type("credit_card_number", "4111111111111111");
1521 $this->type("cvv2", "000");
1522 $this->select("credit_card_exp_date[M]", "value=1");
1523 $this->select("credit_card_exp_date[Y]", "value=2020");
1526 $this->type("billing_first_name", $firstName . 'billing');
1527 $this->type("billing_last_name", $lastName . 'billing');
1528 $this->type("billing_street_address-5", "0121 Mount Highschool.");
1529 $this->type(" billing_city-5", "Shangai");
1530 $this->select("billing_country_id-5", "value=1228");
1531 $this->select("billing_state_province_id-5", "value=1004");
1532 $this->type("billing_postal_code-5", "94129");
1533 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
1535 $this->click("_qf_Confirm_next-bottom");
1536 $this->waitForPageToLoad($this->getTimeoutMsec());
1538 // Type search name in autocomplete.
1539 $this->click('sort_name_navigation');
1540 $this->type('css=input#sort_name_navigation', $orgName);
1541 $this->typeKeys('css=input#sort_name_navigation', $orgName);
1543 // Wait for result list.
1544 $this->waitForElementPresent("css=div.ac_results-inner li");
1546 // Visit organization page.
1547 $this->click("css=div.ac_results-inner li");
1548 $this->waitForPageToLoad($this->getTimeoutMsec());
1550 //check whether the image is present
1551 $this->assertTrue($this->isElementPresent("xpath=//div[@id='crm-contact-thumbnail']/div/a/img"));