tags:

views:

31

answers:

6

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: 

PHPUnit

simplemotives
A: 

http://www.phpunit.de/ is a good one. Works just like junit for java does.

Chris
A: 

take a look at http://www.phpunit.de/

maggie
+2  A: 

The de-facto standards are:

  • PHPUnit – generally used to test OOP-driven applications.
  • phpt – used by the PHP project.

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
A: 

I would think that PhpUnit would be the defacto unit test suite for php.

http://www.phpunit.de/

David Young
+1  A: 

The PHPUnit is much more robust and popular.

Also have a look at:

List of Testing frameworks for PHP at Wikipedia

Sarfraz