gpt4 book ai didi

php - fatal error : Class 'PHPUnit_Framework_TestCase' not found

转载 作者:可可西里 更新时间:2023-11-01 00:00:21 27 4
gpt4 key购买 nike

我正在使用 XAMPP 1.8.1、Windows 7 64 位、Netbeans IDE 7.4我已经安装了 PHPUnit。当我运行代码时,出现以下错误。

Fatal error: Class 'PHPUnit_Framework_TestCase' not found in D:\xampp\htdocs\PHPUnit\index.php on line 6

代码是:

<?php

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

}

?>

我在环境变量PATH中添加了D:\xampp\php有人建议我如何解决这个问题吗?提前致谢。

最佳答案

对于新的 PHPUnit 版本,您只需要在使用 use PHPUnit\Framework\TestCase; 的帮助下扩展 TestCase 而不是 PHPUnit_Framework_TestCase >

陈旧的方式:

// No namespace in this old method

class ClassATest extends PHPUnit_Framework_TestCase {

}

6.x等版本采用的新方式:

// Namespace used in this new method

use PHPunit\Framework\TestCase;

class ClassATest extends TestCase {

}

如果您不使用这种新方法,就会遇到困难。采用它,这将解决您的问题。

关于php - fatal error : Class 'PHPUnit_Framework_TestCase' not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21773872/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com