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 = '';
35 protected function setUp() {
39 public function testOnBehalfOfOrganization() {
40 $this->webtestLogin();
42 // create new individual
43 $firstName = 'John_' . substr(sha1(rand()), 0, 7);
44 $lastName = 'Anderson_' . substr(sha1(rand()), 0, 7);
45 $email = "{$firstName}.{$lastName}@example.com";
46 $contactParams = array(
47 'first_name' => $firstName,
48 'last_name' => $lastName,
51 $streetAddress = "100 Main Street";
53 //adding contact for membership sign up
54 $this->webtestAddContact($firstName, $lastName, $email);
55 $cid = $this->urlArg('cid');
57 // Use default payment processor
58 $processorName = 'Test Processor';
59 $processorType = 'Dummy';
60 $pageTitle = substr(sha1(rand()), 0, 7);
62 $hash = substr(sha1(rand()), 0, 7);
63 $amountSection = TRUE;
65 $onBehalf = 'optional';
69 $memPriceSetId = NULL;
72 $profilePostId = NULL;
76 $honoreeSection = FALSE;
77 $isAddPaymentProcessor = TRUE;
78 $isPcpApprovalNeeded = FALSE;
79 $isSeparatePayment = FALSE;
81 // create a new online contribution page
82 // create contribution page with randomized title and default params
83 $pageId = $this->webtestAddContributionPage($hash,
86 array($processorName => $processorType),
100 $isAddPaymentProcessor,
101 $isPcpApprovalNeeded,
107 $this->webtestLogout();
108 //$this->_testAnomoyousOganization($pageId, $cid, $pageTitle);
109 $this->webtestLogout();
110 $this->_testUserWithOneRelationship($pageId, $cid, $pageTitle);
111 $this->webtestLogout();
112 $this->_testUserWithMoreThanOneRelationship($pageId, $cid, $pageTitle);
115 public function testOnBehalfOfOrganizationWithMembershipData() {
116 $this->webtestLogin();
118 // create new individual
119 $this->openCiviPage("profile/edit", "reset=1&gid=4");
120 $firstName = 'John_x_' . substr(sha1(rand()), 0, 7);
121 $lastName = 'Anderson_c_' . substr(sha1(rand()), 0, 7);
123 $this->waitForPageToLoad($this->getTimeoutMsec());
124 $this->waitForElementPresent("_qf_Edit_next");
125 $this->type("first_name", $firstName);
126 $this->type("last_name", $lastName);
127 $this->clickLink("_qf_Edit_next", "profilewrap4");
129 // Is status message correct?
130 $this->assertTextPresent("Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!");
134 $this->openCiviPage("admin/custom/group", "action=add&reset=1");
136 //fill custom group title
137 $customGroupTitle = 'custom_' . substr(sha1(rand()), 0, 7);
138 $this->click("title");
139 $this->type("title", $customGroupTitle);
141 //custom group extends
142 $this->click("extends[0]");
143 $this->select("extends[0]", "value=Membership");
144 //$this->click("//option[@value='Contact']");
145 $this->click("_qf_Group_next-bottom");
146 $this->waitForElementPresent("_qf_Field_cancel-bottom");
148 //Is custom group created?
149 $this->assertTrue($this->isTextPresent("Your custom field set '{$customGroupTitle}' has been added. You can add custom fields now."));
151 //add custom field - alphanumeric checkbox
152 $checkboxFieldLabel = 'custom_field' . substr(sha1(rand()), 0, 4);
153 $this->click("label");
154 $this->type("label", $checkboxFieldLabel);
155 $this->click("data_type[1]");
156 $this->select("data_type[1]", "value=CheckBox");
157 $this->click("//option[@value='CheckBox']");
158 $checkboxOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
159 $this->type("option_label_1", $checkboxOptionLabel1);
160 $this->type("option_value_1", "1");
161 $checkboxOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
162 $this->type("option_label_2", $checkboxOptionLabel2);
163 $this->type("option_value_2", "2");
164 $this->click("link=another choice");
165 $checkboxOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
166 $this->type("option_label_3", $checkboxOptionLabel3);
167 $this->type("option_value_3", "3");
169 //enter options per line
170 $this->type("options_per_line", "2");
172 //enter pre help message
173 $this->type("help_pre", "this is field pre help");
175 //enter post help message
176 $this->type("help_post", "this field post help");
179 $this->click("is_searchable");
182 $this->click("_qf_Field_next");
183 $this->waitForPageToLoad($this->getTimeoutMsec());
185 //Is custom field created?
186 $this->assertTrue($this->isTextPresent("Custom field '$checkboxFieldLabel' has been saved."));
188 //create another custom field - Integer Radio
189 $this->click("//a[@id='newCustomField']/span");
190 $this->waitForPageToLoad($this->getTimeoutMsec());
191 $this->click("data_type[0]");
192 $this->select("data_type[0]", "value=1");
193 $this->click("//option[@value='1']");
194 $this->click("data_type[1]");
195 $this->select("data_type[1]", "value=Radio");
196 $this->click("//option[@value='Radio']");
198 $radioFieldLabel = 'custom_field' . substr(sha1(rand()), 0, 4);
199 $this->type("label", $radioFieldLabel);
200 $radioOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
201 $this->type("option_label_1", $radioOptionLabel1);
202 $this->type("option_value_1", "1");
203 $radioOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
204 $this->type("option_label_2", $radioOptionLabel2);
205 $this->type("option_value_2", "2");
206 $this->click("link=another choice");
207 $radioOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
208 $this->type("option_label_3", $radioOptionLabel3);
209 $this->type("option_value_3", "3");
211 //select options per line
212 $this->type("options_per_line", "3");
215 $this->type("help_pre", "this is field pre help");
217 //enter post help msg
218 $this->type("help_post", "this is field post help");
221 $this->click("is_searchable");
224 $this->click("_qf_Field_next");
225 $this->waitForPageToLoad($this->getTimeoutMsec());
227 //Is custom field created
228 $this->assertTrue($this->isTextPresent("Custom field '$radioFieldLabel' has been saved."));
230 //add the above custom data to the On Behalf of Profile
231 $this->openCiviPage("admin/uf/group", "reset=1");
232 $this->click("link=Reserved Profiles");
234 $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']");
235 $this->waitForPageToLoad($this->getTimeoutMsec());
237 $this->click("link=Add Field");
238 $this->waitForElementPresent('_qf_Field_next-bottom');
239 $this->select('field_name[0]', 'value=Membership');
240 $label = $checkboxFieldLabel . ' :: ' . $customGroupTitle;
241 $this->select('field_name[1]', "label=$label");
242 $this->click('field_name[1]');
243 $this->click('_qf_Field_next_new-bottom');
244 $this->waitForPageToLoad($this->getTimeoutMsec());
246 $this->select('field_name[0]', 'value=Membership');
247 $label = $radioFieldLabel . ' :: ' . $customGroupTitle;
248 $this->select('field_name[1]', "label=$label");
249 $this->click('field_name[1]');
250 $this->click('_qf_Field_next-bottom');
251 $this->waitForPageToLoad($this->getTimeoutMsec());
252 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$radioFieldLabel}' has been saved to 'On Behalf Of Organization'."));
254 //create organisation
255 $orgName = "Org WebAccess " . substr(sha1(rand()), 0, 7);
256 $orgEmail = "org" . substr(sha1(rand()), 0, 7) . "@web.com";
257 $this->webtestAddOrganization($orgName, $orgEmail);
259 $this->waitForPageToLoad($this->getTimeoutMsec());
260 $this->click("css=li#tab_member a");
262 $this->waitForElementPresent('link=Add Membership');
263 $this->click('link=Add Membership');
265 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
267 // fill in Membership Organization and Type
268 $this->select('membership_type_id[0]', "value=1");
269 $this->select('membership_type_id[1]', "value=1");
272 $sourceText = 'On behalf Membership Webtest';
273 $this->type('source', $sourceText);
275 $this->waitForElementPresent("css=div#{$customGroupTitle} div.crm-accordion-header");
276 $this->click("css=div#{$customGroupTitle} div.crm-accordion-header");
277 //$this->waitForElementPresent('_qf_Membership_cancel-bottom111');
279 // select newly created processor
280 $xpath = "xpath=//label[text() = '{$checkboxOptionLabel1}']/preceding-sibling::input[1]";
281 $this->assertTrue($this->isTextPresent($checkboxOptionLabel1));
282 $this->check($xpath);
284 $xpath = "xpath=//label[text() = '{$checkboxOptionLabel3}']/preceding-sibling::input[1]";
285 $this->assertTrue($this->isTextPresent($checkboxOptionLabel3));
286 $this->check($xpath);
288 $xpath = "xpath=//label[text() = '{$radioOptionLabel1}']/preceding-sibling::input[1]";
289 $this->assertTrue($this->isTextPresent($radioOptionLabel1));
290 $this->check($xpath);
292 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
293 $this->click('_qf_Membership_upload-bottom');
295 $this->waitForPageToLoad($this->getTimeoutMsec());
296 $this->click("css=li#tab_rel a");
298 $this->waitForElementPresent('link=Add Relationship');
299 $this->click('link=Add Relationship');
301 $this->waitForElementPresent('relationship_type_id');
302 $this->click("relationship_type_id");
303 $this->select("relationship_type_id", "label=Employer of");
304 // search organization
305 $this->type('contact_1', $firstName);
306 $this->click("contact_1");
307 $this->waitForElementPresent("css=div.ac_results-inner li");
308 $this->click("css=div.ac_results-inner li");
309 $this->assertContains($firstName, $this->getValue('contact_1'), "autocomplete expected $firstName but didn’t find it in " . $this->getValue('contact_1'));
312 $this->click("is_permission_a_b");
313 $this->click("is_permission_b_a");
316 $this->click("details-save");
317 $this->waitForPageToLoad($this->getTimeoutMsec());
319 // Use default payment processor
320 $processorName = 'Test Processor';
321 $processorType = 'Dummy';
322 $pageTitle = substr(sha1(rand()), 0, 7);
324 $hash = substr(sha1(rand()), 0, 7);
325 $amountSection = TRUE;
331 $memPriceSetId = NULL;
333 $profilePreId = NULL;
334 $profilePostId = NULL;
338 $honoreeSection = FALSE;
339 $isAddPaymentProcessor = TRUE;
340 $isPcpApprovalNeeded = FALSE;
341 $isSeparatePayment = FALSE;
343 // create a new online contribution page
344 // create contribution page with randomized title and default params
345 $pageId = $this->webtestAddContributionPage($hash,
348 array($processorName => $processorType),
362 $isAddPaymentProcessor,
363 $isPcpApprovalNeeded,
369 //scenario 1 : add membership data in pre / post profile and check for formRule
371 $this->openCiviPage("admin/uf/group", "reset=1");
372 $this->click('link=Add Profile');
374 $profileTitle = "test profile" . substr(sha1(rand()), 0, 7);
375 // Add membership custom data field to profile
376 $this->waitForElementPresent('_qf_Group_cancel-bottom');
377 $this->type('title', $profileTitle);
378 $this->clickLink('_qf_Group_next-bottom');
380 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now."));
382 $gid = $this->urlArg('gid');
384 $this->openCiviPage('admin/uf/group/field/add', array(
389 $this->select('field_name[0]', "value=Membership");
390 $this->select('field_name[1]', "label={$checkboxFieldLabel} :: {$customGroupTitle}");
391 $this->click('field_name[1]');
392 $this->click('label');
394 // Clicking save and new
395 $this->click('_qf_Field_next_new-bottom');
396 $this->waitForPageToLoad($this->getTimeoutMsec());
397 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$checkboxFieldLabel}' has been saved to '{$profileTitle}'."));
399 $this->openCiviPage("admin/contribute/custom", "reset=1&action=update&id={$pageId}", '_qf_Custom_next-bottom');
400 $this->select('custom_pre_id', "label={$profileTitle}");
401 $this->click('_qf_Custom_next-bottom');
402 $this->waitForPageToLoad($this->getTimeoutMsec());
403 // Because it tends to cause problems, all uses of sleep() must be justified in comments
404 // Sleep should never be used for wait for anything to load from the server
405 // Justification for this instance: FIXME
407 $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");
409 $this->select('custom_pre_id', "- select -");
410 $this->select('custom_post_id', "label={$profileTitle}");
411 $this->click('_qf_Custom_next-bottom');
412 $this->waitForPageToLoad($this->getTimeoutMsec());
413 // Because it tends to cause problems, all uses of sleep() must be justified in comments
414 // Sleep should never be used for wait for anything to load from the server
415 // Justification for this instance: FIXME
417 $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");
419 //scenario 2 : disable 'on behalf of', add membership data in pre / post profile
420 //then try to add 'on behalf of' and check for formRule
421 //disable 'on behalf of'
422 $this->openCiviPage("admin/contribute/settings", "reset=1&action=update&id={$pageId}", '_qf_Settings_next-bottom');
423 $this->uncheck('is_organization');
424 $this->click('_qf_Settings_next-bottom');
425 $this->waitForPageToLoad($this->getTimeoutMsec());
427 //set a membership field profile for this contribution page
428 $this->click('css=li#tab_custom a');
429 $this->waitForElementPresent('_qf_Custom_next-bottom');
430 $this->select('custom_pre_id', "label={$profileTitle}");
431 $this->click('_qf_Custom_next-bottom');
432 $this->waitForPageToLoad($this->getTimeoutMsec());
434 //now visit the title settings page and configure the profile as on behalf of
435 $this->click('css=li#tab_settings a');
436 $this->waitForElementPresent('_qf_Settings_next-bottom');
437 $this->check('is_organization');
438 $this->click('_qf_Settings_next-bottom');
439 $this->waitForPageToLoad($this->getTimeoutMsec());
440 // Because it tends to cause problems, all uses of sleep() must be justified in comments
441 // Sleep should never be used for wait for anything to load from the server
442 // Justification for this instance: FIXME
444 $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");
447 $this->webtestLogout();
450 public function testOnBehalfOfOrganizationWithOrgData() {
451 $this->webtestLogin();
453 $this->openCiviPage("profile/edit", "reset=1&gid=4");
454 $firstName = 'John_x_' . substr(sha1(rand()), 0, 7);
455 $lastName = 'Anderson_c_' . substr(sha1(rand()), 0, 7);
457 $this->waitForPageToLoad($this->getTimeoutMsec());
458 $this->waitForElementPresent("_qf_Edit_next");
459 $this->type("first_name", $firstName);
460 $this->type("last_name", $lastName);
461 $this->clickLink("_qf_Edit_next", "profilewrap4");
463 $cid = $this->urlArg('id');
464 // Is status message correct?
465 $this->assertTextPresent("Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!");
467 //add org fields to profile
468 $this->openCiviPage("admin/uf/group", "reset=1");
469 $this->click("link=Reserved Profiles");
471 $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']");
472 $this->waitForPageToLoad($this->getTimeoutMsec());
474 $this->click("link=Add Field");
475 $this->waitForElementPresent('_qf_Field_next-bottom');
477 $this->select('field_name[0]', 'value=Organization');
478 $this->select('field_name[1]', 'label=Legal Identifier');
479 $this->click('field_name[1]');
480 $this->click('_qf_Field_next_new-bottom');
481 $this->waitForPageToLoad($this->getTimeoutMsec());
483 $this->select('field_name[0]', 'value=Organization');
484 $this->select('field_name[1]', 'label=Legal Name');
485 $this->click('field_name[1]');
486 $this->click('_qf_Field_next-bottom');
487 $this->waitForPageToLoad($this->getTimeoutMsec());
489 //create organisation
490 $orgName = "Org WebAccess " . substr(sha1(rand()), 0, 7);
491 $orgEmail = "org" . substr(sha1(rand()), 0, 7) . "@web.com";
492 $this->webtestAddOrganization($orgName, $orgEmail);
494 $this->waitForPageToLoad($this->getTimeoutMsec());
495 $this->click("css=li#tab_rel a");
497 $this->waitForElementPresent('link=Add Relationship');
498 $this->click('link=Add Relationship');
500 $this->waitForElementPresent('relationship_type_id');
501 $this->click("relationship_type_id");
502 $this->select("relationship_type_id", "label=Employer of");
503 // search organization
504 $this->type('contact_1', $firstName);
505 $this->click("contact_1");
506 $this->waitForElementPresent("css=div.ac_results-inner li");
507 $this->click("css=div.ac_results-inner li");
508 $this->assertContains($firstName, $this->getValue('contact_1'), "autocomplete expected $firstName but didn’t find it in " . $this->getValue('contact_1'));
511 $this->click("is_permission_a_b");
512 $this->click("is_permission_b_a");
515 $this->waitForElementPresent("details-save");
516 $this->click("details-save");
517 $this->waitForElementPresent("Relationships");
519 $pageTitle = substr(sha1(rand()), 0, 7);
521 $hash = substr(sha1(rand()), 0, 7);
522 $amountSection = TRUE;
528 $memPriceSetId = NULL;
530 $profilePreId = NULL;
531 $profilePostId = NULL;
535 $honoreeSection = FALSE;
536 $isAddPaymentProcessor = FALSE;
537 $isPcpApprovalNeeded = FALSE;
538 $isSeparatePayment = FALSE;
540 // create a new online contribution page
541 // create contribution page with randomized title and default params
542 $pageId = $this->webtestAddContributionPage($hash,
559 $isAddPaymentProcessor,
560 $isPcpApprovalNeeded,
565 $this->_testOrganization($pageId, $cid, $pageTitle);
568 public function testWithContactSubtypeDupe() {
569 $this->webtestLogin();
571 //create organisation
572 $orgName = "Org WebAccess " . substr(sha1(rand()), 0, 7);
573 $orgEmail = "org" . substr(sha1(rand()), 0, 7) . "@web.com";
574 $contactSubType = 'Sponsor';
575 $this->webtestAddOrganization($orgName, $orgEmail, $contactSubType);
577 $this->waitForPageToLoad($this->getTimeoutMsec());
578 $cid = $this->urlArg('cid');
580 $pageTitle = substr(sha1(rand()), 0, 7);
582 $hash = substr(sha1(rand()), 0, 7);
583 $amountSection = TRUE;
588 $memberships = FALSE;
589 $memPriceSetId = NULL;
591 $profilePreId = NULL;
592 $profilePostId = NULL;
596 $honoreeSection = FALSE;
597 $isAddPaymentProcessor = FALSE;
598 $isPcpApprovalNeeded = FALSE;
599 $isSeparatePayment = FALSE;
601 // create a new online contribution page
602 // create contribution page with randomized title and default params
603 $pageId = $this->webtestAddContributionPage($hash,
620 $isAddPaymentProcessor,
621 $isPcpApprovalNeeded,
626 //Open Live Contribution Page
627 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom");
628 $this->waitForElementPresent("onbehalf_state_province-3");
630 $this->type("onbehalf_organization_name", $orgName);
631 $this->waitForElementPresent("onbehalf_phone-3-1");
632 $this->type("onbehalf_phone-3-1", 9999999999);
633 $this->waitForElementPresent("onbehalf_email-3");
634 $this->type("onbehalf_email-3", "org@example.com");
635 $this->type("onbehalf_street_address-3", "Test Street Address");
636 $this->type("onbehalf_city-3", "Test City");
637 $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
638 $this->click("onbehalf_country-3");
639 $this->select("onbehalf_country-3", "label=United States");
640 $this->click("onbehalf_state_province-3");
641 $this->select("onbehalf_state_province-3", "label=Alabama");
643 $this->waitForElementPresent("_qf_Main_upload-bottom");
644 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
646 $this->click("_qf_Confirm_next-bottom");
647 $this->waitForPageToLoad($this->getTimeoutMsec());
649 $this->openCiviPage("contact/view", "reset=1&cid=$cid", "xpath=//div[@class='crm-content crm-contact_type_label']");
651 $this->verifyText("xpath=//div[@class='crm-content crm-contact_type_label']", $contactSubType);
659 public function _testOrganization($pageId, $cid, $pageTitle) {
660 //Open Live Contribution Page
661 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom");
663 $this->waitForElementPresent("onbehalf_state_province-3");
665 $this->waitForElementPresent("onbehalf_phone-3-1");
666 $this->type("onbehalf_phone-3-1", 9999999999);
667 $this->waitForElementPresent("onbehalf_email-3");
668 $this->type("onbehalf_email-3", "org@example.com");
669 $this->type("onbehalf_street_address-3", "Test Street Address");
670 $this->type("onbehalf_city-3", "Test City");
671 $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
672 $this->click("onbehalf_country-3");
673 $this->select("onbehalf_country-3", "label=United States");
674 $this->click("onbehalf_state_province-3");
675 $this->select("onbehalf_state_province-3", "label=Alabama");
677 $this->waitForElementPresent("_qf_Main_upload-bottom");
678 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
680 $this->click("_qf_Confirm_next-bottom");
681 $this->waitForPageToLoad($this->getTimeoutMsec());
690 public function _testAnomoyousOganization($pageId, $cid, $pageTitle) {
691 //Open Live Contribution Page
692 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom");
694 $this->click('CIVICRM_QFID_0_8');
695 $this->type('css=div.other_amount-section input', 60);
697 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
698 $lastName = 'An' . substr(sha1(rand()), 0, 7);
699 $orgName = 'org_11_' . substr(sha1(rand()), 0, 7);
700 $this->type("email-5", $firstName . "@example.com");
702 // enable onbehalforganization block
703 $this->click("is_for_organization");
704 $this->waitForElementPresent("onbehalf_state_province-3");
706 // onbehalforganization info
707 $this->type("onbehalf_organization_name", $orgName);
708 $this->type("onbehalf_phone-3-1", 9999999999);
709 $this->type("onbehalf_email-3", "{$orgName}@example.com");
710 $this->type("onbehalf_street_address-3", "Test Street Address");
711 $this->type("onbehalf_city-3", "Test City");
712 $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
713 $this->click("onbehalf_country-3");
714 $this->select("onbehalf_country-3", "label=United States");
715 $this->click("onbehalf_state_province-3");
716 $this->select("onbehalf_state_province-3", "label=Alabama");
719 $this->select("credit_card_type", "value=Visa");
720 $this->type("credit_card_number", "4111111111111111");
721 $this->type("cvv2", "000");
722 $this->select("credit_card_exp_date[M]", "value=1");
723 $this->select("credit_card_exp_date[Y]", "value=2020");
726 $this->type("billing_first_name", $firstName . 'billing');
727 $this->type("billing_last_name", $lastName . 'billing');
728 $this->type("billing_street_address-5", "0121 Mount Highschool.");
729 $this->type(" billing_city-5", "Shangai");
730 $this->select("billing_country_id-5", "value=1228");
731 $this->select("billing_state_province_id-5", "value=1004");
732 $this->type("billing_postal_code-5", "94129");
733 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
735 $this->click("_qf_Confirm_next-bottom");
736 $this->waitForPageToLoad($this->getTimeoutMsec());
738 //login to check contribution
740 // Log in using webtestLogin() method
741 $this->webtestLogin();
744 $this->openCiviPage("contribute/search", "reset=1");
745 $this->type("sort_name", $orgName);
746 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
747 $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom");
749 // verify contrb created
755 foreach ($expected as $value => $label) {
756 $this->verifyText("xpath=id( 'ContributionView' )/div[2]/table[1]/tbody/tr[$value]/td[2]", preg_quote($label));
765 public function _testUserWithOneRelationship($pageId, $cid, $pageTitle) {
766 $this->webtestLogin('admin');
769 $groupName = $this->WebtestAddGroup();
770 $this->openCiviPage("group", "reset=1", "_qf_Search_refresh");
771 $groupId = $this->getText("xpath=//table[@id='crm-group-selector']/tbody//tr/td[text()='{$groupName}']/../td[2]");
773 $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
775 $this->click('link=Edit');
776 $this->waitForElementPresent('_qf_Contact_cancel-bottom');
777 $this->click('addressBlock');
778 $this->waitForElementPresent('link=Another Address');
781 $this->select('address_1_location_type_id', 'label=Billing');
782 $this->type('address_1_street_address', '0121 Mount Highschool.');
783 $this->type('address_1_city', "Shangai");
784 $this->type('address_1_postal_code', "94129");
785 $this->select('address_1_country_id', "value=1228");
786 $this->select('address_1_state_province_id', "value=1004");
787 $this->click('_qf_Contact_upload_view-bottom');
788 $this->waitForPageToLoad($this->getTimeoutMsec());
790 // add contact to group
792 $this->click("css=li#tab_group a");
793 $this->waitForElementPresent("group_id");
796 $this->select("group_id", "label={$groupName}");
797 $this->click("_qf_GroupContact_next");
798 $this->waitForPageToLoad($this->getTimeoutMsec());
800 $this->openCiviPage("admin/custom/group", "action=add&reset=1", "_qf_Group_next-bottom");
802 // fill in a unique title for the custom group
803 $groupTitle = "Custom Group" . substr(sha1(rand()), 0, 7);
804 $this->type("title", $groupTitle);
806 // select the group this custom data set extends
807 $this->select("extends[0]", "value=Contribution");
808 $this->waitForElementPresent("extends[1]");
810 // save the custom group
811 $this->click("_qf_Group_next-bottom");
812 $this->waitForElementPresent("_qf_Field_next_new-bottom");
813 $this->assertTrue($this->isTextPresent("Your custom field set '$groupTitle' has been added. You can add custom fields now."));
815 // add a custom field to the custom group
816 $fieldTitle = "Custom Field " . substr(sha1(rand()), 0, 7);
817 $this->type("label", $fieldTitle);
819 $this->select("data_type[1]", "value=Text");
820 $this->click('_qf_Field_next-bottom');
822 $this->waitForPageToLoad($this->getTimeoutMsec());
823 $this->assertTrue($this->isTextPresent("Custom field '$fieldTitle' has been saved."));
824 $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"));
826 // Enable CiviCampaign module if necessary
827 $this->enableComponents("CiviCampaign");
829 // add the required permission
830 $permission = array('edit-2-administer-civicampaign');
831 $this->changePermissions($permission);
833 // Log in as normal user
834 $this->webtestLogin();
836 $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom");
838 $title = 'Campaign ' . substr(sha1(rand()), 0, 7);
839 $this->type("title", $title);
841 // select the campaign type
842 $this->select("campaign_type_id", "value=2");
844 // fill in the description
845 $this->type("description", "This is a test campaign");
847 // include groups for the campaign
848 $this->addSelection("includeGroups-f", "label={$groupName}");
849 $this->click("//option[@value={$groupId}]");
852 // fill the end date for campaign
853 $this->webtestFillDate("end_date", "+1 year");
855 // select campaign status
856 $this->select("status_id", "value=2");
859 $this->click("_qf_Campaign_upload-bottom");
860 $this->waitForElementPresent("xpath=//div[@id='campaigns_wrapper']//table[@id='campaigns']/tbody//tr/td[3][text()='{$title}']");
861 $this->assertTrue($this->isTextPresent("Campaign {$title} has been saved."), "Status message didn't show up after saving!");
863 $this->openCiviPage("admin/uf/group", "reset=1");
864 $this->click("link=Reserved Profiles");
866 $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']");
867 $this->waitForPageToLoad($this->getTimeoutMsec());
869 $this->click("link=Add Field");
870 $this->waitForElementPresent('_qf_Field_next-bottom');
871 $this->select('field_name[0]', 'value=Contribution');
872 $this->select('field_name[1]', 'label=Campaign');
873 $this->click('field_name[1]');
874 $this->click('_qf_Field_next_new-bottom');
875 $this->waitForPageToLoad($this->getTimeoutMsec());
877 $this->select('field_name[0]', 'value=Contribution');
878 $this->select('field_name[1]', "label=$fieldTitle :: $groupTitle");
879 $this->click('field_name[1]');
880 $this->click('_qf_Field_next-bottom');
881 $this->waitForPageToLoad($this->getTimeoutMsec());
882 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$fieldTitle}' has been saved to 'On Behalf Of Organization'."));
884 // Open Page to create Organization
885 $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom");
886 $orgName1 = 'org1_' . substr(sha1(rand()), 0, 7);
888 // Type Organization name
889 $this->type("organization_name", $orgName1);
891 // Type Organizatio email for main
892 $this->type("email_1_email", "{$orgName1}@example.com");
893 $this->select("email_1_location_type_id", "value=3");
895 // type phone no for main
896 $this->type("phone_1_phone", 9999999999);
897 $this->select("phone_1_location_type_id", "value=3");
900 $this->click("addressBlock");
901 $this->waitForElementPresent("address_1_street_address");
903 //fill in address 1 for main
904 $this->select("address_1_location_type_id", "value=3");
905 $this->type("address_1_street_address", "{$orgName1} street address");
906 $this->type("address_1_city", "{$orgName1} city");
907 $this->type("address_1_postal_code", substr(sha1(rand()), 0, 4));
908 $this->assertTrue($this->isTextPresent("- select - United States"));
909 $this->select("address_1_state_province_id", "value=1019");
910 $this->type("address_1_geo_code_1", "1234");
911 $this->type("address_1_geo_code_2", "5678");
913 // Save the Organization
914 $this->click("_qf_Contact_upload_view-bottom");
915 $this->waitForPageToLoad($this->getTimeoutMsec());
918 $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1");
920 // select relationship type
921 $this->click("relationship_type_id");
922 $this->select("relationship_type_id", "value=4_a_b");
924 // search organization
925 $this->type('contact_1', $orgName1);
926 $this->click("contact_1");
927 $this->waitForElementPresent("css=div.ac_results-inner li");
928 $this->click("css=div.ac_results-inner li");
929 $this->assertContains($orgName1, $this->getValue('contact_1'), "autocomplete expected $orgName1 but didn’t find it in " . $this->getValue('contact_1'));
931 $this->waitForElementPresent("add_current_employer");
932 $this->click("add_current_employer");
935 $this->click("is_permission_a_b");
936 $this->click("is_permission_b_a");
939 $this->waitForElementPresent("details-save");
940 $this->click("details-save");
942 //Open Live Contribution Page
943 $this->openCiviPage("contribute/transact", "reset=1&id={$pageId}&cid=$cid", "onbehalf_state_province-3");
944 $this->click('CIVICRM_QFID_amount_other_radio_4');
945 $this->type('amount_other', 60);
946 $this->click('onbehalf_contribution_campaign_id');
947 $this->select('onbehalf_contribution_campaign_id', "label={$title}");
948 $this->type("onbehalf_custom_{$fieldId}", 'Test Subject');
951 $this->select("credit_card_type", "value=Visa");
952 $this->type("credit_card_number", "4111111111111111");
953 $this->type("cvv2", "000");
954 $this->select("credit_card_exp_date[M]", "value=1");
955 $this->select("credit_card_exp_date[Y]", "value=2020");
958 $this->type("billing_street_address-5", "0121 Mount Highschool.");
959 $this->type(" billing_city-5", "Shangai");
960 $this->select("billing_country_id-5", "value=1228");
961 $this->select("billing_state_province_id-5", "value=1004");
962 $this->type("billing_postal_code-5", "94129");
964 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
965 $this->click("_qf_Confirm_next-bottom");
966 $this->waitForPageToLoad($this->getTimeoutMsec());
969 $this->openCiviPage("contribute/search", "reset=1");
970 $this->type("sort_name", $orgName1);
971 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
972 $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom");
974 // verify contrb created
981 foreach ($expected as $value => $label) {
982 $this->verifyText("xpath=id( 'ContributionView' )/div[2]/table[1]/tbody/tr[$value]/td[2]", preg_quote($label));
985 $this->openCiviPage("admin/uf/group", "reset=1");
986 $this->click("link=Reserved Profiles");
988 $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']");
989 $this->waitForPageToLoad($this->getTimeoutMsec());
991 $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']");
992 $this->waitForElementPresent('_qf_Field_next-bottom');
994 $this->click('_qf_Field_next-bottom');
995 $this->waitForPageToLoad($this->getTimeoutMsec());
996 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'), "Status message didn't show up after saving!");
998 $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']");
999 $this->waitForElementPresent('_qf_Field_next-bottom');
1001 $this->click('_qf_Field_next-bottom');
1002 $this->waitForPageToLoad($this->getTimeoutMsec());
1003 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'), "Status message didn't show up after saving!");
1007 * @param int $pageId
1011 public function _testUserWithMoreThanOneRelationship($pageId, $cid, $pageTitle) {
1012 $this->webtestLogin('admin');
1013 $this->waitForPageToLoad($this->getTimeoutMsec());
1016 $groupName = $this->WebtestAddGroup();
1017 $this->openCiviPage("group", "reset=1", '_qf_Search_refresh');
1018 $this->click('_qf_Search_refresh');
1019 $this->waitForElementPresent("xpath=//div[@id='group']/div[3]/table/tbody//tr/td[text()='{$groupName}']/../td[2]");
1020 $groupId = $this->getText("xpath=//div[@id='group']/div[3]/table/tbody//tr/td[text()='{$groupName}']/../td[2]");
1022 $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
1024 $this->click('link=Edit');
1025 $this->waitForElementPresent('_qf_Contact_cancel-bottom');
1026 $this->click('addressBlock');
1027 $this->waitForElementPresent('link=Another Address');
1030 $this->select('address_1_location_type_id', 'label=Billing');
1031 $this->type('address_1_street_address', '0121 Mount Highschool.');
1032 $this->type('address_1_city', "Shangai");
1033 $this->type('address_1_postal_code', "94129");
1034 $this->select('address_1_country_id', "value=1228");
1035 $this->select('address_1_state_province_id', "value=1004");
1036 $this->click('_qf_Contact_upload_view-bottom');
1037 $this->waitForPageToLoad($this->getTimeoutMsec());
1039 // add contact to group
1041 $this->click("css=li#tab_group a");
1042 $this->waitForElementPresent("group_id");
1045 $this->select("group_id", "label=$groupName");
1046 $this->click("_qf_GroupContact_next");
1047 $this->waitForPageToLoad($this->getTimeoutMsec());
1049 $this->openCiviPage("admin/custom/group", "action=add&reset=1", "_qf_Group_next-bottom");
1051 // fill in a unique title for the c$groupIdustom group
1052 $groupTitle = "Members Custom Group" . substr(sha1(rand()), 0, 7);
1053 $this->type("title", $groupTitle);
1055 // select the group this custom data set extends
1056 $this->select("extends[0]", "value=Membership");
1057 $this->waitForElementPresent("extends[1]");
1059 // save the custom group
1060 $this->click("_qf_Group_next-bottom");
1062 $this->waitForElementPresent("_qf_Field_next_new-bottom");
1063 $this->assertTrue($this->isTextPresent("Your custom field set '$groupTitle' has been added. You can add custom fields now."));
1065 // add a custom field to the custom group
1066 $fieldTitle = "Member Custom Field " . substr(sha1(rand()), 0, 7);
1067 $this->type("label", $fieldTitle);
1069 $this->select("data_type[1]", "value=Text");
1070 $this->click('_qf_Field_next-bottom');
1072 $this->waitForPageToLoad($this->getTimeoutMsec());
1073 $this->assertTrue($this->isTextPresent("Custom field '$fieldTitle' has been saved."));
1074 $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"));
1076 // Enable CiviCampaign module if necessary
1077 $this->enableComponents("CiviCampaign");
1079 // add the required permission
1080 $permission = array('edit-2-administer-civicampaign');
1081 $this->changePermissions($permission);
1083 // Log in as normal user
1084 $this->webtestLogin();
1086 $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom");
1088 $title = 'Campaign ' . substr(sha1(rand()), 0, 7);
1089 $this->type("title", $title);
1091 // select the campaign type
1092 $this->select("campaign_type_id", "value=2");
1094 // fill in the description
1095 $this->type("description", "This is a test campaign");
1097 // include groups for the campaign
1098 $this->addSelection("includeGroups-f", "label={$groupName}");
1099 $this->click("//option[@value={$groupId}]");
1100 $this->click("add");
1102 // fill the end date for campaign
1103 $this->webtestFillDate("end_date", "+1 year");
1105 // select campaign status
1106 $this->select("status_id", "value=2");
1109 $this->click("_qf_Campaign_upload-bottom");
1110 $this->waitForPageToLoad($this->getTimeoutMsec());
1112 $this->assertTrue($this->isTextPresent("Campaign {$title} has been saved."), "Status message didn't show up after saving!");
1114 $this->openCiviPage("admin/uf/group", "reset=1");
1115 $this->click("link=Reserved Profiles");
1116 $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']");
1117 $this->waitForPageToLoad($this->getTimeoutMsec());
1119 $this->click("link=Add Field");
1120 $this->waitForElementPresent('_qf_Field_next-bottom');
1121 $this->select('field_name[0]', 'value=Membership');
1122 $this->select('field_name[1]', 'label=Campaign');
1123 $this->click('field_name[1]');
1124 $this->clickLink('_qf_Field_next_new-bottom', '_qf_Field_cancel-bottom');
1126 $this->select('field_name[0]', 'value=Membership');
1127 $this->select('field_name[1]', "label=$fieldTitle :: $groupTitle");
1128 $this->click('field_name[1]');
1129 $this->click('_qf_Field_next-bottom');
1130 $this->waitForPageToLoad($this->getTimeoutMsec());
1131 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$fieldTitle}' has been saved to 'On Behalf Of Organization'."),
1132 "Status message didn't show up after saving!"
1135 // Open Page to create Organization 1
1136 $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom");
1137 $orgName1 = 'org1_' . substr(sha1(rand()), 0, 7);
1139 // Type Organization name
1140 $this->type("organization_name", $orgName1);
1142 // Type Organizatio email for main
1143 $this->type("email_1_email", "{$orgName1}@example.com");
1144 $this->select("email_1_location_type_id", "value=3");
1146 // type phone no for main
1147 $this->type("phone_1_phone", substr(sha1(rand()), 0, 4));
1148 $this->select("phone_1_location_type_id", "value=3");
1151 $this->click("addressBlock");
1152 $this->waitForElementPresent("address_1_street_address");
1154 //fill in address 1 for main
1155 $this->select("address_1_location_type_id", "value=3");
1156 $this->type("address_1_street_address", "{$orgName1} street address");
1157 $this->type("address_1_city", "{$orgName1} city");
1158 $this->type("address_1_postal_code", "9999999999");
1159 $this->assertTrue($this->isTextPresent("- select - United States"));
1160 $this->select("address_1_state_province_id", "value=1019");
1161 $this->type("address_1_geo_code_1", "1234");
1162 $this->type("address_1_geo_code_2", "5678");
1164 // Save the Organization
1165 $this->click("_qf_Contact_upload_view-bottom");
1166 $this->waitForPageToLoad($this->getTimeoutMsec());
1168 // create second orzanization
1169 $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom");
1170 $orgName2 = 'org2_' . substr(sha1(rand()), 0, 7);
1172 // Type Organization name
1173 $this->type("organization_name", $orgName2);
1175 // Type Organizatio email for main
1176 $this->type("email_1_email", "{$orgName2}@example.com");
1177 $this->select("email_1_location_type_id", "value=3");
1179 // type phone no for main
1180 $this->type("phone_1_phone", substr(sha1(rand()), 0, 4));
1181 $this->select("phone_1_location_type_id", "value=3");
1184 $this->click("addressBlock");
1185 $this->waitForElementPresent("address_1_street_address");
1187 //fill in address 1 for main
1188 $this->select("address_1_location_type_id", "value=3");
1189 $this->type("address_1_street_address", "{$orgName2} street address");
1190 $this->type("address_1_city", "{$orgName2} city");
1191 $this->type("address_1_postal_code", "7777777777");
1192 $this->assertTrue($this->isTextPresent("- select - United States"));
1193 $this->select("address_1_state_province_id", "value=1019");
1194 $this->type("address_1_geo_code_1", "1224");
1195 $this->type("address_1_geo_code_2", "5628");
1197 // Save the Organization
1198 $this->click("_qf_Contact_upload_view-bottom");
1199 $this->waitForPageToLoad($this->getTimeoutMsec());
1201 // create Membership type
1202 $title1 = "Membership Type" . substr(sha1(rand()), 0, 7);
1203 $this->openCiviPage("admin/member/membershipType", "reset=1&action=browse");
1205 $this->click("link=Add Membership Type");
1206 $this->waitForElementPresent('_qf_MembershipType_cancel-bottom');
1208 $this->type('name', $title1);
1209 $this->type('member_org', $orgName1);
1210 $this->click('_qf_MembershipType_refresh');
1211 $this->waitForElementPresent("xpath=//div[@id='membership_type_form']/fieldset/table[2]/tbody/tr[2]/td[2]");
1213 $this->type('minimum_fee', '50');
1215 $this->select('financial_type_id', 'value=2');
1217 $this->type('duration_interval', 1);
1218 $this->select('duration_unit', "label=year");
1220 $this->select('period_type', "label=fixed");
1221 $this->waitForElementPresent('fixed_period_rollover_day[d]');
1223 $this->select('fixed_period_start_day[M]', 'value=4');
1224 $this->select('fixed_period_rollover_day[M]', 'value=1');
1226 $this->select('relationship_type_id', 'value=4_b_a');
1228 $this->click('_qf_MembershipType_upload-bottom');
1229 $this->waitForElementPresent('link=Add Membership Type');
1230 $this->assertTrue($this->isTextPresent("The membership type '$title1' has been saved."));
1231 $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"));
1234 $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1");
1236 // select relationship type
1237 $this->click("relationship_type_id");
1238 $this->select("relationship_type_id", "value=4_a_b");
1240 // search organization
1241 $this->type('contact_1', $orgName1);
1242 $this->click("contact_1");
1243 $this->waitForElementPresent("css=div.ac_results-inner li");
1244 $this->click("css=div.ac_results-inner li");
1245 $this->assertContains($orgName1, $this->getValue('contact_1'), "autocomplete expected $orgName1 but didn’t find it in " . $this->getValue('contact_1'));
1248 $this->click("is_permission_a_b");
1249 $this->click("is_permission_b_a");
1251 // save relationship
1252 $this->click("details-save");
1255 $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1");
1257 // select relationship type
1258 $this->click("relationship_type_id");
1259 $this->select("relationship_type_id", "value=4_a_b");
1261 // search organization
1262 $this->type('contact_1', $orgName2);
1263 $this->click("contact_1");
1264 $this->waitForElementPresent("css=div.ac_results-inner li");
1265 $this->click("css=div.ac_results-inner li");
1266 $this->assertContains($orgName2, $this->getValue('contact_1'), "autocomplete expected $orgName2 but didn’t find it in " . $this->getValue('contact_1'));
1269 $this->click("is_permission_a_b");
1270 $this->click("is_permission_b_a");
1272 // save relationship
1273 $this->click("details-save");
1275 // set membership type
1276 $this->openCiviPage("admin/contribute/membership", "reset=1&action=update&id=$pageId", "_qf_MembershipBlock_upload_done-bottom");
1277 $this->click("member_is_active");
1278 $this->click("membership_type[{$typeId}]");
1279 $this->click("xpath=//div[@id='memberFields']//table[@class='report']/tbody//tr/td[1]/label[text()='{$title1}']/../../td[2]/input");
1280 $this->click('_qf_MembershipBlock_upload_done-bottom');
1281 $this->waitForPageToLoad($this->getTimeoutMsec());
1283 //Open Live Membership Page
1284 $this->openCiviPage('contribute/transact', "reset=1&id=$pageId&cid=$cid", "_qf_Main_upload-bottom");
1285 $this->click('CIVICRM_QFID_amount_other_radio_4');
1286 $this->type('amount_other', 60);
1287 $this->click('onbehalf_organization_name');
1288 $this->type('onbehalf_organization_name', $orgName1);
1289 $this->typeKeys('onbehalf_organization_name', $orgName1);
1290 $this->click("onbehalf_organization_name");
1291 $this->waitForElementPresent("css=div.ac_results-inner li");
1292 $this->click("css=div.ac_results-inner li");
1293 // Because it tends to cause problems, all uses of sleep() must be justified in comments
1294 // Sleep should never be used for wait for anything to load from the server
1295 // Justification for this instance: FIXME
1297 $this->click('onbehalf_member_campaign_id');
1298 $this->select('onbehalf_member_campaign_id', "label={$title}");
1299 $this->type("onbehalf_custom_{$fieldId}", 'Test Subject');
1301 $this->assertContains($orgName1, $this->getValue('onbehalf_organization_name'), "autocomplete expected $orgName1 but didn’t find it in " . $this->getValue('onbehalf_organization_name'));
1304 $this->select("credit_card_type", "value=Visa");
1305 $this->type("credit_card_number", "4111111111111111");
1306 $this->type("cvv2", "000");
1307 $this->select("credit_card_exp_date[M]", "value=1");
1308 $this->select("credit_card_exp_date[Y]", "value=2020");
1310 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
1311 $this->click("_qf_Confirm_next-bottom");
1312 $this->waitForPageToLoad($this->getTimeoutMsec());
1314 //Find Membership for organization
1315 $this->openCiviPage("member/search", "reset=1");
1316 $this->type("sort_name", $orgName1);
1317 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='memberSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
1318 $this->clickLink("xpath=//div[@id='memberSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_MembershipView_cancel-bottom");
1320 //verify contrb created
1326 foreach ($expected as $value => $label) {
1327 $this->verifyText("xpath=//form[@id='MembershipView']/div[2]/div/table/tbody/tr[$value]/td[2]", preg_quote($label));
1330 // find membership for contact in relationship
1331 $this->openCiviPage("contact/view", "reset=1&force=1&cid={$cid}");
1332 $this->click("css=li#tab_member a");
1333 $this->waitForElementPresent("xpath=//div[@id='memberships']/div/table//tbody//tr/td[1][text()='{$title1}']");
1334 $this->click("xpath=//div[@id='memberships']/div/table//tbody//tr/td[1][text()='{$title1}']/../td[7]/span/a[text()='View']");
1335 $this->waitForPageToLoad($this->getTimeoutMsec());
1337 //verify contrb created
1342 foreach ($expected as $value => $label) {
1343 $this->verifyText("xpath=//form[@id='MembershipView']/div[2]/div/table/tbody/tr[$value]/td[2]", preg_quote($label));
1346 $this->openCiviPage("admin/uf/group", "reset=1");
1347 $this->click("link=Reserved Profiles");
1348 $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']");
1349 $this->waitForPageToLoad($this->getTimeoutMsec());
1351 $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']");
1352 $this->waitForElementPresent('_qf_Field_next-bottom');
1354 $this->click('_qf_Field_next-bottom');
1355 $this->waitForPageToLoad($this->getTimeoutMsec());
1356 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'),
1357 "Status message didn't show up after saving!"
1360 $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']");
1361 $this->waitForElementPresent('_qf_Field_next-bottom');
1363 $this->click('_qf_Field_next-bottom');
1364 $this->waitForPageToLoad($this->getTimeoutMsec());
1365 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'),
1366 "Status message didn't show up after saving!"
1369 $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
1370 $this->click("css=li#tab_rel a");
1372 $this->waitForElementPresent("xpath=//div[@id='current-relationships']/div/table/tbody//tr/td[2]/a[text()='{$orgName1}']");
1373 $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']");
1375 // Check confirmation alert.
1376 $this->assertTrue((bool) preg_match("/^Are you sure you want to delete this relationship?/",
1377 $this->getConfirmation()
1379 $this->chooseOkOnNextConfirmation();
1380 $this->waitForPageToLoad($this->getTimeoutMsec());
1381 $this->assertTrue($this->isTextPresent('Selected relationship has been deleted successfully.'),
1382 "Status message didn't show up after saving!"
1386 public function testOnBehalfOfOrganizationWithImage() {
1387 $this->webtestLogin();
1389 $this->openCiviPage("profile/edit", "reset=1&gid=4");
1390 $firstName = 'John_x_' . substr(sha1(rand()), 0, 7);
1391 $lastName = 'Anderson_c_' . substr(sha1(rand()), 0, 7);
1393 $this->waitForPageToLoad($this->getTimeoutMsec());
1394 $this->waitForElementPresent("_qf_Edit_next");
1395 $this->type("first_name", $firstName);
1396 $this->type("last_name", $lastName);
1397 $this->clickLink("_qf_Edit_next", "profilewrap4");
1399 $cid = $this->urlArg('id');
1400 $this->assertType('numeric', $cid);
1401 // Is status message correct?
1402 $this->assertTextPresent("Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!");
1404 $this->openCiviPage("admin/uf/group", "reset=1");
1405 $this->click("link=Reserved Profiles");
1407 $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']");
1408 $this->waitForPageToLoad($this->getTimeoutMsec());
1410 $this->click("link=Add Field");
1411 $this->waitForElementPresent('_qf_Field_next-bottom');
1413 $this->select('field_name[0]', 'value=Contact');
1414 $this->select('field_name[1]', 'label=Image Url');
1415 $this->click('field_name[1]');
1416 $this->click('_qf_Field_next-bottom');
1417 $this->waitForPageToLoad($this->getTimeoutMsec());
1419 // Use default payment processor
1420 $processorName = 'Test Processor';
1421 $processorType = 'Dummy';
1422 $pageTitle = substr(sha1(rand()), 0, 7);
1424 $hash = substr(sha1(rand()), 0, 7);
1425 $amountSection = TRUE;
1430 $memberships = FALSE;
1431 $memPriceSetId = NULL;
1433 $profilePreId = NULL;
1434 $profilePostId = NULL;
1438 $honoreeSection = FALSE;
1439 $isAddPaymentProcessor = TRUE;
1440 $isPcpApprovalNeeded = FALSE;
1441 $isSeparatePayment = FALSE;
1443 // create a new online contribution page
1444 // create contribution page with randomized title and default params
1445 $pageId = $this->webtestAddContributionPage($hash,
1448 array($processorName => $processorType),
1462 $isAddPaymentProcessor,
1463 $isPcpApprovalNeeded,
1468 $this->_testOrganizationWithImageUpload($pageId, $cid, $pageTitle);
1470 $this->openCiviPage("admin/uf/group", "reset=1");
1471 $this->click("link=Reserved Profiles");
1473 $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']");
1474 $this->waitForPageToLoad($this->getTimeoutMsec());
1475 $this->click("xpath=//table[@id='option11']/tbody//tr/td/span[text()='Image Url']/../following-sibling::td[8]/span[2]/ul/li[2]/a");
1476 $this->waitForPageToLoad($this->getTimeoutMsec());
1477 $this->click('_qf_Field_next-bottom');
1478 $this->waitForPageToLoad($this->getTimeoutMsec());
1479 $this->waitForText('crm-notification-container', "Selected Profile Field has been deleted.");
1483 * @param int $pageId
1487 public function _testOrganizationWithImageUpload($pageId, $cid, $pageTitle) {
1488 //Open Live Contribution Page
1489 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", '_qf_Main_upload-bottom');
1491 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
1492 $lastName = 'An' . substr(sha1(rand()), 0, 7);
1493 $orgName = 'org_11_' . substr(sha1(rand()), 0, 7);
1494 $this->type("email-5", $firstName . "@example.com");
1496 // onbehalforganization info
1497 $this->type("onbehalf_organization_name", $orgName);
1498 $this->type("onbehalf_phone-3-1", 9999999999);
1499 $this->type("onbehalf_email-3", "{$orgName}@example.com");
1500 $this->type("onbehalf_street_address-3", "Test Street Address");
1501 $this->type("onbehalf_city-3", "Test City");
1502 $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
1503 $this->click("onbehalf_country-3");
1504 $this->select("onbehalf_country-3", "label=United States");
1505 $this->click("onbehalf_state_province-3");
1506 $this->select("onbehalf_state_province-3", "label=Alabama");
1508 // check for upload field.
1509 $this->waitForElementPresent("onbehalf_image_URL");
1511 //header("Content-Type: image/png");
1512 $im = imagecreate(110, 20)
1513 or die("Cannot Initialize new GD image stream");
1514 $background_color = imagecolorallocate($im, 0, 0, 0);
1515 $text_color = imagecolorallocate($im, 233, 14, 91);
1516 imagestring($im, 1, 5, 5, "On Behalf-Org Logo", $text_color);
1517 imagepng($im, "/tmp/file.png");
1519 $imagePath = "/tmp/file.png";
1520 $this->webtestAttachFile('onbehalf_image_URL', $imagePath);
1524 $this->select("credit_card_type", "value=Visa");
1525 $this->type("credit_card_number", "4111111111111111");
1526 $this->type("cvv2", "000");
1527 $this->select("credit_card_exp_date[M]", "value=1");
1528 $this->select("credit_card_exp_date[Y]", "value=2020");
1531 $this->type("billing_first_name", $firstName . 'billing');
1532 $this->type("billing_last_name", $lastName . 'billing');
1533 $this->type("billing_street_address-5", "0121 Mount Highschool.");
1534 $this->type(" billing_city-5", "Shangai");
1535 $this->select("billing_country_id-5", "value=1228");
1536 $this->select("billing_state_province_id-5", "value=1004");
1537 $this->type("billing_postal_code-5", "94129");
1538 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
1540 $this->click("_qf_Confirm_next-bottom");
1541 $this->waitForPageToLoad($this->getTimeoutMsec());
1543 // Type search name in autocomplete.
1544 $this->click('sort_name_navigation');
1545 $this->type('css=input#sort_name_navigation', $orgName);
1546 $this->typeKeys('css=input#sort_name_navigation', $orgName);
1548 // Wait for result list.
1549 $this->waitForElementPresent("css=div.ac_results-inner li");
1551 // Visit organization page.
1552 $this->click("css=div.ac_results-inner li");
1553 $this->waitForPageToLoad($this->getTimeoutMsec());
1555 //check whether the image is present
1556 $this->assertTrue($this->isElementPresent("xpath=//div[@id='crm-contact-thumbnail']/div/a/img"));