Are there any good open source php test suites? So far I found only http://www.lastcraft.com/simple_test.php but I couldn't found much reviews about this project. Can any one suggest me some good test suites for the php?
A:
http://www.phpunit.de/ is a good one. Works just like junit for java does.
Chris
2010-07-26 16:21:53
+2
A:
The de-facto standards are:
This is an example of a test case with PHPUnit (from the manual):
class StackTest extends PHPUnit_Framework_TestCase
{
public function testPushAndPop()
{
$stack = array();
$this->assertEquals(0, count($stack));
array_push($stack, 'foo');
$this->assertEquals('foo', $stack[count($stack)-1]);
$this->assertEquals(1, count($stack));
$this->assertEquals('foo', array_pop($stack));
$this->assertEquals(0, count($stack));
}
}
And this is a test with phpt:
--TEST-- URL stat PHP_STREAM_URL_STAT_QUIET does not leak memory --SKIPIF-- <?php if(!extension_loaded("rar")) print "skip"; ?> --FILE-- <?php $file = "rar://" . dirname(__FILE__) . '/dirlink_unix.rar' . "#non_existant_file"; var_dump(is_dir($file)); echo "Done.\n"; --EXPECTF-- bool(false) Done.
Artefacto
2010-07-26 16:22:00
A:
I would think that PhpUnit would be the defacto unit test suite for php.
David Young
2010-07-26 16:22:14