diff --git a/config/application.config.php b/config/application.config.php
index d72316b3f27ed88885ccda1136ece11f22e4933d..cd399ba68aa961505e41cc0d9b53ea044942e339 100644
--- a/config/application.config.php
+++ b/config/application.config.php
@@ -5,7 +5,7 @@ $modules = [
     'Zend\Router', 'ZfcRbac',
     'VuFindTheme', 'VuFindSearch', 'VuFind', 'VuFindAdmin', 'VuFindApi'
 ];
-if (PHP_SAPI == 'cli' && !defined('VUFIND_PHPUNIT_RUNNING')) {
+if (PHP_SAPI == 'cli' && APPLICATION_ENV !== 'testing') {
     $modules[] = 'Zend\Mvc\Console';
     $modules[] = 'VuFindConsole';
 }
@@ -52,7 +52,7 @@ if (!is_dir($cacheDir)) {
 }
 
 // Enable caching unless in dev mode or running tests:
-$useCache = APPLICATION_ENV != 'development' && !defined('VUFIND_PHPUNIT_RUNNING');
+$useCache = APPLICATION_ENV != 'development' && APPLICATION_ENV != 'testing';
 
 // Build configuration:
 return [
diff --git a/module/VuFind/src/VuFind/Cookie/CookieManager.php b/module/VuFind/src/VuFind/Cookie/CookieManager.php
index fb28e15413b1b303caa6a2951e2b316889023967..411d30fe63aad2c05c757bc9a3d70afd8de145a6 100644
--- a/module/VuFind/src/VuFind/Cookie/CookieManager.php
+++ b/module/VuFind/src/VuFind/Cookie/CookieManager.php
@@ -163,8 +163,8 @@ class CookieManager
      */
     public function proxySetCookie()
     {
-        // Special case: in test suite or CLI -- don't actually write headers!
-        return defined('VUFIND_PHPUNIT_RUNNING') || 'cli' === PHP_SAPI
+        // Special case: in CLI -- don't actually write headers!
+        return 'cli' === PHP_SAPI
             ? true : call_user_func_array('setcookie', func_get_args());
     }
 
diff --git a/module/VuFind/tests/bootstrap.php b/module/VuFind/tests/bootstrap.php
index 2940cf01b56056d4031e5fc1567c9eba5fefe1ae..05bef2d6ab8e1119670aaa94d2bdd412d51094fc 100644
--- a/module/VuFind/tests/bootstrap.php
+++ b/module/VuFind/tests/bootstrap.php
@@ -1,8 +1,5 @@
 <?php
 
-// Set flag that we're in test mode
-define('VUFIND_PHPUNIT_RUNNING', 1);
-
 // Set path to this module
 define('VUFIND_PHPUNIT_MODULE_PATH', __DIR__);