3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License along with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
28 require_once 'CiviTest/CiviSeleniumTestCase.php';
29 class WebTest_Contribute_OnBehalfOfOrganization
extends CiviSeleniumTestCase
{
30 protected $pageno = '';
31 protected function setUp() {
35 function testOnBehalfOfOrganization() {
36 $this->webtestLogin();
38 // create new individual
39 $firstName = 'John_' . substr(sha1(rand()), 0, 7);
40 $lastName = 'Anderson_' . substr(sha1(rand()), 0, 7);
41 $email = "{$firstName}.{$lastName}@example.com";
42 $contactParams = array(
43 'first_name' => $firstName,
44 'last_name' => $lastName,
47 $streetAddress = "100 Main Street";
49 //adding contact for membership sign up
50 $this->webtestAddContact($firstName, $lastName, $email);
51 $urlElements = $this->parseURL();
52 print_r($urlElements);
53 $cid = $urlElements['queryString']['cid'];
54 $this->assertType('numeric', $cid);
56 // We need a payment processor
57 $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7);
58 $processorType = 'Dummy';
59 $pageTitle = substr(sha1(rand()), 0, 7);
61 $hash = substr(sha1(rand()), 0, 7);
62 $amountSection = TRUE;
64 $onBehalf = 'optional';
68 $memPriceSetId = NULL;
71 $profilePostId = NULL;
75 $honoreeSection = FALSE;
76 $isAddPaymentProcessor = TRUE;
77 $isPcpApprovalNeeded = FALSE;
78 $isSeparatePayment = FALSE;
80 // create a new online contribution page
81 // create contribution page with randomized title and default params
82 $pageId = $this->webtestAddContributionPage($hash,
85 array($processorName => $processorType),
99 $isAddPaymentProcessor,
100 $isPcpApprovalNeeded,
106 $this->webtestLogout();
107 //$this->_testAnomoyousOganization($pageId, $cid, $pageTitle);
108 $this->webtestLogout();
109 $this->_testUserWithOneRelationship($pageId, $cid, $pageTitle);
110 $this->webtestLogout();
111 $this->_testUserWithMoreThanOneRelationship($pageId, $cid, $pageTitle);
114 function testOnBehalfOfOrganizationWithMembershipData() {
115 $this->webtestLogin();
117 // create new individual
118 $this->openCiviPage("profile/edit", "reset=1&gid=4");
119 $firstName = 'John_x_' . substr(sha1(rand()), 0, 7);
120 $lastName = 'Anderson_c_' . substr(sha1(rand()), 0, 7);
122 $this->waitForPageToLoad($this->getTimeoutMsec());
123 $this->waitForElementPresent("_qf_Edit_next");
124 $this->type("first_name", $firstName);
125 $this->type("last_name", $lastName);
126 $this->click("_qf_Edit_next");
127 $this->waitForPageToLoad($this->getTimeoutMsec());
128 $this->waitForElementPresent("profilewrap4");
130 // Is status message correct?
131 $this->assertTextPresent("Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!");
135 $this->openCiviPage("admin/custom/group", "action=add&reset=1");
137 //fill custom group title
138 $customGroupTitle = 'custom_' . substr(sha1(rand()), 0, 7);
139 $this->click("title");
140 $this->type("title", $customGroupTitle);
142 //custom group extends
143 $this->click("extends[0]");
144 $this->select("extends[0]", "value=Membership");
145 //$this->click("//option[@value='Contact']");
146 $this->click("_qf_Group_next-bottom");
147 $this->waitForElementPresent("_qf_Field_cancel-bottom");
149 //Is custom group created?
150 $this->assertTrue($this->isTextPresent("Your custom field set '{$customGroupTitle}' has been added. You can add custom fields now."));
152 //add custom field - alphanumeric checkbox
153 $checkboxFieldLabel = 'custom_field' . substr(sha1(rand()), 0, 4);
154 $this->click("label");
155 $this->type("label", $checkboxFieldLabel);
156 $this->click("data_type[1]");
157 $this->select("data_type[1]", "value=CheckBox");
158 $this->click("//option[@value='CheckBox']");
159 $checkboxOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
160 $this->type("option_label_1", $checkboxOptionLabel1);
161 $this->type("option_value_1", "1");
162 $checkboxOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
163 $this->type("option_label_2", $checkboxOptionLabel2);
164 $this->type("option_value_2", "2");
165 $this->click("link=another choice");
166 $checkboxOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
167 $this->type("option_label_3", $checkboxOptionLabel3);
168 $this->type("option_value_3", "3");
170 //enter options per line
171 $this->type("options_per_line", "2");
173 //enter pre help message
174 $this->type("help_pre", "this is field pre help");
176 //enter post help message
177 $this->type("help_post", "this field post help");
180 $this->click("is_searchable");
183 $this->click("_qf_Field_next");
184 $this->waitForPageToLoad($this->getTimeoutMsec());
186 //Is custom field created?
187 $this->assertTrue($this->isTextPresent("Your custom field '$checkboxFieldLabel' has been saved."));
189 //create another custom field - Integer Radio
190 $this->click("//a[@id='newCustomField']/span");
191 $this->waitForPageToLoad($this->getTimeoutMsec());
192 $this->click("data_type[0]");
193 $this->select("data_type[0]", "value=1");
194 $this->click("//option[@value='1']");
195 $this->click("data_type[1]");
196 $this->select("data_type[1]", "value=Radio");
197 $this->click("//option[@value='Radio']");
199 $radioFieldLabel = 'custom_field' . substr(sha1(rand()), 0, 4);
200 $this->type("label", $radioFieldLabel);
201 $radioOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
202 $this->type("option_label_1", $radioOptionLabel1);
203 $this->type("option_value_1", "1");
204 $radioOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
205 $this->type("option_label_2", $radioOptionLabel2);
206 $this->type("option_value_2", "2");
207 $this->click("link=another choice");
208 $radioOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
209 $this->type("option_label_3", $radioOptionLabel3);
210 $this->type("option_value_3", "3");
212 //select options per line
213 $this->type("options_per_line", "3");
216 $this->type("help_pre", "this is field pre help");
218 //enter post help msg
219 $this->type("help_post", "this is field post help");
222 $this->click("is_searchable");
225 $this->click("_qf_Field_next");
226 $this->waitForPageToLoad($this->getTimeoutMsec());
228 //Is custom field created
229 $this->assertTrue($this->isTextPresent("Your custom field '$radioFieldLabel' has been saved."));
231 //add the above custom data to the On Behalf of Profile
232 $this->openCiviPage("admin/uf/group", "reset=1");
233 $this->click("link=Reserved Profiles");
235 $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']");
236 $this->waitForPageToLoad($this->getTimeoutMsec());
238 $this->click("link=Add Field");
239 $this->waitForElementPresent('_qf_Field_next-bottom');
240 $this->select('field_name[0]', 'value=Membership');
241 $label = $checkboxFieldLabel.' :: '. $customGroupTitle;
242 $this->select('field_name[1]', "label=$label");
243 $this->click('field_name[1]');
244 $this->click('_qf_Field_next_new-bottom');
245 $this->waitForPageToLoad($this->getTimeoutMsec());
247 $this->select('field_name[0]', 'value=Membership');
248 $label = $radioFieldLabel.' :: '. $customGroupTitle;
249 $this->select('field_name[1]', "label=$label");
250 $this->click('field_name[1]');
251 $this->click('_qf_Field_next-bottom');
252 $this->waitForPageToLoad($this->getTimeoutMsec());
253 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$radioFieldLabel}' has been saved to 'On Behalf Of Organization'."));
255 //create organisation
256 $orgName = "Org WebAccess ". substr(sha1(rand()), 0, 7);
257 $orgEmail = "org". substr(sha1(rand()), 0, 7) . "@web.com";
258 $this->webtestAddOrganization($orgName, $orgEmail);
260 $this->waitForPageToLoad($this->getTimeoutMsec());
261 $this->click("css=li#tab_member a");
263 $this->waitForElementPresent('link=Add Membership');
264 $this->click('link=Add Membership');
266 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
268 // fill in Membership Organization and Type
269 $this->select('membership_type_id[0]', "value=1");
270 $this->select('membership_type_id[1]', "value=1");
273 $sourceText = 'On behalf Membership Webtest';
274 $this->type('source', $sourceText);
276 $this->waitForElementPresent("css=div#{$customGroupTitle} div.crm-accordion-header");
277 $this->click("css=div#{$customGroupTitle} div.crm-accordion-header");
278 //$this->waitForElementPresent('_qf_Membership_cancel-bottom111');
280 // select newly created processor
281 $xpath = "xpath=//label[text() = '{$checkboxOptionLabel1}']/preceding-sibling::input[1]";
282 $this->assertTrue($this->isTextPresent($checkboxOptionLabel1));
283 $this->check($xpath);
285 $xpath = "xpath=//label[text() = '{$checkboxOptionLabel3}']/preceding-sibling::input[1]";
286 $this->assertTrue($this->isTextPresent($checkboxOptionLabel3));
287 $this->check($xpath);
289 $xpath = "xpath=//label[text() = '{$radioOptionLabel1}']/preceding-sibling::input[1]";
290 $this->assertTrue($this->isTextPresent($radioOptionLabel1));
291 $this->check($xpath);
293 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
294 $this->click('_qf_Membership_upload-bottom');
297 $this->waitForPageToLoad($this->getTimeoutMsec());
298 $this->click("css=li#tab_rel a");
300 $this->waitForElementPresent('link=Add Relationship');
301 $this->click('link=Add Relationship');
303 $this->waitForElementPresent('relationship_type_id');
304 $this->click("relationship_type_id");
305 $this->select("relationship_type_id", "label=Employer of");
306 // search organization
307 $this->type('contact_1', $firstName);
308 $this->click("contact_1");
309 $this->waitForElementPresent("css=div.ac_results-inner li");
310 $this->click("css=div.ac_results-inner li");
311 $this->assertContains($firstName, $this->getValue('contact_1'), "autocomplete expected $firstName but didn’t find it in " . $this->getValue('contact_1'));
314 $this->click("is_permission_a_b");
315 $this->click("is_permission_b_a");
318 $this->click("details-save");
319 $this->waitForPageToLoad($this->getTimeoutMsec());
321 // We need a payment processor
322 $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7);
323 $processorType = 'Dummy';
324 $pageTitle = substr(sha1(rand()), 0, 7);
326 $hash = substr(sha1(rand()), 0, 7);
327 $amountSection = TRUE;
333 $memPriceSetId = NULL;
335 $profilePreId = NULL;
336 $profilePostId = NULL;
340 $honoreeSection = FALSE;
341 $isAddPaymentProcessor = TRUE;
342 $isPcpApprovalNeeded = FALSE;
343 $isSeparatePayment = FALSE;
345 // create a new online contribution page
346 // create contribution page with randomized title and default params
347 $pageId = $this->webtestAddContributionPage($hash,
350 array($processorName => $processorType),
364 $isAddPaymentProcessor,
365 $isPcpApprovalNeeded,
371 //scenario 1 : add membership data in pre / post profile and check for formRule
373 $this->openCiviPage("admin/uf/group", "reset=1");
374 $this->click('link=Add Profile');
376 $profileTitle = "test profile" . substr(sha1(rand()), 0, 7);
377 // Add membership custom data field to profile
378 $this->waitForElementPresent('_qf_Group_cancel-bottom');
379 $this->type('title', $profileTitle);
380 $this->click('_qf_Group_next-bottom');
382 $this->waitForElementPresent('_qf_Field_cancel-bottom');
383 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now."));
385 $this->select('field_name[0]', "value=Membership");
386 $this->select('field_name[1]', "label={$checkboxFieldLabel} :: {$customGroupTitle}");
387 $this->click('field_name[1]');
388 $this->click('label');
390 // Clicking save and new
391 $this->click('_qf_Field_next_new-bottom');
392 $this->waitForPageToLoad($this->getTimeoutMsec());
393 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$checkboxFieldLabel}' has been saved to '{$profileTitle}'."));
395 $this->openCiviPage("admin/contribute/custom", "reset=1&action=update&id={$pageId}", '_qf_Custom_next-bottom');
396 $this->select('custom_pre_id', "label={$profileTitle}");
397 $this->click('_qf_Custom_next-bottom');
398 $this->waitForPageToLoad($this->getTimeoutMsec());
399 // Because it tends to cause problems, all uses of sleep() must be justified in comments
400 // Sleep should never be used for wait for anything to load from the server
401 // Justification for this instance: FIXME
403 $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");
405 $this->select('custom_pre_id', "- select -");
406 $this->select('custom_post_id', "label={$profileTitle}");
407 $this->click('_qf_Custom_next-bottom');
408 $this->waitForPageToLoad($this->getTimeoutMsec());
409 // Because it tends to cause problems, all uses of sleep() must be justified in comments
410 // Sleep should never be used for wait for anything to load from the server
411 // Justification for this instance: FIXME
413 $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");
415 //scenario 2 : disable 'on behalf of', add membership data in pre / post profile
416 //then try to add 'on behalf of' and check for formRule
417 //disable 'on behalf of'
418 $this->openCiviPage("admin/contribute/settings", "reset=1&action=update&id={$pageId}", '_qf_Settings_next-bottom');
419 $this->uncheck('is_organization');
420 $this->click('_qf_Settings_next-bottom');
421 $this->waitForPageToLoad($this->getTimeoutMsec());
423 //set a membership field profile for this contribution page
424 $this->click('css=li#tab_custom a');
425 $this->waitForElementPresent('_qf_Custom_next-bottom');
426 $this->select('custom_pre_id', "label={$profileTitle}");
427 $this->click('_qf_Custom_next-bottom');
428 $this->waitForPageToLoad($this->getTimeoutMsec());
430 //now visit the title settings page and configure the profile as on behalf of
431 $this->click('css=li#tab_settings a');
432 $this->waitForElementPresent('_qf_Settings_next-bottom');
433 $this->check('is_organization');
434 $this->click('_qf_Settings_next-bottom');
435 $this->waitForPageToLoad($this->getTimeoutMsec());
436 // Because it tends to cause problems, all uses of sleep() must be justified in comments
437 // Sleep should never be used for wait for anything to load from the server
438 // Justification for this instance: FIXME
440 $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");
443 $this->webtestLogout();
446 function testOnBehalfOfOrganizationWithOrgData() {
447 $this->webtestLogin();
449 $this->openCiviPage("profile/edit", "reset=1&gid=4");
450 $firstName = 'John_x_' . substr(sha1(rand()), 0, 7);
451 $lastName = 'Anderson_c_' . substr(sha1(rand()), 0, 7);
453 $this->waitForPageToLoad($this->getTimeoutMsec());
454 $this->waitForElementPresent("_qf_Edit_next");
455 $this->type("first_name", $firstName);
456 $this->type("last_name", $lastName);
457 $this->click("_qf_Edit_next");
458 $this->waitForPageToLoad($this->getTimeoutMsec());
459 $this->waitForElementPresent("profilewrap4");
461 $urlElements = $this->parseURL();
462 print_r($urlElements);
463 $cid = $urlElements['queryString']['id'];
464 $this->assertType('numeric', $cid);
465 // Is status message correct?
466 $this->assertTextPresent("Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!");
469 //add org fields to profile
470 $this->openCiviPage("admin/uf/group", "reset=1");
471 $this->click("link=Reserved Profiles");
473 $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']");
474 $this->waitForPageToLoad($this->getTimeoutMsec());
476 $this->click("link=Add Field");
477 $this->waitForElementPresent('_qf_Field_next-bottom');
479 $this->select('field_name[0]', 'value=Organization');
480 $this->select('field_name[1]', 'label=Legal Identifier');
481 $this->click('field_name[1]');
482 $this->click('_qf_Field_next_new-bottom');
483 $this->waitForPageToLoad($this->getTimeoutMsec());
485 $this->select('field_name[0]', 'value=Organization');
486 $this->select('field_name[1]', 'label=Legal Name');
487 $this->click('field_name[1]');
488 $this->click('_qf_Field_next-bottom');
489 $this->waitForPageToLoad($this->getTimeoutMsec());
492 //create organisation
493 $orgName = "Org WebAccess ". substr(sha1(rand()), 0, 7);
494 $orgEmail = "org". substr(sha1(rand()), 0, 7) . "@web.com";
495 $this->webtestAddOrganization($orgName, $orgEmail);
497 $this->waitForPageToLoad($this->getTimeoutMsec());
498 $this->click("css=li#tab_rel a");
500 $this->waitForElementPresent('link=Add Relationship');
501 $this->click('link=Add Relationship');
503 $this->waitForElementPresent('relationship_type_id');
504 $this->click("relationship_type_id");
505 $this->select("relationship_type_id", "label=Employer of");
506 // search organization
507 $this->type('contact_1', $firstName);
508 $this->click("contact_1");
509 $this->waitForElementPresent("css=div.ac_results-inner li");
510 $this->click("css=div.ac_results-inner li");
511 $this->assertContains($firstName, $this->getValue('contact_1'), "autocomplete expected $firstName but didn’t find it in " . $this->getValue('contact_1'));
514 $this->click("is_permission_a_b");
515 $this->click("is_permission_b_a");
518 $this->waitForElementPresent("details-save");
519 $this->click("details-save");
520 $this->waitForElementPresent("Relationships");
522 $pageTitle = substr(sha1(rand()), 0, 7);
524 $hash = substr(sha1(rand()), 0, 7);
525 $amountSection = TRUE;
531 $memPriceSetId = NULL;
533 $profilePreId = NULL;
534 $profilePostId = NULL;
538 $honoreeSection = FALSE;
539 $isAddPaymentProcessor = FALSE;
540 $isPcpApprovalNeeded = FALSE;
541 $isSeparatePayment = FALSE;
543 // create a new online contribution page
544 // create contribution page with randomized title and default params
545 $pageId = $this->webtestAddContributionPage($hash,
562 $isAddPaymentProcessor,
563 $isPcpApprovalNeeded,
568 $this->_testOrganization($pageId, $cid, $pageTitle);
572 function _testOrganization($pageId, $cid, $pageTitle) {
573 //Open Live Contribution Page
574 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom");
576 $this->waitForElementPresent("onbehalf_state_province-3");
578 $this->waitForElementPresent("onbehalf_phone-3-1");
579 $this->type("onbehalf_phone-3-1", 9999999999);
580 $this->waitForElementPresent("onbehalf_email-3");
581 $this->type("onbehalf_email-3", "org@example.com");
582 $this->type("onbehalf_street_address-3", "Test Street Address");
583 $this->type("onbehalf_city-3", "Test City");
584 $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
585 $this->click("onbehalf_country-3");
586 $this->select("onbehalf_country-3", "label=United States");
587 $this->click("onbehalf_state_province-3");
588 $this->select("onbehalf_state_province-3", "label=Alabama");
590 $this->waitForElementPresent("_qf_Main_upload-bottom");
591 $this->click("_qf_Main_upload-bottom");
593 $this->waitForPageToLoad($this->getTimeoutMsec());
595 $this->waitForElementPresent("_qf_Confirm_next-bottom");
597 $this->click("_qf_Confirm_next-bottom");
598 $this->waitForPageToLoad($this->getTimeoutMsec());
602 function _testAnomoyousOganization($pageId, $cid, $pageTitle) {
603 //Open Live Contribution Page
604 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom");
606 $this->click('CIVICRM_QFID_0_8');
607 $this->type('css=div.other_amount-section input', 60);
609 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
610 $lastName = 'An' . substr(sha1(rand()), 0, 7);
611 $orgName = 'org_11_' . substr(sha1(rand()), 0, 7);
612 $this->type("email-5", $firstName . "@example.com");
614 // enable onbehalforganization block
615 $this->click("is_for_organization");
616 $this->waitForElementPresent("onbehalf_state_province-3");
618 // onbehalforganization info
619 $this->type("onbehalf_organization_name", $orgName);
620 $this->type("onbehalf_phone-3-1", 9999999999);
621 $this->type("onbehalf_email-3", "{$orgName}@example.com");
622 $this->type("onbehalf_street_address-3", "Test Street Address");
623 $this->type("onbehalf_city-3", "Test City");
624 $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
625 $this->click("onbehalf_country-3");
626 $this->select("onbehalf_country-3", "label=United States");
627 $this->click("onbehalf_state_province-3");
628 $this->select("onbehalf_state_province-3", "label=Alabama");
632 $this->select("credit_card_type", "value=Visa");
633 $this->type("credit_card_number", "4111111111111111");
634 $this->type("cvv2", "000");
635 $this->select("credit_card_exp_date[M]", "value=1");
636 $this->select("credit_card_exp_date[Y]", "value=2020");
639 $this->type("billing_first_name", $firstName . 'billing');
640 $this->type("billing_last_name", $lastName . 'billing');
641 $this->type("billing_street_address-5", "0121 Mount Highschool.");
642 $this->type(" billing_city-5", "Shangai");
643 $this->select("billing_country_id-5", "value=1228");
644 $this->select("billing_state_province_id-5", "value=1004");
645 $this->type("billing_postal_code-5", "94129");
646 $this->click("_qf_Main_upload-bottom");
648 $this->waitForPageToLoad($this->getTimeoutMsec());
649 $this->waitForElementPresent("_qf_Confirm_next-bottom");
651 $this->click("_qf_Confirm_next-bottom");
652 $this->waitForPageToLoad($this->getTimeoutMsec());
654 //login to check contribution
656 // Log in using webtestLogin() method
657 $this->webtestLogin();
660 $this->openCiviPage("contribute/search", "reset=1");
661 $this->type("sort_name", $orgName);
662 $this->click("_qf_Search_refresh");
664 $this->waitForPageToLoad($this->getTimeoutMsec());
666 $this->waitForElementPresent("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
667 $this->click("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
668 $this->waitForPageToLoad($this->getTimeoutMsec());
669 $this->waitForElementPresent("_qf_ContributionView_cancel-bottom");
671 // verify contrb created
677 foreach ($expected as $value => $label) {
678 $this->verifyText("xpath=id( 'ContributionView' )/div[2]/table[1]/tbody/tr[$value]/td[2]", preg_quote($label));
682 function _testUserWithOneRelationship($pageId, $cid, $pageTitle) {
683 $this->webtestLogin('admin');
686 $groupName = $this->WebtestAddGroup();
687 $this->openCiviPage("group", "reset=1", "_qf_Search_refresh");
688 $groupId = $this->getText("xpath=//table[@id='crm-group-selector']/tbody//tr/td[text()='{$groupName}']/../td[2]");
690 $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
692 $this->click('link=Edit');
693 $this->waitForElementPresent('_qf_Contact_cancel-bottom');
694 $this->click('addressBlock');
695 $this->waitForElementPresent('link=Another Address');
698 $this->select('address_1_location_type_id', 'label=Billing');
699 $this->type('address_1_street_address', '0121 Mount Highschool.');
700 $this->type('address_1_city', "Shangai");
701 $this->type('address_1_postal_code', "94129");
702 $this->select('address_1_country_id', "value=1228");
703 $this->select('address_1_state_province_id', "value=1004");
704 $this->click('_qf_Contact_upload_view-bottom');
705 $this->waitForPageToLoad($this->getTimeoutMsec());
707 // add contact to group
709 $this->click("css=li#tab_group a");
710 $this->waitForElementPresent("group_id");
713 $this->select("group_id", "label={$groupName}");
714 $this->click("_qf_GroupContact_next");
715 $this->waitForPageToLoad($this->getTimeoutMsec());
717 $this->openCiviPage("admin/custom/group", "action=add&reset=1", "_qf_Group_next-bottom");
719 // fill in a unique title for the custom group
720 $groupTitle = "Custom Group" . substr(sha1(rand()), 0, 7);
721 $this->type("title", $groupTitle);
723 // select the group this custom data set extends
724 $this->select("extends[0]", "value=Contribution");
725 $this->waitForElementPresent("extends[1]");
727 // save the custom group
728 $this->click("_qf_Group_next-bottom");
729 $this->waitForElementPresent("_qf_Field_next_new-bottom");
730 $this->assertTrue($this->isTextPresent("Your custom field set '$groupTitle' has been added. You can add custom fields now."));
732 // add a custom field to the custom group
733 $fieldTitle = "Custom Field " . substr(sha1(rand()), 0, 7);
734 $this->type("label", $fieldTitle);
736 $this->select("data_type[1]", "value=Text");
737 $this->click('_qf_Field_next-bottom');
739 $this->waitForPageToLoad($this->getTimeoutMsec());
740 $this->assertTrue($this->isTextPresent("Your custom field '$fieldTitle' has been saved."));
741 $url = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']/div[2]/table/tbody//tr/td[1][text()='$fieldTitle']/../td[8]/span/a@href"));
744 // Enable CiviCampaign module if necessary
745 $this->enableComponents("CiviCampaign");
747 // add the required permission
748 $permission = array('edit-2-administer-civicampaign');
749 $this->changePermissions($permission);
751 // Log in as normal user
752 $this->webtestLogin();
754 $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom");
756 $title = 'Campaign ' . substr(sha1(rand()), 0, 7);
757 $this->type("title", $title);
759 // select the campaign type
760 $this->select("campaign_type_id", "value=2");
762 // fill in the description
763 $this->type("description", "This is a test campaign");
765 // include groups for the campaign
766 $this->addSelection("includeGroups-f", "label={$groupName}");
767 $this->click("//option[@value={$groupId}]");
770 // fill the end date for campaign
771 $this->webtestFillDate("end_date", "+1 year");
773 // select campaign status
774 $this->select("status_id", "value=2");
777 $this->click("_qf_Campaign_upload-bottom");
778 $this->waitForElementPresent("xpath=//div[@id='campaigns_wrapper']//table[@id='campaigns']/tbody//tr/td[3][text()='{$title}']");
779 $this->assertTrue($this->isTextPresent("Campaign {$title} has been saved."), "Status message didn't show up after saving!");
781 $this->openCiviPage("admin/uf/group", "reset=1");
782 $this->click("link=Reserved Profiles");
784 $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']");
785 $this->waitForPageToLoad($this->getTimeoutMsec());
787 $this->click("link=Add Field");
788 $this->waitForElementPresent('_qf_Field_next-bottom');
789 $this->select('field_name[0]', 'value=Contribution');
790 $this->select('field_name[1]', 'label=Campaign');
791 $this->click('field_name[1]');
792 $this->click('_qf_Field_next_new-bottom');
793 $this->waitForPageToLoad($this->getTimeoutMsec());
795 $this->select('field_name[0]', 'value=Contribution');
796 $this->select('field_name[1]', "label=$fieldTitle :: $groupTitle");
797 $this->click('field_name[1]');
798 $this->click('_qf_Field_next-bottom');
799 $this->waitForPageToLoad($this->getTimeoutMsec());
800 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$fieldTitle}' has been saved to 'On Behalf Of Organization'."));
802 // Open Page to create Organization
803 $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom");
804 $orgName1 = 'org1_' . substr(sha1(rand()), 0, 7);
806 // Type Organization name
807 $this->type("organization_name", $orgName1);
809 // Type Organizatio email for main
810 $this->type("email_1_email", "{$orgName1}@example.com");
811 $this->select("email_1_location_type_id", "value=3");
813 // type phone no for main
814 $this->type("phone_1_phone", 9999999999);
815 $this->select("phone_1_location_type_id", "value=3");
818 $this->click("addressBlock");
819 $this->waitForElementPresent("address_1_street_address");
821 //fill in address 1 for main
822 $this->select("address_1_location_type_id", "value=3");
823 $this->type("address_1_street_address", "{$orgName1} street address");
824 $this->type("address_1_city", "{$orgName1} city");
825 $this->type("address_1_postal_code", substr(sha1(rand()), 0, 4));
826 $this->assertTrue($this->isTextPresent("- select - United States"));
827 $this->select("address_1_state_province_id", "value=1019");
828 $this->type("address_1_geo_code_1", "1234");
829 $this->type("address_1_geo_code_2", "5678");
831 // Save the Organization
832 $this->click("_qf_Contact_upload_view-bottom");
833 $this->waitForPageToLoad($this->getTimeoutMsec());
836 $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1");
838 // select relationship type
839 $this->click("relationship_type_id");
840 $this->select("relationship_type_id", "value=4_a_b");
842 // search organization
843 $this->type('contact_1', $orgName1);
844 $this->click("contact_1");
845 $this->waitForElementPresent("css=div.ac_results-inner li");
846 $this->click("css=div.ac_results-inner li");
847 $this->assertContains($orgName1, $this->getValue('contact_1'), "autocomplete expected $orgName1 but didn’t find it in " . $this->getValue('contact_1'));
849 $this->waitForElementPresent("add_current_employer");
850 $this->click("add_current_employer");
853 $this->click("is_permission_a_b");
854 $this->click("is_permission_b_a");
857 $this->waitForElementPresent("details-save");
858 $this->click("details-save");
860 //Open Live Contribution Page
861 $this->openCiviPage("contribute/transact", "reset=1&id={$pageId}&cid=$cid", "onbehalf_state_province-3");
862 $this->click('CIVICRM_QFID_amount_other_radio_4');
863 $this->type('amount_other', 60);
864 $this->click('onbehalf_contribution_campaign_id');
865 $this->select('onbehalf_contribution_campaign_id', "label={$title}");
866 $this->type("onbehalf_custom_{$fieldId}", 'Test Subject');
869 $this->select("credit_card_type", "value=Visa");
870 $this->type("credit_card_number", "4111111111111111");
871 $this->type("cvv2", "000");
872 $this->select("credit_card_exp_date[M]", "value=1");
873 $this->select("credit_card_exp_date[Y]", "value=2020");
876 $this->type("billing_street_address-5", "0121 Mount Highschool.");
877 $this->type(" billing_city-5", "Shangai");
878 $this->select("billing_country_id-5", "value=1228");
879 $this->select("billing_state_province_id-5", "value=1004");
880 $this->type("billing_postal_code-5", "94129");
882 $this->click("_qf_Main_upload-bottom");
883 $this->waitForPageToLoad($this->getTimeoutMsec());
884 $this->waitForElementPresent("_qf_Confirm_next-bottom");
885 $this->click("_qf_Confirm_next-bottom");
886 $this->waitForPageToLoad($this->getTimeoutMsec());
889 $this->openCiviPage("contribute/search", "reset=1");
890 $this->type("sort_name", $orgName1);
891 $this->click("_qf_Search_refresh");
892 $this->waitForPageToLoad($this->getTimeoutMsec());
893 $this->waitForElementPresent("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
894 $this->click("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
895 $this->waitForPageToLoad($this->getTimeoutMsec());
896 $this->waitForElementPresent("_qf_ContributionView_cancel-bottom");
898 // verify contrb created
905 foreach ($expected as $value => $label) {
906 $this->verifyText("xpath=id( 'ContributionView' )/div[2]/table[1]/tbody/tr[$value]/td[2]", preg_quote($label));
910 $this->openCiviPage("admin/uf/group", "reset=1");
911 $this->click("link=Reserved Profiles");
913 $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']");
914 $this->waitForPageToLoad($this->getTimeoutMsec());
916 $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']");
917 $this->waitForElementPresent('_qf_Field_next-bottom');
919 $this->click('_qf_Field_next-bottom');
920 $this->waitForPageToLoad($this->getTimeoutMsec());
921 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'), "Status message didn't show up after saving!");
923 $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']");
924 $this->waitForElementPresent('_qf_Field_next-bottom');
926 $this->click('_qf_Field_next-bottom');
927 $this->waitForPageToLoad($this->getTimeoutMsec());
928 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'), "Status message didn't show up after saving!");
931 function _testUserWithMoreThanOneRelationship($pageId, $cid, $pageTitle) {
932 $this->webtestLogin('admin');
933 $this->waitForPageToLoad($this->getTimeoutMsec());
936 $groupName = $this->WebtestAddGroup();
937 $this->openCiviPage("group", "reset=1", '_qf_Search_refresh');
938 $this->click('_qf_Search_refresh');
939 $this->waitForElementPresent("xpath=//div[@id='group']/div[3]/table/tbody//tr/td[text()='{$groupName}']/../td[2]");
940 $groupId = $this->getText("xpath=//div[@id='group']/div[3]/table/tbody//tr/td[text()='{$groupName}']/../td[2]");
942 $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
944 $this->click('link=Edit');
945 $this->waitForElementPresent('_qf_Contact_cancel-bottom');
946 $this->click('addressBlock');
947 $this->waitForElementPresent('link=Another Address');
950 $this->select('address_1_location_type_id', 'label=Billing');
951 $this->type('address_1_street_address', '0121 Mount Highschool.');
952 $this->type('address_1_city', "Shangai");
953 $this->type('address_1_postal_code', "94129");
954 $this->select('address_1_country_id', "value=1228");
955 $this->select('address_1_state_province_id', "value=1004");
956 $this->click('_qf_Contact_upload_view-bottom');
957 $this->waitForPageToLoad($this->getTimeoutMsec());
959 // add contact to group
961 $this->click("css=li#tab_group a");
962 $this->waitForElementPresent("group_id");
965 $this->select("group_id", "label=$groupName");
966 $this->click("_qf_GroupContact_next");
967 $this->waitForPageToLoad($this->getTimeoutMsec());
969 $this->openCiviPage("admin/custom/group", "action=add&reset=1", "_qf_Group_next-bottom");
971 // fill in a unique title for the c$groupIdustom group
972 $groupTitle = "Members Custom Group" . substr(sha1(rand()), 0, 7);
973 $this->type("title", $groupTitle);
975 // select the group this custom data set extends
976 $this->select("extends[0]", "value=Membership");
977 $this->waitForElementPresent("extends[1]");
979 // save the custom group
980 $this->click("_qf_Group_next-bottom");
982 $this->waitForElementPresent("_qf_Field_next_new-bottom");
983 $this->assertTrue($this->isTextPresent("Your custom field set '$groupTitle' has been added. You can add custom fields now."));
985 // add a custom field to the custom group
986 $fieldTitle = "Member Custom Field " . substr(sha1(rand()), 0, 7);
987 $this->type("label", $fieldTitle);
989 $this->select("data_type[1]", "value=Text");
990 $this->click('_qf_Field_next-bottom');
992 $this->waitForPageToLoad($this->getTimeoutMsec());
993 $this->assertTrue($this->isTextPresent("Your custom field '$fieldTitle' has been saved."));
994 $url = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']/div[2]/table/tbody//tr/td[1]/span[text()='$fieldTitle']/../td[8]/span/a@href"));
997 // Enable CiviCampaign module if necessary
998 $this->enableComponents("CiviCampaign");
1000 // add the required permission
1001 $permission = array('edit-2-administer-civicampaign');
1002 $this->changePermissions($permission);
1004 // Log in as normal user
1005 $this->webtestLogin();
1007 $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom");
1009 $title = 'Campaign ' . substr(sha1(rand()), 0, 7);
1010 $this->type("title", $title);
1012 // select the campaign type
1013 $this->select("campaign_type_id", "value=2");
1015 // fill in the description
1016 $this->type("description", "This is a test campaign");
1018 // include groups for the campaign
1019 $this->addSelection("includeGroups-f", "label={$groupName}");
1020 $this->click("//option[@value={$groupId}]");
1021 $this->click("add");
1023 // fill the end date for campaign
1024 $this->webtestFillDate("end_date", "+1 year");
1026 // select campaign status
1027 $this->select("status_id", "value=2");
1030 $this->click("_qf_Campaign_upload-bottom");
1031 $this->waitForPageToLoad($this->getTimeoutMsec());
1033 $this->assertTrue($this->isTextPresent("Campaign {$title} has been saved."), "Status message didn't show up after saving!");
1035 $this->openCiviPage("admin/uf/group", "reset=1");
1036 $this->click("link=Reserved Profiles");
1037 $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']");
1038 $this->waitForPageToLoad($this->getTimeoutMsec());
1040 $this->click("link=Add Field");
1041 $this->waitForElementPresent('_qf_Field_next-bottom');
1042 $this->select('field_name[0]', 'value=Membership');
1043 $this->select('field_name[1]', 'label=Campaign');
1044 $this->click('field_name[1]');
1045 $this->click('_qf_Field_next_new-bottom');
1046 $this->waitForPageToLoad($this->getTimeoutMsec());
1047 $this->waitForElementPresent('_qf_Field_cancel-bottom');
1049 $this->select('field_name[0]', 'value=Membership');
1050 $this->select('field_name[1]', "label=$fieldTitle :: $groupTitle");
1051 $this->click('field_name[1]');
1052 $this->click('_qf_Field_next-bottom');
1053 $this->waitForPageToLoad($this->getTimeoutMsec());
1054 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$fieldTitle}' has been saved to 'On Behalf Of Organization'."),
1055 "Status message didn't show up after saving!"
1058 // Open Page to create Organization 1
1059 $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom");
1060 $orgName1 = 'org1_' . substr(sha1(rand()), 0, 7);
1062 // Type Organization name
1063 $this->type("organization_name", $orgName1);
1065 // Type Organizatio email for main
1066 $this->type("email_1_email", "{$orgName1}@example.com");
1067 $this->select("email_1_location_type_id", "value=3");
1069 // type phone no for main
1070 $this->type("phone_1_phone", substr(sha1(rand()), 0, 4));
1071 $this->select("phone_1_location_type_id", "value=3");
1074 $this->click("addressBlock");
1075 $this->waitForElementPresent("address_1_street_address");
1077 //fill in address 1 for main
1078 $this->select("address_1_location_type_id", "value=3");
1079 $this->type("address_1_street_address", "{$orgName1} street address");
1080 $this->type("address_1_city", "{$orgName1} city");
1081 $this->type("address_1_postal_code", "9999999999");
1082 $this->assertTrue($this->isTextPresent("- select - United States"));
1083 $this->select("address_1_state_province_id", "value=1019");
1084 $this->type("address_1_geo_code_1", "1234");
1085 $this->type("address_1_geo_code_2", "5678");
1087 // Save the Organization
1088 $this->click("_qf_Contact_upload_view-bottom");
1089 $this->waitForPageToLoad($this->getTimeoutMsec());
1091 // create second orzanization
1092 $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom");
1093 $orgName2 = 'org2_' . substr(sha1(rand()), 0, 7);
1095 // Type Organization name
1096 $this->type("organization_name", $orgName2);
1098 // Type Organizatio email for main
1099 $this->type("email_1_email", "{$orgName2}@example.com");
1100 $this->select("email_1_location_type_id", "value=3");
1102 // type phone no for main
1103 $this->type("phone_1_phone", substr(sha1(rand()), 0, 4));
1104 $this->select("phone_1_location_type_id", "value=3");
1107 $this->click("addressBlock");
1108 $this->waitForElementPresent("address_1_street_address");
1110 //fill in address 1 for main
1111 $this->select("address_1_location_type_id", "value=3");
1112 $this->type("address_1_street_address", "{$orgName2} street address");
1113 $this->type("address_1_city", "{$orgName2} city");
1114 $this->type("address_1_postal_code", "7777777777");
1115 $this->assertTrue($this->isTextPresent("- select - United States"));
1116 $this->select("address_1_state_province_id", "value=1019");
1117 $this->type("address_1_geo_code_1", "1224");
1118 $this->type("address_1_geo_code_2", "5628");
1120 // Save the Organization
1121 $this->click("_qf_Contact_upload_view-bottom");
1122 $this->waitForPageToLoad($this->getTimeoutMsec());
1125 // create Membership type
1126 $title1 = "Membership Type" . substr(sha1(rand()), 0, 7);
1127 $this->openCiviPage("admin/member/membershipType", "reset=1&action=browse");
1129 $this->click("link=Add Membership Type");
1130 $this->waitForElementPresent('_qf_MembershipType_cancel-bottom');
1132 $this->type('name', $title1);
1133 $this->type('member_org', $orgName1);
1134 $this->click('_qf_MembershipType_refresh');
1135 $this->waitForElementPresent("xpath=//div[@id='membership_type_form']/fieldset/table[2]/tbody/tr[2]/td[2]");
1137 $this->type('minimum_fee', '50');
1139 $this->select( 'financial_type_id', 'value=2' );
1141 $this->type('duration_interval', 1);
1142 $this->select('duration_unit', "label=year");
1144 $this->select('period_type', "label=fixed");
1145 $this->waitForElementPresent('fixed_period_rollover_day[d]');
1147 $this->select('fixed_period_start_day[M]', 'value=4');
1148 $this->select('fixed_period_rollover_day[M]', 'value=1');
1150 $this->select('relationship_type_id', 'value=4_b_a');
1152 $this->click('_qf_MembershipType_upload-bottom');
1153 $this->waitForElementPresent('link=Add Membership Type');
1154 $this->assertTrue($this->isTextPresent("The membership type '$title1' has been saved."));
1155 $typeUrl = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/div[2]/table/tbody//tr/td[1][text()='{$title1}']/../td[10]/span/a[3]@href"));
1156 $typeId = $typeUrl[1];
1159 $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1");
1161 // select relationship type
1162 $this->click("relationship_type_id");
1163 $this->select("relationship_type_id", "value=4_a_b");
1165 // search organization
1166 $this->type('contact_1', $orgName1);
1167 $this->click("contact_1");
1168 $this->waitForElementPresent("css=div.ac_results-inner li");
1169 $this->click("css=div.ac_results-inner li");
1170 $this->assertContains($orgName1, $this->getValue('contact_1'), "autocomplete expected $orgName1 but didn’t find it in " . $this->getValue('contact_1'));
1173 $this->click("is_permission_a_b");
1174 $this->click("is_permission_b_a");
1176 // save relationship
1177 $this->click("details-save");
1180 $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1");
1182 // select relationship type
1183 $this->click("relationship_type_id");
1184 $this->select("relationship_type_id", "value=4_a_b");
1186 // search organization
1187 $this->type('contact_1', $orgName2);
1188 $this->click("contact_1");
1189 $this->waitForElementPresent("css=div.ac_results-inner li");
1190 $this->click("css=div.ac_results-inner li");
1191 $this->assertContains($orgName2, $this->getValue('contact_1'), "autocomplete expected $orgName2 but didn’t find it in " . $this->getValue('contact_1'));
1194 $this->click("is_permission_a_b");
1195 $this->click("is_permission_b_a");
1197 // save relationship
1198 $this->click("details-save");
1200 // set membership type
1201 $this->openCiviPage("admin/contribute/membership", "reset=1&action=update&id=$pageId", "_qf_MembershipBlock_upload_done-bottom");
1202 $this->click("member_is_active");
1203 $this->click("membership_type[{$typeId}]");
1204 $this->click("xpath=//div[@id='memberFields']//table[@class='report']/tbody//tr/td[1]/label[text()='{$title1}']/../../td[2]/input");
1205 $this->click('_qf_MembershipBlock_upload_done-bottom');
1206 $this->waitForPageToLoad($this->getTimeoutMsec());
1208 //Open Live Membership Page
1209 $this->open($this->sboxPath
. "civicrm/contribute/transact?reset=1&id=" . $pageId . "&cid=" . $cid);
1210 $this->waitForElementPresent("_qf_Main_upload-bottom");
1211 $this->click('CIVICRM_QFID_amount_other_radio_4');
1212 $this->type('amount_other', 60);
1213 $this->click('onbehalf_organization_name');
1214 $this->type('onbehalf_organization_name', $orgName1);
1215 $this->typeKeys('onbehalf_organization_name', $orgName1);
1216 $this->click("onbehalf_organization_name");
1217 $this->waitForElementPresent("css=div.ac_results-inner li");
1218 $this->click("css=div.ac_results-inner li");
1219 // Because it tends to cause problems, all uses of sleep() must be justified in comments
1220 // Sleep should never be used for wait for anything to load from the server
1221 // Justification for this instance: FIXME
1223 $this->click('onbehalf_member_campaign_id');
1224 $this->select('onbehalf_member_campaign_id', "label={$title}");
1225 $this->type("onbehalf_custom_{$fieldId}", 'Test Subject');
1227 $this->assertContains($orgName1, $this->getValue('onbehalf_organization_name'), "autocomplete expected $orgName1 but didn’t find it in " . $this->getValue('onbehalf_organization_name'));
1230 $this->select("credit_card_type", "value=Visa");
1231 $this->type("credit_card_number", "4111111111111111");
1232 $this->type("cvv2", "000");
1233 $this->select("credit_card_exp_date[M]", "value=1");
1234 $this->select("credit_card_exp_date[Y]", "value=2020");
1236 $this->click("_qf_Main_upload-bottom");
1237 $this->waitForPageToLoad($this->getTimeoutMsec());
1238 $this->waitForElementPresent("_qf_Confirm_next-bottom");
1239 $this->click("_qf_Confirm_next-bottom");
1240 $this->waitForPageToLoad($this->getTimeoutMsec());
1242 //Find Membership for organization
1243 $this->openCiviPage("member/search", "reset=1");
1244 $this->type("sort_name", $orgName1);
1245 $this->click("_qf_Search_refresh");
1246 $this->waitForPageToLoad($this->getTimeoutMsec());
1247 $this->waitForElementPresent("xpath=//div[@id='memberSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
1248 $this->click("xpath=//div[@id='memberSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
1249 $this->waitForPageToLoad($this->getTimeoutMsec());
1250 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
1252 //verify contrb created
1258 foreach ($expected as $value => $label) {
1259 $this->verifyText("xpath=//form[@id='MembershipView']/div[2]/div/table/tbody/tr[$value]/td[2]", preg_quote($label));
1262 // find membership for contact in relationship
1263 $this->openCiviPage("contact/view", "reset=1&force=1&cid={$cid}");
1264 $this->click("css=li#tab_member a");
1265 $this->waitForElementPresent("xpath=//div[@id='memberships']/div/table//tbody//tr/td[1][text()='{$title1}']");
1266 $this->click("xpath=//div[@id='memberships']/div/table//tbody//tr/td[1][text()='{$title1}']/../td[7]/span/a[text()='View']");
1267 $this->waitForPageToLoad($this->getTimeoutMsec());
1269 //verify contrb created
1274 foreach ($expected as $value => $label) {
1275 $this->verifyText("xpath=//form[@id='MembershipView']/div[2]/div/table/tbody/tr[$value]/td[2]", preg_quote($label));
1278 $this->openCiviPage("admin/uf/group", "reset=1");
1279 $this->click("link=Reserved Profiles");
1280 $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']");
1281 $this->waitForPageToLoad($this->getTimeoutMsec());
1283 $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']");
1284 $this->waitForElementPresent('_qf_Field_next-bottom');
1286 $this->click('_qf_Field_next-bottom');
1287 $this->waitForPageToLoad($this->getTimeoutMsec());
1288 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'),
1289 "Status message didn't show up after saving!"
1292 $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']");
1293 $this->waitForElementPresent('_qf_Field_next-bottom');
1295 $this->click('_qf_Field_next-bottom');
1296 $this->waitForPageToLoad($this->getTimeoutMsec());
1297 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'),
1298 "Status message didn't show up after saving!"
1301 $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
1302 $this->click("css=li#tab_rel a");
1304 $this->waitForElementPresent("xpath=//div[@id='current-relationships']/div/table/tbody//tr/td[2]/a[text()='{$orgName1}']");
1305 $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']");
1307 // Check confirmation alert.
1308 $this->assertTrue((bool)preg_match("/^Are you sure you want to delete this relationship?/",
1309 $this->getConfirmation()
1311 $this->chooseOkOnNextConfirmation();
1312 $this->waitForPageToLoad($this->getTimeoutMsec());
1313 $this->assertTrue($this->isTextPresent('Selected relationship has been deleted successfully.'),
1314 "Status message didn't show up after saving!"
1319 function testOnBehalfOfOrganizationWithImage() {
1320 $this->webtestLogin();
1322 $this->openCiviPage("profile/edit", "reset=1&gid=4");
1323 $firstName = 'John_x_' . substr(sha1(rand()), 0, 7);
1324 $lastName = 'Anderson_c_' . substr(sha1(rand()), 0, 7);
1326 $this->waitForPageToLoad($this->getTimeoutMsec());
1327 $this->waitForElementPresent("_qf_Edit_next");
1328 $this->type("first_name", $firstName);
1329 $this->type("last_name", $lastName);
1330 $this->click("_qf_Edit_next");
1331 $this->waitForPageToLoad($this->getTimeoutMsec());
1332 $this->waitForElementPresent("profilewrap4");
1334 $urlElements = $this->parseURL();
1335 $cid = $urlElements['queryString']['id'];
1336 $this->assertType('numeric', $cid);
1337 // Is status message correct?
1338 $this->assertTextPresent("Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!");
1340 $this->openCiviPage("admin/uf/group", "reset=1");
1341 $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("link=Add Field");
1347 $this->waitForElementPresent('_qf_Field_next-bottom');
1349 $this->select('field_name[0]', 'value=Contact');
1350 $this->select('field_name[1]', 'label=Image Url');
1351 $this->click('field_name[1]');
1352 $this->click('_qf_Field_next-bottom');
1353 $this->waitForPageToLoad($this->getTimeoutMsec());
1355 // We need a payment processor
1356 $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7);
1357 $processorType = 'Dummy';
1358 $pageTitle = substr(sha1(rand()), 0, 7);
1360 $hash = substr(sha1(rand()), 0, 7);
1361 $amountSection = TRUE;
1366 $memberships = FALSE;
1367 $memPriceSetId = NULL;
1369 $profilePreId = NULL;
1370 $profilePostId = NULL;
1374 $honoreeSection = FALSE;
1375 $isAddPaymentProcessor = TRUE;
1376 $isPcpApprovalNeeded = FALSE;
1377 $isSeparatePayment = FALSE;
1379 // create a new online contribution page
1380 // create contribution page with randomized title and default params
1381 $pageId = $this->webtestAddContributionPage($hash,
1384 array($processorName => $processorType),
1398 $isAddPaymentProcessor,
1399 $isPcpApprovalNeeded,
1404 $this->_testOrganizationWithImageUpload($pageId, $cid, $pageTitle);
1406 $this->openCiviPage("admin/uf/group", "reset=1");
1407 $this->click("link=Reserved Profiles");
1409 $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']");
1410 $this->waitForPageToLoad($this->getTimeoutMsec());
1411 $this->click("xpath=//table[@id='option11']/tbody//tr/td/span[text()='Image Url']/../following-sibling::td[8]/span[2]/ul/li[2]/a");
1412 $this->waitForPageToLoad($this->getTimeoutMsec());
1413 $this->click('_qf_Field_next-bottom');
1414 $this->waitForPageToLoad($this->getTimeoutMsec());
1415 $this->assertElementContainsText('crm-notification-container', "Selected Profile Field has been deleted.");
1418 function _testOrganizationWithImageUpload($pageId, $cid, $pageTitle) {
1419 //Open Live Contribution Page
1420 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId");
1422 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
1423 $lastName = 'An' . substr(sha1(rand()), 0, 7);
1424 $orgName = 'org_11_' . substr(sha1(rand()), 0, 7);
1425 $this->type("email-5", $firstName . "@example.com");
1427 // onbehalforganization info
1428 $this->type("onbehalf_organization_name", $orgName);
1429 $this->type("onbehalf_phone-3-1", 9999999999);
1430 $this->type("onbehalf_email-3", "{$orgName}@example.com");
1431 $this->type("onbehalf_street_address-3", "Test Street Address");
1432 $this->type("onbehalf_city-3", "Test City");
1433 $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
1434 $this->click("onbehalf_country-3");
1435 $this->select("onbehalf_country-3", "label=United States");
1436 $this->click("onbehalf_state_province-3");
1437 $this->select("onbehalf_state_province-3", "label=Alabama");
1439 // check for upload field.
1440 $this->waitForElementPresent("onbehalf_image_URL");
1442 //header("Content-Type: image/png");
1443 $im = imagecreate(110, 20)
1444 or die("Cannot Initialize new GD image stream");
1445 $background_color = imagecolorallocate($im, 0, 0, 0);
1446 $text_color = imagecolorallocate($im, 233, 14, 91);
1447 imagestring($im, 1, 5, 5, "On Behalf-Org Logo", $text_color);
1448 imagepng($im,"/tmp/file.png");
1450 $imagePath = "/tmp/file.png";
1451 $this->webtestAttachFile('onbehalf_image_URL', $imagePath);
1455 $this->select("credit_card_type", "value=Visa");
1456 $this->type("credit_card_number", "4111111111111111");
1457 $this->type("cvv2", "000");
1458 $this->select("credit_card_exp_date[M]", "value=1");
1459 $this->select("credit_card_exp_date[Y]", "value=2020");
1462 $this->type("billing_first_name", $firstName . 'billing');
1463 $this->type("billing_last_name", $lastName . 'billing');
1464 $this->type("billing_street_address-5", "0121 Mount Highschool.");
1465 $this->type(" billing_city-5", "Shangai");
1466 $this->select("billing_country_id-5", "value=1228");
1467 $this->select("billing_state_province_id-5", "value=1004");
1468 $this->type("billing_postal_code-5", "94129");
1469 $this->click("_qf_Main_upload-bottom");
1471 $this->waitForPageToLoad($this->getTimeoutMsec());
1472 $this->waitForElementPresent("_qf_Confirm_next-bottom");
1474 $this->click("_qf_Confirm_next-bottom");
1475 $this->waitForPageToLoad($this->getTimeoutMsec());
1477 // Type search name in autocomplete.
1478 $this->click('sort_name_navigation');
1479 $this->type('css=input#sort_name_navigation', $orgName);
1480 $this->typeKeys('css=input#sort_name_navigation', $orgName);
1482 // Wait for result list.
1483 $this->waitForElementPresent("css=div.ac_results-inner li");
1485 // Visit organization page.
1486 $this->click("css=div.ac_results-inner li");
1487 $this->waitForPageToLoad($this->getTimeoutMsec());
1489 //check whether the image is present
1490 $this->assertTrue($this->isElementPresent("xpath=//div[@id='crm-contact-thumbnail']/div/a/img"));