PHP : First Unit Test

Code to be tested

// Check.php
class Check {
	public function spitFalse() {
		return false;
	public function spitTrue() {
		return true;

Test Code

// CheckTest.php
class CheckTest extends PHPUnit_Framework_TestCase
	public function setUp(){ }
	public function tearDown(){ }
	public function testSpitFalse() {
		$chk = new Check();
	public function testSpitTrue() {
		$chk = new Check();

Run Test Code

phpunit CheckTest


OK (2 tests, 2 assertions)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: