mpe*_*pen 6 php phpunit unit-testing ubuntu-11.10
当我尝试phpunit .从项目的tests文件夹中运行时出现以下错误:
PHP Fatal error: Call to undefined method PHP_CodeCoverage_Filter::getInstance() in /usr/share/php/PHPUnit/Framework.php on line 46
Run Code Online (Sandbox Code Playgroud)
我通过以下命令安装了PHPUnit:
sudo pear channel-discover pear.symfony-project.com
sudo pear channel-discover components.ez.no
sudo pear install --alldeps phpunit/PHPUnit
Run Code Online (Sandbox Code Playgroud)
因为其他方法似乎都不起作用,包括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/
Run Code Online (Sandbox Code Playgroud)
但这没有任何帮助.现在我到处都是一堆垃圾:
版本信息:
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.
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
小智 7
你可以尝试这个,我已经在我的Ubuntu 12.04上完成了
我尝试了很多其他方法.当我得到错误打击时,这可以工作.
hegaofeng @ ubuntu:〜$ phpunit PHP警告:require_once(PHPUnit/Framework/MockObject/Autoload.php):无法打开>?> stream:/usr/share/php/PHPUnit/Autoload.php上没有这样的文件或目录第48行PHP致命错误:require_once():在/ usr中打开所需的>'PHPUnit/Framework/MockObject/Autoload.php'>(include_path ='.:/ usr/share/php:/ usr/share/pear')失败/share/php/PHPUnit/Autoload.php on> line 48 hegaofeng @ ubuntu:〜$ cd/usr/share/php /
我没有使用实际的pear.phpunit.de通道安装PHPUnit 时遇到问题,特别是在尝试使用像apt-get或yum这样的包管理器时.尝试删除从git存储库中提取的所有手动安装的东西,并执行pear uninstallPHPUnit及其可选依赖项.然后:
这对我有用......希望它有所帮助.
UPDATE
这可能不言而喻,但在执行上述步骤之前,您还应该清除以前的apt-get尝试: