Studyon Minte9.com
ZCE 5.3

Study

PHPUnit-1.3.2




<?php function isEven($n) { return $n%2 == 0; } function isOdd($n) { return $n%2 != 0; } { ini_set("include_path", ini_get("include_path") . ";PHPUnit-1.3.2"); require "PHPUnit.php"; class TestCase extends PHPUnit_TestCase { public function testEven() { $this->assertEquals(isEven(2), true); $this->assertEquals(isEven(3), false); } public function testOdd() { $this->assertEquals(isOdd(2), false); $this->assertEquals(isOdd(3), true); } } $suite = new PHPUnit_TestSuite("TestCase"); // automaticaly add methods that starts with 'test' print PHPUnit::run($suite)->toHTML(); // TestCase TestCase->testEven() passed // TestCase TestCase->testOdd() passed }
 


http://pear.php.net/package/PHPUnit/download