Changeset 3132 for trunk/modules
- Timestamp:
- 07/17/2008 01:59:35 AM (5 months ago)
- Location:
- trunk/modules/unit_test
- Files:
-
- 3 modified
-
libraries/Unit_Test.php (modified) (8 diffs)
-
tests/Example_Test.php (modified) (1 diff)
-
views/kohana_unit_test.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/unit_test/libraries/Unit_Test.php
r3131 r3132 110 110 // Initialize test class results and stats 111 111 $this->results[$class] = array(); 112 $this->stats[$class] = array('passed' => 0, 'failed' => 0, 'errors' => 0, 'total' => 0, 113 'score' => 0); 114 112 $this->stats[$class] = array 113 ( 114 'passed' => 0, 115 'failed' => 0, 116 'errors' => 0, 117 'total' => 0, 118 'score' => 0, 119 ); 115 120 116 121 // Loop through all the class methods … … 120 125 if ( ! $method->isPublic() OR $method->isStatic() OR $method->getNumberOfRequiredParameters() !== 0) 121 126 continue; 122 127 123 128 // Test methods should be suffixed with "_test" 124 129 if (substr($method_name = $method->getName(), -5) !== '_test') … … 153 158 } 154 159 catch (Kohana_Unit_Test_Exception $e) 155 { 160 { 156 161 $this->stats[$class]['total']++; 157 162 // Test failed … … 168 173 } 169 174 170 171 $this->stats[$class]['score'] = $this->stats[$class]['passed'] * 100 / 172 $this->stats[$class]['total']; 175 // Calculate score 176 $this->stats[$class]['score'] = $this->stats[$class]['passed'] * 100 / $this->stats[$class]['total']; 177 173 178 // Cleanup 174 179 unset($object); … … 207 212 * 208 213 */ 209 private function collect_code_coverage_information() 210 { 211 212 213 214 } 215 214 private function collect_code_coverage_information() 215 { 216 217 218 219 } 220 216 221 217 222 /** … … 373 378 } 374 379 375 public function assert_in_array($value, $array, $debug = NULL) 380 public function assert_in_array($value, $array, $debug = NULL) 376 381 { 377 382 if ( ! in_array($value, $array)) { 378 383 throw new Kohana_Unit_Test_Exception(Kohana::lang('unit_test.assert_in_array', gettype($value), var_export($value, TRUE)), $debug); 379 } 380 384 } 385 381 386 return $this; 382 387 } … … 456 461 public function assert_class_attribute($attribute, $class) 457 462 { 458 459 460 461 } 462 463 public function assert_class_static_attribute($attribute, $class) 464 { 465 466 467 468 } 469 470 public function assert_file_exists($file) 471 { 472 463 464 465 466 } 467 468 public function assert_class_static_attribute($attribute, $class) 469 { 470 471 472 473 } 474 475 public function assert_file_exists($file) 476 { 477 473 478 474 479 … … 479 484 480 485 abstract class Database_Unit_Test_Case { 481 486 482 487 483 488 -
trunk/modules/unit_test/tests/Example_Test.php
r3131 r3132 73 73 } 74 74 75 public function array_key_test() 75 public function array_key_test() 76 76 { 77 $array = array( "a" => "A", "b" => "B");78 $this->assert_array_key( "a", $array);77 $array = array('a' => 'A', 'b' => 'B'); 78 $this->assert_array_key('a', $array); 79 79 } 80 81 public function in_array_test() 80 81 public function in_array_test() 82 82 { 83 $array = array( "X", "Y", "Z");84 $this->assert_in_array( "X", $array);85 } 83 $array = array('X', 'Y', 'Z'); 84 $this->assert_in_array('X', $array); 85 } 86 86 87 87 public function debug_example_test() -
trunk/modules/unit_test/views/kohana_unit_test.php
r3129 r3132 101 101 <table> 102 102 <tr> 103 <th>% of Passed Tests</th>104 <th class="k-stats"><?php printf("%s: %.2f%%", Kohana::lang('unit_test.score'), $stats[$class]['score']) ?></th>105 </tr>106 107 <tr>108 103 <th><?php echo $class ?></th> 109 104 <th class="k-stats"> 110 <?php echo Kohana::lang('unit_test.total'), ': ', $stats[$class]['total'] ?> 105 <?php printf('%s: %.2f%%', Kohana::lang('unit_test.score'), $stats[$class]['score']) ?> | 106 <?php echo Kohana::lang('unit_test.total'), ': ', $stats[$class]['total'] ?>, 111 107 <?php echo Kohana::lang('unit_test.passed'), ': ', $stats[$class]['passed'] ?>, 112 108 <?php echo Kohana::lang('unit_test.failed'), ': ', $stats[$class]['failed'] ?>,
