From c0bc3902f095f893ecf256039f3f8ab16fdcb439 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 3 Apr 2014 22:16:10 -0700 Subject: [PATCH] CRM-14423 - Run env checks before executing tests --- CRM/Utils/Check.php | 14 ++++++++++++++ tests/phpunit/CiviTest/CiviUnitTestCase.php | 2 ++ 2 files changed, 16 insertions(+) diff --git a/CRM/Utils/Check.php b/CRM/Utils/Check.php index 08b8d7af7c..9b13b0db7a 100644 --- a/CRM/Utils/Check.php +++ b/CRM/Utils/Check.php @@ -79,6 +79,20 @@ class CRM_Utils_Check { } } + /** + * Throw an exception if any of the checks fail + */ + public function assertValid() { + $messages = $this->checkAll(); + if (!empty($messages)) { + $messagesAsArray = array(); + foreach ($messages as $message) { + $messagesAsArray[] = $message->toArray(); + } + throw new Exception('There are configuration problems with this installation: ' . print_r($messagesAsArray, TRUE)); + } + } + /** * Run some sanity checks. * diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index 1151b5e2c4..118fde48ce 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -306,6 +306,8 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { // also set this global hack $GLOBALS['_PEAR_ERRORSTACK_OVERRIDE_CALLBACK'] = array(); + + CRM_Utils_Check::singleton()->assertValid(); } /** -- 2.25.1