From b036b8acc0835126e76814abdd76da4d80d4b0fc Mon Sep 17 00:00:00 2001 From: shadlaws Date: Sun, 10 Mar 2013 11:27:10 +0100 Subject: Follow-on fix: if tests throw an exception, don't throw another by calling an undefined variable. --- modules/gallery_unit_test/controllers/gallery_unit_test.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'modules') diff --git a/modules/gallery_unit_test/controllers/gallery_unit_test.php b/modules/gallery_unit_test/controllers/gallery_unit_test.php index 3275d741..6b2bf479 100644 --- a/modules/gallery_unit_test/controllers/gallery_unit_test.php +++ b/modules/gallery_unit_test/controllers/gallery_unit_test.php @@ -145,9 +145,14 @@ class Gallery_Unit_Test_Controller extends Controller { print $e->getTraceAsString() . "\n"; } - $failed = 0; - foreach ($unit_test->stats as $class => $stats) { - $failed += ($stats["failed"] + $stats["errors"]); + if (!isset($unit_test)) { + // If an exception is thrown, it's possible that $unit_test was never set. + $failed = 1; + } else { + $failed = 0; + foreach ($unit_test->stats as $class => $stats) { + $failed += ($stats["failed"] + $stats["errors"]); + } } if (PHP_SAPI == 'cli') { exit($failed); -- cgit v1.2.3