Changeset 2283

Show
Ignore:
Timestamp:
03/11/2008 03:45:27 AM (9 months ago)
Author:
Geert
Message:

Added unit_test.hide_passed config option to allow a more compact test report by hiding the passed tests.

Location:
trunk/modules/unit_test
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/modules/unit_test/config/unit_test.php

    r2279 r2283  
    66 */ 
    77$config['paths'] = array(); 
     8 
     9/** 
     10 * Set to TRUE if you want to hide passed tests from the report. 
     11 */ 
     12$config['hide_passed'] = FALSE; 
  • trunk/modules/unit_test/libraries/Unit_Test.php

    r2279 r2283  
    139139         * Generates nice test results. 
    140140         * 
    141          * @return  string  rendered test results html 
    142          */ 
    143         public function report() 
    144         { 
     141         * @param   boolean  hide passed tests from the report 
     142         * @return  string   rendered test results html 
     143         */ 
     144        public function report($hide_passed = NULL) 
     145        { 
     146                // No tests found 
    145147                if (empty($this->results)) 
    146                         return ''; 
    147  
     148                        return Kohana::lang('unit_test.no_tests_found'); 
     149 
     150                // Hide passed tests from the report? 
     151                $hide_passed = (bool) (($hide_passed !== NULL) ? $hide_passed : Config::item('unit_test.hide_passed', FALSE, FALSE)); 
     152 
     153                // Render unit_test report 
    148154                return View::factory('kohana_unit_test') 
    149155                        ->set('results', $this->results) 
    150156                        ->set('stats', $this->stats) 
     157                        ->set('hide_passed', $hide_passed) 
    151158                        ->render(); 
    152159        } 
  • trunk/modules/unit_test/views/kohana_unit_test.php

    r2278 r2283  
    109109                        foreach ($methods as $method => $result): 
    110110 
    111                         ?> 
     111                                // Hide passed tests from report 
     112                                if ($result === TRUE AND $hide_passed === TRUE) 
     113                                        continue; 
     114 
     115                                ?> 
    112116 
    113117                                <tr class="<?php echo text::alternate('', 'k-altrow') ?>"> 
     
    118122                                                <td class="k-passed"><strong><?php echo Kohana::lang('unit_test.passed') ?></strong></td> 
    119123 
    120                                         <?php else: /* $result == Kohana_Unit_Test_Exception */ ?> 
     124                                        <?php elseif ($result instanceof Kohana_Unit_Test_Exception): ?> 
    121125 
    122126                                                <td class="k-failed">