Show
Ignore:
Timestamp:
03/10/2008 09:41:45 AM (9 months ago)
Author:
Geert
Message:

Made assert methods chainable. Thanks, allain.

Files:
1 modified

Legend:

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

    r2265 r2270  
    145145                if ($value != TRUE) 
    146146                        throw new Kohana_Unit_Test_Exception(Kohana::lang('unit_test.assert_true', gettype($value), var_export($value, TRUE)), $debug); 
     147 
     148                return $this; 
    147149        } 
    148150 
     
    151153                if ($value !== TRUE) 
    152154                        throw new Kohana_Unit_Test_Exception(Kohana::lang('unit_test.assert_true_strict', gettype($value), var_export($value, TRUE)), $debug); 
     155 
     156                return $this; 
    153157        } 
    154158 
     
    157161                if ($value != FALSE) 
    158162                        throw new Kohana_Unit_Test_Exception(Kohana::lang('unit_test.assert_false', gettype($value), var_export($value, TRUE)), $debug); 
     163 
     164                return $this; 
    159165        } 
    160166 
     
    163169                if ($value !== FALSE) 
    164170                        throw new Kohana_Unit_Test_Exception(Kohana::lang('unit_test.assert_false_strict', gettype($value), var_export($value, TRUE)), $debug); 
     171 
     172                return $this; 
    165173        } 
    166174 
     
    169177                if ($value1 != $value2) 
    170178                        throw new Kohana_Unit_Test_Exception(Kohana::lang('unit_test.assert_equal', gettype($value1), var_export($value1, TRUE), gettype($value2), var_export($value2, TRUE)), $debug); 
     179 
     180                return $this; 
    171181        } 
    172182 
     
    175185                if ($value1 == $value2) 
    176186                        throw new Kohana_Unit_Test_Exception(Kohana::lang('unit_test.assert_not_equal', gettype($value1), var_export($value1, TRUE), gettype($value2), var_export($value2, TRUE)), $debug); 
     187 
     188                return $this; 
    177189        } 
    178190 
     
    181193                if ($value1 !== $value2) 
    182194                        throw new Kohana_Unit_Test_Exception(Kohana::lang('unit_test.assert_identical', gettype($value1), var_export($value1, TRUE), gettype($value2), var_export($value2, TRUE)), $debug); 
     195 
     196                return $this; 
    183197        } 
    184198 
     
    187201                if ($value1 === $value2) 
    188202                        throw new Kohana_Unit_Test_Exception(Kohana::lang('unit_test.assert_not_identical', gettype($value1), var_export($value1, TRUE), gettype($value2), var_export($value2, TRUE)), $debug); 
     203 
     204                return $this; 
    189205        } 
    190206 
     
    193209                if ( ! is_bool($value)) 
    194210                        throw new Kohana_Unit_Test_Exception(Kohana::lang('unit_test.assert_boolean', gettype($value), var_export($value, TRUE)), $debug); 
     211 
     212                return $this; 
    195213        } 
    196214 
     
    199217                if (is_bool($value)) 
    200218                        throw new Kohana_Unit_Test_Exception(Kohana::lang('unit_test.assert_not_boolean', gettype($value), var_export($value, TRUE)), $debug); 
     219 
     220                return $this; 
    201221        } 
    202222 
     
    205225                if ( ! is_int($value)) 
    206226                        throw new Kohana_Unit_Test_Exception(Kohana::lang('unit_test.assert_integer', gettype($value), var_export($value, TRUE)), $debug); 
     227 
     228                return $this; 
    207229        } 
    208230 
     
    211233                if (is_int($value)) 
    212234                        throw new Kohana_Unit_Test_Exception(Kohana::lang('unit_test.assert_not_integer', gettype($value), var_export($value, TRUE)), $debug); 
     235 
     236                return $this; 
    213237        } 
    214238 
     
    217241                if ( ! is_float($value)) 
    218242                        throw new Kohana_Unit_Test_Exception(Kohana::lang('unit_test.assert_float', gettype($value), var_export($value, TRUE)), $debug); 
     243 
     244                return $this; 
    219245        } 
    220246 
     
    223249                if (is_float($value)) 
    224250                        throw new Kohana_Unit_Test_Exception(Kohana::lang('unit_test.assert_not_float', gettype($value), var_export($value, TRUE)), $debug); 
     251 
     252                return $this; 
    225253        } 
    226254 
     
    229257                if ( ! is_array($value)) 
    230258                        throw new Kohana_Unit_Test_Exception(Kohana::lang('unit_test.assert_array', gettype($value), var_export($value, TRUE)), $debug); 
     259 
     260                return $this; 
    231261        } 
    232262 
     
    235265                if (is_array($value)) 
    236266                        throw new Kohana_Unit_Test_Exception(Kohana::lang('unit_test.assert_not_array', gettype($value), var_export($value, TRUE)), $debug); 
     267 
     268                return $this; 
    237269        } 
    238270 
     
    241273                if ( ! is_object($value)) 
    242274                        throw new Kohana_Unit_Test_Exception(Kohana::lang('unit_test.assert_object', gettype($value), var_export($value, TRUE)), $debug); 
     275 
     276                return $this; 
    243277        } 
    244278 
     
    247281                if (is_object($value)) 
    248282                        throw new Kohana_Unit_Test_Exception(Kohana::lang('unit_test.assert_not_object', gettype($value), var_export($value, TRUE)), $debug); 
     283 
     284                return $this; 
    249285        } 
    250286 
     
    253289                if ($value !== NULL) 
    254290                        throw new Kohana_Unit_Test_Exception(Kohana::lang('unit_test.assert_null', gettype($value), var_export($value, TRUE)), $debug); 
     291 
     292                return $this; 
    255293        } 
    256294 
     
    259297                if ($value === NULL) 
    260298                        throw new Kohana_Unit_Test_Exception(Kohana::lang('unit_test.assert_not_null', gettype($value), var_export($value, TRUE)), $debug); 
     299 
     300                return $this; 
    261301        } 
    262302 
     
    265305                if ( ! empty($value)) 
    266306                        throw new Kohana_Unit_Test_Exception(Kohana::lang('unit_test.assert_empty', gettype($value), var_export($value, TRUE)), $debug); 
     307 
     308                return $this; 
    267309        } 
    268310 
     
    271313                if (empty($value)) 
    272314                        throw new Kohana_Unit_Test_Exception(Kohana::lang('unit_test.assert_empty', gettype($value), var_export($value, TRUE)), $debug); 
     315 
     316                return $this; 
    273317        } 
    274318 
     
    277321                if ( ! is_string($value) OR ! is_string($regex) OR ! preg_match($regex, $value)) 
    278322                        throw new Kohana_Unit_Test_Exception(Kohana::lang('unit_test.assert_pattern', var_export($value, TRUE), var_export($regex, TRUE)), $debug); 
     323 
     324                return $this; 
    279325        } 
    280326 
     
    283329                if ( ! is_string($value) OR ! is_string($regex) OR preg_match($regex, $value)) 
    284330                        throw new Kohana_Unit_Test_Exception(Kohana::lang('unit_test.assert_not_pattern', var_export($value, TRUE), var_export($regex, TRUE)), $debug); 
     331 
     332                return $this; 
    285333        } 
    286334