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());
472 * @param int $orgName
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
531 $this->openCiviPage("contribute/search", "reset=1");
532 $this->type("sort_name", $orgName['name']);
533 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
534 $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom");
536 // verify contrb created
538 'From' => $orgName['name'],
539 'Financial Type' => 'Donation',
540 'Online Contribution Page' => $pageTitle,
542 $this->webtestVerifyTabularData($expected);
551 public function _testUserWithOneRelationship($pageId, $cid, $pageTitle) {
552 $this->webtestLogin('admin');
555 $groupName = $this->WebtestAddGroup();
556 $this->openCiviPage("group", "reset=1", "_qf_Search_refresh");
557 $groupId = $this->getText("xpath=//table[@id='crm-group-selector']/tbody//tr/td[text()='{$groupName}']/../td[2]");
559 $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
561 $this->click('link=Edit');
562 $this->waitForElementPresent('_qf_Contact_cancel-bottom');
563 $this->click('addressBlock');
564 $this->waitForElementPresent('link=Another Address');
567 $this->select('address_1_location_type_id', 'label=Billing');
568 $this->type('address_1_street_address', '0121 Mount Highschool.');
569 $this->type('address_1_city', "Shangai");
570 $this->type('address_1_postal_code', "94129");
571 $this->select('address_1_country_id', "value=1228");
572 $this->select('address_1_state_province_id', "value=1004");
573 $this->click('_qf_Contact_upload_view-bottom');
574 $this->waitForPageToLoad($this->getTimeoutMsec());
576 // add contact to group
578 $this->click("css=li#tab_group a");
579 $this->waitForElementPresent("group_id");
582 $this->select("group_id", "label={$groupName}");
583 $this->click("_qf_GroupContact_next");
584 $this->waitForPageToLoad($this->getTimeoutMsec());
586 $this->openCiviPage("admin/custom/group", "action=add&reset=1", "_qf_Group_next-bottom");
588 // fill in a unique title for the custom group
589 $groupTitle = "Custom Group" . substr(sha1(rand()), 0, 7);
590 $this->type("title", $groupTitle);
592 // select the group this custom data set extends
593 $this->select("extends[0]", "value=Contribution");
594 $this->waitForElementPresent("extends[1]");
596 // save the custom group
597 $this->click("_qf_Group_next-bottom");
598 $this->waitForElementPresent("_qf_Field_next_new-bottom");
599 $this->assertTrue($this->isTextPresent("Your custom field set '$groupTitle' has been added. You can add custom fields now."));
601 // add a custom field to the custom group
602 $fieldTitle = "Custom Field " . substr(sha1(rand()), 0, 7);
603 $this->type("label", $fieldTitle);
605 $this->select("data_type[1]", "value=Text");
606 $this->click('_qf_Field_next-bottom');
608 $this->waitForPageToLoad($this->getTimeoutMsec());
609 $this->assertTrue($this->isTextPresent("Custom field '$fieldTitle' has been saved."));
610 $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"));
612 // Enable CiviCampaign module if necessary
613 $this->enableComponents("CiviCampaign");
615 // add the required permission
616 $permission = array('edit-2-administer-civicampaign');
617 $this->changePermissions($permission);
619 // Log in as normal user
620 $this->webtestLogin();
622 $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom");
624 $title = 'Campaign ' . substr(sha1(rand()), 0, 7);
625 $this->type("title", $title);
627 // select the campaign type
628 $this->select("campaign_type_id", "value=2");
630 // fill in the description
631 $this->type("description", "This is a test campaign");
633 // include groups for the campaign
634 $this->addSelection("includeGroups-f", "label={$groupName}");
635 $this->click("//option[@value={$groupId}]");
638 // fill the end date for campaign
639 $this->webtestFillDate("end_date", "+1 year");
641 // select campaign status
642 $this->select("status_id", "value=2");
645 $this->click("_qf_Campaign_upload-bottom");
646 $this->waitForElementPresent("xpath=//div[@id='campaigns_wrapper']//table[@id='campaigns']/tbody//tr/td[3][text()='{$title}']");
647 $this->assertTrue($this->isTextPresent("Campaign {$title} has been saved."), "Status message didn't show up after saving!");
649 $this->openCiviPage("admin/uf/group", "reset=1");
650 $this->click("link=Reserved Profiles");
652 $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']");
653 $this->waitForPageToLoad($this->getTimeoutMsec());
655 $this->click("link=Add Field");
656 $this->waitForElementPresent('_qf_Field_next-bottom');
657 $this->select('field_name[0]', 'value=Contribution');
658 $this->select('field_name[1]', 'label=Campaign');
659 $this->click('field_name[1]');
660 $this->click('_qf_Field_next_new-bottom');
661 $this->waitForPageToLoad($this->getTimeoutMsec());
663 $this->select('field_name[0]', 'value=Contribution');
664 $this->select('field_name[1]', "label=$fieldTitle :: $groupTitle");
665 $this->click('field_name[1]');
666 $this->click('_qf_Field_next-bottom');
667 $this->waitForPageToLoad($this->getTimeoutMsec());
668 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$fieldTitle}' has been saved to 'On Behalf Of Organization'."));
670 // Open Page to create Organization
671 $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom");
672 $orgName1 = 'org1_' . substr(sha1(rand()), 0, 7);
674 // Type Organization name
675 $this->type("organization_name", $orgName1);
677 // Type Organizatio email for main
678 $this->type("email_1_email", "{$orgName1}@example.com");
679 $this->select("email_1_location_type_id", "value=3");
681 // type phone no for main
682 $this->type("phone_1_phone", 9999999999);
683 $this->select("phone_1_location_type_id", "value=3");
686 $this->click("addressBlock");
687 $this->waitForElementPresent("address_1_street_address");
689 //fill in address 1 for main
690 $this->select("address_1_location_type_id", "value=3");
691 $this->type("address_1_street_address", "{$orgName1} street address");
692 $this->type("address_1_city", "{$orgName1} city");
693 $this->type("address_1_postal_code", substr(sha1(rand()), 0, 4));
694 $this->assertTrue($this->isTextPresent("- select - UNITED STATES"));
695 $this->select("address_1_state_province_id", "value=1019");
696 $this->type("address_1_geo_code_1", "1234");
697 $this->type("address_1_geo_code_2", "5678");
699 // Save the Organization
700 $this->click("_qf_Contact_upload_view-bottom");
701 $this->waitForPageToLoad($this->getTimeoutMsec());
704 $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1");
706 // select relationship type
707 $this->click("relationship_type_id");
708 $this->select("relationship_type_id", "value=4_a_b");
710 // search organization
711 $this->type('contact_1', $orgName1);
712 $this->click("contact_1");
713 $this->waitForElementPresent("css=div.ac_results-inner li");
714 $this->click("css=div.ac_results-inner li");
715 $this->assertContains($orgName1, $this->getValue('contact_1'), "autocomplete expected $orgName1 but didn’t find it in " . $this->getValue('contact_1'));
717 $this->waitForElementPresent("add_current_employer");
718 $this->click("add_current_employer");
721 $this->click("is_permission_a_b");
722 $this->click("is_permission_b_a");
725 $this->waitForElementPresent("details-save");
726 $this->click("details-save");
728 //Open Live Contribution Page
729 $this->openCiviPage("contribute/transact", "reset=1&id={$pageId}&cid=$cid", "onbehalf_state_province-3");
730 $this->click('CIVICRM_QFID_amount_other_radio_4');
731 $this->type('amount_other', 60);
732 $this->click('onbehalf_contribution_campaign_id');
733 $this->select('onbehalf_contribution_campaign_id', "label={$title}");
734 $this->type("onbehalf_custom_{$fieldId}", 'Test Subject');
737 $this->select("credit_card_type", "value=Visa");
738 $this->type("credit_card_number", "4111111111111111");
739 $this->type("cvv2", "000");
740 $this->select("credit_card_exp_date[M]", "value=1");
741 $this->select("credit_card_exp_date[Y]", "value=2020");
744 $this->type("billing_street_address-5", "0121 Mount Highschool.");
745 $this->type(" billing_city-5", "Shangai");
746 $this->select("billing_country_id-5", "value=1228");
747 $this->select("billing_state_province_id-5", "value=1004");
748 $this->type("billing_postal_code-5", "94129");
750 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
751 $this->click("_qf_Confirm_next-bottom");
752 $this->waitForPageToLoad($this->getTimeoutMsec());
755 $this->openCiviPage("contribute/search", "reset=1");
756 $this->type("sort_name", $orgName1);
757 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
758 $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom");
760 // verify contrb created
767 foreach ($expected as $value => $label) {
768 $this->verifyText("xpath=id( 'ContributionView' )/div[2]/table[1]/tbody/tr[$value]/td[2]", preg_quote($label));
771 $this->openCiviPage("admin/uf/group", "reset=1");
772 $this->click("link=Reserved Profiles");
774 $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']");
775 $this->waitForPageToLoad($this->getTimeoutMsec());
777 $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']");
778 $this->waitForElementPresent('_qf_Field_next-bottom');
780 $this->click('_qf_Field_next-bottom');
781 $this->waitForPageToLoad($this->getTimeoutMsec());
782 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'), "Status message didn't show up after saving!");
784 $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']");
785 $this->waitForElementPresent('_qf_Field_next-bottom');
787 $this->click('_qf_Field_next-bottom');
788 $this->waitForPageToLoad($this->getTimeoutMsec());
789 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'), "Status message didn't show up after saving!");
797 public function _testUserWithMoreThanOneRelationship($pageId, $cid, $pageTitle) {
798 $this->webtestLogin('admin');
799 $this->waitForPageToLoad($this->getTimeoutMsec());
802 $groupName = $this->WebtestAddGroup();
803 $this->openCiviPage("group", "reset=1", '_qf_Search_refresh');
804 $this->click('_qf_Search_refresh');
805 $this->waitForElementPresent("xpath=//div[@id='group']/div[3]/table/tbody//tr/td[text()='{$groupName}']/../td[2]");
806 $groupId = $this->getText("xpath=//div[@id='group']/div[3]/table/tbody//tr/td[text()='{$groupName}']/../td[2]");
808 $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
810 $this->click('link=Edit');
811 $this->waitForElementPresent('_qf_Contact_cancel-bottom');
812 $this->click('addressBlock');
813 $this->waitForElementPresent('link=Another Address');
816 $this->select('address_1_location_type_id', 'label=Billing');
817 $this->type('address_1_street_address', '0121 Mount Highschool.');
818 $this->type('address_1_city', "Shangai");
819 $this->type('address_1_postal_code', "94129");
820 $this->select('address_1_country_id', "value=1228");
821 $this->select('address_1_state_province_id', "value=1004");
822 $this->click('_qf_Contact_upload_view-bottom');
823 $this->waitForPageToLoad($this->getTimeoutMsec());
825 // add contact to group
827 $this->click("css=li#tab_group a");
828 $this->waitForElementPresent("group_id");
831 $this->select("group_id", "label=$groupName");
832 $this->click("_qf_GroupContact_next");
833 $this->waitForPageToLoad($this->getTimeoutMsec());
835 $this->openCiviPage("admin/custom/group", "action=add&reset=1", "_qf_Group_next-bottom");
837 // fill in a unique title for the c$groupIdustom group
838 $groupTitle = "Members Custom Group" . substr(sha1(rand()), 0, 7);
839 $this->type("title", $groupTitle);
841 // select the group this custom data set extends
842 $this->select("extends[0]", "value=Membership");
843 $this->waitForElementPresent("extends[1]");
845 // save the custom group
846 $this->click("_qf_Group_next-bottom");
848 $this->waitForElementPresent("_qf_Field_next_new-bottom");
849 $this->assertTrue($this->isTextPresent("Your custom field set '$groupTitle' has been added. You can add custom fields now."));
851 // add a custom field to the custom group
852 $fieldTitle = "Member Custom Field " . substr(sha1(rand()), 0, 7);
853 $this->type("label", $fieldTitle);
855 $this->select("data_type[1]", "value=Text");
856 $this->click('_qf_Field_next-bottom');
858 $this->waitForPageToLoad($this->getTimeoutMsec());
859 $this->assertTrue($this->isTextPresent("Custom field '$fieldTitle' has been saved."));
860 $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"));
862 // Enable CiviCampaign module if necessary
863 $this->enableComponents("CiviCampaign");
865 // add the required permission
866 $permission = array('edit-2-administer-civicampaign');
867 $this->changePermissions($permission);
869 // Log in as normal user
870 $this->webtestLogin();
872 $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom");
874 $title = 'Campaign ' . substr(sha1(rand()), 0, 7);
875 $this->type("title", $title);
877 // select the campaign type
878 $this->select("campaign_type_id", "value=2");
880 // fill in the description
881 $this->type("description", "This is a test campaign");
883 // include groups for the campaign
884 $this->addSelection("includeGroups-f", "label={$groupName}");
885 $this->click("//option[@value={$groupId}]");
888 // fill the end date for campaign
889 $this->webtestFillDate("end_date", "+1 year");
891 // select campaign status
892 $this->select("status_id", "value=2");
895 $this->click("_qf_Campaign_upload-bottom");
896 $this->waitForPageToLoad($this->getTimeoutMsec());
898 $this->assertTrue($this->isTextPresent("Campaign {$title} has been saved."), "Status message didn't show up after saving!");
900 $this->openCiviPage("admin/uf/group", "reset=1");
901 $this->click("link=Reserved Profiles");
902 $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']");
903 $this->waitForPageToLoad($this->getTimeoutMsec());
905 $this->click("link=Add Field");
906 $this->waitForElementPresent('_qf_Field_next-bottom');
907 $this->select('field_name[0]', 'value=Membership');
908 $this->select('field_name[1]', 'label=Campaign');
909 $this->click('field_name[1]');
910 $this->clickLink('_qf_Field_next_new-bottom', '_qf_Field_cancel-bottom');
912 $this->select('field_name[0]', 'value=Membership');
913 $this->select('field_name[1]', "label=$fieldTitle :: $groupTitle");
914 $this->click('field_name[1]');
915 $this->click('_qf_Field_next-bottom');
916 $this->waitForPageToLoad($this->getTimeoutMsec());
917 $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$fieldTitle}' has been saved to 'On Behalf Of Organization'."),
918 "Status message didn't show up after saving!"
921 // Open Page to create Organization 1
922 $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom");
923 $orgName1 = 'org1_' . substr(sha1(rand()), 0, 7);
925 // Type Organization name
926 $this->type("organization_name", $orgName1);
928 // Type Organizatio email for main
929 $this->type("email_1_email", "{$orgName1}@example.com");
930 $this->select("email_1_location_type_id", "value=3");
932 // type phone no for main
933 $this->type("phone_1_phone", substr(sha1(rand()), 0, 4));
934 $this->select("phone_1_location_type_id", "value=3");
937 $this->click("addressBlock");
938 $this->waitForElementPresent("address_1_street_address");
940 //fill in address 1 for main
941 $this->select("address_1_location_type_id", "value=3");
942 $this->type("address_1_street_address", "{$orgName1} street address");
943 $this->type("address_1_city", "{$orgName1} city");
944 $this->type("address_1_postal_code", "9999999999");
945 $this->assertTrue($this->isTextPresent("- select - UNITED STATES"));
946 $this->select("address_1_state_province_id", "value=1019");
947 $this->type("address_1_geo_code_1", "1234");
948 $this->type("address_1_geo_code_2", "5678");
950 // Save the Organization
951 $this->click("_qf_Contact_upload_view-bottom");
952 $this->waitForPageToLoad($this->getTimeoutMsec());
954 // create second orzanization
955 $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom");
956 $orgName2 = 'org2_' . substr(sha1(rand()), 0, 7);
958 // Type Organization name
959 $this->type("organization_name", $orgName2);
961 // Type Organizatio email for main
962 $this->type("email_1_email", "{$orgName2}@example.com");
963 $this->select("email_1_location_type_id", "value=3");
965 // type phone no for main
966 $this->type("phone_1_phone", substr(sha1(rand()), 0, 4));
967 $this->select("phone_1_location_type_id", "value=3");
970 $this->click("addressBlock");
971 $this->waitForElementPresent("address_1_street_address");
973 //fill in address 1 for main
974 $this->select("address_1_location_type_id", "value=3");
975 $this->type("address_1_street_address", "{$orgName2} street address");
976 $this->type("address_1_city", "{$orgName2} city");
977 $this->type("address_1_postal_code", "7777777777");
978 $this->assertTrue($this->isTextPresent("- select - UNITED STATES"));
979 $this->select("address_1_state_province_id", "value=1019");
980 $this->type("address_1_geo_code_1", "1224");
981 $this->type("address_1_geo_code_2", "5628");
983 // Save the Organization
984 $this->click("_qf_Contact_upload_view-bottom");
985 $this->waitForPageToLoad($this->getTimeoutMsec());
987 // create Membership type
988 $title1 = "Membership Type" . substr(sha1(rand()), 0, 7);
989 $this->openCiviPage("admin/member/membershipType", "reset=1&action=browse");
991 $this->click("link=Add Membership Type");
992 $this->waitForElementPresent('_qf_MembershipType_cancel-bottom');
994 $this->type('name', $title1);
995 $this->type('member_org', $orgName1);
996 $this->click('_qf_MembershipType_refresh');
997 $this->waitForElementPresent("xpath=//div[@id='membership_type_form']/fieldset/table[2]/tbody/tr[2]/td[2]");
999 $this->type('minimum_fee', '50');
1001 $this->select('financial_type_id', 'value=2');
1003 $this->type('duration_interval', 1);
1004 $this->select('duration_unit', "label=year");
1006 $this->select('period_type', "label=fixed");
1007 $this->waitForElementPresent('fixed_period_rollover_day[d]');
1009 $this->select('fixed_period_start_day[M]', 'value=4');
1010 $this->select('fixed_period_rollover_day[M]', 'value=1');
1012 $this->select('relationship_type_id', 'value=4_b_a');
1014 $this->click('_qf_MembershipType_upload-bottom');
1015 $this->waitForElementPresent('link=Add Membership Type');
1016 $this->assertTrue($this->isTextPresent("The membership type '$title1' has been saved."));
1017 $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"));
1020 $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1");
1022 // select relationship type
1023 $this->click("relationship_type_id");
1024 $this->select("relationship_type_id", "value=4_a_b");
1026 // search organization
1027 $this->type('contact_1', $orgName1);
1028 $this->click("contact_1");
1029 $this->waitForElementPresent("css=div.ac_results-inner li");
1030 $this->click("css=div.ac_results-inner li");
1031 $this->assertContains($orgName1, $this->getValue('contact_1'), "autocomplete expected $orgName1 but didn’t find it in " . $this->getValue('contact_1'));
1034 $this->click("is_permission_a_b");
1035 $this->click("is_permission_b_a");
1037 // save relationship
1038 $this->click("details-save");
1041 $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1");
1043 // select relationship type
1044 $this->click("relationship_type_id");
1045 $this->select("relationship_type_id", "value=4_a_b");
1047 // search organization
1048 $this->type('contact_1', $orgName2);
1049 $this->click("contact_1");
1050 $this->waitForElementPresent("css=div.ac_results-inner li");
1051 $this->click("css=div.ac_results-inner li");
1052 $this->assertContains($orgName2, $this->getValue('contact_1'), "autocomplete expected $orgName2 but didn’t find it in " . $this->getValue('contact_1'));
1055 $this->click("is_permission_a_b");
1056 $this->click("is_permission_b_a");
1058 // save relationship
1059 $this->click("details-save");
1061 // set membership type
1062 $this->openCiviPage("admin/contribute/membership", "reset=1&action=update&id=$pageId", "_qf_MembershipBlock_upload_done-bottom");
1063 $this->click("member_is_active");
1064 $this->click("membership_type[{$typeId}]");
1065 $this->click("xpath=//div[@id='memberFields']//table[@class='report']/tbody//tr/td[1]/label[text()='{$title1}']/../../td[2]/input");
1066 $this->click('_qf_MembershipBlock_upload_done-bottom');
1067 $this->waitForPageToLoad($this->getTimeoutMsec());
1069 //Open Live Membership Page
1070 $this->openCiviPage('contribute/transact', "reset=1&id=$pageId&cid=$cid", "_qf_Main_upload-bottom");
1071 $this->click('CIVICRM_QFID_amount_other_radio_4');
1072 $this->type('amount_other', 60);
1073 $this->click('onbehalf_organization_name');
1074 $this->type('onbehalf_organization_name', $orgName1);
1075 $this->typeKeys('onbehalf_organization_name', $orgName1);
1076 $this->click("onbehalf_organization_name");
1077 $this->waitForElementPresent("css=div.ac_results-inner li");
1078 $this->click("css=div.ac_results-inner li");
1079 // Because it tends to cause problems, all uses of sleep() must be justified in comments
1080 // Sleep should never be used for wait for anything to load from the server
1081 // Justification for this instance: FIXME
1083 $this->click('onbehalf_member_campaign_id');
1084 $this->select('onbehalf_member_campaign_id', "label={$title}");
1085 $this->type("onbehalf_custom_{$fieldId}", 'Test Subject');
1087 $this->assertContains($orgName1, $this->getValue('onbehalf_organization_name'), "autocomplete expected $orgName1 but didn’t find it in " . $this->getValue('onbehalf_organization_name'));
1090 $this->select("credit_card_type", "value=Visa");
1091 $this->type("credit_card_number", "4111111111111111");
1092 $this->type("cvv2", "000");
1093 $this->select("credit_card_exp_date[M]", "value=1");
1094 $this->select("credit_card_exp_date[Y]", "value=2020");
1096 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
1097 $this->click("_qf_Confirm_next-bottom");
1098 $this->waitForPageToLoad($this->getTimeoutMsec());
1100 //Find Membership for organization
1101 $this->openCiviPage("member/search", "reset=1");
1102 $this->type("sort_name", $orgName1);
1103 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='memberSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
1104 $this->clickLink("xpath=//div[@id='memberSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_MembershipView_cancel-bottom");
1106 //verify contrb created
1112 foreach ($expected as $value => $label) {
1113 $this->verifyText("xpath=//form[@id='MembershipView']/div[2]/div/table/tbody/tr[$value]/td[2]", preg_quote($label));
1116 // find membership for contact in relationship
1117 $this->openCiviPage("contact/view", "reset=1&force=1&cid={$cid}");
1118 $this->click("css=li#tab_member a");
1119 $this->waitForElementPresent("xpath=//div[@id='memberships']/div/table//tbody//tr/td[1][text()='{$title1}']");
1120 $this->click("xpath=//div[@id='memberships']/div/table//tbody//tr/td[1][text()='{$title1}']/../td[7]/span/a[text()='View']");
1121 $this->waitForPageToLoad($this->getTimeoutMsec());
1123 //verify contrb created
1128 foreach ($expected as $value => $label) {
1129 $this->verifyText("xpath=//form[@id='MembershipView']/div[2]/div/table/tbody/tr[$value]/td[2]", preg_quote($label));
1132 $this->openCiviPage("admin/uf/group", "reset=1");
1133 $this->click("link=Reserved Profiles");
1134 $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']");
1135 $this->waitForPageToLoad($this->getTimeoutMsec());
1137 $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']");
1138 $this->waitForElementPresent('_qf_Field_next-bottom');
1140 $this->click('_qf_Field_next-bottom');
1141 $this->waitForPageToLoad($this->getTimeoutMsec());
1142 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'),
1143 "Status message didn't show up after saving!"
1146 $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']");
1147 $this->waitForElementPresent('_qf_Field_next-bottom');
1149 $this->click('_qf_Field_next-bottom');
1150 $this->waitForPageToLoad($this->getTimeoutMsec());
1151 $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'),
1152 "Status message didn't show up after saving!"
1155 $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
1156 $this->click("css=li#tab_rel a");
1158 $this->waitForElementPresent("xpath=//div[@id='current-relationships']/div/table/tbody//tr/td[2]/a[text()='{$orgName1}']");
1159 $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']");
1161 // Check confirmation alert.
1162 $this->assertTrue((bool) preg_match("/^Are you sure you want to delete this relationship?/",
1163 $this->getConfirmation()
1165 $this->chooseOkOnNextConfirmation();
1166 $this->waitForPageToLoad($this->getTimeoutMsec());
1167 $this->assertTrue($this->isTextPresent('Selected relationship has been deleted successfully.'),
1168 "Status message didn't show up after saving!"
1172 public function testOnBehalfOfOrganizationWithImage() {
1173 $this->webtestLogin();
1175 $this->openCiviPage("profile/edit", "reset=1&gid=4");
1176 $firstName = 'John_x_' . substr(sha1(rand()), 0, 7);
1177 $lastName = 'Anderson_c_' . substr(sha1(rand()), 0, 7);
1179 $this->waitForPageToLoad($this->getTimeoutMsec());
1180 $this->waitForElementPresent("_qf_Edit_next");
1181 $this->type("first_name", $firstName);
1182 $this->type("last_name", $lastName);
1183 $this->clickLink("_qf_Edit_next", "profilewrap4");
1185 $cid = $this->urlArg('id');
1186 $this->assertType('numeric', $cid);
1187 // Is status message correct?
1188 $this->assertTextPresent("Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!");
1190 $this->openCiviPage("admin/uf/group", "reset=1");
1191 $this->click("link=Reserved Profiles");
1193 $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']");
1194 $this->waitForPageToLoad($this->getTimeoutMsec());
1196 $this->click("link=Add Field");
1197 $this->waitForElementPresent('_qf_Field_next-bottom');
1199 $this->select('field_name[0]', 'value=Contact');
1200 $this->select('field_name[1]', 'label=Image Url');
1201 $this->click('field_name[1]');
1202 $this->click('_qf_Field_next-bottom');
1203 $this->waitForPageToLoad($this->getTimeoutMsec());
1205 // Use default payment processor
1206 $processorName = 'Test Processor';
1207 $processorType = 'Dummy';
1208 $pageTitle = substr(sha1(rand()), 0, 7);
1210 $hash = substr(sha1(rand()), 0, 7);
1211 $amountSection = TRUE;
1216 $memberships = FALSE;
1217 $memPriceSetId = NULL;
1219 $profilePreId = NULL;
1220 $profilePostId = NULL;
1224 $honoreeSection = FALSE;
1225 $isAddPaymentProcessor = TRUE;
1226 $isPcpApprovalNeeded = FALSE;
1227 $isSeparatePayment = FALSE;
1229 // create a new online contribution page
1230 // create contribution page with randomized title and default params
1231 $pageId = $this->webtestAddContributionPage($hash,
1234 array($processorName => $processorType),
1248 $isAddPaymentProcessor,
1249 $isPcpApprovalNeeded,
1254 $this->_testOrganizationWithImageUpload($pageId, $cid, $pageTitle);
1256 $this->openCiviPage("admin/uf/group", "reset=1");
1257 $this->click("link=Reserved Profiles");
1259 $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']");
1260 $this->waitForPageToLoad($this->getTimeoutMsec());
1261 $this->click("xpath=//table[@id='option11']/tbody//tr/td/span[text()='Image Url']/../following-sibling::td[8]/span[2]/ul/li[2]/a");
1262 $this->waitForPageToLoad($this->getTimeoutMsec());
1263 $this->click('_qf_Field_next-bottom');
1264 $this->waitForPageToLoad($this->getTimeoutMsec());
1265 $this->waitForText('crm-notification-container', "Selected Profile Field has been deleted.");
1269 * @param int $pageId
1273 public function _testOrganizationWithImageUpload($pageId, $cid, $pageTitle) {
1274 //Open Live Contribution Page
1275 $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", '_qf_Main_upload-bottom');
1277 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
1278 $lastName = 'An' . substr(sha1(rand()), 0, 7);
1279 $orgName = 'org_11_' . substr(sha1(rand()), 0, 7);
1280 $this->type("email-5", $firstName . "@example.com");
1282 // onbehalforganization info
1283 $this->type("onbehalf_organization_name", $orgName);
1284 $this->type("onbehalf_phone-3-1", 9999999999);
1285 $this->type("onbehalf_email-3", "{$orgName}@example.com");
1286 $this->type("onbehalf_street_address-3", "Test Street Address");
1287 $this->type("onbehalf_city-3", "Test City");
1288 $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
1289 $this->click("onbehalf_country-3");
1290 $this->select("onbehalf_country-3", "label=UNITED STATES");
1291 $this->click("onbehalf_state_province-3");
1292 $this->select("onbehalf_state_province-3", "label=Alabama");
1294 // check for upload field.
1295 $this->waitForElementPresent("onbehalf_image_URL");
1297 //header("Content-Type: image/png");
1298 $im = imagecreate(110, 20)
1299 or die("Cannot Initialize new GD image stream");
1300 $background_color = imagecolorallocate($im, 0, 0, 0);
1301 $text_color = imagecolorallocate($im, 233, 14, 91);
1302 imagestring($im, 1, 5, 5, "On Behalf-Org Logo", $text_color);
1303 imagepng($im, "/tmp/file.png");
1305 $imagePath = "/tmp/file.png";
1306 $this->webtestAttachFile('onbehalf_image_URL', $imagePath);
1310 $this->select("credit_card_type", "value=Visa");
1311 $this->type("credit_card_number", "4111111111111111");
1312 $this->type("cvv2", "000");
1313 $this->select("credit_card_exp_date[M]", "value=1");
1314 $this->select("credit_card_exp_date[Y]", "value=2020");
1317 $this->type("billing_first_name", $firstName . 'billing');
1318 $this->type("billing_last_name", $lastName . 'billing');
1319 $this->type("billing_street_address-5", "0121 Mount Highschool.");
1320 $this->type(" billing_city-5", "Shangai");
1321 $this->select("billing_country_id-5", "value=1228");
1322 $this->select("billing_state_province_id-5", "value=1004");
1323 $this->type("billing_postal_code-5", "94129");
1324 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
1326 $this->click("_qf_Confirm_next-bottom");
1327 $this->waitForPageToLoad($this->getTimeoutMsec());
1329 // Type search name in autocomplete.
1330 $this->click('sort_name_navigation');
1331 $this->type('css=input#sort_name_navigation', $orgName);
1332 $this->typeKeys('css=input#sort_name_navigation', $orgName);
1334 // Wait for result list.
1335 $this->waitForElementPresent("css=div.ac_results-inner li");
1337 // Visit organization page.
1338 $this->click("css=div.ac_results-inner li");
1339 $this->waitForPageToLoad($this->getTimeoutMsec());
1341 //check whether the image is present
1342 $this->assertTrue($this->isElementPresent("xpath=//div[@id='crm-contact-thumbnail']/div/a/img"));