From fd0c0a608a5de2b26c29d3c44a7929e5a3b2c042 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 18 May 2009 00:14:07 +0000 Subject: Updated kohana and modules/unit_test to upstream r4356 --- modules/unit_test/i18n/en_US/unit_test.php | 2 ++ modules/unit_test/libraries/Unit_Test.php | 20 +++++++++---- modules/unit_test/views/kohana_unit_test_cli.php | 36 ++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 modules/unit_test/views/kohana_unit_test_cli.php (limited to 'modules/unit_test') 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 @@ + $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 -- cgit v1.2.3