From d3f2fd13927846c7b00144ab3c20136f6e74b93c Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 17 Aug 2015 19:43:52 -0700 Subject: [PATCH] CRM-16373 - WebTest_Member - Remove references to CRM_Core_Config_Variables --- tests/phpunit/CiviTest/CiviSeleniumTestCase.php | 17 +++++++++++++++++ .../WebTest/Member/FixedMembershipTypeTest.php | 12 ++++-------- .../WebTest/Member/InheritedMembershipTest.php | 5 ++--- .../Member/OfflineMembershipAddPricesetTest.php | 6 ++---- .../Member/OnlineMembershipAddPricesetTest.php | 6 ++---- 5 files changed, 27 insertions(+), 19 deletions(-) diff --git a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php index 8e04a51bd6..7502e60893 100644 --- a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php +++ b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php @@ -48,6 +48,8 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { // Current logged-in user protected $loggedInAs = NULL; + private $settingCache; + /** * Constructor. * @@ -101,6 +103,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { if (property_exists($this->settings, 'rcPort') && $this->settings->rcPort) { $this->setPort($this->settings->rcPort); } + $this->settingCache = array(); } /** @@ -415,6 +418,20 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { return $_config_backend[$field]; } + /** + * @param string $field + * @return mixed + */ + public function webtestGetSetting($field) { + if (!isset($this->settingCache[$field])) { + $result = $this->webtest_civicrm_api("Setting", "getsingle", array( + 'return' => $field, + )); + $this->settingCache[$field] = $result[$field]; + } + return $this->settingCache[$field]; + } + /** * Ensures the required CiviCRM components are enabled. * @param $components diff --git a/tests/phpunit/WebTest/Member/FixedMembershipTypeTest.php b/tests/phpunit/WebTest/Member/FixedMembershipTypeTest.php index 33f41b57a2..318e141e94 100644 --- a/tests/phpunit/WebTest/Member/FixedMembershipTypeTest.php +++ b/tests/phpunit/WebTest/Member/FixedMembershipTypeTest.php @@ -136,13 +136,12 @@ class WebTest_Member_FixedMembershipTypeTest extends CiviSeleniumTestCase { // expected calc'd end date $endDate = date('Y-m-d', mktime(0, 0, 0, 3, 31, $nextYear)); - $configVars = new CRM_Core_Config_Variables(); foreach (array( 'joinDate', 'startDate', 'endDate', ) as $date) { - $$date = CRM_Utils_Date::customFormat($$date, $configVars->dateformatFull); + $$date = CRM_Utils_Date::customFormat($$date, $this->webtestGetSetting('dateformatFull')); } $query = " @@ -295,13 +294,12 @@ SELECT end_event_adjust_interval // expected calc'd end date $endDate = date('Y-m-d', mktime(0, 0, 0, 8, 31, $currentYear + 2)); - $configVars = new CRM_Core_Config_Variables(); foreach (array( 'joinDate', 'startDate', 'endDate', ) as $date) { - $$date = CRM_Utils_Date::customFormat($$date, $configVars->dateformatFull); + $$date = CRM_Utils_Date::customFormat($$date, $this->webtestGetSetting('dateformatFull')); } $query = " @@ -447,13 +445,12 @@ SELECT end_event_adjust_interval $joinDate = date('Y-m-d', mktime(0, 0, 0, 11, 15, $currentYear)); $startDate = date('Y-m-d', mktime(0, 0, 0, 1, 1, $currentYear)); $endDate = date('Y-m-d', mktime(0, 0, 0, 12, 31, $nextYear)); - $configVars = new CRM_Core_Config_Variables(); foreach (array( 'joinDate', 'startDate', 'endDate', ) as $date) { - $$date = CRM_Utils_Date::customFormat($$date, $configVars->dateformatFull); + $$date = CRM_Utils_Date::customFormat($$date, $this->webtestGetSetting('dateformatFull')); } $query = " @@ -601,13 +598,12 @@ SELECT end_event_adjust_interval // expected calc'd start and end dates $startDate = date('Y-m-d', mktime(0, 0, 0, 1, 1, $currentYear)); $endDate = date('Y-m-d', mktime(0, 0, 0, 12, 31, $currentYear)); - $configVars = new CRM_Core_Config_Variables(); foreach (array( 'joinDate', 'startDate', 'endDate', ) as $date) { - $$date = CRM_Utils_Date::customFormat($$date, $configVars->dateformatFull); + $$date = CRM_Utils_Date::customFormat($$date, $this->webtestGetSetting('dateformatFull')); } $query = " diff --git a/tests/phpunit/WebTest/Member/InheritedMembershipTest.php b/tests/phpunit/WebTest/Member/InheritedMembershipTest.php index b886cf4bde..47b506d468 100644 --- a/tests/phpunit/WebTest/Member/InheritedMembershipTest.php +++ b/tests/phpunit/WebTest/Member/InheritedMembershipTest.php @@ -35,7 +35,7 @@ class WebTest_Member_InheritedMembershipTest extends CiviSeleniumTestCase { } public function testInheritedMembership() { - $this->markTestSkipped('Skipping for now as it works fine locally.'); + //$this->markTestSkipped('Skipping for now as it works fine locally.'); // Log in using webtestLogin() method $this->webtestLogin(); @@ -115,13 +115,12 @@ class WebTest_Member_InheritedMembershipTest extends CiviSeleniumTestCase { $joinDate = date('Y-m-d'); $startDate = date('Y-m-d'); $endDate = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') - 1, date('Y') + 1)); - $configVars = new CRM_Core_Config_Variables(); foreach (array( 'joinDate', 'startDate', 'endDate', ) as $date) { - $$date = CRM_Utils_Date::customFormat($$date, $configVars->dateformatFull); + $$date = CRM_Utils_Date::customFormat($$date, $this->webtestGetSetting('dateformatFull')); } $this->webtestVerifyTabularData( diff --git a/tests/phpunit/WebTest/Member/OfflineMembershipAddPricesetTest.php b/tests/phpunit/WebTest/Member/OfflineMembershipAddPricesetTest.php index 62a540792d..3c3273656b 100644 --- a/tests/phpunit/WebTest/Member/OfflineMembershipAddPricesetTest.php +++ b/tests/phpunit/WebTest/Member/OfflineMembershipAddPricesetTest.php @@ -309,13 +309,12 @@ class WebTest_Member_OfflineMembershipAddPricesetTest extends CiviSeleniumTestCa $joinDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear)); $startDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear)); $endDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, $previousDay, $endYear)); - $configVars = new CRM_Core_Config_Variables(); foreach (array( 'joinDate', 'startDate', 'endDate', ) as $date) { - $$date = CRM_Utils_Date::customFormat($$date, $configVars->dateformatFull); + $$date = CRM_Utils_Date::customFormat($$date, $this->webtestGetSetting('dateformatFull')); } if (!$renew) { @@ -402,13 +401,12 @@ class WebTest_Member_OfflineMembershipAddPricesetTest extends CiviSeleniumTestCa $joinDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear)); $startDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear)); $endDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, $previousDay, $endYear)); - $configVars = new CRM_Core_Config_Variables(); foreach (array( 'joinDate', 'startDate', 'endDate', ) as $date) { - $$date = CRM_Utils_Date::customFormat($$date, $configVars->dateformatFull); + $$date = CRM_Utils_Date::customFormat($$date, $this->webtestGetSetting('dateformatFull')); } $this->click('css=li#tab_member a'); diff --git a/tests/phpunit/WebTest/Member/OnlineMembershipAddPricesetTest.php b/tests/phpunit/WebTest/Member/OnlineMembershipAddPricesetTest.php index c60496e86f..4de10d433f 100644 --- a/tests/phpunit/WebTest/Member/OnlineMembershipAddPricesetTest.php +++ b/tests/phpunit/WebTest/Member/OnlineMembershipAddPricesetTest.php @@ -321,13 +321,12 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas $joinDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear)); $startDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear)); $endDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, $previousDay, $endYear)); - $configVars = new CRM_Core_Config_Variables(); foreach (array( 'joinDate', 'startDate', 'endDate', ) as $date) { - $$date = CRM_Utils_Date::customFormat($$date, $configVars->dateformatFull); + $$date = CRM_Utils_Date::customFormat($$date, $this->webtestGetSetting('dateformatFull')); } $this->click("xpath=//div[@id='priceset']/div[2]/div[2]/div/span/input"); @@ -446,13 +445,12 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas $joinDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear)); $startDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear)); $endDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, $previousDay, $endYear)); - $configVars = new CRM_Core_Config_Variables(); foreach (array( 'joinDate', 'startDate', 'endDate', ) as $date) { - $$date = CRM_Utils_Date::customFormat($$date, $configVars->dateformatFull); + $$date = CRM_Utils_Date::customFormat($$date, $this->webtestGetSetting('dateformatFull')); } $i = ($term == 3) ? 3 : (($term == 2) ? 2 : 1); $this->waitForElementPresent("xpath=//div[@id='priceset']/div[2]/div[2]/div[$i]/span/input"); -- 2.25.1