Skip to content

Instantly share code, notes, and snippets.

@mgroves
Created July 3, 2011 05:15
Show Gist options
  • Select an option

  • Save mgroves/1061971 to your computer and use it in GitHub Desktop.

Select an option

Save mgroves/1061971 to your computer and use it in GitHub Desktop.
24 line PHP unit testing framework
<?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