CRM-16373 - WebTest_Member - Remove references to CRM_Core_Config_Variables
authorTim Otten <totten@civicrm.org>
Tue, 18 Aug 2015 02:43:52 +0000 (19:43 -0700)
committerTim Otten <totten@civicrm.org>
Tue, 18 Aug 2015 07:11:32 +0000 (00:11 -0700)
tests/phpunit/CiviTest/CiviSeleniumTestCase.php
tests/phpunit/WebTest/Member/FixedMembershipTypeTest.php
tests/phpunit/WebTest/Member/InheritedMembershipTest.php
tests/phpunit/WebTest/Member/OfflineMembershipAddPricesetTest.php
tests/phpunit/WebTest/Member/OnlineMembershipAddPricesetTest.php

index 8e04a51bd69029c0ef60cb67a4de94bef433ca1c..7502e6089391b5c89fd436b2d8a21b40fb1f8e33 100644 (file)
@@ -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
index 33f41b57a26d5d554db5bf4fdb5a1fc2f29d9056..318e141e94d2d3b5dd6b02fb22a1e0b6b9a1b6a8 100644 (file)
@@ -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 = "
index b886cf4bde73840feb7c841820f601470bbba31f..47b506d468ef1974052ced3b78e0e8af14888ac1 100644 (file)
@@ -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(
index 62a540792d5c9f8ee1a99fce56f5ec01e1413121..3c3273656b3810f2c720635bd562378997f46f88 100644 (file)
@@ -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');
index c60496e86ffeb31835ef1886db0b2e1229d4c2c6..4de10d433fb428bea641b5cd916e9345a235f525 100644 (file)
@@ -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");