<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.3 |
+ | CiviCRM version 4.5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013 |
+ | Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
*/
require_once 'CiviTest/CiviSeleniumTestCase.php';
+
+/**
+ * Class WebTest_Contact_AdvancedSearchTest
+ */
class WebTest_Contact_AdvancedSearchTest extends CiviSeleniumTestCase {
protected function setUp() {
$this->createDetailContact($firstName);
// go to group tab and add to new group
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("_qf_GroupContact_next");
+ $this->clickAjaxLink("css=li#tab_group a", "_qf_GroupContact_next");
$this->select("group_id", "$groupName");
- $this->click("_qf_GroupContact_next");
- $this->waitForPageToLoad($this->getTimeoutMsec());
+ $this->clickAjaxLink("_qf_GroupContact_next");
+ $this->waitForText('crm-notification-container', "Contact has been added to '$groupName'");
// go to tag tab and add to new tag
- $this->click("css=li#tab_tag a");
- $this->waitForElementPresent("css=div#tagtree");
- $this->click("xpath=//ul/li/label[text()=\"$tagName\"]");
- $this->waitForElementPresent("css=.success");
-
- // is status message correct?
- $this->waitForTextPresent("Saved");
- $this->waitForText('crm-notification-container', "Saved");
-
- // go to event tab and register for event ( auto add activity and contribution )
- $this->click("css=li#tab_participant a");
- $this->waitForElementPresent("link=Add Event Registration");
- $this->click("link=Add Event Registration");
- $this->waitForElementPresent("note");
- // fall fundraiser dinner event label is variable
- $this->select("event_id", "value=1");
+ $this->clickAjaxLink("css=li#tab_tag a", "css=div#tagtree");
+ $this->click("xpath=//ul/li/span/label[text()=\"$tagName\"]");
+ $this->checkCRMStatus();
+
+ // register for event ( auto add activity and contribution )
+ $this->clickPopupLink("link=Register for Event");
+ $this->waitForText('s2id_event_id', "- select event -");
+ $this->select2("event_id", "Fall Fundraiser Dinner");
$this->waitForElementPresent("receipt_text");
- $this->click("role_id[2]");
+ $this->multiselect2("role_id", array('Volunteer'));
+ // Select $100 fee
+ $this->click("css=input[data-amount=100]");
$this->check("record_contribution");
$this->waitForElementPresent("contribution_status_id");
$this->select("payment_instrument_id", "Check");
$this->type("check_number", "chqNo$firstName");
$this->type("trxn_id", "trid$firstName");
- $this->click("_qf_Participant_upload-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
+ $this->clickAjaxLink("_qf_Participant_upload-bottom", "link=Add Event Registration");
$this->waitForText('crm-notification-container', "Event registration for $firstName adv$firstName has been added");
- // go to pledge tab and add pledge
- $this->click("css=li#tab_pledge a");
- $this->waitForElementPresent("link=Add Pledge");
- $this->click("link=Add Pledge");
+ // Add pledge
+ $this->clickPopupLink("link=Add Pledge");
$this->waitForElementPresent("contribution_page_id");
$this->type("amount", "200");
$this->type("installments", "5");
$this->type("frequency_interval", "1");
$this->select("frequency_unit", "month(s)");
- $this->click("_qf_Pledge_upload-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
+ $this->clickAjaxLink("_qf_Pledge_upload-bottom", "link=Add Pledge");
$this->waitForText('crm-notification-container', "Pledge has been recorded and the payment schedule has been created.");
- // go to Membership tab and add membership
- $this->click("css=li#tab_member a");
- $this->waitForElementPresent("link=Add Membership");
- $this->clickLink("link=Add Membership");
+ // Add membership
+ $this->clickPopupLink("link=Add Membership", "_qf_Membership_cancel-bottom");
//let the organisation be default (Default Organization)
$this->select("membership_type_id[0]", "value=1");
$this->click("membership_type_id[1]");
$this->select("membership_type_id[1]", "Student");
$this->type("source", "membership source$firstName");
- $this->clickLink("_qf_Membership_upload-bottom");
-
+ $this->clickAjaxLink("_qf_Membership_upload-bottom");
$this->waitForText('crm-notification-container', "Student membership for $firstName adv$firstName has been added");
- // go to relationship tab and add relationship
- $this->click("css=li#tab_rel a");
- $this->waitForElementPresent("link=Add Relationship");
- $this->click("link=Add Relationship");
- $this->waitForElementPresent("_qf_Relationship_cancel");
- $this->select("relationship_type_id", "Employee of");
- $this->webtestFillAutocomplete("Default"); //default organization is provided as employer contact
- $this->waitForElementPresent("details-save");
+ // Add relationship
+ $this->clickPopupLink("link=Add Relationship", "_qf_Relationship_cancel");
+ $this->select2("relationship_type_id", "Employee of");
+ $this->waitForElementPresent("xpath=//input[@id='related_contact_id'][@placeholder='- select organization -']");
+ $this->select2("related_contact_id", "Default", TRUE);
$this->webtestFillDate("start_date", "-1 day");
$this->webtestFillDate("end_date", "+1 day");
- $this->clickLink("details-save");
- $this->waitForText('crm-notification-container', "New relationship created.");
+ $this->clickAjaxLink('_qf_Relationship_upload-bottom', NULL);
+ $this->waitForText('crm-notification-container', "Relationship created.");
//-------------- advance search --------------
'CiviContribute' => array('contribution_currency_type', 'addContributionSearchDetail'),
'CiviEvent' => array('participant_fee_amount_high', 'addParticipantSearchDetail'),
'CiviMember' => array('member_end_date_high', 'addMemberSearchDetail'),
- 'CiviPledge' => array('pledge_in_honor_of', 'addPledgeSearchDetail'),
+ 'CiviPledge' => array('pledge_frequency_interval', 'addPledgeSearchDetail'),
'relationship' => array("xpath=//div[@id='relationship']/table/tbody/tr//td/label[text()='Relationship Status']/../label[text()='All']", ''),
);
function testActivitySearchByTypeTest() {
$this->webtestLogin();
$this->openCiviPage('contact/search/advanced', 'reset=1');
- $this->click("activity");
- $this->waitForElementPresent('activity_subject');
+ $this->clickAjaxLink("activity", 'activity_subject');
$this->check("xpath=//div[@id='Activity']//div/label[text()='Tell a Friend']/../input");
- $this->click("_qf_Advanced_refresh");
- $this->waitForPageToLoad($this->getTimeoutMsec());
+ $this->clickLink("_qf_Advanced_refresh");
$count = explode(" ", trim($this->getText("xpath=//div[@id='search-status']/table/tbody/tr/td")));
$count = $count[0];
$this->assertTrue(is_numeric($count), "The total count of search results not found");
//go to next page
$this->click("xpath=//div[@class='crm-search-results']/div[@class='crm-pager']/span[@class='crm-pager-nav']/a[@title='next page']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
+ $this->waitForElementPresent("task");
$j = $j + $subTotal;
}
}
//function to check match for sumbit Advance Search
+ /**
+ * @param string $firstName
+ */
function submitSearch($firstName) {
$this->clickLink("_qf_Advanced_refresh");
// verify unique name
$this->click("xpath=//form[@id='Advanced']//div[2]/div/div[1]");
}
- // function to fill auto complete
- function fillAutoComplete($text, $elementId) {
- $this->click("$elementId");
- $this->type("$elementId", "$text");
- $this->typeKeys("$elementId", "$text");
- $this->waitForElementPresent("css=div.ac_results li");
- $this->click("css=div.ac_results li");
- $this->assertContains($text, $this->getValue("$elementId"),
- "autocomplete expected $text but didn’t find it in " . $this->getValue("$elementId")
- );
+ /*
+ * Check for CRM-14952
+ */
+ function testStateSorting() {
+ $this->webtestLogin();
+ $this->openCiviPage('contact/search/advanced', 'reset=1', 'group');
+ $this->select2("group", "Newsletter", TRUE);
+ $this->select2("group", "Summer", TRUE);
+ $this->select2("group", "Advisory", TRUE);
+ $this->clickAjaxLink("location", 'country');
+ $this->select2("country", "United States", False);
+ $this->waitForElementPresent('state_province');
+ $this->multiselect2("state_province", array("Ohio", "New York", "New Mexico", "Connecticut", "Georgia", "New Jersey", "Texas"));
+ $this->clickLink("_qf_Advanced_refresh", "xpath=//div[@class='crm-search-results']//table/tbody/tr[1]/td[6]");
+
+ $stateBeforeSort = $this->getText("xpath=//div[@class='crm-search-results']//table/tbody/tr[1]/td[6]");
+ $this->click("xpath=//div[@class='crm-search-results']//table/thead/tr//th/a[contains(text(),'State')]");
+ $this->waitForElementPresent("xpath=//div[@class='crm-search-results']//table/thead/tr//th/a[contains(text(),'State')]");
+ $this->assertElementNotContainsText("xpath=//div[@class='crm-search-results']//table/tbody/tr[1]/td[6]", $stateBeforeSort);
}
// function to fill basic search detail
+ /**
+ * @param string $firstName
+ * @param string $groupName
+ * @param $tagName
+ */
function addBasicSearchDetail($firstName, $groupName, $tagName) {
// fill partial sort name
$this->type("sort_name", "$firstName");
// select subtype
- $this->select("crmasmSelect0", "value=Individual\ 1Student");
+ $this->select("contact_type", "value=Individual\ 1Student");
// select group
- $this->select("crmasmSelect1", "label=$groupName");
+ $this->select("group", "label=$groupName");
// select tag
- $this->select("crmasmSelect3", "label=$tagName");
+ $this->select("contact_tags", "label=$tagName");
// select prefered language
$this->select("preferred_language", "value=en_US");
// select privacy
}
// function to fill address search block values in advance search
+ /**
+ * @param $firstName
+ */
function addAddressSearchDetail($firstName) {
// select location type (home and main)
- $this->click("xpath=//div[@id='location']/table/tbody/tr[1]/td[1]//label[text()='Home']");
- $this->click("xpath=//div[@id='location']/table/tbody/tr[1]/td[1]//label[text()='Main']");
+ $this->multiselect2('location_type', array('Home', 'Main'));
// fill street address
$this->type("street_address", "street 1 $firstName");
// fill city
// select country
$this->select("country", "United States");
// select state-province
- $this->select("state_province", "Alaska");
+ $this->waitForElementPresent('state_province');
+ $this->select2("state_province", "Alaska", TRUE);
}
// function to fill activity search block in advance search
+ /**
+ * @param $firstName
+ */
function addActivitySearchDetail($firstName) {
// check activity types
$checkActivityTypes = array("Contribution", "Event Registration", "Membership Signup");
foreach ($checkActivityTypes as $labels) {
- $this->click("xpath=//div[@id='activity']/table/tbody/tr[1]/td[1]/div[1]//div/label[text()=\"$labels\"]");
+ $this->click("xpath=//div[@id='activity']/table/tbody/tr[2]/td[1]/div[1]//div/label[text()=\"$labels\"]");
}
// fill date range
$this->select("activity_date_relative","value=0");
}
//function to fill contribution search details
+ /**
+ * @param $firstName
+ */
function addContributionSearchDetail($firstName) {
// fill contribution date range
$this->select("contribution_date_relative","value=0");
// function to fill participant search details
function addParticipantSearchDetail() {
// fill event name
- $this->fillAutoComplete("Fall Fundraiser Dinner", "event_name");
+ $this->select2("event_id", "Fall Fundraiser Dinner");
// fill event type
- $this->fillAutoComplete("Fundraiser", "event_type");
+ $this->select2("event_type_id", "Fundraiser");
// check participant status (registered)
$this->click("xpath=//div[@id='participantForm']/table/tbody//tr/td/label[text()='Participant Status']/../div//div/label[text()='Registered']");
// check participant role (Volunteer)
$this->click("xpath=//div[@id='participantForm']/table/tbody//tr/td/label[text()='Participant Role']/../div//div/label[text()='Volunteer']");
// fill participant fee level (couple)
- $this->fillAutoComplete("Couple", "participant_fee_level");
+ $this->select2("participant_fee_id", "Couple");
// fill amount range
$this->type("participant_fee_amount_low", "1");
$this->type("participant_fee_amount_high", "150");
}
// function to fill member search details
+ /**
+ * @param $firstName
+ */
function addMemberSearchDetail($firstName) {
// check membership type (Student)
$this->click("xpath=//div[@id='memberForm']/table/tbody/tr[1]/td[1]/div[1]//div/label[text()='Student']");
}
// function to fill member search details
+ /**
+ * @param $firstName
+ */
function addPledgeSearchDetail($firstName) {
// fill pledge schedule date range
$this->select("pledge_payment_date_relative","value=0");
}
// function to create contact with details (contact details, address, Constituent information ...)
+ /**
+ * @param null $firstName
+ */
function createDetailContact($firstName = NULL) {
if (!$firstName) {
$firstName = substr(sha1(rand()), 0, 7);
$this->type("first_name", "$firstName");
$this->type("middle_name", "mid$firstName");
$this->type("last_name", "adv$firstName");
- $this->select("contact_sub_type", "label=- $Subtype");
+ $this->select("contact_sub_type", "label=$Subtype");
$this->type("email_1_email", "$firstName@advsearch.co.in");
$this->type("phone_1_phone", "123456789");
$this->type("external_identifier", "extid$firstName");
$this->webtestFillDate("deceased_date", "now");
// save contact
- $this->click("_qf_Contact_upload_view");
- $this->waitForPageToLoad($this->getTimeoutMsec());
+ $this->clickLink("_qf_Contact_upload_view", 'css=.crm-summary-display_name');
$this->assertElementContainsText('css=.crm-summary-display_name', "$firstName adv$firstName");
}
}