Changeset 3131 for trunk/modules

Show
Ignore:
Timestamp:
07/16/2008 08:39:52 PM (5 months ago)
Author:
msaraujo
Message:

add assert_in_array

Location:
trunk/modules/unit_test
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/modules/unit_test/i18n/en_US/unit_test.php

    r3130 r3131  
    3030        'assert_not_float'     => 'assert_not_float: Expected not a float, but was given (%s) %s.', 
    3131        'assert_array'         => 'assert_array: Expected an array, but was given (%s) %s.', 
    32         'assert_array_key'     => 'assert_array_key: Expected a valid key, but was given (%s) %s.',      
     32        'assert_array_key'     => 'assert_array_key: Expected a valid key, but was given (%s) %s.', 
     33        'assert_in_array'      => 'assert_in_array: Expected a valid value, but was given (%s) %s.',     
    3334        'assert_not_array'     => 'assert_not_array: Expected not an array, but was given (%s) %s.', 
    3435        'assert_object'        => 'assert_object: Expected an object, but was given (%s) %s.', 
  • trunk/modules/unit_test/libraries/Unit_Test.php

    r3130 r3131  
    364364        } 
    365365 
    366         public function assert_array_key($key, $array) 
     366        public function assert_array_key($key, $array, $debug = NULL) 
    367367        { 
    368368                if ( ! array_key_exists($key, $array)) { 
    369                         throw new Kohana_Unit_Test_Exception(Kohana::lang('unit_test.assert_array_key', gettype($value), var_export($value, TRUE)), $debug); 
     369                        throw new Kohana_Unit_Test_Exception(Kohana::lang('unit_test.assert_array_key', gettype($key), var_export($key, TRUE)), $debug); 
    370370                } 
    371371 
     372                return $this; 
     373        } 
     374 
     375        public function assert_in_array($value, $array, $debug = NULL)  
     376        { 
     377                if ( ! in_array($value, $array)) { 
     378                        throw new Kohana_Unit_Test_Exception(Kohana::lang('unit_test.assert_in_array', gettype($value), var_export($value, TRUE)), $debug); 
     379                }                
     380                 
    372381                return $this; 
    373382        } 
     
    445454        } 
    446455 
    447         public function assert_class_attribute()  
     456        public function assert_class_attribute($attribute, $class) 
    448457        { 
    449458                 
     
    452461        } 
    453462 
    454         public function assert_class_static_attribute()  
     463        public function assert_class_static_attribute($attribute, $class)  
    455464        { 
    456465                 
     
    459468        } 
    460469         
     470        public function assert_file_exists($file)  
     471        { 
     472                 
     473 
     474 
     475        } 
     476 
    461477} // End Unit_Test_Case 
    462478 
  • trunk/modules/unit_test/tests/Example_Test.php

    r3130 r3131  
    7878                $this->assert_array_key("a", $array); 
    7979        } 
    80  
     80         
     81        public function in_array_test()  
     82        { 
     83                $array = array("X", "Y", "Z"); 
     84                $this->assert_in_array("X", $array); 
     85        }        
    8186 
    8287        public function debug_example_test()