CRM-17860 - CiviUnitTestCase/ExternalBatch - Work with unified civicrm.settings.php
authorTim Otten <totten@civicrm.org>
Fri, 22 Jan 2016 11:50:10 +0000 (03:50 -0800)
committerTim Otten <totten@civicrm.org>
Tue, 2 Feb 2016 04:56:23 +0000 (21:56 -0700)
Civi/API/ExternalBatch.php
templates/CRM/common/civicrm.settings.php.template
tests/phpunit/CiviTest/CiviUnitTestCase.php
tests/phpunit/CiviTest/bootstrap.php
tests/phpunit/CiviTest/civicrm.settings.local.php.txt [deleted file]

index 1ff9282d0ad1326bd730fd808051ac963de9d362..f153795021b5e0464fcdb31f6b62871f4afe4a25 100644 (file)
@@ -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,
+    ));
   }
 
   /**
index f5f4cc2cdf21c59648cf6b62bcef7cba33c55e6d..33b8c5d26c45ad6a3f5664a89bb93da76b323258 100644 (file)
  * (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%%');
+  }
 }
 
 /**
index ee73850bb338c07b693be7eff2c919984e2cd150..2e7fbf1f09d9261e3cdea8acb1c24680508b250d 100755 (executable)
@@ -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.');
index b87d9e2522dbfe646fd17a1dffa5a6f2408dcc53..955ce7ef1fe5b249a8eee963e75f55678e749322 100644 (file)
@@ -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 (file)
index e60f9bd..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-<?php
-// Set a variable on your shell:
-//  export CIVICRM_TEST_DSN= mysql://db_username:db_password@localhost/civicrm_tests_dev
-// or modify and uncomment the configuration string under with your own config
-// This file is a template for applying local-only test configuration options.
-// It should be copied to "civicrm.settings.local.php".
-
-// For more details, see:
-// http://wiki.civicrm.org/confluence/display/CRM/Setting+up+your+personal+testing+sandbox+HOWTO
-
-// Set the data-source for the test database. Tables in this database will be periodically
-// deleted, truncated, etc.
-// define( 'CIVICRM_DSN', "mysql://db_username:db_password@localhost/civicrm_tests_dev" );
-
-// To disable auto-generation of files in api/v3/examples:
-// define('DONT_DOCUMENT_TEST_CONFIG', TRUE);