Skip to content

Instantly share code, notes, and snippets.

@jasdeepkhalsa
Created April 18, 2013 16:17
Show Gist options
  • Select an option

  • Save jasdeepkhalsa/5414028 to your computer and use it in GitHub Desktop.

Select an option

Save jasdeepkhalsa/5414028 to your computer and use it in GitHub Desktop.
Simple PHP Unit Test Class by Jasdeep Khalsa
<?php
class TestClass{
private $tests = array('Pass'=>0,'Fail'=>0);
public function test($expected, $actual){
if($expected === $actual){
return $this->tests['Pass'] += 1;
} else {
return $this->tests['Fail'] += 1;
}
}
public function results(){
return print_r($this->tests);
}
}
// Usage:
$t = new TestClass;
$t->test(1,1); // Pass
$t->test(1,0); // Fail
$t->results();
// Output:
// Array ( [Pass] => 1 [Fail] => 1 )
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment