0
我是新來使用phpunit。我在Netbeans 8.0.1上運行測試。該代碼是https://phpunit.de/manual/4.3/en/writing-tests-for-phpunit.html頁面上的Example 2.2。我收到一條錯誤消息:「StackTest :: testPop() 傳遞給StackTest :: testPop()的參數1必須是一個數組,給定爲null。」 我不知道爲什麼有錯誤。我是否需要輸入其他代碼或其他內容? 感謝您的回覆,提前。phpunit依賴關係netbean 8.0.1的StackTest
以下是代碼:
類StackTest PHPUnit_Framework_TestCase的擴展{
public function testEmpty() {
$stack = array();
$this->assertEmpty($stack);
return $stack;
}
/**
* @depends testEmpty
*/
public function testPush(array $stack) {
array_push($stack, 'foo');
$this->assertEquals('foo', $stack[count($stack)-1]);
$this->assertNotEmpty($stack);
}
/**
* @depends testPush
*/
public function testPop(array $stack) {
$this->assertEquals('foo', array_pop($stack));
$this->assertEmpty($stack);
}
}