【问题标题】:"Fatal error: Call to undefined method PHPUnit_Util_Filter::addfiletofilter() in /usr/bin/phpunit on line 48"“致命错误:在第 48 行的 /usr/bin/phpunit 中调用未定义的方法 PHPUnit_Util_Filter::addfiletofilter()”
【发布时间】:2012-09-03 01:55:49
【问题描述】:

我刚刚在我们的 Ubuntu/Linux 服务器上使用 PEAR 安装了 phpunit (Linux mccoy 2.6.28-11-server #42-Ubuntu SMP Fri Apr 17 02:45:36 UTC 2009 x86_64 GNU/Linux)

当我尝试运行单元测试时出现错误:

“致命错误:在第 48 行的 /usr/bin/phpunit 中调用未定义的方法 PHPUnit_Util_Filter::addfiletofilter()”

我在谷歌上搜索过这个问题并在上面遇到了一些线程,但是这些似乎都不能解决我的问题。

我已将以下行添加到我的

/etc/php5/cli/php.ini:

include_path = ".:/usr/share/php/PHPUnit"

(我也试过不包含“/PHPUnit”文件夹)

但我仍然收到此错误。

任何帮助将不胜感激

gvanto

编辑:这是文件 /user/bin/phpunit 开头的内容:

// ...just comments prior to this

 if (extension_loaded('xdebug')) {
     xdebug_disable(); }

 if (strpos('/usr/bin/php', '@php_bin') === 0) {
     set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path()); }

 require_once 'PHPUnit/Util/Filter.php';

 PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT'); //line 48

 require 'PHPUnit/TextUI/Command.php';

 define('PHPUnit_MAIN_METHOD', 'PHPUnit_TextUI_Command::main');

【问题讨论】:

  • 如果它可以帮助其他遇到此问题的人,我只是将此行注释为最后一次尝试修复它,而 phpuni 似乎没有抱怨(到目前为止)

标签: unit-testing phpunit command-line-interface php


【解决方案1】:

似乎是版本冲突/安装问题。

pear version 应该产生1.9.4.。如果不是 pear upgrade 并按照命令进行操作,直到完成为止。

然后sudo pear install --force --alldeps phpunit/phpunit修复安装。+

您的包含路径应​​包含“pear”目录。使用pear config-show 找到它。

【讨论】:

    猜你喜欢
    • 2011-07-17
    • 2016-12-23
    • 2014-07-13
    • 1970-01-01
    • 1970-01-01
    • 2015-01-28
    • 2015-05-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多