From bb183ede23d1af1d26468582d01bb679ce76e41e Mon Sep 17 00:00:00 2001 From: diosmosis <benaka@piwik.pro> Date: Thu, 11 Jun 2015 15:48:49 -0700 Subject: [PATCH] Workaround phpunit class loading issue caused by testing environment variables. Sometimes a test case class will be loaded before phpunit starts running (ie, in bootstrap.php), which causes the phpunit file loader to fail if a path to a test file is specified on the command line. --- tests/PHPUnit/bootstrap.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/PHPUnit/bootstrap.php b/tests/PHPUnit/bootstrap.php index 661b37ab38..2b3cdf0146 100644 --- a/tests/PHPUnit/bootstrap.php +++ b/tests/PHPUnit/bootstrap.php @@ -46,7 +46,13 @@ if (getenv('PIWIK_USE_XHPROF') == 1) { // setup container for tests function setupRootContainer() { - Environment::setGlobalEnvironmentManipulator(new TestingEnvironmentManipulator(new TestingEnvironmentVariables())); + // before running tests, delete the TestingEnvironmentVariables file, since it can indirectly mess w/ + // phpunit's class loading (if a test class is loaded in bootstrap.php, phpunit can't load it from a file, + // so executing the tests in a file will fail) + $vars = new TestingEnvironmentVariables(); + $vars->delete(); + + Environment::setGlobalEnvironmentManipulator(new TestingEnvironmentManipulator($vars)); $rootTestEnvironment = new \Piwik\Application\Environment(null); $rootTestEnvironment->init(); -- GitLab