gpt4 book ai didi

php - 运行 PHPUnit 时出错

转载 作者:可可西里 更新时间:2023-11-01 13:08:49 25 4
gpt4 key购买 nike

当我尝试从项目的测试文件夹中运行 phpunit . 时出现以下错误:

PHP Fatal error:  Call to undefined method PHP_CodeCoverage_Filter::getInstance() in /usr/share/php/PHPUnit/Framework.php on line 46

我通过这些命令安装了 PHPUnit:

sudo pear channel-discover pear.symfony-project.com
sudo pear channel-discover components.ez.no
sudo pear install --alldeps phpunit/PHPUnit

因为其他方法似乎都不起作用,包括 apt-get

认为 CodeCoverage 在某个时间点更改了他们的单例模式,因此删除了 getInstance 但我不知道如何修复此错误。如何降级 CodeCoverage 或升级 PHPUnit?

我尝试通过以下命令手动安装所有内容的最新版本:

sudo apt-get install git
mkdir phpunit && cd phpunit
git clone git://github.com/sebastianbergmann/phpunit.git
git clone git://github.com/sebastianbergmann/dbunit.git
git clone git://github.com/sebastianbergmann/php-file-iterator.git
git clone git://github.com/sebastianbergmann/php-text-template.git
git clone git://github.com/sebastianbergmann/php-code-coverage.git
git clone git://github.com/sebastianbergmann/php-token-stream.git
git clone git://github.com/sebastianbergmann/php-timer.git
git clone git://github.com/sebastianbergmann/phpunit-mock-objects.git
git clone git://github.com/sebastianbergmann/phpunit-selenium.git
git clone git://github.com/sebastianbergmann/phpunit-story.git
git clone git://github.com/sebastianbergmann/php-invoker.git
sudo cp -r dbunit/PHPUnit /usr/share/php/
sudo cp -r php-code-coverage/PHP /usr/share/php/
sudo cp -r php-file-iterator/File /usr/share/php/
sudo cp -r php-invoker/PHP /usr/share/php/
sudo cp -r php-text-template/Text /usr/share/php/
sudo cp -r php-timer/PHP /usr/share/php/
sudo cp -r php-token-stream/PHP /usr/share/php/
sudo cp -r phpunit/PHPUnit /usr/share/php/
sudo cp -r phpunit-mock-objects/PHPUnit /usr/share/php/
sudo cp -r phpunit-selenium/PHPUnit /usr/share/php/
sudo cp -r phpunit-story/PHPUnit /usr/share/php/
sudo cp -r phpunit/phpunit.php /usr/share/php/

但这没有任何帮助。现在我到处都是一堆垃圾:\


版本信息:

PEAR Version: 1.9.4
PHP Version: 5.3.6-13ubuntu3.3
Zend Engine Version: 2.3.0
PHPUnit 3.6.9 by Sebastian Bergmann.

Installed packages, channel pear.phpunit.de:
============================================
Package Version State
File_Iterator 1.3.1 stable
PHPUnit 3.6.9 stable
PHPUnit_MockObject 1.1.1 stable
PHP_CodeCoverage 1.1.1 stable
PHP_Invoker 1.1.0 stable
PHP_Timer 1.0.2 stable
PHP_TokenStream 1.1.2 stable
Text_Template 1.1.1 stable

最佳答案

你可以试试这个,我已经在我的 Ubuntu 12.04 上完成了

  1. sudo pear uninstall phpunit/PHPUnit
  2. sudo pear uninstall pear.phpunit.de/PHPUnit_MockObject
  3. sudo pear install pear.phpunit.de/PHPUnit_MockObject
  4. sudo pear install --alldeps pear.phpunit.de/PHPUnit

我试过很多其他的方法。当我遇到错误时,这会起作用。

hegaofeng@ubuntu:~$ phpunit PHP Warning: require_once(PHPUnit/Framework/MockObject/Autoload.php): failed to open >?>stream: No such file or directory in /usr/share/php/PHPUnit/Autoload.php on line 48 PHP Fatal error: require_once(): Failed opening required >'PHPUnit/Framework/MockObject/Autoload.php' >(include_path='.:/usr/share/php:/usr/share/pear') in /usr/share/php/PHPUnit/Autoload.php on >line 48 hegaofeng@ubuntu:~$ cd /usr/share/php/

关于php - 运行 PHPUnit 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8991620/

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