public function testOnBehalfOfOrganizationWithMembershipData() {
$this->webtestLogin();
- // create new individual
- $this->openCiviPage("profile/edit", "reset=1&gid=4");
- $firstName = 'John_x_' . substr(sha1(rand()), 0, 7);
- $lastName = 'Anderson_c_' . substr(sha1(rand()), 0, 7);
-
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForElementPresent("_qf_Edit_next");
- $this->type("first_name", $firstName);
- $this->type("last_name", $lastName);
- $this->clickLink("_qf_Edit_next", "profilewrap4");
-
- // Is status message correct?
- $this->assertTextPresent("Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!");
-
- //custom data
-
- $this->openCiviPage("admin/custom/group", "action=add&reset=1");
-
- //fill custom group title
- $customGroupTitle = 'custom_' . substr(sha1(rand()), 0, 7);
- $this->click("title");
- $this->type("title", $customGroupTitle);
-
- //custom group extends
- $this->click("extends[0]");
- $this->select("extends[0]", "value=Membership");
- //$this->click("//option[@value='Contact']");
- $this->click("_qf_Group_next-bottom");
- $this->waitForElementPresent("_qf_Field_cancel-bottom");
-
- //Is custom group created?
- $this->assertTrue($this->isTextPresent("Your custom field set '{$customGroupTitle}' has been added. You can add custom fields now."));
-
- //add custom field - alphanumeric checkbox
- $checkboxFieldLabel = 'custom_field' . substr(sha1(rand()), 0, 4);
- $this->click("label");
- $this->type("label", $checkboxFieldLabel);
- $this->click("data_type[1]");
- $this->select("data_type[1]", "value=CheckBox");
- $this->click("//option[@value='CheckBox']");
- $checkboxOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type("option_label_1", $checkboxOptionLabel1);
- $this->type("option_value_1", "1");
- $checkboxOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type("option_label_2", $checkboxOptionLabel2);
- $this->type("option_value_2", "2");
- $this->click("link=another choice");
- $checkboxOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type("option_label_3", $checkboxOptionLabel3);
- $this->type("option_value_3", "3");
-
- //enter options per line
- $this->type("options_per_line", "2");
-
- //enter pre help message
- $this->type("help_pre", "this is field pre help");
-
- //enter post help message
- $this->type("help_post", "this field post help");
-
- //Is searchable?
- $this->click("is_searchable");
-
- //clicking save
- $this->click("_qf_Field_next");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //Is custom field created?
- $this->assertTrue($this->isTextPresent("Custom field '$checkboxFieldLabel' has been saved."));
-
- //create another custom field - Integer Radio
- $this->click("//a[@id='newCustomField']/span");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->click("data_type[0]");
- $this->select("data_type[0]", "value=1");
- $this->click("//option[@value='1']");
- $this->click("data_type[1]");
- $this->select("data_type[1]", "value=Radio");
- $this->click("//option[@value='Radio']");
-
- $radioFieldLabel = 'custom_field' . substr(sha1(rand()), 0, 4);
- $this->type("label", $radioFieldLabel);
- $radioOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type("option_label_1", $radioOptionLabel1);
- $this->type("option_value_1", "1");
- $radioOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type("option_label_2", $radioOptionLabel2);
- $this->type("option_value_2", "2");
- $this->click("link=another choice");
- $radioOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type("option_label_3", $radioOptionLabel3);
- $this->type("option_value_3", "3");
-
- //select options per line
- $this->type("options_per_line", "3");
-
- //enter pre help msg
- $this->type("help_pre", "this is field pre help");
-
- //enter post help msg
- $this->type("help_post", "this is field post help");
-
- //Is searchable?
- $this->click("is_searchable");
-
- //clicking save
- $this->click("_qf_Field_next");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //Is custom field created
- $this->assertTrue($this->isTextPresent("Custom field '$radioFieldLabel' has been saved."));
-
- //add the above custom data to the On Behalf of Profile
- $this->openCiviPage("admin/uf/group", "reset=1");
- $this->click("link=Reserved Profiles");
-
- $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']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->click("link=Add Field");
- $this->waitForElementPresent('_qf_Field_next-bottom');
- $this->select('field_name[0]', 'value=Membership');
- $label = $checkboxFieldLabel . ' :: ' . $customGroupTitle;
- $this->select('field_name[1]', "label=$label");
- $this->click('field_name[1]');
- $this->click('_qf_Field_next_new-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->select('field_name[0]', 'value=Membership');
- $label = $radioFieldLabel . ' :: ' . $customGroupTitle;
- $this->select('field_name[1]', "label=$label");
- $this->click('field_name[1]');
- $this->click('_qf_Field_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$radioFieldLabel}' has been saved to 'On Behalf Of Organization'."));
-
- //create organisation
- $orgName = "Org WebAccess " . substr(sha1(rand()), 0, 7);
- $orgEmail = "org" . substr(sha1(rand()), 0, 7) . "@web.com";
- $this->webtestAddOrganization($orgName, $orgEmail);
-
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->click("css=li#tab_member a");
-
- $this->waitForElementPresent('link=Add Membership');
- $this->click('link=Add Membership');
-
- $this->waitForElementPresent('_qf_Membership_cancel-bottom');
-
- // fill in Membership Organization and Type
- $this->select('membership_type_id[0]', "value=1");
- $this->select('membership_type_id[1]', "value=1");
-
- // fill in Source
- $sourceText = 'On behalf Membership Webtest';
- $this->type('source', $sourceText);
-
- $this->waitForElementPresent("css=div#{$customGroupTitle} div.crm-accordion-header");
- $this->click("css=div#{$customGroupTitle} div.crm-accordion-header");
- //$this->waitForElementPresent('_qf_Membership_cancel-bottom111');
-
- // select newly created processor
- $xpath = "xpath=//label[text() = '{$checkboxOptionLabel1}']/preceding-sibling::input[1]";
- $this->assertTrue($this->isTextPresent($checkboxOptionLabel1));
- $this->check($xpath);
-
- $xpath = "xpath=//label[text() = '{$checkboxOptionLabel3}']/preceding-sibling::input[1]";
- $this->assertTrue($this->isTextPresent($checkboxOptionLabel3));
- $this->check($xpath);
-
- $xpath = "xpath=//label[text() = '{$radioOptionLabel1}']/preceding-sibling::input[1]";
- $this->assertTrue($this->isTextPresent($radioOptionLabel1));
- $this->check($xpath);
+ // Create three new individual
+ $individuals = $organizations = array();
+ for ($i = 0; $i < 3; $i++) {
+ $firstName = 'John_x_' . substr(sha1(rand()), 0, 7);
+ $individuals[] = $firstName;
+ $this->webtestAddContact($firstName, "Memberson", "{$firstName}@memberson.com");
+ }
- $this->waitForElementPresent('_qf_Membership_cancel-bottom');
- $this->click('_qf_Membership_upload-bottom');
+ // Create two organisations, one used for new Membership Type, and other for inherited membership purpose
+ for ($i = 0; $i < 2; $i++) {
+ $orgName1 = "Org WebAccess" . substr(sha1(rand()), 0, 7);
+ $orgEmail1 = substr(sha1(rand()), 0, 7) . "@web.com";
+ $organizations[] = array('name' => $orgName1, 'email' => $orgEmail1);
+ $this->webtestAddOrganization($orgName1, $orgEmail1);
+ }
- $this->waitForPageToLoad($this->getTimeoutMsec());
+ // Create Employee relationship of last created organization $organizations[1] with all three $individuals
+ $this->waitForAjaxContent();
$this->click("css=li#tab_rel a");
-
$this->waitForElementPresent('link=Add Relationship');
$this->click('link=Add Relationship');
-
$this->waitForElementPresent('relationship_type_id');
$this->click("relationship_type_id");
$this->select("relationship_type_id", "label=Employer of");
// search organization
- $this->type('contact_1', $firstName);
- $this->click("contact_1");
- $this->waitForElementPresent("css=div.ac_results-inner li");
- $this->click("css=div.ac_results-inner li");
- $this->assertContains($firstName, $this->getValue('contact_1'), "autocomplete expected $firstName but didn’t find it in " . $this->getValue('contact_1'));
-
+ $this->select2('related_contact_id', $individuals, TRUE);
// give permission
- $this->click("is_permission_a_b");
- $this->click("is_permission_b_a");
-
+ //$this->click("is_permission_a_b");
+ //$this->click("is_permission_b_a");
// save relationship
- $this->click("details-save");
- $this->waitForPageToLoad($this->getTimeoutMsec());
+ $this->click("_qf_Relationship_upload");
+ $this->waitForAjaxContent();
+
+ $title = 'Membership Type' . substr(sha1(rand()), 0, 7);
+ //Create membership type
+ $this->openCiviPage("admin/member/membershipType", "reset=1&action=browse");
+ $this->click("link=Add Membership Type");
+ $this->waitForElementPresent('_qf_MembershipType_cancel-bottom');
+ $this->type('name', $title);
+ $this->select2('member_of_contact_id', $organizations[0]['name']);
+ $this->type('minimum_fee', '100');
+ $this->select('financial_type_id', 'value=2');
+ $this->type('duration_interval', 1);
+ $this->select('duration_unit', "label=year");
+ $this->select('period_type', "value=rolling");
+ //Choose 'Employer of' relationship
+ $this->select('relationship_type_id', 'value=5_b_a');
+ $this->click('_qf_MembershipType_upload-bottom');
+ $this->waitForAjaxContent();
+ $this->waitForText('crm-notification-container', "The membership type '$title' has been saved.");
+ //Retrieve membership type ID from newly created membership type
+ $memTypeId = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td[1]/div[text()='{$title}']/../../td[12]/span/a[3]@href"));
+ $memTypeId = $memTypeId[1];
// Use default payment processor
$processorName = 'Test Processor';
$hash = substr(sha1(rand()), 0, 7);
$amountSection = TRUE;
$payLater = TRUE;
- $onBehalf = TRUE;
+ $onBehalf = 'optional';
$pledges = FALSE;
$recurring = FALSE;
- $memberships = TRUE;
+ $memberships = array(array('id' => $memTypeId, 'name' => $title, 'default' => 1));
$memPriceSetId = NULL;
$friend = TRUE;
$profilePreId = NULL;
$honoreeSection
);
- //check for formRule
- //scenario 1 : add membership data in pre / post profile and check for formRule
- //add new profile
- $this->openCiviPage("admin/uf/group", "reset=1");
- $this->click('link=Add Profile');
-
- $profileTitle = "test profile" . substr(sha1(rand()), 0, 7);
- // Add membership custom data field to profile
- $this->waitForElementPresent('_qf_Group_cancel-bottom');
- $this->type('title', $profileTitle);
- $this->clickLink('_qf_Group_next-bottom');
-
- $this->assertTrue($this->isTextPresent("Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now."));
-
- $gid = $this->urlArg('gid');
-
- $this->openCiviPage('admin/uf/group/field/add', array(
- 'action' => 'add',
- 'reset' => 1,
- 'gid' => $gid,
- ), 'field_name[0]');
- $this->select('field_name[0]', "value=Membership");
- $this->select('field_name[1]', "label={$checkboxFieldLabel} :: {$customGroupTitle}");
- $this->click('field_name[1]');
- $this->click('label');
-
- // Clicking save and new
- $this->click('_qf_Field_next_new-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$checkboxFieldLabel}' has been saved to '{$profileTitle}'."));
-
- $this->openCiviPage("admin/contribute/custom", "reset=1&action=update&id={$pageId}", '_qf_Custom_next-bottom');
- $this->select('custom_pre_id', "label={$profileTitle}");
- $this->click('_qf_Custom_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- sleep(3);
- $this->assertTrue($this->isTextPresent('You should move the membership related fields in the "On Behalf" profile for this Contribution Page'), "Form rule didn't showed up while incorrectly configuring membership fields profile for 'on behalf of' contribution page");
-
- $this->select('custom_pre_id', "- select -");
- $this->select('custom_post_id', "label={$profileTitle}");
- $this->click('_qf_Custom_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- sleep(3);
- $this->assertTrue($this->isTextPresent('You should move the membership related fields in the "On Behalf" profile for this Contribution Page'), "Form rule didn't showed up while incorrectly configuring membership fields profile for 'on behalf of' contribution page");
-
- //scenario 2 : disable 'on behalf of', add membership data in pre / post profile
- //then try to add 'on behalf of' and check for formRule
- //disable 'on behalf of'
- $this->openCiviPage("admin/contribute/settings", "reset=1&action=update&id={$pageId}", '_qf_Settings_next-bottom');
- $this->uncheck('is_organization');
- $this->click('_qf_Settings_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //set a membership field profile for this contribution page
- $this->click('css=li#tab_custom a');
- $this->waitForElementPresent('_qf_Custom_next-bottom');
- $this->select('custom_pre_id', "label={$profileTitle}");
- $this->click('_qf_Custom_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
+ $this->_testAnomoyousOrganization($pageId, $organizations[1], $pageTitle);
- //now visit the title settings page and configure the profile as on behalf of
- $this->click('css=li#tab_settings a');
- $this->waitForElementPresent('_qf_Settings_next-bottom');
- $this->check('is_organization');
- $this->click('_qf_Settings_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- sleep(3);
- $this->assertTrue($this->isTextPresent("You should move the membership related fields configured in 'Includes Profile (top of page)' to the 'On Behalf' profile for this Contribution Page"), "Form rule 'You should move the membership related fields configured in 'Includes Profile (top of page)' to the 'On Behalf' profile for this Contribution Page' didn't showed up");
-
- //logout
- $this->webtestLogout();
+ //Check if all three of the individuals has inherited membership
+ $this->openCiviPage("member/search", "reset=1");
+ $this->multiselect2("membership_type_id", array($title));
+ $this->click("CIVICRM_QFID_0_member_is_primary");
+ $this->click('_qf_Search_refresh');
+ // It suppose to be 3 but since we are registring contribution onBehalf of anonymous contact(email-5)
+ $this->waitForText('search-status', "4 Results");
+ foreach ($individuals as $individual) {
+ $this->isTextPresent($individual);
+ }
}
public function testOnBehalfOfOrganizationWithOrgData() {
* @param int $cid
* @param $pageTitle
*/
- public function _testAnomoyousOganization($pageId, $cid, $pageTitle) {
+ public function _testAnomoyousOrganization($pageId, $orgName, $pageTitle) {
+ $this->webtestLogout();
//Open Live Contribution Page
$this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom");
- $this->click('CIVICRM_QFID_0_8');
- $this->type('css=div.other_amount-section input', 60);
-
$firstName = 'Ma' . substr(sha1(rand()), 0, 4);
$lastName = 'An' . substr(sha1(rand()), 0, 7);
- $orgName = 'org_11_' . substr(sha1(rand()), 0, 7);
$this->type("email-5", $firstName . "@example.com");
+ $this->click('CIVICRM_QFID_0_12');
+ $this->type('css=div.other_amount-section input', 60);
+
// enable onbehalforganization block
$this->click("is_for_organization");
$this->waitForElementPresent("onbehalf_state_province-3");
// onbehalforganization info
- $this->type("onbehalf_organization_name", $orgName);
+ $this->type("onbehalf_organization_name", $orgName['name']);
$this->type("onbehalf_phone-3-1", 9999999999);
- $this->type("onbehalf_email-3", "{$orgName}@example.com");
+ $this->type("onbehalf_email-3", $orgName['email']);
$this->type("onbehalf_street_address-3", "Test Street Address");
$this->type("onbehalf_city-3", "Test City");
$this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
$this->click("_qf_Confirm_next-bottom");
$this->waitForPageToLoad($this->getTimeoutMsec());
- //login to check contribution
-
// Log in using webtestLogin() method
$this->webtestLogin();
+ // TODO: webtestVerifyTabularData function is causing timeout error, reason why most of the Webtests are failing
+ // where its been called to assert tabular data
+ /*
//Find Contribution
$this->openCiviPage("contribute/search", "reset=1");
- $this->type("sort_name", $orgName);
+ $this->type("sort_name", $orgName['name']);
$this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
- $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom");
+ //$this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom");
// verify contrb created
$expected = array(
- 1 => $orgName,
- 2 => 'Donation',
- 10 => $pageTitle,
+ 'From' => $orgName['name'],
+ 'Financial Type' => 'Donation',
+ 'Online Contribution Page' => $pageTitle,
);
- foreach ($expected as $value => $label) {
- $this->verifyText("xpath=id( 'ContributionView' )/div[2]/table[1]/tbody/tr[$value]/td[2]", preg_quote($label));
- }
+ $this->webtestVerifyTabularData($expected);
+ */
}
/**