3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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 three new individual
119 $individuals = $organizations = array();
120 for ($i = 0; $i < 3; $i++
) {
121 $firstName = 'John_x_' . substr(sha1(rand()), 0, 7);
122 $individuals[] = $firstName;
123 $this->webtestAddContact($firstName, "Memberson", "{$firstName}@memberson.com");
126 // Create two organisations, one used for new Membership Type, and other for inherited membership purpose
127 for ($i = 0; $i < 2; $i++
) {
128 $orgName1 = "Org WebAccess" . substr(sha1(rand()), 0, 7);
129 $orgEmail1 = substr(sha1(rand()), 0, 7) . "@web.com";
130 $organizations[] = array('name' => $orgName1, 'email' => $orgEmail1);
131 $this->webtestAddOrganization($orgName1, $orgEmail1);
134 // Create Employee relationship of last created organization $organizations[1] with all three $individuals
135 $this->waitForAjaxContent();
136 $this->click("css=li#tab_rel a");
137 $this->waitForElementPresent('link=Add Relationship');
138 $this->click('link=Add Relationship');
139 $this->waitForElementPresent('relationship_type_id');
140 $this->click("relationship_type_id");
141 $this->select("relationship_type_id", "label=Employer of");
142 // search organization
143 $this->select2('related_contact_id', $individuals, TRUE);
145 //$this->click("is_permission_a_b");
146 //$this->click("is_permission_b_a");
148 $this->click("_qf_Relationship_upload");
149 $this->waitForAjaxContent();
151 $title = 'Membership Type' . substr(sha1(rand()), 0, 7);
152 //Create membership type
153 $this->openCiviPage("admin/member/membershipType", "reset=1&action=browse");
154 $this->click("link=Add Membership Type");
155 $this->waitForElementPresent('_qf_MembershipType_cancel-bottom');
156 $this->type('name', $title);
157 $this->select2('member_of_contact_id', $organizations[0]['name']);
158 $this->type('minimum_fee', '100');
159 $this->select('financial_type_id', 'value=2');
160 $this->type('duration_interval', 1);
161 $this->select('duration_unit', "label=year");
162 $this->select('period_type', "value=rolling");
163 //Choose 'Employer of' relationship
164 $this->select('relationship_type_id', 'value=5_b_a');
165 $this->click('_qf_MembershipType_upload-bottom');
166 $this->waitForAjaxContent();
167 $this->waitForText('crm-notification-container', "The membership type '$title' has been saved.");
168 //Retrieve membership type ID from newly created membership type
169 $memTypeId = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td[1]/div[text()='{$title}']/../../td[12]/span/a[3]@href"));
170 $memTypeId = $memTypeId[1];
172 // Use default payment processor
173 $processorName = 'Test Processor';
174 $processorType = 'Dummy';
175 $pageTitle = substr(sha1(rand()), 0, 7);
177 $hash = substr(sha1(rand()), 0, 7);
178 $amountSection = TRUE;
180 $onBehalf = 'optional';
183 $memberships = array(array('id' => $memTypeId, 'name' => $title, 'default' => 1));
184 $memPriceSetId = NULL;
186 $profilePreId = NULL;
187 $profilePostId = NULL;
191 $honoreeSection = FALSE;
192 $isAddPaymentProcessor = TRUE;
193 $isPcpApprovalNeeded = FALSE;
194 $isSeparatePayment = FALSE;
196 // create a new online contribution page
197 // create contribution page with randomized title and default params
198 $pageId = $this->webtestAddContributionPage($hash,
201 array($processorName => $processorType),
215 $isAddPaymentProcessor,
216 $isPcpApprovalNeeded,
221 $this->_testAnomoyousOrganization($pageId, $organizations[1], $pageTitle);
223 //Check if all three of the individuals has inherited membership
224 $this->openCiviPage("member/search", "reset=1");
225 $this->multiselect2("membership_type_id", array($title));
226 $this->click("CIVICRM_QFID_0_member_is_primary");
227 $this->click('_qf_Search_refresh');
228 // It suppose to be 3 but since we are registring contribution onBehalf of anonymous contact(email-5)
229 $this->waitForText('search-status', "4 Results");
230 foreach ($individuals as $individual) {
231 $this->isTextPresent($individual);
235 public function testOnBehalfOfOrganizationWithOrgData() {
236 $this->webtestLogin();
238 $this->openCiviPage("profile/edit", "reset=1&gid=4");
239 $firstName = 'John_x_' . substr(sha1(rand()), 0, 7);
240 $lastName = 'Anderson_c_' . substr(sha1(rand()), 0, 7);
242 $this->waitForPageToLoad($this->getTimeoutMsec());
243 $this->waitForElementPresent("_qf_Edit_next");
244 $this->type("first_name", $firstName);
245 $this->type("last_name", $lastName);
246 $this->clickLink("_qf_Edit_next", "profilewrap4");
248 $cid = $this->urlArg('id');
249 // Is status message correct?
250 $this->assertTextPresent("Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!");
252 //add org fields to profile
253 $this->openCiviPage("admin/uf/group", "reset=1");
254 $this->click("link=Reserved Profiles");
256 $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']");
257 $this->waitForPageToLoad($this->getTimeoutMsec());
259 $this->click("link=Add Field");
260 $this->waitForElementPresent('_qf_Field_next-bottom');
262 $this->select('field_name[0]', 'value=Organization');
263 $this->select('field_name[1]', 'label=Legal Identifier');
264 $this->click('field_name[1]');
265 $this->click('_qf_Field_next_new-bottom');
266 $this->waitForPageToLoad($this->getTimeoutMsec());
268 $this->select('field_name[0]', 'value=Organization');
269 $this->select('field_name[1]', 'label=Legal Name');
270 $this->click('field_name[1]');
271 $this->click('_qf_Field_next-bottom');
272 $this->waitForPageToLoad($this->getTimeoutMsec());
274 //create organisation
275 $orgName = "Org WebAccess " . substr(sha1(rand()), 0, 7);
276 $orgEmail = "org" . substr(sha1(rand()), 0, 7) . "@web.com";
277 $this->webtestAddOrganization($orgName, $orgEmail);
279 $this->waitForPageToLoad($this->getTimeoutMsec());
280 $this->click("css=li#tab_rel a");
282 $this->waitForElementPresent('link=Add Relationship');
283 $this->click('link=Add Relationship');
285 $this->waitForElementPresent('relationship_type_id');
286 $this->click("relationship_type_id");
287 $this->select("relationship_type_id", "label=Employer of");
288 // search organization
289 $this->type('contact_1', $firstName);
290 $this->click("contact_1");
291 $this->waitForElementPresent("css=div.ac_results-inner li");
292 $this->click("css=div.ac_results-inner li");
293 $this->assertContains($firstName, $this->getValue('contact_1'), "autocomplete expected $firstName but didn’t find it in " . $this->getValue('contact_1'));
296 $this->click("is_permission_a_b");
297 $this->click("is_permission_b_a");
300 $this->waitForElementPresent("details-save");
301 $this->click("details-save");
302 $this->waitForElementPresent("Relationships");
304 $pageTitle = substr(sha1(rand()), 0, 7);
306 $hash = substr(sha1(rand()), 0, 7);
307 $amountSection = TRUE;
313 $memPriceSetId = NULL;
315 $profilePreId = NULL;
316 $profilePostId = NULL;
320 $honoreeSection = FALSE;
321 $isAddPaymentProcessor = FALSE;
322 $isPcpApprovalNeeded = FALSE;
323 $isSeparatePayment = FALSE;
325 // create a new online contribution page
326 // create contribution page with randomized title and default params
327 $pageId = $this->webtestAddContributionPage($hash,
344 $isAddPaymentProcessor,
345 $isPcpApprovalNeeded,
350 $this->_testOrganization($pageId, $cid, $pageTitle);
353 public function testWithContactSubtypeDupe() {
354 $this->webtestLogin();
356 //create organisation
357 $orgName = "Org WebAccess " . substr(sha1(rand()), 0, 7);
358 $orgEmail = "org" . substr(sha1(rand()), 0, 7) . "@web.com";
359 $contactSubType = 'Sponsor';
360 $this->webtestAddOrganization($orgName, $orgEmail, $contactSubType);
362 $this->waitForPageToLoad($this->getTimeoutMsec());
363 $cid = $this->urlArg('cid');
365 $pageTitle = substr(sha1(rand()), 0, 7);
367 $hash = substr(sha1(rand()), 0, 7);
368 $amountSection = TRUE;
373 $memberships = FALSE;
374 $memPriceSetId = NULL;
376 $profilePreId = NULL;
377 $profilePostId = NULL;
381 $honoreeSection = FALSE;
382 $isAddPaymentProcessor = FALSE;
383 $isPcpApprovalNeeded = FALSE;
384 $isSeparatePayment = FALSE;
386 // create a new online contribution page
387 // create contribution page with randomized title and default params
388 $pageId = $this->webtestAddContributionPage($hash,
405 $isAddPaymentProcessor,
406 $isPcpApprovalNeeded,
411 //Open Live Contribution Page
412 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom");
413 $this->waitForElementPresent("onbehalf_state_province-3");
415 $this->type("onbehalf_organization_name", $orgName);
416 $this->waitForElementPresent("onbehalf_phone-3-1");
417 $this->type("onbehalf_phone-3-1", 9999999999);
418 $this->waitForElementPresent("onbehalf_email-3");
419 $this->type("onbehalf_email-3", "org@example.com");
420 $this->type("onbehalf_street_address-3", "Test Street Address");
421 $this->type("onbehalf_city-3", "Test City");
422 $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
423 $this->click("onbehalf_country-3");
424 $this->select("onbehalf_country-3", "label=UNITED STATES");
425 $this->click("onbehalf_state_province-3");
426 $this->select("onbehalf_state_province-3", "label=Alabama");
428 $this->waitForElementPresent("_qf_Main_upload-bottom");
429 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
431 $this->click("_qf_Confirm_next-bottom");
432 $this->waitForPageToLoad($this->getTimeoutMsec());
434 $this->openCiviPage("contact/view", "reset=1&cid=$cid", "xpath=//div[@class='crm-content crm-contact_type_label']");
436 $this->verifyText("xpath=//div[@class='crm-content crm-contact_type_label']", $contactSubType);
444 public function _testOrganization($pageId, $cid, $pageTitle) {
445 //Open Live Contribution Page
446 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom");
448 $this->waitForElementPresent("onbehalf_state_province-3");
450 $this->waitForElementPresent("onbehalf_phone-3-1");
451 $this->type("onbehalf_phone-3-1", 9999999999);
452 $this->waitForElementPresent("onbehalf_email-3");
453 $this->type("onbehalf_email-3", "org@example.com");
454 $this->type("onbehalf_street_address-3", "Test Street Address");
455 $this->type("onbehalf_city-3", "Test City");
456 $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
457 $this->click("onbehalf_country-3");
458 $this->select("onbehalf_country-3", "label=UNITED STATES");
459 $this->click("onbehalf_state_province-3");
460 $this->select("onbehalf_state_province-3", "label=Alabama");
462 $this->waitForElementPresent("_qf_Main_upload-bottom");
463 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
465 $this->click("_qf_Confirm_next-bottom");
466 $this->waitForPageToLoad($this->getTimeoutMsec());
475 public function _testAnomoyousOrganization($pageId, $orgName, $pageTitle) {
476 $this->webtestLogout();
477 //Open Live Contribution Page
478 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom");
480 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
481 $lastName = 'An' . substr(sha1(rand()), 0, 7);
482 $this->type("email-5", $firstName . "@example.com");
484 $this->click('CIVICRM_QFID_0_12');
485 $this->type('css=div.other_amount-section input', 60);
487 // enable onbehalforganization block
488 $this->click("is_for_organization");
489 $this->waitForElementPresent("onbehalf_state_province-3");
491 // onbehalforganization info
492 $this->type("onbehalf_organization_name", $orgName['name']);
493 $this->type("onbehalf_phone-3-1", 9999999999);
494 $this->type("onbehalf_email-3", $orgName['email']);
495 $this->type("onbehalf_street_address-3", "Test Street Address");
496 $this->type("onbehalf_city-3", "Test City");
497 $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
498 $this->click("onbehalf_country-3");
499 $this->select("onbehalf_country-3", "label=UNITED STATES");
500 $this->click("onbehalf_state_province-3");
501 $this->select("onbehalf_state_province-3", "label=Alabama");
504 $this->select("credit_card_type", "value=Visa");
505 $this->type("credit_card_number", "4111111111111111");
506 $this->type("cvv2", "000");
507 $this->select("credit_card_exp_date[M]", "value=1");
508 $this->select("credit_card_exp_date[Y]", "value=2020");
511 $this->type("billing_first_name", $firstName . 'billing');
512 $this->type("billing_last_name", $lastName . 'billing');
513 $this->type("billing_street_address-5", "0121 Mount Highschool.");
514 $this->type(" billing_city-5", "Shangai");
515 $this->select("billing_country_id-5", "value=1228");
516 $this->select("billing_state_province_id-5", "value=1004");
517 $this->type("billing_postal_code-5", "94129");
518 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
520 $this->click("_qf_Confirm_next-bottom");
521 $this->waitForPageToLoad($this->getTimeoutMsec());
523 // Log in using webtestLogin() method
524 $this->webtestLogin();
526 // TODO: webtestVerifyTabularData function is causing timeout error, reason why most of the Webtests are failing
527 // where its been called to assert tabular data
530 $this->openCiviPage("contribute/search", "reset=1");
531 $this->type("sort_name", $orgName['name']);
532 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
533 //$this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom");
535 // verify contrb created
537 'From' => $orgName['name'],
538 'Financial Type' => 'Donation',
539 'Online Contribution Page' => $pageTitle,
541 $this->webtestVerifyTabularData($expected);
550 public function _testUserWithOneRelationship($pageId, $cid, $pageTitle) {
551 $this->webtestLogin('admin');
554 $groupName = $this->WebtestAddGroup();
555 $this->openCiviPage("group", "reset=1", "_qf_Search_refresh");
556 $groupId = $this->getText("xpath=//table[@id='crm-group-selector']/tbody//tr/td[text()='{$groupName}']/../td[2]");
558 $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
560 $this->click('link=Edit');
561 $this->waitForElementPresent('_qf_Contact_cancel-bottom');
562 $this->click('addressBlock');
563 $this->waitForElementPresent('link=Another Address');
566 $this->select('address_1_location_type_id', 'label=Billing');
567 $this->type('address_1_street_address', '0121 Mount Highschool.');
568 $this->type('address_1_city', "Shangai");
569 $this->type('address_1_postal_code', "94129");
570 $this->select('address_1_country_id', "value=1228");
571 $this->select('address_1_state_province_id', "value=1004");
572 $this->click('_qf_Contact_upload_view-bottom');
573 $this->waitForPageToLoad($this->getTimeoutMsec());
575 // add contact to group
577 $this->click("css=li#tab_group a");
578 $this->waitForElementPresent("group_id");
581 $this->select("group_id", "label={$groupName}");
582 $this->click("_qf_GroupContact_next");
583 $this->waitForPageToLoad($this->getTimeoutMsec());
585 $this->openCiviPage("admin/custom/group", "action=add&reset=1", "_qf_Group_next-bottom");
587 // fill in a unique title for the custom group
588 $groupTitle = "Custom Group" . substr(sha1(rand()), 0, 7);
589 $this->type("title", $groupTitle);
591 // select the group this custom data set extends
592 $this->select("extends[0]", "value=Contribution");
593 $this->waitForElementPresent("extends[1]");
595 // save the custom group
596 $this->click("_qf_Group_next-bottom");
597 $this->waitForElementPresent("_qf_Field_next_new-bottom");
598 $this->assertTrue($this->isTextPresent("Your custom field set '$groupTitle' has been added. You can add custom fields now."));
600 // add a custom field to the custom group
601 $fieldTitle = "Custom Field " . substr(sha1(rand()), 0, 7);
602 $this->type("label", $fieldTitle);
604 $this->select("data_type[1]", "value=Text");
605 $this->click('_qf_Field_next-bottom');
607 $this->waitForPageToLoad($this->getTimeoutMsec());
608 $this->assertTrue($this->isTextPresent("Custom field '$fieldTitle' has been saved."));
609 $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"));
611 // Enable CiviCampaign module if necessary
612 $this->enableComponents("CiviCampaign");
614 // add the required permission
615 $permission = array('edit-2-administer-civicampaign');
616 $this->changePermissions($permission);
618 // Log in as normal user
619 $this->webtestLogin();
621 $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom");
623 $title = 'Campaign ' . substr(sha1(rand()), 0, 7);
624 $this->type("title", $title);
626 // select the campaign type
627 $this->select("campaign_type_id", "value=2");
629 // fill in the description
630 $this->type("description", "This is a test campaign");
632 // include groups for the campaign
633 $this->addSelection("includeGroups-f", "label={$groupName}");
634 $this->click("//option[@value={$groupId}]");
637 // fill the end date for campaign
638 $this->webtestFillDate("end_date", "+1 year");
640 // select campaign status
641 $this->select("status_id", "value=2");
644 $this->click("_qf_Campaign_upload-bottom");
645 $this->waitForElementPresent("xpath=//div[@id='campaigns_wrapper']//table[@id='campaigns']/tbody//tr/td[3][text()='{$title}']");
646 $this->assertTrue($this->isTextPresent("Campaign {$title} has been saved."), "Status message didn't show up after saving!");
648 $this->openCiviPage("admin/uf/group", "reset=1");
649 $this->click("link=Reserved Profiles");
651 $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']");
652 $this->waitForPageToLoad($this->getTimeoutMsec());
654 $this->click("link=Add Field");
655 $this->waitForElementPresent('_qf_Field_next-bottom');
656 $this->select('field_name[0]', 'value=Contribution');
657 $this->select('field_name[1]', 'label=Campaign');
658 $this->click('field_name[1]');
659 $this->click('_qf_Field_next_new-bottom');
660 $this->waitForPageToLoad($this->getTimeoutMsec());
662 $this->select('field_name[0]', 'value=Contribution');
663 $this->select('field_name[1]', "label=$fieldTitle :: $groupTitle");
664 $this->click('field_name[1]');
665 $this->click('_qf_Field_next-bottom');
666 $this->waitForPageToLoad($this->getTimeoutMsec());
667 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$fieldTitle}' has been saved to 'On Behalf Of Organization'."));
669 // Open Page to create Organization
670 $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom");
671 $orgName1 = 'org1_' . substr(sha1(rand()), 0, 7);
673 // Type Organization name
674 $this->type("organization_name", $orgName1);
676 // Type Organizatio email for main
677 $this->type("email_1_email", "{$orgName1}@example.com");
678 $this->select("email_1_location_type_id", "value=3");
680 // type phone no for main
681 $this->type("phone_1_phone", 9999999999);
682 $this->select("phone_1_location_type_id", "value=3");
685 $this->click("addressBlock");
686 $this->waitForElementPresent("address_1_street_address");
688 //fill in address 1 for main
689 $this->select("address_1_location_type_id", "value=3");
690 $this->type("address_1_street_address", "{$orgName1} street address");
691 $this->type("address_1_city", "{$orgName1} city");
692 $this->type("address_1_postal_code", substr(sha1(rand()), 0, 4));
693 $this->assertTrue($this->isTextPresent("- select - UNITED STATES"));
694 $this->select("address_1_state_province_id", "value=1019");
695 $this->type("address_1_geo_code_1", "1234");
696 $this->type("address_1_geo_code_2", "5678");
698 // Save the Organization
699 $this->click("_qf_Contact_upload_view-bottom");
700 $this->waitForPageToLoad($this->getTimeoutMsec());
703 $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1");
705 // select relationship type
706 $this->click("relationship_type_id");
707 $this->select("relationship_type_id", "value=4_a_b");
709 // search organization
710 $this->type('contact_1', $orgName1);
711 $this->click("contact_1");
712 $this->waitForElementPresent("css=div.ac_results-inner li");
713 $this->click("css=div.ac_results-inner li");
714 $this->assertContains($orgName1, $this->getValue('contact_1'), "autocomplete expected $orgName1 but didn’t find it in " . $this->getValue('contact_1'));
716 $this->waitForElementPresent("add_current_employer");
717 $this->click("add_current_employer");
720 $this->click("is_permission_a_b");
721 $this->click("is_permission_b_a");
724 $this->waitForElementPresent("details-save");
725 $this->click("details-save");
727 //Open Live Contribution Page
728 $this->openCiviPage("contribute/transact", "reset=1&id={$pageId}&cid=$cid", "onbehalf_state_province-3");
729 $this->click('CIVICRM_QFID_amount_other_radio_4');
730 $this->type('amount_other', 60);
731 $this->click('onbehalf_contribution_campaign_id');
732 $this->select('onbehalf_contribution_campaign_id', "label={$title}");
733 $this->type("onbehalf_custom_{$fieldId}", 'Test Subject');
736 $this->select("credit_card_type", "value=Visa");
737 $this->type("credit_card_number", "4111111111111111");
738 $this->type("cvv2", "000");
739 $this->select("credit_card_exp_date[M]", "value=1");
740 $this->select("credit_card_exp_date[Y]", "value=2020");
743 $this->type("billing_street_address-5", "0121 Mount Highschool.");
744 $this->type(" billing_city-5", "Shangai");
745 $this->select("billing_country_id-5", "value=1228");
746 $this->select("billing_state_province_id-5", "value=1004");
747 $this->type("billing_postal_code-5", "94129");
749 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
750 $this->click("_qf_Confirm_next-bottom");
751 $this->waitForPageToLoad($this->getTimeoutMsec());
754 $this->openCiviPage("contribute/search", "reset=1");
755 $this->type("sort_name", $orgName1);
756 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
757 $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom");
759 // verify contrb created
766 foreach ($expected as $value => $label) {
767 $this->verifyText("xpath=id( 'ContributionView' )/div[2]/table[1]/tbody/tr[$value]/td[2]", preg_quote($label));
770 $this->openCiviPage("admin/uf/group", "reset=1");
771 $this->click("link=Reserved Profiles");
773 $this->click("xpath=//div[@id='reserved-profiles']/div/div/table/tbody//tr/td[1][text()='On Behalf Of Organization']/../td[5]/span/a[text()='Fields']");
774 $this->waitForPageToLoad($this->getTimeoutMsec());
776 $this->click("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']");
777 $this->waitForElementPresent('_qf_Field_next-bottom');
779 $this->click('_qf_Field_next-bottom');
780 $this->waitForPageToLoad($this->getTimeoutMsec());
781 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'), "Status message didn't show up after saving!");
783 $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']");
784 $this->waitForElementPresent('_qf_Field_next-bottom');
786 $this->click('_qf_Field_next-bottom');
787 $this->waitForPageToLoad($this->getTimeoutMsec());
788 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'), "Status message didn't show up after saving!");
796 public function _testUserWithMoreThanOneRelationship($pageId, $cid, $pageTitle) {
797 $this->webtestLogin('admin');
798 $this->waitForPageToLoad($this->getTimeoutMsec());
801 $groupName = $this->WebtestAddGroup();
802 $this->openCiviPage("group", "reset=1", '_qf_Search_refresh');
803 $this->click('_qf_Search_refresh');
804 $this->waitForElementPresent("xpath=//div[@id='group']/div[3]/table/tbody//tr/td[text()='{$groupName}']/../td[2]");
805 $groupId = $this->getText("xpath=//div[@id='group']/div[3]/table/tbody//tr/td[text()='{$groupName}']/../td[2]");
807 $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
809 $this->click('link=Edit');
810 $this->waitForElementPresent('_qf_Contact_cancel-bottom');
811 $this->click('addressBlock');
812 $this->waitForElementPresent('link=Another Address');
815 $this->select('address_1_location_type_id', 'label=Billing');
816 $this->type('address_1_street_address', '0121 Mount Highschool.');
817 $this->type('address_1_city', "Shangai");
818 $this->type('address_1_postal_code', "94129");
819 $this->select('address_1_country_id', "value=1228");
820 $this->select('address_1_state_province_id', "value=1004");
821 $this->click('_qf_Contact_upload_view-bottom');
822 $this->waitForPageToLoad($this->getTimeoutMsec());
824 // add contact to group
826 $this->click("css=li#tab_group a");
827 $this->waitForElementPresent("group_id");
830 $this->select("group_id", "label=$groupName");
831 $this->click("_qf_GroupContact_next");
832 $this->waitForPageToLoad($this->getTimeoutMsec());
834 $this->openCiviPage("admin/custom/group", "action=add&reset=1", "_qf_Group_next-bottom");
836 // fill in a unique title for the c$groupIdustom group
837 $groupTitle = "Members Custom Group" . substr(sha1(rand()), 0, 7);
838 $this->type("title", $groupTitle);
840 // select the group this custom data set extends
841 $this->select("extends[0]", "value=Membership");
842 $this->waitForElementPresent("extends[1]");
844 // save the custom group
845 $this->click("_qf_Group_next-bottom");
847 $this->waitForElementPresent("_qf_Field_next_new-bottom");
848 $this->assertTrue($this->isTextPresent("Your custom field set '$groupTitle' has been added. You can add custom fields now."));
850 // add a custom field to the custom group
851 $fieldTitle = "Member Custom Field " . substr(sha1(rand()), 0, 7);
852 $this->type("label", $fieldTitle);
854 $this->select("data_type[1]", "value=Text");
855 $this->click('_qf_Field_next-bottom');
857 $this->waitForPageToLoad($this->getTimeoutMsec());
858 $this->assertTrue($this->isTextPresent("Custom field '$fieldTitle' has been saved."));
859 $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"));
861 // Enable CiviCampaign module if necessary
862 $this->enableComponents("CiviCampaign");
864 // add the required permission
865 $permission = array('edit-2-administer-civicampaign');
866 $this->changePermissions($permission);
868 // Log in as normal user
869 $this->webtestLogin();
871 $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom");
873 $title = 'Campaign ' . substr(sha1(rand()), 0, 7);
874 $this->type("title", $title);
876 // select the campaign type
877 $this->select("campaign_type_id", "value=2");
879 // fill in the description
880 $this->type("description", "This is a test campaign");
882 // include groups for the campaign
883 $this->addSelection("includeGroups-f", "label={$groupName}");
884 $this->click("//option[@value={$groupId}]");
887 // fill the end date for campaign
888 $this->webtestFillDate("end_date", "+1 year");
890 // select campaign status
891 $this->select("status_id", "value=2");
894 $this->click("_qf_Campaign_upload-bottom");
895 $this->waitForPageToLoad($this->getTimeoutMsec());
897 $this->assertTrue($this->isTextPresent("Campaign {$title} has been saved."), "Status message didn't show up after saving!");
899 $this->openCiviPage("admin/uf/group", "reset=1");
900 $this->click("link=Reserved Profiles");
901 $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']");
902 $this->waitForPageToLoad($this->getTimeoutMsec());
904 $this->click("link=Add Field");
905 $this->waitForElementPresent('_qf_Field_next-bottom');
906 $this->select('field_name[0]', 'value=Membership');
907 $this->select('field_name[1]', 'label=Campaign');
908 $this->click('field_name[1]');
909 $this->clickLink('_qf_Field_next_new-bottom', '_qf_Field_cancel-bottom');
911 $this->select('field_name[0]', 'value=Membership');
912 $this->select('field_name[1]', "label=$fieldTitle :: $groupTitle");
913 $this->click('field_name[1]');
914 $this->click('_qf_Field_next-bottom');
915 $this->waitForPageToLoad($this->getTimeoutMsec());
916 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$fieldTitle}' has been saved to 'On Behalf Of Organization'."),
917 "Status message didn't show up after saving!"
920 // Open Page to create Organization 1
921 $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom");
922 $orgName1 = 'org1_' . substr(sha1(rand()), 0, 7);
924 // Type Organization name
925 $this->type("organization_name", $orgName1);
927 // Type Organizatio email for main
928 $this->type("email_1_email", "{$orgName1}@example.com");
929 $this->select("email_1_location_type_id", "value=3");
931 // type phone no for main
932 $this->type("phone_1_phone", substr(sha1(rand()), 0, 4));
933 $this->select("phone_1_location_type_id", "value=3");
936 $this->click("addressBlock");
937 $this->waitForElementPresent("address_1_street_address");
939 //fill in address 1 for main
940 $this->select("address_1_location_type_id", "value=3");
941 $this->type("address_1_street_address", "{$orgName1} street address");
942 $this->type("address_1_city", "{$orgName1} city");
943 $this->type("address_1_postal_code", "9999999999");
944 $this->assertTrue($this->isTextPresent("- select - UNITED STATES"));
945 $this->select("address_1_state_province_id", "value=1019");
946 $this->type("address_1_geo_code_1", "1234");
947 $this->type("address_1_geo_code_2", "5678");
949 // Save the Organization
950 $this->click("_qf_Contact_upload_view-bottom");
951 $this->waitForPageToLoad($this->getTimeoutMsec());
953 // create second orzanization
954 $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom");
955 $orgName2 = 'org2_' . substr(sha1(rand()), 0, 7);
957 // Type Organization name
958 $this->type("organization_name", $orgName2);
960 // Type Organizatio email for main
961 $this->type("email_1_email", "{$orgName2}@example.com");
962 $this->select("email_1_location_type_id", "value=3");
964 // type phone no for main
965 $this->type("phone_1_phone", substr(sha1(rand()), 0, 4));
966 $this->select("phone_1_location_type_id", "value=3");
969 $this->click("addressBlock");
970 $this->waitForElementPresent("address_1_street_address");
972 //fill in address 1 for main
973 $this->select("address_1_location_type_id", "value=3");
974 $this->type("address_1_street_address", "{$orgName2} street address");
975 $this->type("address_1_city", "{$orgName2} city");
976 $this->type("address_1_postal_code", "7777777777");
977 $this->assertTrue($this->isTextPresent("- select - UNITED STATES"));
978 $this->select("address_1_state_province_id", "value=1019");
979 $this->type("address_1_geo_code_1", "1224");
980 $this->type("address_1_geo_code_2", "5628");
982 // Save the Organization
983 $this->click("_qf_Contact_upload_view-bottom");
984 $this->waitForPageToLoad($this->getTimeoutMsec());
986 // create Membership type
987 $title1 = "Membership Type" . substr(sha1(rand()), 0, 7);
988 $this->openCiviPage("admin/member/membershipType", "reset=1&action=browse");
990 $this->click("link=Add Membership Type");
991 $this->waitForElementPresent('_qf_MembershipType_cancel-bottom');
993 $this->type('name', $title1);
994 $this->type('member_org', $orgName1);
995 $this->click('_qf_MembershipType_refresh');
996 $this->waitForElementPresent("xpath=//div[@id='membership_type_form']/fieldset/table[2]/tbody/tr[2]/td[2]");
998 $this->type('minimum_fee', '50');
1000 $this->select('financial_type_id', 'value=2');
1002 $this->type('duration_interval', 1);
1003 $this->select('duration_unit', "label=year");
1005 $this->select('period_type', "label=fixed");
1006 $this->waitForElementPresent('fixed_period_rollover_day[d]');
1008 $this->select('fixed_period_start_day[M]', 'value=4');
1009 $this->select('fixed_period_rollover_day[M]', 'value=1');
1011 $this->select('relationship_type_id', 'value=4_b_a');
1013 $this->click('_qf_MembershipType_upload-bottom');
1014 $this->waitForElementPresent('link=Add Membership Type');
1015 $this->assertTrue($this->isTextPresent("The membership type '$title1' has been saved."));
1016 $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"));
1019 $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1");
1021 // select relationship type
1022 $this->click("relationship_type_id");
1023 $this->select("relationship_type_id", "value=4_a_b");
1025 // search organization
1026 $this->type('contact_1', $orgName1);
1027 $this->click("contact_1");
1028 $this->waitForElementPresent("css=div.ac_results-inner li");
1029 $this->click("css=div.ac_results-inner li");
1030 $this->assertContains($orgName1, $this->getValue('contact_1'), "autocomplete expected $orgName1 but didn’t find it in " . $this->getValue('contact_1'));
1033 $this->click("is_permission_a_b");
1034 $this->click("is_permission_b_a");
1036 // save relationship
1037 $this->click("details-save");
1040 $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1");
1042 // select relationship type
1043 $this->click("relationship_type_id");
1044 $this->select("relationship_type_id", "value=4_a_b");
1046 // search organization
1047 $this->type('contact_1', $orgName2);
1048 $this->click("contact_1");
1049 $this->waitForElementPresent("css=div.ac_results-inner li");
1050 $this->click("css=div.ac_results-inner li");
1051 $this->assertContains($orgName2, $this->getValue('contact_1'), "autocomplete expected $orgName2 but didn’t find it in " . $this->getValue('contact_1'));
1054 $this->click("is_permission_a_b");
1055 $this->click("is_permission_b_a");
1057 // save relationship
1058 $this->click("details-save");
1060 // set membership type
1061 $this->openCiviPage("admin/contribute/membership", "reset=1&action=update&id=$pageId", "_qf_MembershipBlock_upload_done-bottom");
1062 $this->click("member_is_active");
1063 $this->click("membership_type[{$typeId}]");
1064 $this->click("xpath=//div[@id='memberFields']//table[@class='report']/tbody//tr/td[1]/label[text()='{$title1}']/../../td[2]/input");
1065 $this->click('_qf_MembershipBlock_upload_done-bottom');
1066 $this->waitForPageToLoad($this->getTimeoutMsec());
1068 //Open Live Membership Page
1069 $this->openCiviPage('contribute/transact', "reset=1&id=$pageId&cid=$cid", "_qf_Main_upload-bottom");
1070 $this->click('CIVICRM_QFID_amount_other_radio_4');
1071 $this->type('amount_other', 60);
1072 $this->click('onbehalf_organization_name');
1073 $this->type('onbehalf_organization_name', $orgName1);
1074 $this->typeKeys('onbehalf_organization_name', $orgName1);
1075 $this->click("onbehalf_organization_name");
1076 $this->waitForElementPresent("css=div.ac_results-inner li");
1077 $this->click("css=div.ac_results-inner li");
1078 // Because it tends to cause problems, all uses of sleep() must be justified in comments
1079 // Sleep should never be used for wait for anything to load from the server
1080 // Justification for this instance: FIXME
1082 $this->click('onbehalf_member_campaign_id');
1083 $this->select('onbehalf_member_campaign_id', "label={$title}");
1084 $this->type("onbehalf_custom_{$fieldId}", 'Test Subject');
1086 $this->assertContains($orgName1, $this->getValue('onbehalf_organization_name'), "autocomplete expected $orgName1 but didn’t find it in " . $this->getValue('onbehalf_organization_name'));
1089 $this->select("credit_card_type", "value=Visa");
1090 $this->type("credit_card_number", "4111111111111111");
1091 $this->type("cvv2", "000");
1092 $this->select("credit_card_exp_date[M]", "value=1");
1093 $this->select("credit_card_exp_date[Y]", "value=2020");
1095 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
1096 $this->click("_qf_Confirm_next-bottom");
1097 $this->waitForPageToLoad($this->getTimeoutMsec());
1099 //Find Membership for organization
1100 $this->openCiviPage("member/search", "reset=1");
1101 $this->type("sort_name", $orgName1);
1102 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='memberSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
1103 $this->clickLink("xpath=//div[@id='memberSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_MembershipView_cancel-bottom");
1105 //verify contrb created
1111 foreach ($expected as $value => $label) {
1112 $this->verifyText("xpath=//form[@id='MembershipView']/div[2]/div/table/tbody/tr[$value]/td[2]", preg_quote($label));
1115 // find membership for contact in relationship
1116 $this->openCiviPage("contact/view", "reset=1&force=1&cid={$cid}");
1117 $this->click("css=li#tab_member a");
1118 $this->waitForElementPresent("xpath=//div[@id='memberships']/div/table//tbody//tr/td[1][text()='{$title1}']");
1119 $this->click("xpath=//div[@id='memberships']/div/table//tbody//tr/td[1][text()='{$title1}']/../td[7]/span/a[text()='View']");
1120 $this->waitForPageToLoad($this->getTimeoutMsec());
1122 //verify contrb created
1127 foreach ($expected as $value => $label) {
1128 $this->verifyText("xpath=//form[@id='MembershipView']/div[2]/div/table/tbody/tr[$value]/td[2]", preg_quote($label));
1131 $this->openCiviPage("admin/uf/group", "reset=1");
1132 $this->click("link=Reserved Profiles");
1133 $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']");
1134 $this->waitForPageToLoad($this->getTimeoutMsec());
1136 $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']");
1137 $this->waitForElementPresent('_qf_Field_next-bottom');
1139 $this->click('_qf_Field_next-bottom');
1140 $this->waitForPageToLoad($this->getTimeoutMsec());
1141 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'),
1142 "Status message didn't show up after saving!"
1145 $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']");
1146 $this->waitForElementPresent('_qf_Field_next-bottom');
1148 $this->click('_qf_Field_next-bottom');
1149 $this->waitForPageToLoad($this->getTimeoutMsec());
1150 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'),
1151 "Status message didn't show up after saving!"
1154 $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
1155 $this->click("css=li#tab_rel a");
1157 $this->waitForElementPresent("xpath=//div[@id='current-relationships']/div/table/tbody//tr/td[2]/a[text()='{$orgName1}']");
1158 $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']");
1160 // Check confirmation alert.
1161 $this->assertTrue((bool) preg_match("/^Are you sure you want to delete this relationship?/",
1162 $this->getConfirmation()
1164 $this->chooseOkOnNextConfirmation();
1165 $this->waitForPageToLoad($this->getTimeoutMsec());
1166 $this->assertTrue($this->isTextPresent('Selected relationship has been deleted successfully.'),
1167 "Status message didn't show up after saving!"
1171 public function testOnBehalfOfOrganizationWithImage() {
1172 $this->webtestLogin();
1174 $this->openCiviPage("profile/edit", "reset=1&gid=4");
1175 $firstName = 'John_x_' . substr(sha1(rand()), 0, 7);
1176 $lastName = 'Anderson_c_' . substr(sha1(rand()), 0, 7);
1178 $this->waitForPageToLoad($this->getTimeoutMsec());
1179 $this->waitForElementPresent("_qf_Edit_next");
1180 $this->type("first_name", $firstName);
1181 $this->type("last_name", $lastName);
1182 $this->clickLink("_qf_Edit_next", "profilewrap4");
1184 $cid = $this->urlArg('id');
1185 $this->assertType('numeric', $cid);
1186 // Is status message correct?
1187 $this->assertTextPresent("Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!");
1189 $this->openCiviPage("admin/uf/group", "reset=1");
1190 $this->click("link=Reserved Profiles");
1192 $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']");
1193 $this->waitForPageToLoad($this->getTimeoutMsec());
1195 $this->click("link=Add Field");
1196 $this->waitForElementPresent('_qf_Field_next-bottom');
1198 $this->select('field_name[0]', 'value=Contact');
1199 $this->select('field_name[1]', 'label=Image Url');
1200 $this->click('field_name[1]');
1201 $this->click('_qf_Field_next-bottom');
1202 $this->waitForPageToLoad($this->getTimeoutMsec());
1204 // Use default payment processor
1205 $processorName = 'Test Processor';
1206 $processorType = 'Dummy';
1207 $pageTitle = substr(sha1(rand()), 0, 7);
1209 $hash = substr(sha1(rand()), 0, 7);
1210 $amountSection = TRUE;
1215 $memberships = FALSE;
1216 $memPriceSetId = NULL;
1218 $profilePreId = NULL;
1219 $profilePostId = NULL;
1223 $honoreeSection = FALSE;
1224 $isAddPaymentProcessor = TRUE;
1225 $isPcpApprovalNeeded = FALSE;
1226 $isSeparatePayment = FALSE;
1228 // create a new online contribution page
1229 // create contribution page with randomized title and default params
1230 $pageId = $this->webtestAddContributionPage($hash,
1233 array($processorName => $processorType),
1247 $isAddPaymentProcessor,
1248 $isPcpApprovalNeeded,
1253 $this->_testOrganizationWithImageUpload($pageId, $cid, $pageTitle);
1255 $this->openCiviPage("admin/uf/group", "reset=1");
1256 $this->click("link=Reserved Profiles");
1258 $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']");
1259 $this->waitForPageToLoad($this->getTimeoutMsec());
1260 $this->click("xpath=//table[@id='option11']/tbody//tr/td/span[text()='Image Url']/../following-sibling::td[8]/span[2]/ul/li[2]/a");
1261 $this->waitForPageToLoad($this->getTimeoutMsec());
1262 $this->click('_qf_Field_next-bottom');
1263 $this->waitForPageToLoad($this->getTimeoutMsec());
1264 $this->waitForText('crm-notification-container', "Selected Profile Field has been deleted.");
1268 * @param int $pageId
1272 public function _testOrganizationWithImageUpload($pageId, $cid, $pageTitle) {
1273 //Open Live Contribution Page
1274 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", '_qf_Main_upload-bottom');
1276 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
1277 $lastName = 'An' . substr(sha1(rand()), 0, 7);
1278 $orgName = 'org_11_' . substr(sha1(rand()), 0, 7);
1279 $this->type("email-5", $firstName . "@example.com");
1281 // onbehalforganization info
1282 $this->type("onbehalf_organization_name", $orgName);
1283 $this->type("onbehalf_phone-3-1", 9999999999);
1284 $this->type("onbehalf_email-3", "{$orgName}@example.com");
1285 $this->type("onbehalf_street_address-3", "Test Street Address");
1286 $this->type("onbehalf_city-3", "Test City");
1287 $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
1288 $this->click("onbehalf_country-3");
1289 $this->select("onbehalf_country-3", "label=UNITED STATES");
1290 $this->click("onbehalf_state_province-3");
1291 $this->select("onbehalf_state_province-3", "label=Alabama");
1293 // check for upload field.
1294 $this->waitForElementPresent("onbehalf_image_URL");
1296 //header("Content-Type: image/png");
1297 $im = imagecreate(110, 20)
1298 or die("Cannot Initialize new GD image stream");
1299 $background_color = imagecolorallocate($im, 0, 0, 0);
1300 $text_color = imagecolorallocate($im, 233, 14, 91);
1301 imagestring($im, 1, 5, 5, "On Behalf-Org Logo", $text_color);
1302 imagepng($im, "/tmp/file.png");
1304 $imagePath = "/tmp/file.png";
1305 $this->webtestAttachFile('onbehalf_image_URL', $imagePath);
1309 $this->select("credit_card_type", "value=Visa");
1310 $this->type("credit_card_number", "4111111111111111");
1311 $this->type("cvv2", "000");
1312 $this->select("credit_card_exp_date[M]", "value=1");
1313 $this->select("credit_card_exp_date[Y]", "value=2020");
1316 $this->type("billing_first_name", $firstName . 'billing');
1317 $this->type("billing_last_name", $lastName . 'billing');
1318 $this->type("billing_street_address-5", "0121 Mount Highschool.");
1319 $this->type(" billing_city-5", "Shangai");
1320 $this->select("billing_country_id-5", "value=1228");
1321 $this->select("billing_state_province_id-5", "value=1004");
1322 $this->type("billing_postal_code-5", "94129");
1323 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
1325 $this->click("_qf_Confirm_next-bottom");
1326 $this->waitForPageToLoad($this->getTimeoutMsec());
1328 // Type search name in autocomplete.
1329 $this->click('sort_name_navigation');
1330 $this->type('css=input#sort_name_navigation', $orgName);
1331 $this->typeKeys('css=input#sort_name_navigation', $orgName);
1333 // Wait for result list.
1334 $this->waitForElementPresent("css=div.ac_results-inner li");
1336 // Visit organization page.
1337 $this->click("css=div.ac_results-inner li");
1338 $this->waitForPageToLoad($this->getTimeoutMsec());
1340 //check whether the image is present
1341 $this->assertTrue($this->isElementPresent("xpath=//div[@id='crm-contact-thumbnail']/div/a/img"));