Created
April 18, 2013 16:17
-
-
Save jasdeepkhalsa/5414028 to your computer and use it in GitHub Desktop.
Simple PHP Unit Test Class by Jasdeep Khalsa
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 | |
| 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