CRM-16189, moved the function from PseudoConstant to BAO
authorPradeep Nayak <pradpnayak@gmail.com>
Wed, 22 Jun 2016 21:20:42 +0000 (02:50 +0530)
committerPradeep Nayak <pradpnayak@gmail.com>
Wed, 22 Jun 2016 21:20:42 +0000 (02:50 +0530)
----------------------------------------
* CRM-16189: Improve support for Accrual Method bookkeeping
  https://issues.civicrm.org/jira/browse/CRM-16189

CRM/Contribute/BAO/Contribution.php
CRM/Contribute/PseudoConstant.php
tests/phpunit/CRM/Contribute/BAO/ContributionTest.php
tests/phpunit/CRM/Contribute/PseudoConstantTest.php [deleted file]

index c30c4b8cb326c923ad68f5a3b76f6a3dafa80a64..28ad9988b94aa3f1b877d30e3dc512c859bf54b5 100644 (file)
@@ -5028,4 +5028,22 @@ LIMIT 1;";
     return $values;
   }
 
+  /**
+   * Get values of CiviContribute Settings
+   * and check if its enabled or not.
+   *
+   *
+   * @param string $name
+   * @return string
+   *
+   */
+  public static function checkContributeSettings($name = NULL) {
+    $contributeSettings = Civi::settings()->get('contribution_invoice_settings');
+
+    if ($name) {
+      return CRM_Utils_Array::value($name, $contributeSettings);
+    }
+    return $contributeSettings;
+  }
+
 }
index 350181e4a9cdba720e3193b7f9b43bc881b0f61c..f5f79750b506b511384946c33f172ff9d7f8ad1c 100644 (file)
@@ -101,12 +101,6 @@ class CRM_Contribute_PseudoConstant extends CRM_Core_PseudoConstant {
    */
   private static $batch;
 
-  /**
-   * Get values of CiviContribute Settings
-   * @var array
-   */
-  private static $contributeSettings;
-
   /**
    * DEPRECATED. Please use the buildOptions() method in the appropriate BAO object.
    *
@@ -446,24 +440,4 @@ class CRM_Contribute_PseudoConstant extends CRM_Core_PseudoConstant {
     return self::$batch;
   }
 
-  /**
-   * Get values of CiviContribute Settings
-   * and check if its enabled or not
-   *
-   *
-   * @param string $name
-   * @return string
-   *
-   */
-  public static function checkContributeSettings($name = NULL) {
-    if (empty(self::$contributeSettings)) {
-      self::$contributeSettings = Civi::settings()->get('contribution_invoice_settings');
-    }
-
-    if ($name) {
-      return CRM_Utils_Array::value($name, self::$contributeSettings);
-    }
-    return self::$contributeSettings;
-  }
-
 }
index cc42f0c69a44d6c742c25bc429bed0cc678d65d3..b2173e5e42f559c951089b155b79280294362822 100644 (file)
@@ -830,4 +830,20 @@ WHERE eft.entity_id = %1 AND ft.to_financial_account_id <> %2";
     $this->assertEquals("$ 200.00 - STUDENT", $activity->subject, 'Check for total amount in activity.');
   }
 
+  /**
+   * Test checkContributeSettings.
+   */
+  public function testCheckContributeSettings() {
+    $settings = CRM_Contribute_BAO_Contribution::checkContributeSettings('deferred_revenue_enabled');
+    $this->assertNull($settings);
+    $params = array(
+      'contribution_invoice_settings' => array(
+        'deferred_revenue_enabled' => '1',
+      ),
+    );
+    $this->callAPISuccess('Setting', 'create', $params);
+    $settings = CRM_Contribute_BAO_Contribution::checkContributeSettings('deferred_revenue_enabled');
+    $this->assertEquals($settings, 1, 'Check for settings has failed');
+  }
+
 }
diff --git a/tests/phpunit/CRM/Contribute/PseudoConstantTest.php b/tests/phpunit/CRM/Contribute/PseudoConstantTest.php
deleted file mode 100644 (file)
index f402fe0..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7                                                |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2016                                |
- +--------------------------------------------------------------------+
- | 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 and the CiviCRM Licensing Exception 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        |
- +--------------------------------------------------------------------+
- */
-
-/**
- * Tests for pseudoconstant retrieval
- * @group headless
- */
-class CRM_Contribute_PseudoConstantTest extends CiviUnitTestCase {
-
-  public function setUp() {
-    parent::setUp();
-  }
-
-  /**
-   * Test checkContributeSettings.
-   */
-  public function testCheckContributeSettings() {
-    $settings = CRM_Contribute_PseudoConstant::checkContributeSettings('deferred_revenue_enabled');
-    $this->assertNull($settings);
-    CRM_Contribute_PseudoConstant::flush('contributeSettings');
-    $params = array(
-      'contribution_invoice_settings' => array(
-        'deferred_revenue_enabled' => '1',
-      ),
-    );
-    $this->callAPISuccess('Setting', 'create', $params);
-    $settings = CRM_Contribute_PseudoConstant::checkContributeSettings('deferred_revenue_enabled');
-    $this->assertEquals($settings, 1, "Check for settings has failed");
-  }
-
-}