2010-07-26 38 views

回答

5

事實上的標準是:

  • PHPUnit - 通常用於測試OOP驅動的應用程序。
  • phpt - 由PHP項目使用。

這是一個測試的情況下使用PHPUnit的例子(從手動):

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)); 
    } 
} 

並且這與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. 
0

我還建議PHPUnit的。我使用它與Netbeans,它工作得很好。

相關問題