Changeset 3132 for trunk/modules

Show
Ignore:
Timestamp:
07/17/2008 01:59:35 AM (5 months ago)
Author:
Geert
Message:

A few unit_test CodingStyle follow-ups

Location:
trunk/modules/unit_test
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/modules/unit_test/libraries/Unit_Test.php

    r3131 r3132  
    110110                                // Initialize test class results and stats 
    111111                                $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                                ); 
    115120 
    116121                                // Loop through all the class methods 
     
    120125                                        if ( ! $method->isPublic() OR $method->isStatic() OR $method->getNumberOfRequiredParameters() !== 0) 
    121126                                                continue; 
    122                                          
     127 
    123128                                        // Test methods should be suffixed with "_test" 
    124129                                        if (substr($method_name = $method->getName(), -5) !== '_test') 
     
    153158                                        } 
    154159                                        catch (Kohana_Unit_Test_Exception $e) 
    155                                         {        
     160                                        { 
    156161                                                $this->stats[$class]['total']++; 
    157162                                                // Test failed 
     
    168173                                        } 
    169174 
    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 
    173178                                        // Cleanup 
    174179                                        unset($object); 
     
    207212         * 
    208213         */ 
    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 
    216221 
    217222        /** 
     
    373378        } 
    374379 
    375         public function assert_in_array($value, $array, $debug = NULL)  
     380        public function assert_in_array($value, $array, $debug = NULL) 
    376381        { 
    377382                if ( ! in_array($value, $array)) { 
    378383                        throw new Kohana_Unit_Test_Exception(Kohana::lang('unit_test.assert_in_array', gettype($value), var_export($value, TRUE)), $debug); 
    379                 }                
    380                  
     384                } 
     385 
    381386                return $this; 
    382387        } 
     
    456461        public function assert_class_attribute($attribute, $class) 
    457462        { 
    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 
    473478 
    474479 
     
    479484 
    480485abstract class Database_Unit_Test_Case { 
    481          
     486 
    482487 
    483488 
  • trunk/modules/unit_test/tests/Example_Test.php

    r3131 r3132  
    7373        } 
    7474 
    75         public function array_key_test()  
     75        public function array_key_test() 
    7676        { 
    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); 
    7979        } 
    80          
    81         public function in_array_test()  
     80 
     81        public function in_array_test() 
    8282        { 
    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        } 
    8686 
    8787        public function debug_example_test() 
  • trunk/modules/unit_test/views/kohana_unit_test.php

    r3129 r3132  
    101101        <table> 
    102102                <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> 
    108103                        <th><?php echo $class ?></th> 
    109104                        <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'] ?>, 
    111107                                <?php echo Kohana::lang('unit_test.passed'), ': ', $stats[$class]['passed'] ?>, 
    112108                                <?php echo Kohana::lang('unit_test.failed'), ': ', $stats[$class]['failed'] ?>,