Skip to content
Snippets Groups Projects
Commit a9dccfee authored by Yashodha Chaku's avatar Yashodha Chaku
Browse files

Merge pull request #1937 from NileemaJadhav/CRM-testqa

--  CRM-13617 - Webtest for link of custom data for country to state/province drop downs
parents 1232e04b 69932a56
Branches
Tags
No related merge requests found
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.4 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2013 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License along with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
require_once 'CiviTest/CiviSeleniumTestCase.php';
class WebTest_Profile_ProfileCountryState extends CiviSeleniumTestCase {
protected function setUp() {
parent::setUp();
}
function testStateCountry() {
$this->webtestLogin();
$config = CRM_Core_Config::singleton();
$import = new CRM_Utils_Migrate_Import();
global $civicrm_root;
$path = $civicrm_root . '/tests/phpunit/WebTest/Profile/xml/CountryStateWebtest.xml';
$import->run($path);
$result = $this->webtest_civicrm_api('uf_group', 'get', array( 'name' => 'country_state_province_web_test_19' ));
if($result['id']) {
$gid = $result['id'];
$this->openCiviPage("admin/setting/localization", "reset=1", "_qf_Localization_next-bottom");
$country = array(1001 => 'Afghanistan', 1013 => 'Australia', 1039 => 'Canada', 1101 => 'India');
$enabledCountries = $this->getSelectOptions("countryLimit-t");
$enabledStates = $this->getSelectOptions("provinceLimit-t");
foreach($country as $countryID => $countryName) {
if(!in_array($countryName, $enabledCountries)) {
$this->addSelection("countryLimit-f", "label=$countryName");
$this->click("xpath=//select[@id='countryLimit-f']/option[@value='$countryID']");
$this->click("xpath=//tr[@class='crm-localization-form-block-countryLimit']/td[2]/table//tbody/tr/td[2]/input[@name='add']");
}
if(!in_array($countryName, $enabledStates)) {
$this->addSelection("provinceLimit-f", "label=$countryName");
$this->click("//option[@value='$countryID']");
$this->click("xpath=//tr[@class='crm-localization-form-block-provinceLimit']/td[2]/table//tbody/tr/td[2]/input[@name='add']");
}
$added = true;
}
if ($added) {
$this->click("_qf_Localization_next-bottom");
$this->waitForPageToLoad($this->getTimeoutMsec());
$this->waitForText('crm-notification-container', "Saved");
}
$url = $this->sboxPath . "civicrm/profile/create?gid={$gid}&reset=1";
$this->open($url);
$this->waitForElementPresent("xpath=//form[@id='Edit']/div[2]/div/div/div[2]/select");
$this->click("xpath=//form[@id='Edit']/div[2]/div/div/div[2]/select");
$countryID = array_rand($country);
$states = CRM_Core_PseudoConstant::stateProvinceForCountry($countryID, 'id');
$stateID = array_rand($states);
$this->select("xpath=//form[@id='Edit']/div[2]/div/div/div[2]/select", "value=$countryID");
$this->waitForElementPresent("xpath=//form[@id='Edit']/div[2]/div/div[2]/div[2]/select");
$this->click("xpath=//form[@id='Edit']/div[2]/div/div[2]/div[2]/select");
$this->select("xpath=//form[@id='Edit']/div[2]/div/div[2]/div[2]/select", "value=$stateID");
$this->clickLink('_qf_Edit_next', NULL);
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="iso-8859-1" ?>
<CustomData>
<CustomGroups>
<CustomGroup>
<name>country_state_test</name>
<title>Country test</title>
<extends>Individual</extends>
<style>Tab</style>
<collapse_display>1</collapse_display>
<help_pre></help_pre>
<help_post></help_post>
<weight>14</weight>
<is_active>1</is_active>
<table_name>civicrm_value_country_state_test_14</table_name>
<is_multiple>1</is_multiple>
<collapse_adv_display>0</collapse_adv_display>
<created_date></created_date>
<is_reserved>0</is_reserved>
</CustomGroup>
</CustomGroups>
<CustomFields>
<CustomField>
<name>country1</name>
<label>country1</label>
<data_type>Country</data_type>
<html_type>Select Country</html_type>
<is_required>0</is_required>
<is_searchable>0</is_searchable>
<is_search_range>0</is_search_range>
<weight>1</weight>
<is_active>1</is_active>
<is_view>0</is_view>
<text_length>255</text_length>
<note_columns>60</note_columns>
<note_rows>4</note_rows>
<column_name>country1_66</column_name>
<custom_group_name>country_state_test</custom_group_name>
</CustomField>
<CustomField>
<name>state1</name>
<label>state1</label>
<data_type>StateProvince</data_type>
<html_type>Select State/Province</html_type>
<is_required>0</is_required>
<is_searchable>0</is_searchable>
<is_search_range>0</is_search_range>
<weight>2</weight>
<is_active>1</is_active>
<is_view>0</is_view>
<text_length>255</text_length>
<note_columns>60</note_columns>
<note_rows>4</note_rows>
<column_name>state1_67</column_name>
<custom_group_name>country_state_test</custom_group_name>
</CustomField>
</CustomFields>
<ProfileGroups>
<ProfileGroup>
<is_active>1</is_active>
<group_type>Individual</group_type>
<title>Country and state province web test</title>
<add_captcha>0</add_captcha>
<is_map>0</is_map>
<is_edit_link>0</is_edit_link>
<is_uf_link>0</is_uf_link>
<is_update_dupe>0</is_update_dupe>
<name>country_state_province_web_test_19</name>
<created_date></created_date>
<is_proximity_search>0</is_proximity_search>
</ProfileGroup>
</ProfileGroups>
<ProfileFields>
<ProfileField>
<field_name>custom.civicrm_value_country_state_test_14.country1_66</field_name>
<is_active>1</is_active>
<is_view>0</is_view>
<is_required>0</is_required>
<weight>1</weight>
<help_post></help_post>
<help_pre></help_pre>
<visibility>User and User Admin Only</visibility>
<in_selector>0</in_selector>
<is_searchable>0</is_searchable>
<label>country1</label>
<field_type>Individual</field_type>
<is_multi_summary>1</is_multi_summary>
<profile_group_name>Country and state province web test</profile_group_name>
</ProfileField>
<ProfileField>
<field_name>custom.civicrm_value_country_state_test_14.state1_67</field_name>
<is_active>1</is_active>
<is_view>0</is_view>
<is_required>0</is_required>
<weight>2</weight>
<help_post></help_post>
<help_pre></help_pre>
<visibility>User and User Admin Only</visibility>
<in_selector>0</in_selector>
<is_searchable>0</is_searchable>
<label>state1</label>
<field_type>Individual</field_type>
<is_multi_summary>1</is_multi_summary>
<profile_group_name>Country and state province web test</profile_group_name>
</ProfileField>
</ProfileFields>
<ProfileJoins>
<ProfileJoin>
<is_active>1</is_active>
<module>Profile</module>
<weight>15</weight>
<profile_group_name>Country and state province web test</profile_group_name>
</ProfileJoin>
</ProfileJoins>
</CustomData>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment