summaryrefslogtreecommitdiff
path: root/modules/unit_test
diff options
context:
space:
mode:
Diffstat (limited to 'modules/unit_test')
-rw-r--r--modules/unit_test/i18n/en_US/unit_test.php2
-rw-r--r--modules/unit_test/libraries/Unit_Test.php20
-rw-r--r--modules/unit_test/views/kohana_unit_test_cli.php36
3 files changed, 52 insertions, 6 deletions
diff --git a/modules/unit_test/i18n/en_US/unit_test.php b/modules/unit_test/i18n/en_US/unit_test.php
index 34ff1c11..a4ec7c57 100644
--- a/modules/unit_test/i18n/en_US/unit_test.php
+++ b/modules/unit_test/i18n/en_US/unit_test.php
@@ -2,6 +2,8 @@
$lang = array
(
+ 'class' => 'Class',
+ 'method' => 'Method',
'invalid_test_path' => 'Failed to open test path: %s.',
'duplicate_test_class' => 'Duplicate test class named %s found in %s.',
'test_class_not_found' => 'No test class by the name of %s found in %s.',
diff --git a/modules/unit_test/libraries/Unit_Test.php b/modules/unit_test/libraries/Unit_Test.php
index cf8b85f0..debf53ab 100644
--- a/modules/unit_test/libraries/Unit_Test.php
+++ b/modules/unit_test/libraries/Unit_Test.php
@@ -211,13 +211,21 @@ class Unit_Test_Core {
// Hide passed tests from the report?
$hide_passed = (bool) (($hide_passed !== NULL) ? $hide_passed : Kohana::config('unit_test.hide_passed', FALSE, FALSE));
-
+
+
+ if (PHP_SAPI == 'cli')
+ {
+ $report = View::factory('kohana_unit_test_cli');
+ }
+ else
+ {
+ $report = View::factory('kohana_unit_test');
+ }
// Render unit_test report
- return View::factory('kohana_unit_test')
- ->set('results', $this->results)
- ->set('stats', $this->stats)
- ->set('hide_passed', $hide_passed)
- ->render();
+ return $report->set('results', $this->results)
+ ->set('stats', $this->stats)
+ ->set('hide_passed', $hide_passed)
+ ->render();
}
/**
diff --git a/modules/unit_test/views/kohana_unit_test_cli.php b/modules/unit_test/views/kohana_unit_test_cli.php
new file mode 100644
index 00000000..b0a9b6d4
--- /dev/null
+++ b/modules/unit_test/views/kohana_unit_test_cli.php
@@ -0,0 +1,36 @@
+<?php defined('SYSPATH') OR die('No direct access allowed.');
+
+foreach ($results as $class => $methods)
+{
+ echo "\n\n" . Kohana::lang('unit_test.class') . ': ' . $class . "\n\n";
+ printf('%s: %.2f%%', Kohana::lang('unit_test.score'), $stats[$class]['score']);
+ echo ",\n" . Kohana::lang('unit_test.total'), ': ', $stats[$class]['total'] . ",\n";
+ echo Kohana::lang('unit_test.passed'), ': ', $stats[$class]['passed'] . ",\n";
+ echo Kohana::lang('unit_test.failed'), ': ', $stats[$class]['failed'] . ",\n";
+ echo Kohana::lang('unit_test.errors'), ': ', $stats[$class]['errors'] . "\n\n";
+
+ if (empty($methods))
+ {
+ echo Kohana::lang('unit_test.no_tests_found');
+ }
+ else
+ {
+ foreach ($methods as $method => $result)
+ {
+ // Hide passed tests from report
+ if ($result === TRUE AND $hide_passed === TRUE)
+ continue;
+
+ echo Kohana::lang('unit_test.method') . ': ' . $method . ': ';
+
+ if ($result === TRUE)
+ {
+ echo Kohana::lang('unit_test.passed') . "\n";
+ }
+ else
+ {
+ echo Kohana::lang('unit_test.failed') . "\n\t" . $result->getMessage() . "\n";
+ }
+ }
+ }
+} \ No newline at end of file