Created
July 3, 2011 05:15
-
-
Save mgroves/1061971 to your computer and use it in GitHub Desktop.
24 line PHP unit testing framework
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function assertEquals($var1, $var2) | |
| { | |
| if($var1 != $var2) { | |
| throw new Exception("Expected " . $var1 . " but was " . $var2); | |
| } | |
| } | |
| $funcs = get_defined_functions(); | |
| foreach($funcs["user"] as $func) | |
| { | |
| if(substr($func,0,4) == "test") { | |
| try { | |
| eval($func . "();"); | |
| echo($func . " Passed!\n"); | |
| } | |
| catch(Exception $e) | |
| { | |
| echo($func . " Failed! (" . $e->getMessage() . ")\n"); | |
| } | |
| } | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment