From c87c6f6859d4406e3c7022f2b2c5507190a34dc1 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 18 May 2009 00:16:37 +0000 Subject: There's a new view for CLI unit test output in the Unit_Test library --- .../gallery_unit_test/views/kohana_unit_test.php | 84 ---------------------- .../views/kohana_unit_test_cli.php | 84 ++++++++++++++++++++++ 2 files changed, 84 insertions(+), 84 deletions(-) delete mode 100644 modules/gallery_unit_test/views/kohana_unit_test.php create mode 100644 modules/gallery_unit_test/views/kohana_unit_test_cli.php (limited to 'modules/gallery_unit_test') diff --git a/modules/gallery_unit_test/views/kohana_unit_test.php b/modules/gallery_unit_test/views/kohana_unit_test.php deleted file mode 100644 index 29990785..00000000 --- a/modules/gallery_unit_test/views/kohana_unit_test.php +++ /dev/null @@ -1,84 +0,0 @@ - - $methods) { - echo "+", str_repeat("-", 98), "+\n"; - printf("| %-96.96s |\n", $class); - echo "+", str_repeat("-", 87), "+", str_repeat("-", 10), "+\n"; - - foreach (array("score", "total", "passed", "failed", "errors") as $key) { - @$totals[$key] += $stats[$class][$key]; - } - - if (empty($methods)) { - printf("| %s%-96.96s%s |\n", magenta_start(), "NO TESTS FOUND", color_end()); - } else { - foreach ($methods as $method => $result) { - // Hide passed tests from report - if ($result === true AND $hide_passed === true) { - continue; - } - if ($result === true) { - printf("| %s%-85.85s%s | %sPASS%s |\n", - green_start(), $method, color_end(), - green_start(), color_end()); - } else if ($result instanceof Kohana_Unit_Test_Exception) { - printf("| %s%-85.85s%s | %sFAIL%s |\n", - red_start(), $method, color_end(), - red_start(), color_end()); - echo " ", $result->getMessage(), "\n"; - echo " ", $result->getFile(); - echo " ", "(" . Kohana::lang("unit_test.line") . " " . $result->getLine(), ")\n"; - if ($result->getDebug() !== null) { - echo " ", "(", gettype($result->getDebug()), ") ", - var_export($result->getDebug(), true), "\n"; - } - echo "\n"; - } else if ($result instanceof Exception) { - printf("| %s%-85.85s%s | %sERROR%s |\n", - magenta_start(), $method, color_end(), - magenta_start(), color_end()); - if ($result->getMessage()) { - echo " ", $result->getMessage(), "\n"; - } - echo " ", $result->getFile(), " (Line ", $result->getLine(), ")\n"; - echo "\n"; - echo $result->getTraceAsString(), "\n"; - } - } - } - - echo "+", str_repeat("=", 87), "+", str_repeat("=", 10), "+\n"; - printf("| %-40.40s %-13.13s %-13.13s %-13.13s %-13.13s |\n", - $class, - "Score: {$stats[$class]['score']}", - "Total: {$stats[$class]['total']}", - "PASS: {$stats[$class]['passed']}", - "FAIL: {$stats[$class]['failed']}", - "ERROR: {$stats[$class]['errors']}"); - echo "+", str_repeat("=", 98), "+\n\n\n"; -} - -printf(" %-40.40s %-13.13s %-13.13s %-13.13s %-13.13s\n", - "TOTAL", - "Score: " . ($totals["total"] ? 100 * ($totals["passed"] / $totals["total"]) : 0), - "Total: {$totals['total']}", - "PASS: {$totals['passed']}", - "FAIL: {$totals['failed']}", - "ERROR: {$totals['errors']}"); diff --git a/modules/gallery_unit_test/views/kohana_unit_test_cli.php b/modules/gallery_unit_test/views/kohana_unit_test_cli.php new file mode 100644 index 00000000..29990785 --- /dev/null +++ b/modules/gallery_unit_test/views/kohana_unit_test_cli.php @@ -0,0 +1,84 @@ + + $methods) { + echo "+", str_repeat("-", 98), "+\n"; + printf("| %-96.96s |\n", $class); + echo "+", str_repeat("-", 87), "+", str_repeat("-", 10), "+\n"; + + foreach (array("score", "total", "passed", "failed", "errors") as $key) { + @$totals[$key] += $stats[$class][$key]; + } + + if (empty($methods)) { + printf("| %s%-96.96s%s |\n", magenta_start(), "NO TESTS FOUND", color_end()); + } else { + foreach ($methods as $method => $result) { + // Hide passed tests from report + if ($result === true AND $hide_passed === true) { + continue; + } + if ($result === true) { + printf("| %s%-85.85s%s | %sPASS%s |\n", + green_start(), $method, color_end(), + green_start(), color_end()); + } else if ($result instanceof Kohana_Unit_Test_Exception) { + printf("| %s%-85.85s%s | %sFAIL%s |\n", + red_start(), $method, color_end(), + red_start(), color_end()); + echo " ", $result->getMessage(), "\n"; + echo " ", $result->getFile(); + echo " ", "(" . Kohana::lang("unit_test.line") . " " . $result->getLine(), ")\n"; + if ($result->getDebug() !== null) { + echo " ", "(", gettype($result->getDebug()), ") ", + var_export($result->getDebug(), true), "\n"; + } + echo "\n"; + } else if ($result instanceof Exception) { + printf("| %s%-85.85s%s | %sERROR%s |\n", + magenta_start(), $method, color_end(), + magenta_start(), color_end()); + if ($result->getMessage()) { + echo " ", $result->getMessage(), "\n"; + } + echo " ", $result->getFile(), " (Line ", $result->getLine(), ")\n"; + echo "\n"; + echo $result->getTraceAsString(), "\n"; + } + } + } + + echo "+", str_repeat("=", 87), "+", str_repeat("=", 10), "+\n"; + printf("| %-40.40s %-13.13s %-13.13s %-13.13s %-13.13s |\n", + $class, + "Score: {$stats[$class]['score']}", + "Total: {$stats[$class]['total']}", + "PASS: {$stats[$class]['passed']}", + "FAIL: {$stats[$class]['failed']}", + "ERROR: {$stats[$class]['errors']}"); + echo "+", str_repeat("=", 98), "+\n\n\n"; +} + +printf(" %-40.40s %-13.13s %-13.13s %-13.13s %-13.13s\n", + "TOTAL", + "Score: " . ($totals["total"] ? 100 * ($totals["passed"] / $totals["total"]) : 0), + "Total: {$totals['total']}", + "PASS: {$totals['passed']}", + "FAIL: {$totals['failed']}", + "ERROR: {$totals['errors']}"); -- cgit v1.2.3