diff options
Diffstat (limited to 'modules/gallery_unit_test')
-rw-r--r-- | modules/gallery_unit_test/controllers/test.php | 28 | ||||
-rw-r--r-- | modules/gallery_unit_test/views/kohana_unit_test.php | 58 |
2 files changed, 86 insertions, 0 deletions
diff --git a/modules/gallery_unit_test/controllers/test.php b/modules/gallery_unit_test/controllers/test.php new file mode 100644 index 00000000..de3a3410 --- /dev/null +++ b/modules/gallery_unit_test/controllers/test.php @@ -0,0 +1,28 @@ +<?php +/* + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2008 Bharat Mediratta + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + */ +class Test_Controller extends Controller { + function Index() { + if (!defined('TEST_MODE')) { + print Kohana::show_404(); + } + $test = new Unit_Test(DOCROOT . "modules/gallery_unit_test/tests"); + echo $test; + } +} diff --git a/modules/gallery_unit_test/views/kohana_unit_test.php b/modules/gallery_unit_test/views/kohana_unit_test.php new file mode 100644 index 00000000..2201245c --- /dev/null +++ b/modules/gallery_unit_test/views/kohana_unit_test.php @@ -0,0 +1,58 @@ +<?php +foreach ($results as $class => $methods) { + echo str_repeat("-", 100), "\n"; + echo $class, "\n"; + echo str_repeat("-", 100), "\n"; + + foreach (array("score", "total", "passed", "failed", "errors") as $key) { + @$totals[$key] += $stats[$class][$key]; + } + + if (empty($methods)) { + echo Kohana::lang("unit_test.no_tests_found"), "\n"; + } else { + foreach ($methods as $method => $result) { + // Hide passed tests from report + if ($result === true AND $hide_passed === true) { + continue; + } + printf("%-40.40s", $method); + if ($result === true) { + echo Kohana::lang("unit_test.passed"), "\n"; + } else if ($result instanceof Kohana_Unit_Test_Exception) { + echo Kohana::lang("unit_test.failed"), "\n"; + echo " ", html::specialchars($result->getMessage()), "\n"; + echo " ", html::specialchars($result->getFile()); + echo " ", "(" . Kohana::lang("unit_test.line") . " " . $result->getLine(), ")\n"; + if ($result->getDebug() !== null) { + echo " ", "(", gettype($result->getDebug()), ") ", + html::specialchars(var_export($result->getDebug(), true)), "\n"; + } + } else if ($result instanceof Exception) { + echo Kohana::lang("unit_test.error"), "\n"; + if ($result->getMessage()) { + echo " ", html::specialchars($result->getMessage()), "\n"; + } + echo " ", html::specialchars($result->getFile()), " (", + Kohana::lang("unit_test.line"), " ", $result->getLine(), ")\n"; + } + } + } + + echo str_repeat("=", 100), "\n"; + printf(">> %s\t%s: %.2f%%\t%s: %d\t%s: %d\t%s: %d\t%s: %d\n", + $class, + Kohana::lang("unit_test.score"), $stats[$class]["score"], + Kohana::lang("unit_test.total"), $stats[$class]["total"], + Kohana::lang("unit_test.passed"), $stats[$class]["passed"], + Kohana::lang("unit_test.failed"), $stats[$class]["failed"], + Kohana::lang("unit_test.errors"), $stats[$class]["errors"]); + echo str_repeat("-", 100), "\n\n\n"; +} + +printf(">> TOTAL\t%s: %.2f%%\t%s: %d\t%s: %d\t%s: %d\t%s: %d\n", + Kohana::lang("unit_test.score"), 100 * ($totals["passed"] / $totals["total"]), + Kohana::lang("unit_test.total"), $totals["total"], + Kohana::lang("unit_test.passed"), $totals["passed"], + Kohana::lang("unit_test.failed"), $totals["failed"], + Kohana::lang("unit_test.errors"), $totals["errors"]); |