【问题标题】:PHPUnit for CodeIgniter error with Class PHPUnit_Util_Filesystem带有类 PHPUnit_Util_Filesystem 的 CodeIgniter 的 PHPUnit 错误
【发布时间】:2014-09-01 05:16:25
【问题描述】:

一直在尝试将 PHPUnit 与 CIUnit 一起使用,以便使用 codeigniter 完成测试,但在尝试指向我的 phpunit 安装时出现此错误。

PHPUnit 安装在这里,路径在配置文件中设置:

/home/web/phpunit/PHPUnit/

在codeigniter的tests目录上

/home/web/web.com/codeigniter/tests

$ phpunit


Fatal error: Class 'PHPUnit_Util_Filesystem' not found in /home/web/phpunit/PHPUnit/Autoload.php on line 209

违规行:

if (PHPUnit_Util_Filesystem::fileExistsInIncludePath('PHP/Invoker/Autoload.php')) {
require_once 'PHP/Invoker/Autoload.php';
}

PHPUnit 文件夹的目录没有 Util 文件夹,但我手动添加了它,其中有一个 Filesystem.php 但不确定为什么即使手动添加它也无法正确访问。任何帮助表示赞赏。

更新: 能够使用 phar 文件使用 PHPUnit。现在我遇到了类似的错误,但能够在 phpunit-master 目录上运行其他测试。

我现在得到这个错误:

Fatal error: Call to undefined method PHPUnit_Util_Filesystem::fileExistsInIncludePath() in /home/web/web.com/codeigniter/application/third_party/CIUnit/PHPUnit/Autoload.php on line 209

该函数确实存在并且在文件系统中。第 92 行

 public static function fileExistsInIncludePath($file)

所以现在不确定是什么问题。

【问题讨论】:

  • 你是如何安装phpunit的?
  • @zerkms 第一次迭代使用的是 zip 文件,但随后下载了 phar 文件 phpunit.de/getting-started.html 也许我应该删除由 zip 文件创建的旧 phpunit?

标签: php codeigniter phpunit


【解决方案1】:

删除旧的 PHPUnit 安装,只使用从 phpunit 网站下载的 phpunit.phar。

wget https://phar.phpunit.de/phpunit.phar
php phpunit.phar

这解决了所有问题。例如,如果运行模型应该是:

phpunit models/

现在工作正常。

【讨论】:

    猜你喜欢
    • 2013-07-11
    • 1970-01-01
    • 2016-08-15
    • 2018-01-30
    • 1970-01-01
    • 1970-01-01
    • 2014-06-11
    • 2014-06-03
    • 1970-01-01
    相关资源
    最近更新 更多