PHPUnit错误-找不到类 [英] PHPUnit error - Class could not be found

查看:494
本文介绍了PHPUnit错误-找不到类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在系统上安装了PHPUnit 3.5,并将其从3.4升级,并且在使用新版本时遇到了一些麻烦.当我尝试运行测试时,我总是得到相同的输出.这是我尝试在命令行中从PHPUnit手册

I just installed PHPUnit 3.5 on my system, upgrading it from 3.4, and I'm having some trouble with the new version. When I try to run a test, I always get the same output. Here's what I get when I try to run on the command line the StackTest example from the PHPUnit manual, example 4.1:

> phpunit StackTest

X-Powered-By: PHP/5.2.17
Content-type: text/html

PHPUnit 3.5.13 by Sebastian Bergmann.

Class StackTest could not be found in StackTest.php.

更糟糕的是,当我尝试从Web浏览器运行它时,得到以下输出:

Worse yet, when I try to run it from a web browser, I get the following output:

Fatal error: Class 'PHPUnit_Framework_TestCase' not found in /path/to/tests/StackTest.php on line 2 

有人知道如何设置吗?谢谢.

Does anyone know how to set this up? Thanks.

推荐答案

我遇到了您在Windows上描述的问题. 问题出在第131行的pear \ PHPUnit \ Runner \ StandardTestSuiteLoader.php文件中,这是由文件名中不同的驱动器字母大小写引起的.

I had the problem you described on Windows. The problem was in the file pear\PHPUnit\Runner\StandardTestSuiteLoader.php on line 131 an it was caused by different drive letter case in file name in the condition

if ($class->getFileName() == realpath($suiteClassFile)) {

我的简单解决方法是将这一行更改为不区分大小写

My simple fix is to change this line to be case insensitive

if (strtolower($class->getFileName()) == strtolower(realpath($suiteClassFile))) {

这篇关于PHPUnit错误-找不到类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆