Part of the EllisLab Network
   
 
Add is_object as a validation type for unit testing
Posted: 04 November 2009 04:10 PM   [ Ignore ]  
Grad Student
Avatar
Rank
Total Posts:  58
Joined  03-31-2008

If you add

'is_object'

to the array on line 62 of libraries/Unit_test.php, you can use objects as a validation type for unit testing. This is essential to me, as we’re loading application configuration into an object that is loaded as a property of the CI superglobal. We test that configuration is loaded correctly by testing that the method returns an object.

Line 62 of libraries/Unit_test.php should now read:

if (in_array($expected, array('is_object''is_string''is_bool''is_true''is_false''is_int''is_numeric''is_float''is_double''is_array''is_null'), TRUE)) 

The method call in our unit testing framework is:

$this->unit->run(Config::load(), 'is_object''Load Config'); 

It would be most excellent if this was committed.

Profile