From 0a4cd490aecc76e9783586f5fc692e63e7918357 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 22 Jan 2016 03:50:10 -0800 Subject: [PATCH] CRM-17860 - CiviUnitTestCase/ExternalBatch - Work with unified civicrm.settings.php --- Civi/API/ExternalBatch.php | 3 +++ .../CRM/common/civicrm.settings.php.template | 7 ++++++- tests/phpunit/CiviTest/CiviUnitTestCase.php | 1 - tests/phpunit/CiviTest/bootstrap.php | 5 ----- .../CiviTest/civicrm.settings.local.php.txt | 16 ---------------- 5 files changed, 9 insertions(+), 23 deletions(-) delete mode 100644 tests/phpunit/CiviTest/civicrm.settings.local.php.txt diff --git a/Civi/API/ExternalBatch.php b/Civi/API/ExternalBatch.php index 1ff9282d0a..f153795021 100644 --- a/Civi/API/ExternalBatch.php +++ b/Civi/API/ExternalBatch.php @@ -51,6 +51,9 @@ class ExternalBatch { $this->root = $civicrm_root; $this->settingsPath = defined('CIVICRM_SETTINGS_PATH') ? CIVICRM_SETTINGS_PATH : NULL; $this->defaultParams = $defaultParams; + $this->addEnv(array( + 'CIVICRM_UF' => CIVICRM_UF, + )); } /** diff --git a/templates/CRM/common/civicrm.settings.php.template b/templates/CRM/common/civicrm.settings.php.template index f5f4cc2cdf..33b8c5d26c 100644 --- a/templates/CRM/common/civicrm.settings.php.template +++ b/templates/CRM/common/civicrm.settings.php.template @@ -54,7 +54,12 @@ * (Administer::System Settings::Resource URLs). */ if (!defined('CIVICRM_UF')) { - define( 'CIVICRM_UF', '%%cms%%'); + if (getenv('CIVICRM_UF')) { + define('CIVICRM_UF', getenv('CIVICRM_UF')); + } + else { + define('CIVICRM_UF', '%%cms%%'); + } } /** diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index ee73850bb3..2e7fbf1f09 100755 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -920,7 +920,6 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { ); $calls = new \Civi\API\ExternalBatch($defaultParams); - $calls->setSettingsPath("$civicrm_root/tests/phpunit/CiviTest/civicrm.settings.cli.php"); if (!$calls->isSupported()) { $this->markTestSkipped('The test relies on Civi\API\ExternalBatch. This is unsupported in the local environment.'); diff --git a/tests/phpunit/CiviTest/bootstrap.php b/tests/phpunit/CiviTest/bootstrap.php index b87d9e2522..955ce7ef1f 100644 --- a/tests/phpunit/CiviTest/bootstrap.php +++ b/tests/phpunit/CiviTest/bootstrap.php @@ -16,11 +16,6 @@ if (file_exists('/etc/timezone')) { # Crank up the memory ini_set('memory_limit', '2G'); -// TODO Consider moving into main civicrm.settings.php so that `cv('api')` works better. -if (!defined('CIVICRM_UF') && getenv('CIVICRM_UF')) { - define('CIVICRM_UF', getenv('CIVICRM_UF')); -} - eval(cv('php:boot --test', 1)); // This is exists to support CiviUnitTestCase::populateDB(). That doesn't make it a good idea. diff --git a/tests/phpunit/CiviTest/civicrm.settings.local.php.txt b/tests/phpunit/CiviTest/civicrm.settings.local.php.txt deleted file mode 100644 index e60f9bdcb9..0000000000 --- a/tests/phpunit/CiviTest/civicrm.settings.local.php.txt +++ /dev/null @@ -1,16 +0,0 @@ -