From a55077dcc7cc4b26e90f58f7196f8201cbb1901f Mon Sep 17 00:00:00 2001 From: Nileema Date: Wed, 13 Nov 2013 15:59:31 +0530 Subject: [PATCH] -- CRM-13617 Webtest modification ---------------------------------------- * CRM-13617: Link Country and state province widget for custom data http://issues.civicrm.org/jira/browse/CRM-13617 --- .../WebTest/Profile/ProfileCountryState.php | 92 +++++++++++--- .../Profile/xml/CountryStateWebtest.xml | 115 ------------------ 2 files changed, 77 insertions(+), 130 deletions(-) delete mode 100644 tests/phpunit/WebTest/Profile/xml/CountryStateWebtest.xml diff --git a/tests/phpunit/WebTest/Profile/ProfileCountryState.php b/tests/phpunit/WebTest/Profile/ProfileCountryState.php index ba52e61de8..20d6def39c 100644 --- a/tests/phpunit/WebTest/Profile/ProfileCountryState.php +++ b/tests/phpunit/WebTest/Profile/ProfileCountryState.php @@ -32,22 +32,58 @@ class WebTest_Profile_ProfileCountryState extends CiviSeleniumTestCase { } function testStateCountry() { - $this->webtestLogin(); + $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"); + // Add new profile. + $this->openCiviPage('admin/uf/group', 'reset=1'); + $this->click('newCiviCRMProfile-top'); + $this->waitForElementPresent('_qf_Group_next-bottom'); + + //Name of profile + $profileTitle = 'Country state province web test temp'; + $this->type('title', $profileTitle); + + //click on save + $this->click('_qf_Group_next'); + $this->waitForPageToLoad($this->getTimeoutMsec()); + + + //check for profile create + $this->waitForText('crm-notification-container', "Profile '{$profileTitle}' has been added. You can add fields to this profile now."); + $gid = $this->urlArg('gid'); + //Add Country field to profile + $this->click('field_name[0]'); + $this->select('field_name[0]', 'value=Contact'); + $this->click("//option[@value='Contact']"); + $this->click('field_name[1]'); + $this->select('field_name[1]', 'value=country'); + $this->click("//option[@value='country']"); + $this->click('is_required'); + + $this->click('_qf_Field_next_new'); + $this->waitForPageToLoad($this->getTimeoutMsec()); + + //Add State field to profile + $this->click('field_name[0]'); + $this->select('field_name[0]', 'value=Contact'); + $this->click("//option[@value='Contact']"); + $this->click('field_name[1]'); + $this->select('field_name[1]', 'value=state_province'); + $this->click("xpath=//select[@id='field_name_1']/option[@value='state_province']"); + $this->click('is_required'); + //click on save + $this->click('_qf_Field_next'); + $this->waitForPageToLoad($this->getTimeoutMsec()); + + if($gid) { + $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"); - + $newCountry = array(); foreach($country as $countryID => $countryName) { if(!in_array($countryName, $enabledCountries)) { + $newCountry[$countryID] = $countryName; $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']"); @@ -63,22 +99,48 @@ class WebTest_Profile_ProfileCountryState extends CiviSeleniumTestCase { $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->openCiviPage("profile/create", "gid=$gid&reset=1", NULL); - $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"); + sleep(2); $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); + $this->openCiviPage('admin/uf/group', 'reset=1'); + $this->waitForElementPresent("xpath=//div[@id='user-profiles']/div/div/table/tbody//tr/td/span[text() = '$profileTitle']/../../td[7]/span[2][text()='more']/ul/li[4]/a[text()='Delete']"); + $this->click("xpath=//div[@id='user-profiles']/div/div/table/tbody//tr/td/span[text() = '$profileTitle']/../../td[7]/span[2][text()='more']/ul/li[4]/a[text()='Delete']"); + + $this->waitForElementPresent('_qf_Group_next-bottom'); + $this->click('_qf_Group_next-bottom'); + $this->waitForElementPresent('newCiviCRMProfile-bottom'); + $this->waitForText('crm-notification-container', "Profile '{$profileTitle}' has been deleted."); + + $this->openCiviPage("admin/setting/localization", "reset=1", "_qf_Localization_next-bottom"); + $enabledCountries = $this->getSelectOptions("countryLimit-t"); + $enabledStates = $this->getSelectOptions("provinceLimit-t"); + $removed = false; + foreach($newCountry as $countryID => $countryName) { + $this->addSelection("countryLimit-t", "label=$countryName"); + $this->click("xpath=//select[@id='countryLimit-t']/option[@value='$countryID']"); + $this->click("xpath=//tr[@class='crm-localization-form-block-countryLimit']/td[2]/table//tbody/tr/td[2]/input[@name='remove']"); + + $this->addSelection("provinceLimit-t", "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='remove']"); + $removed = true; + } + if ($removed) { + $this->click("_qf_Localization_next-bottom"); + $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForText('crm-notification-container', "Saved"); + } } } } \ No newline at end of file diff --git a/tests/phpunit/WebTest/Profile/xml/CountryStateWebtest.xml b/tests/phpunit/WebTest/Profile/xml/CountryStateWebtest.xml deleted file mode 100644 index 87ad9bd13e..0000000000 --- a/tests/phpunit/WebTest/Profile/xml/CountryStateWebtest.xml +++ /dev/null @@ -1,115 +0,0 @@ - - - - - - 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 - - - -- 2.25.1