From: Nileema Date: Fri, 8 Nov 2013 07:23:57 +0000 (+0530) Subject: -- CRM-13617 - Webtest for link of custom data for country to state/province drop... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=69932a562d3f2fbdafaced84011d607f0f08846f;p=civicrm-core.git -- CRM-13617 - Webtest for link of custom data for country to state/province drop downs ---------------------------------------- * CRM-13617: Link Country and state province widget for custom data http://issues.civicrm.org/jira/browse/CRM-13617 --- diff --git a/tests/phpunit/WebTest/Profile/ProfileCountryState.php b/tests/phpunit/WebTest/Profile/ProfileCountryState.php new file mode 100644 index 0000000000..ba52e61de8 --- /dev/null +++ b/tests/phpunit/WebTest/Profile/ProfileCountryState.php @@ -0,0 +1,84 @@ +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 diff --git a/tests/phpunit/WebTest/Profile/xml/CountryStateWebtest.xml b/tests/phpunit/WebTest/Profile/xml/CountryStateWebtest.xml new file mode 100644 index 0000000000..87ad9bd13e --- /dev/null +++ b/tests/phpunit/WebTest/Profile/xml/CountryStateWebtest.xml @@ -0,0 +1,115 @@ + + + + + + country_state_test + Country test + Individual + + 1 + + + 14 + 1 + civicrm_value_country_state_test_14 + 1 + 0 + + 0 + + + + + country1 + + Country + Select Country + 0 + 0 + 0 + 1 + 1 + 0 + 255 + 60 + 4 + country1_66 + country_state_test + + + state1 + + StateProvince + Select State/Province + 0 + 0 + 0 + 2 + 1 + 0 + 255 + 60 + 4 + state1_67 + country_state_test + + + + + 1 + Individual + Country and state province web test + 0 + 0 + 0 + 0 + 0 + country_state_province_web_test_19 + + 0 + + + + + custom.civicrm_value_country_state_test_14.country1_66 + 1 + 0 + 0 + 1 + + + User and User Admin Only + 0 + 0 + + Individual + 1 + Country and state province web test + + + custom.civicrm_value_country_state_test_14.state1_67 + 1 + 0 + 0 + 2 + + + User and User Admin Only + 0 + 0 + + Individual + 1 + Country and state province web test + + + + + 1 + Profile + 15 + Country and state province web test + + +