Changeset 2278
- Timestamp:
- 03/10/08 17:17:44 (6 months ago)
- Location:
- trunk/modules/unit_test
- Files:
-
- 4 modified
-
controllers/unit_test.php (modified) (1 diff)
-
i18n/en_US/unit_test.php (modified) (1 diff)
-
libraries/Unit_Test.php (modified) (5 diffs)
-
views/kohana_unit_test.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/unit_test/controllers/unit_test.php
r2267 r2278 17 17 { 18 18 // Run tests and show results! 19 $test = new Unit_Test(MODPATH.'unit_test/tests/'); 20 echo $test->report(); 19 echo new Unit_Test(MODPATH.'unit_test/tests'); 21 20 } 22 21 -
trunk/modules/unit_test/i18n/en_US/unit_test.php
r2274 r2278 8 8 'test_class_extends' => '%s must extend Unit_Test_Case.', 9 9 'no_tests_found' => 'No tests found', 10 'stats' => 'Passed: %s / %s', 10 11 'passed' => 'Passed', 11 12 'failed' => 'Failed', -
trunk/modules/unit_test/libraries/Unit_Test.php
r2275 r2278 12 12 class Unit_Test_Core { 13 13 14 // The path(s) to recursively scan for tests 14 15 protected $paths = array(); 16 17 // The results of all tests from every test class 15 18 protected $results = array(); 19 20 // Statistics for every test class 21 protected $stats = array(); 16 22 17 23 /** … … 61 67 throw new Kohana_Exception('unit_test.test_class_not_found', $class, $path); 62 68 63 // Instantiate test class results64 $this->results[$class] = array();65 66 69 // Reverse-engineer Test class 67 70 $reflector = new ReflectionClass($class); … … 70 73 if ( ! $reflector->isSubclassOf(new ReflectionClass('Unit_Test_Case'))) 71 74 throw new Kohana_Exception('unit_test.test_class_extends', $class); 75 76 // Initialize test class results and stats 77 $this->results[$class] = array(); 78 $this->stats[$class] = array('passed' => 0, 'failed' => 0); 72 79 73 80 // Loop through all the class methods … … 95 102 { 96 103 $object->$method_name(); 104 105 // Test passed 97 106 $this->results[$class][$method_name] = TRUE; 107 $this->stats[$class]['passed']++; 98 108 } 99 109 catch (Kohana_Unit_Test_Exception $e) 100 110 { 111 // Test failed 101 112 $this->results[$class][$method_name] = $e; 113 $this->stats[$class]['failed']++; 102 114 } 103 115 … … 122 134 public function report() 123 135 { 124 return empty($this->results) ? '' : View::factory('kohana_unit_test')->set('results', $this->results)->render(); 136 if (empty($this->results)) 137 return ''; 138 139 return View::factory('kohana_unit_test') 140 ->set('results', $this->results) 141 ->set('stats', $this->stats) 142 ->render(); 125 143 } 126 144 -
trunk/modules/unit_test/views/kohana_unit_test.php
r2274 r2278 39 39 border-bottom: 1px solid #E5EFF8; 40 40 padding: 3px; 41 } 42 #kohana-unit-test .k-stats 43 { 44 font-weight: normal; 45 color: #83919C; 46 text-align: right; 41 47 } 42 48 #kohana-unit-test .k-debug … … 87 93 <table> 88 94 <tr> 89 <th colspan="2"><?php echo $class ?></th> 95 <th><?php echo $class ?></th> 96 <th class="k-stats"> 97 <?php echo Kohana::lang('unit_test.stats', $stats[$class]['passed'], array_sum($stats[$class])) ?> 98 </th> 90 99 </tr> 91 100
